1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

[KOE-42] Out-of-office dialog now shows progress inline, like shared folders.

This commit is contained in:
Patrick Simpson 2017-03-22 13:36:49 +01:00
parent 0c254f44d0
commit e9ec0cd855
11 changed files with 643 additions and 443 deletions

View File

@ -485,6 +485,11 @@ namespace Acacia.Controls
return Chain(new KUITask(TaskExecutor.TaskContextParam(func, TaskExecutor.OptionHelper(false, true, inUI)), false));
}
public KUITask OnSuccess(Action<ResultType> func, bool inUI = false)
{
return Chain(new KUITask(TaskExecutor.Param(func, TaskExecutor.OptionHelper(false, true, inUI)), false));
}
public KUITask<NewResultType> OnSuccess<NewResultType>(Func<ResultType, NewResultType> func, bool inUI = false)
{
return Chain(new KUITask<NewResultType>(TaskExecutor.Param(func, TaskExecutor.OptionHelper(false, true, inUI)), false));

View File

@ -103,7 +103,7 @@ namespace Acacia.Features.OutOfOffice
}
}
private void StoreOOFSettings(ZPushAccount account, ActiveSync.SettingsOOF settings)
internal void StoreOOFSettings(ZPushAccount account, ActiveSync.SettingsOOF settings)
{
account.SetFeatureData(this, "OOF", settings);
if (_button != null)
@ -115,141 +115,21 @@ namespace Acacia.Features.OutOfOffice
ZPushAccount account = Watcher.CurrentZPushAccount();
if (account != null)
{
try
{
// Fetch the current status
ActiveSync.SettingsOOF settings;
try
{
settings = ProgressDialog.Execute("OOFGet",
(ct) =>
{
using (ZPushConnection con = new ZPushConnection(account, ct))
return con.Execute(new ActiveSync.SettingsOOFGet());
}
);
}
catch (System.Exception e)
{
Logger.Instance.Warning(this, "Exception getting OOF state: {0}", e);
if (MessageBox.Show(
Properties.Resources.OOFGet_Failed,
Properties.Resources.OOFGet_Title,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error
) != DialogResult.OK)
{
return;
}
else
{
// Initialise default settings
settings = new ActiveSync.SettingsOOF();
settings.Message = new ActiveSync.OOFMessage[3];
}
}
// Store them for later use
StoreOOFSettings(account, settings);
// Show the dialog
ShowOOFDialog(account, settings);
}
catch(System.Exception e)
{
Logger.Instance.Warning(this, "Exception: {0}", e);
}
// Show the dialog, let it fetch the settings
ShowOOFDialog(account, null);
}
}
/// <summary>
/// Shows the OOF dialog.
/// </summary>
/// <param name="account">The account.</param>
/// <param name="settings">The setttings, or null, in which case the settings will be retrieved</param>
private void ShowOOFDialog(ZPushAccount account, ActiveSync.SettingsOOF settings)
{
// Show dialog
if (new OutOfOfficeDialog(this, account, settings).ShowDialog() != DialogResult.OK)
return;
try
{
// Store settings
ActiveSync.SettingsOOF actualSettings = ProgressDialog.Execute("OOFSet",
(ct) =>
{
using (ZPushConnection connection = new ZPushConnection(account, ct))
{
// Set the OOF state. This always seems to return ok, so we fetch the settings
// again, to see what happend
connection.Execute(new ActiveSync.SettingsOOFSet(settings));
// Fetch the OOF state
return connection.Execute(new ActiveSync.SettingsOOFGet());
}
}
);
// Store them for later use
StoreOOFSettings(account, actualSettings);
// Check what happened
string message;
MessageBoxIcon messageIcon;
if (settings.State == ActiveSync.OOFState.Disabled)
{
// Tried to disable.
if (actualSettings.State != ActiveSync.OOFState.Disabled)
{
// It's an error if its not actually disabled
message = Properties.Resources.OOFSet_DisableFailed;
messageIcon = MessageBoxIcon.Error;
}
else
{
// All good
message = Properties.Resources.OOFSet_Disabled;
messageIcon = MessageBoxIcon.Information;
}
}
else if (actualSettings.State == ActiveSync.OOFState.Disabled)
{
// It's an error if the state is set to disabled when we tried to enable
message = Properties.Resources.OOFSet_EnableFailed;
messageIcon = MessageBoxIcon.Error;
}
else
{
// All good
if (actualSettings.State == ActiveSync.OOFState.EnabledTimeBased)
{
message = string.Format(Properties.Resources.OOFSet_EnabledTimeBased,
actualSettings.From, actualSettings.Till);
}
else
{
message = Properties.Resources.OOFSet_Enabled;
}
messageIcon = MessageBoxIcon.Information;
// It's okay if the state is not the same, but it deserves a message
if (actualSettings.State != settings.State)
{
message = Properties.Resources.OOFSet_DifferentState + message;
messageIcon = MessageBoxIcon.Warning;
}
}
Logger.Instance.Debug(this, "OOF state updated: {0}, {1}", message, messageIcon);
MessageBox.Show(message,
Properties.Resources.OOFSet_Title,
MessageBoxButtons.OK,
messageIcon
);
}
catch (System.Exception e)
{
ErrorUtil.HandleErrorNew(this, "Exception in OOFSet", e,
Properties.Resources.OOFSet_Title, Properties.Resources.OOFSet_Failed);
}
OutOfOfficeDialog dialog = new OutOfOfficeDialog(this, account, settings);
dialog.ShowDialog();
}
/// <summary>

View File

@ -29,9 +29,11 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OutOfOfficeDialog));
this.tableGlobal = new System.Windows.Forms.TableLayoutPanel();
this._layout = new System.Windows.Forms.TableLayoutPanel();
this._busyHider = new Acacia.Controls.KBusyHider();
this._layoutForm = new System.Windows.Forms.TableLayoutPanel();
this.chkEnable = new System.Windows.Forms.CheckBox();
this.tableDates = new System.Windows.Forms.TableLayoutPanel();
this._layoutDates = new System.Windows.Forms.TableLayoutPanel();
this.radioNoTime = new System.Windows.Forms.RadioButton();
this.radioTime = new System.Windows.Forms.RadioButton();
this.dateFrom = new System.Windows.Forms.DateTimePicker();
@ -43,24 +45,38 @@
this.tableTextEntry = new System.Windows.Forms.TableLayoutPanel();
this.labelBody = new System.Windows.Forms.Label();
this.textBody = new System.Windows.Forms.TextBox();
this.flowButtons = new System.Windows.Forms.FlowLayoutPanel();
this.btnCancel = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.tableGlobal.SuspendLayout();
this.tableDates.SuspendLayout();
this._buttons = new Acacia.Controls.KDialogButtons();
this._layout.SuspendLayout();
this._busyHider.SuspendLayout();
this._layoutForm.SuspendLayout();
this._layoutDates.SuspendLayout();
this.groupTextEntry.SuspendLayout();
this.tableTextEntry.SuspendLayout();
this.flowButtons.SuspendLayout();
this.SuspendLayout();
//
// tableGlobal
// _layout
//
resources.ApplyResources(this.tableGlobal, "tableGlobal");
this.tableGlobal.Controls.Add(this.chkEnable, 0, 0);
this.tableGlobal.Controls.Add(this.tableDates, 0, 1);
this.tableGlobal.Controls.Add(this.groupTextEntry, 0, 2);
this.tableGlobal.Controls.Add(this.flowButtons, 0, 3);
this.tableGlobal.Name = "tableGlobal";
resources.ApplyResources(this._layout, "_layout");
this._layout.Controls.Add(this._busyHider, 0, 0);
this._layout.Controls.Add(this._buttons, 0, 1);
this._layout.Name = "_layout";
//
// _busyHider
//
this._busyHider.Busy = false;
this._busyHider.BusyText = null;
this._busyHider.Cancellation = null;
this._busyHider.Controls.Add(this._layoutForm);
resources.ApplyResources(this._busyHider, "_busyHider");
this._busyHider.Name = "_busyHider";
//
// _layoutForm
//
resources.ApplyResources(this._layoutForm, "_layoutForm");
this._layoutForm.Controls.Add(this.chkEnable, 0, 0);
this._layoutForm.Controls.Add(this._layoutDates, 0, 1);
this._layoutForm.Controls.Add(this.groupTextEntry, 0, 2);
this._layoutForm.Name = "_layoutForm";
//
// chkEnable
//
@ -69,23 +85,23 @@
this.chkEnable.UseVisualStyleBackColor = true;
this.chkEnable.CheckedChanged += new System.EventHandler(this.chkEnable_CheckedChanged);
//
// tableDates
// _layoutDates
//
resources.ApplyResources(this.tableDates, "tableDates");
this.tableDates.Controls.Add(this.radioNoTime, 0, 0);
this.tableDates.Controls.Add(this.radioTime, 0, 1);
this.tableDates.Controls.Add(this.dateFrom, 1, 1);
this.tableDates.Controls.Add(this.timeFrom, 2, 1);
this.tableDates.Controls.Add(this.labelTill, 0, 2);
this.tableDates.Controls.Add(this.dateTill, 1, 2);
this.tableDates.Controls.Add(this.timeTill, 2, 2);
this.tableDates.Name = "tableDates";
resources.ApplyResources(this._layoutDates, "_layoutDates");
this._layoutDates.Controls.Add(this.radioNoTime, 0, 0);
this._layoutDates.Controls.Add(this.radioTime, 0, 1);
this._layoutDates.Controls.Add(this.dateFrom, 1, 1);
this._layoutDates.Controls.Add(this.timeFrom, 2, 1);
this._layoutDates.Controls.Add(this.labelTill, 0, 2);
this._layoutDates.Controls.Add(this.dateTill, 1, 2);
this._layoutDates.Controls.Add(this.timeTill, 2, 2);
this._layoutDates.Name = "_layoutDates";
//
// radioNoTime
//
resources.ApplyResources(this.radioNoTime, "radioNoTime");
this.radioNoTime.Checked = true;
this.tableDates.SetColumnSpan(this.radioNoTime, 3);
this._layoutDates.SetColumnSpan(this.radioNoTime, 3);
this.radioNoTime.Name = "radioNoTime";
this.radioNoTime.TabStop = true;
this.radioNoTime.UseVisualStyleBackColor = true;
@ -128,6 +144,7 @@
this.timeTill.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.timeTill.Name = "timeTill";
this.timeTill.ShowUpDown = true;
this.timeTill.ValueChanged += new System.EventHandler(this.timeTill_ValueChanged);
//
// groupTextEntry
//
@ -153,73 +170,60 @@
this.textBody.AcceptsReturn = true;
resources.ApplyResources(this.textBody, "textBody");
this.textBody.Name = "textBody";
this.textBody.TextChanged += new System.EventHandler(this.textBody_TextChanged);
//
// flowButtons
// _buttons
//
resources.ApplyResources(this.flowButtons, "flowButtons");
this.flowButtons.Controls.Add(this.btnCancel);
this.flowButtons.Controls.Add(this.btnSave);
this.flowButtons.Name = "flowButtons";
//
// btnCancel
//
resources.ApplyResources(this.btnCancel, "btnCancel");
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Name = "btnCancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// btnSave
//
resources.ApplyResources(this.btnSave, "btnSave");
this.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnSave.Name = "btnSave";
this.btnSave.UseVisualStyleBackColor = true;
resources.ApplyResources(this._buttons, "_buttons");
this._buttons.ButtonSize = null;
this._buttons.Cancellation = null;
this._buttons.HasApply = true;
this._buttons.IsDirty = false;
this._buttons.Name = "_buttons";
this._buttons.Apply += new System.EventHandler(this._buttons_Apply);
//
// OutOfOfficeDialog
//
this.AcceptButton = this.btnSave;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.Controls.Add(this.tableGlobal);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.BusyHider = this._busyHider;
this.Controls.Add(this._layout);
this.DialogButtons = this._buttons;
this.Name = "OutOfOfficeDialog";
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.OutOfOfficeDialog_FormClosed);
this.tableGlobal.ResumeLayout(false);
this.tableGlobal.PerformLayout();
this.tableDates.ResumeLayout(false);
this.tableDates.PerformLayout();
this.DirtyFormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OutOfOfficeDialog_DirtyFormClosing);
this.Shown += new System.EventHandler(this.OutOfOfficeDialog_Shown);
this._layout.ResumeLayout(false);
this._layout.PerformLayout();
this._busyHider.ResumeLayout(false);
this._layoutForm.ResumeLayout(false);
this._layoutForm.PerformLayout();
this._layoutDates.ResumeLayout(false);
this._layoutDates.PerformLayout();
this.groupTextEntry.ResumeLayout(false);
this.groupTextEntry.PerformLayout();
this.tableTextEntry.ResumeLayout(false);
this.tableTextEntry.PerformLayout();
this.flowButtons.ResumeLayout(false);
this.flowButtons.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableGlobal;
private System.Windows.Forms.TableLayoutPanel _layout;
private Controls.KDialogButtons _buttons;
private System.Windows.Forms.TableLayoutPanel _layoutForm;
private System.Windows.Forms.CheckBox chkEnable;
private System.Windows.Forms.TableLayoutPanel _layoutDates;
private System.Windows.Forms.RadioButton radioNoTime;
private System.Windows.Forms.GroupBox groupTextEntry;
private System.Windows.Forms.FlowLayoutPanel flowButtons;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.TableLayoutPanel tableDates;
private System.Windows.Forms.RadioButton radioTime;
private System.Windows.Forms.DateTimePicker dateFrom;
private System.Windows.Forms.DateTimePicker timeFrom;
private System.Windows.Forms.Label labelTill;
private System.Windows.Forms.DateTimePicker dateTill;
private System.Windows.Forms.DateTimePicker timeTill;
private System.Windows.Forms.GroupBox groupTextEntry;
private System.Windows.Forms.TableLayoutPanel tableTextEntry;
private System.Windows.Forms.Label labelBody;
private System.Windows.Forms.TextBox textBody;
private System.Windows.Forms.DateTimePicker timeFrom;
private System.Windows.Forms.DateTimePicker timeTill;
private System.Windows.Forms.Label labelTill;
private Controls.KBusyHider _busyHider;
}
}

View File

@ -1,4 +1,6 @@
/// Copyright 2016 Kopano b.v.

using Acacia.Controls;
/// Copyright 2016 Kopano b.v.
///
/// This program is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License, version 3,
@ -13,10 +15,10 @@
/// along with this program.If not, see<http://www.gnu.org/licenses/>.
///
/// Consult LICENSE file for details
using Acacia.UI;
using Acacia.Utils;
using Acacia.ZPush;
using Acacia.ZPush.Connect;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -31,17 +33,24 @@ using System.Windows.Forms;
namespace Acacia.Features.OutOfOffice
{
public partial class OutOfOfficeDialog : KopanoDialog
public partial class OutOfOfficeDialog : KDialogNew
{
private readonly FeatureOutOfOffice _feature;
private readonly ZPushAccount _account;
private ActiveSync.SettingsOOF _settings;
private readonly bool _haveTimes;
private bool _haveTimes;
/// <summary>
/// Set if an old date is fetched from the settings. In this case, the date limit is relaxed to allow setting it.
/// </summary>
private readonly bool _haveOldDate;
private bool _haveOldDate;
public OutOfOfficeDialog(FeatureOutOfOffice owner, ZPushAccount account, ActiveSync.SettingsOOF settings)
#region Init
public OutOfOfficeDialog(FeatureOutOfOffice feature, ZPushAccount account, ActiveSync.SettingsOOF settings)
{
this._feature = feature;
this._account = account;
this._settings = settings;
InitializeComponent();
@ -66,16 +75,33 @@ namespace Acacia.Features.OutOfOffice
// Enable controls
chkEnable_CheckedChanged(chkEnable, null);
radioTime_CheckedChanged(radioTime, null);
}
private void OutOfOfficeDialog_Shown(object sender, EventArgs e)
{
if (_settings == null)
{
// If the settings are not yet available, load them
LoadSettings();
}
else
{
// Otherwise initialise them now
InitSettings();
}
}
private void InitSettings()
{
// Hide time options, only if it is known that these are not supported
_haveTimes = _settings.SupportsTimes != false;
if (!_haveTimes)
{
tableDates.Visible = false;
_layoutDates.Visible = false;
}
// Load settings
switch(owner.GetEffectiveState(settings))
switch(_feature.GetEffectiveState(_settings))
{
case ActiveSync.OOFState.Disabled:
chkEnable.Checked = false;
@ -88,95 +114,61 @@ namespace Acacia.Features.OutOfOffice
chkEnable.Checked = true;
radioTime.Checked = true;
_haveOldDate = settings.Till.Value.CompareTo(DateTime.Today) <= 0;
dateFrom.Value = settings.From.Value;
timeFrom.Value = settings.From.Value;
_haveOldDate = _settings.Till.Value.CompareTo(DateTime.Today) <= 0;
dateFrom.Value = _settings.From.Value;
timeFrom.Value = _settings.From.Value;
dateTill.Value = settings.Till.Value;
timeTill.Value = settings.Till.Value;
dateTill.Value = _settings.Till.Value;
timeTill.Value = _settings.Till.Value;
break;
}
textBody.Text = settings.Message[(int)ActiveSync.OOFTarget.Internal]?.Message;
textBody.Text = _settings.Message[(int)ActiveSync.OOFTarget.Internal]?.Message;
// Set up limits
SetTillTimeLimit();
}
#endregion
#region Event handlers
private void chkEnable_CheckedChanged(object sender, EventArgs e)
{
tableDates.Enabled = chkEnable.Checked;
_layoutDates.Enabled = chkEnable.Checked;
groupTextEntry.Enabled = chkEnable.Checked;
CheckDirty();
}
private void radioTime_CheckedChanged(object sender, EventArgs e)
{
dateFrom.Enabled = timeFrom.Enabled = radioTime.Checked;
dateTill.Enabled = timeTill.Enabled = radioTime.Checked;
CheckDirty();
}
private void OutOfOfficeDialog_FormClosed(object sender, FormClosedEventArgs e)
{
// Save the settings
_settings.From = null;
_settings.Till = null;
if (chkEnable.Checked)
{
if (radioNoTime.Checked || !_haveTimes)
{
_settings.State = ActiveSync.OOFState.Enabled;
}
else
{
_settings.State = ActiveSync.OOFState.EnabledTimeBased;
_settings.From = GetDateTime(dateFrom, timeFrom);
_settings.Till = GetDateTime(dateTill, timeTill);
}
}
else
{
_settings.State = ActiveSync.OOFState.Disabled;
}
// Always set the message, so it's stored
string message = textBody.Text;
for (int i = 0; i < 3; ++i)
{
_settings.Message[i] = new ActiveSync.OOFMessage();
_settings.Message[i].Message = message;
}
}
private DateTime GetDateTime(DateTimePicker dateControl, DateTimePicker timeControl)
{
DateTime date = dateControl.Value;
DateTime time = timeControl.Value;
DateTime combined = new DateTime(date.Year, date.Month, date.Day);
combined = combined.Add(time.TimeOfDay);
return combined;
}
#region Date/Time checking
private void dateFrom_ValueChanged(object sender, EventArgs e)
{
SetTillTimeLimit();
CheckDirty();
}
private void timeFrom_ValueChanged(object sender, EventArgs e)
{
SetTillTimeLimit();
CheckDirty();
}
private void dateTill_ValueChanged(object sender, EventArgs e)
{
SetTillTimeLimit();
CheckDirty();
}
private void timeTill_ValueChanged(object sender, EventArgs e)
{
SetTillTimeLimit();
CheckDirty();
}
private void SetTillTimeLimit()
@ -195,6 +187,212 @@ namespace Acacia.Features.OutOfOffice
}
}
private void textBody_TextChanged(object sender, EventArgs e)
{
CheckDirty();
}
private void CheckDirty()
{
ActiveSync.SettingsOOF settings = GetSettings();
_buttons.IsDirty = _settings != null && !_settings.Equals(settings);
}
private void OutOfOfficeDialog_DirtyFormClosing(object sender, FormClosingEventArgs e)
{
// Require confirmation before closing a dirty form
e.Cancel = MessageBox.Show(Properties.Resources.OOF_Unsaved_Changes,
Text,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
) != DialogResult.Yes;
}
#endregion
#region Settings
private ActiveSync.SettingsOOF GetSettings()
{
ActiveSync.SettingsOOF settings = new ActiveSync.SettingsOOF(true);
if (chkEnable.Checked)
{
if (radioNoTime.Checked || !_haveTimes)
{
settings.State = ActiveSync.OOFState.Enabled;
}
else
{
settings.State = ActiveSync.OOFState.EnabledTimeBased;
settings.From = GetDateTime(dateFrom, timeFrom);
settings.Till = GetDateTime(dateTill, timeTill);
}
}
else
{
settings.State = ActiveSync.OOFState.Disabled;
}
// Always set the message, so it's stored
string message = textBody.Text;
for (int i = 0; i < 3; ++i)
{
settings.Message[i] = new ActiveSync.OOFMessage();
settings.Message[i].Message = message;
}
return settings;
}
private DateTime GetDateTime(DateTimePicker dateControl, DateTimePicker timeControl)
{
DateTime date = dateControl.Value;
DateTime time = timeControl.Value;
DateTime combined = new DateTime(date.Year, date.Month, date.Day);
combined = combined.Add(time.TimeOfDay);
return combined;
}
#endregion
#region Load and save
private void LoadSettings()
{
BusyText = Properties.Resources.OOFGet_Label;
KUITask
.New((ctx) =>
{
using (ZPushConnection con = new ZPushConnection(_account, ctx.CancellationToken))
{
_settings = con.Execute(new ActiveSync.SettingsOOFGet());
}
})
.OnSuccess(InitSettings, true)
.OnError((e) =>
{
Logger.Instance.Warning(this, "Exception getting OOF state: {0}", e);
if (MessageBox.Show(
Properties.Resources.OOFGet_Failed,
Properties.Resources.OOFGet_Title,
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error
) != DialogResult.OK)
{
DialogResult = DialogResult.Cancel;
}
else
{
// Initialise default settings
_settings = new ActiveSync.SettingsOOF(true);
InitSettings();
}
})
.Start(this)
;
}
private void _buttons_Apply(object sender, EventArgs e)
{
BusyText = Properties.Resources.OOFSet_Label;
ActiveSync.SettingsOOF currentSettings = GetSettings();
KUITask
.New((ctx) =>
{
using (ZPushConnection connection = new ZPushConnection(_account, ctx.CancellationToken))
{
// Set the OOF state. This always seems to return ok, so we fetch the settings
// again, to see what happend
connection.Execute(new ActiveSync.SettingsOOFSet(currentSettings));
// Fetch the OOF state
return connection.Execute(new ActiveSync.SettingsOOFGet());
}
})
.OnSuccess((appliedSettings) =>
{
// Store them for later use
_feature.StoreOOFSettings(_account, appliedSettings);
// Check what happened
string message;
MessageBoxIcon messageIcon;
if (currentSettings.State == ActiveSync.OOFState.Disabled)
{
// Tried to disable.
if (appliedSettings.State != ActiveSync.OOFState.Disabled)
{
// It's an error if its not actually disabled
message = Properties.Resources.OOFSet_DisableFailed;
messageIcon = MessageBoxIcon.Error;
}
else
{
// All good
message = Properties.Resources.OOFSet_Disabled;
messageIcon = MessageBoxIcon.Information;
}
}
else if (appliedSettings.State == ActiveSync.OOFState.Disabled)
{
// It's an error if the state is set to disabled when we tried to enable
message = Properties.Resources.OOFSet_EnableFailed;
messageIcon = MessageBoxIcon.Error;
}
else
{
// All good
if (appliedSettings.State == ActiveSync.OOFState.EnabledTimeBased)
{
message = string.Format(Properties.Resources.OOFSet_EnabledTimeBased,
appliedSettings.From, appliedSettings.Till);
}
else
{
message = Properties.Resources.OOFSet_Enabled;
}
messageIcon = MessageBoxIcon.Information;
// It's okay if the state is not the same, but it deserves a message
if (appliedSettings.State != currentSettings.State)
{
message = Properties.Resources.OOFSet_DifferentState + message;
messageIcon = MessageBoxIcon.Warning;
}
}
Logger.Instance.Debug(this, "OOF state updated: {0}, {1}", message, messageIcon);
MessageBox.Show(message,
Properties.Resources.OOFSet_Title,
MessageBoxButtons.OK,
messageIcon
);
if (messageIcon == MessageBoxIcon.Information)
{
// All good, close the dialog
_buttons.IsDirty = false;
DialogResult = DialogResult.OK;
}
else
{
// There was a problem, initialise the dialog to what's set.
_settings = appliedSettings;
InitSettings();
CheckDirty();
}
}, true)
.OnError((x) =>
{
ErrorUtil.HandleErrorNew(this, "Exception in OOFSet", x,
Properties.Resources.OOFSet_Title, Properties.Resources.OOFSet_Failed);
})
.Start(this)
;
}
#endregion
}
}

View File

@ -117,26 +117,29 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableGlobal.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableGlobal.ColumnCount" type="System.Int32, mscorlib">
<data name="_layout.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="_layoutForm.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="chkEnable.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="chkEnable.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="chkEnable.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 2</value>
<value>6, 5</value>
</data>
<data name="chkEnable.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="chkEnable.Size" type="System.Drawing.Size, System.Drawing">
<value>197, 17</value>
<value>515, 36</value>
</data>
<data name="chkEnable.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -151,21 +154,21 @@
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;chkEnable.Parent" xml:space="preserve">
<value>tableGlobal</value>
<value>_layoutForm</value>
</data>
<data name="&gt;&gt;chkEnable.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="tableDates.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<data name="_layoutDates.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
</data>
<data name="tableDates.AutoSize" type="System.Boolean, mscorlib">
<data name="_layoutDates.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="tableDates.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<data name="_layoutDates.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="tableDates.ColumnCount" type="System.Int32, mscorlib">
<data name="_layoutDates.ColumnCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="radioNoTime.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
@ -174,14 +177,17 @@
<data name="radioNoTime.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="radioNoTime.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="radioNoTime.Location" type="System.Drawing.Point, System.Drawing">
<value>18, 2</value>
<value>48, 5</value>
</data>
<data name="radioNoTime.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>18, 2, 2, 2</value>
<value>48, 5, 6, 5</value>
</data>
<data name="radioNoTime.Size" type="System.Drawing.Size, System.Drawing">
<value>109, 17</value>
<value>279, 36</value>
</data>
<data name="radioNoTime.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -196,7 +202,7 @@
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;radioNoTime.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;radioNoTime.ZOrder" xml:space="preserve">
<value>0</value>
@ -207,14 +213,17 @@
<data name="radioTime.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="radioTime.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="radioTime.Location" type="System.Drawing.Point, System.Drawing">
<value>18, 23</value>
<value>48, 51</value>
</data>
<data name="radioTime.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>18, 2, 2, 2</value>
<value>48, 5, 6, 5</value>
</data>
<data name="radioTime.Size" type="System.Drawing.Size, System.Drawing">
<value>45, 20</value>
<value>108, 38</value>
</data>
<data name="radioTime.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -229,19 +238,19 @@
<value>System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;radioTime.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;radioTime.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="dateFrom.Location" type="System.Drawing.Point, System.Drawing">
<value>67, 23</value>
<value>170, 51</value>
</data>
<data name="dateFrom.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="dateFrom.Size" type="System.Drawing.Size, System.Drawing">
<value>128, 20</value>
<value>334, 38</value>
</data>
<data name="dateFrom.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -253,7 +262,7 @@
<value>System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;dateFrom.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;dateFrom.ZOrder" xml:space="preserve">
<value>2</value>
@ -262,13 +271,13 @@
<value>HH:mm</value>
</data>
<data name="timeFrom.Location" type="System.Drawing.Point, System.Drawing">
<value>199, 23</value>
<value>516, 51</value>
</data>
<data name="timeFrom.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="timeFrom.Size" type="System.Drawing.Size, System.Drawing">
<value>66, 20</value>
<value>170, 38</value>
</data>
<data name="timeFrom.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -280,7 +289,7 @@
<value>System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;timeFrom.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;timeFrom.ZOrder" xml:space="preserve">
<value>3</value>
@ -291,14 +300,17 @@
<data name="labelTill.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelTill.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="labelTill.Location" type="System.Drawing.Point, System.Drawing">
<value>33, 45</value>
<value>89, 94</value>
</data>
<data name="labelTill.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>33, 0, 2, 0</value>
<value>89, 0, 6, 0</value>
</data>
<data name="labelTill.Size" type="System.Drawing.Size, System.Drawing">
<value>30, 24</value>
<value>69, 48</value>
</data>
<data name="labelTill.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
@ -316,19 +328,19 @@
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;labelTill.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;labelTill.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="dateTill.Location" type="System.Drawing.Point, System.Drawing">
<value>67, 47</value>
<value>170, 99</value>
</data>
<data name="dateTill.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="dateTill.Size" type="System.Drawing.Size, System.Drawing">
<value>128, 20</value>
<value>334, 38</value>
</data>
<data name="dateTill.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -340,7 +352,7 @@
<value>System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;dateTill.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;dateTill.ZOrder" xml:space="preserve">
<value>5</value>
@ -349,13 +361,13 @@
<value>HH:mm</value>
</data>
<data name="timeTill.Location" type="System.Drawing.Point, System.Drawing">
<value>199, 47</value>
<value>516, 99</value>
</data>
<data name="timeTill.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="timeTill.Size" type="System.Drawing.Size, System.Drawing">
<value>66, 20</value>
<value>170, 38</value>
</data>
<data name="timeTill.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -367,40 +379,40 @@
<value>System.Windows.Forms.DateTimePicker, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;timeTill.Parent" xml:space="preserve">
<value>tableDates</value>
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;timeTill.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="tableDates.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 21</value>
<data name="_layoutDates.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 46</value>
</data>
<data name="tableDates.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<data name="_layoutDates.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="tableDates.RowCount" type="System.Int32, mscorlib">
<data name="_layoutDates.RowCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="tableDates.Size" type="System.Drawing.Size, System.Drawing">
<value>323, 69</value>
<data name="_layoutDates.Size" type="System.Drawing.Size, System.Drawing">
<value>863, 142</value>
</data>
<data name="tableDates.TabIndex" type="System.Int32, mscorlib">
<data name="_layoutDates.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;tableDates.Name" xml:space="preserve">
<value>tableDates</value>
<data name="&gt;&gt;_layoutDates.Name" xml:space="preserve">
<value>_layoutDates</value>
</data>
<data name="&gt;&gt;tableDates.Type" xml:space="preserve">
<data name="&gt;&gt;_layoutDates.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableDates.Parent" xml:space="preserve">
<value>tableGlobal</value>
<data name="&gt;&gt;_layoutDates.Parent" xml:space="preserve">
<value>_layoutForm</value>
</data>
<data name="&gt;&gt;tableDates.ZOrder" xml:space="preserve">
<data name="&gt;&gt;_layoutDates.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="tableDates.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="radioNoTime" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /&gt;&lt;Control Name="radioTime" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dateFrom" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="timeFrom" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="labelTill" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dateTill" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="timeTill" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,15" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<data name="_layoutDates.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="radioNoTime" Row="0" RowSpan="1" Column="0" ColumnSpan="3" /&gt;&lt;Control Name="radioTime" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dateFrom" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="timeFrom" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;Control Name="labelTill" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dateTill" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="timeTill" Row="2" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,AutoSize,0,Absolute,41" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="groupTextEntry.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
@ -423,14 +435,17 @@
<data name="labelBody.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelBody.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="labelBody.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 5</value>
<value>6, 12</value>
</data>
<data name="labelBody.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 5, 2, 0</value>
<value>6, 12, 6, 0</value>
</data>
<data name="labelBody.Size" type="System.Drawing.Size, System.Drawing">
<value>286, 13</value>
<value>756, 32</value>
</data>
<data name="labelBody.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -454,10 +469,10 @@
<value>Top, Bottom, Left, Right</value>
</data>
<data name="textBody.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 20</value>
<value>6, 49</value>
</data>
<data name="textBody.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="textBody.Multiline" type="System.Boolean, mscorlib">
<value>True</value>
@ -466,7 +481,7 @@
<value>Vertical</value>
</data>
<data name="textBody.Size" type="System.Drawing.Size, System.Drawing">
<value>309, 128</value>
<value>823, 358</value>
</data>
<data name="textBody.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
@ -484,16 +499,16 @@
<value>1</value>
</data>
<data name="tableTextEntry.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 11</value>
<value>9, 26</value>
</data>
<data name="tableTextEntry.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="tableTextEntry.RowCount" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="tableTextEntry.Size" type="System.Drawing.Size, System.Drawing">
<value>313, 150</value>
<value>835, 412</value>
</data>
<data name="tableTextEntry.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -511,19 +526,19 @@
<value>0</value>
</data>
<data name="tableTextEntry.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelBody" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="textBody" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,Absolute,20,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="labelBody" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="textBody" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,Percent,100,Absolute,48,Absolute,48" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="groupTextEntry.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 92</value>
<value>6, 193</value>
</data>
<data name="groupTextEntry.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="groupTextEntry.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="groupTextEntry.Size" type="System.Drawing.Size, System.Drawing">
<value>319, 167</value>
<value>851, 453</value>
</data>
<data name="groupTextEntry.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -535,148 +550,151 @@
<value>System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;groupTextEntry.Parent" xml:space="preserve">
<value>tableGlobal</value>
<value>_layoutForm</value>
</data>
<data name="&gt;&gt;groupTextEntry.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="flowButtons.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
<data name="_layoutForm.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="btnCancel.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
<data name="_layoutForm.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>256, 2</value>
<data name="_layoutForm.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 5, 6, 5</value>
</data>
<data name="btnCancel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<data name="_layoutForm.RowCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 27</value>
<data name="_layoutForm.Size" type="System.Drawing.Size, System.Drawing">
<value>863, 651</value>
</data>
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="btnCancel.Text" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="&gt;&gt;btnCancel.Name" xml:space="preserve">
<value>btnCancel</value>
</data>
<data name="&gt;&gt;btnCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnCancel.Parent" xml:space="preserve">
<value>flowButtons</value>
</data>
<data name="&gt;&gt;btnCancel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="btnSave.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="btnSave.Location" type="System.Drawing.Point, System.Drawing">
<value>191, 2</value>
</data>
<data name="btnSave.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="btnSave.Size" type="System.Drawing.Size, System.Drawing">
<value>61, 27</value>
</data>
<data name="btnSave.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="btnSave.Text" xml:space="preserve">
<value>Save</value>
</data>
<data name="&gt;&gt;btnSave.Name" xml:space="preserve">
<value>btnSave</value>
</data>
<data name="&gt;&gt;btnSave.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;btnSave.Parent" xml:space="preserve">
<value>flowButtons</value>
</data>
<data name="&gt;&gt;btnSave.ZOrder" xml:space="preserve">
<data name="_layoutForm.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="flowButtons.FlowDirection" type="System.Windows.Forms.FlowDirection, System.Windows.Forms">
<value>RightToLeft</value>
<data name="&gt;&gt;_layoutForm.Name" xml:space="preserve">
<value>_layoutForm</value>
</data>
<data name="flowButtons.Location" type="System.Drawing.Point, System.Drawing">
<value>2, 263</value>
</data>
<data name="flowButtons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="flowButtons.Size" type="System.Drawing.Size, System.Drawing">
<value>319, 31</value>
</data>
<data name="flowButtons.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;flowButtons.Name" xml:space="preserve">
<value>flowButtons</value>
</data>
<data name="&gt;&gt;flowButtons.Type" xml:space="preserve">
<value>System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;flowButtons.Parent" xml:space="preserve">
<value>tableGlobal</value>
</data>
<data name="&gt;&gt;flowButtons.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="tableGlobal.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 4</value>
</data>
<data name="tableGlobal.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="tableGlobal.RowCount" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="tableGlobal.Size" type="System.Drawing.Size, System.Drawing">
<value>323, 296</value>
</data>
<data name="tableGlobal.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;tableGlobal.Name" xml:space="preserve">
<value>tableGlobal</value>
</data>
<data name="&gt;&gt;tableGlobal.Type" xml:space="preserve">
<data name="&gt;&gt;_layoutForm.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableGlobal.Parent" xml:space="preserve">
<value>$this</value>
<data name="&gt;&gt;_layoutForm.Parent" xml:space="preserve">
<value>_busyHider</value>
</data>
<data name="&gt;&gt;tableGlobal.ZOrder" xml:space="preserve">
<data name="&gt;&gt;_layoutForm.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="tableGlobal.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="chkEnable" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="tableDates" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="groupTextEntry" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="flowButtons" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,Absolute,16" /&gt;&lt;/TableLayoutSettings&gt;</value>
<data name="_layoutForm.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="chkEnable" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_layoutDates" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="groupTextEntry" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,Percent,100,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="_busyHider.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_busyHider.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
</data>
<data name="_busyHider.Size" type="System.Drawing.Size, System.Drawing">
<value>863, 651</value>
</data>
<data name="_busyHider.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="_busyHider.Text" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="&gt;&gt;_busyHider.Name" xml:space="preserve">
<value>_busyHider</value>
</data>
<data name="&gt;&gt;_busyHider.Type" xml:space="preserve">
<value>Acacia.Controls.KBusyHider, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;_busyHider.Parent" xml:space="preserve">
<value>_layout</value>
</data>
<data name="&gt;&gt;_busyHider.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="_buttons.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="_buttons.AutoSizeMode" type="System.Windows.Forms.AutoSizeMode, System.Windows.Forms">
<value>GrowAndShrink</value>
</data>
<data name="_buttons.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_buttons.Location" type="System.Drawing.Point, System.Drawing">
<value>6, 662</value>
</data>
<data name="_buttons.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 5, 6, 5</value>
</data>
<data name="_buttons.Size" type="System.Drawing.Size, System.Drawing">
<value>857, 54</value>
</data>
<data name="_buttons.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="&gt;&gt;_buttons.Name" xml:space="preserve">
<value>_buttons</value>
</data>
<data name="&gt;&gt;_buttons.Type" xml:space="preserve">
<value>Acacia.Controls.KDialogButtons, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;_buttons.Parent" xml:space="preserve">
<value>_layout</value>
</data>
<data name="&gt;&gt;_buttons.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="_layout.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_layout.Location" type="System.Drawing.Point, System.Drawing">
<value>10, 9</value>
</data>
<data name="_layout.RowCount" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="_layout.Size" type="System.Drawing.Size, System.Drawing">
<value>869, 721</value>
</data>
<data name="_layout.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="&gt;&gt;_layout.Name" xml:space="preserve">
<value>_layout</value>
</data>
<data name="&gt;&gt;_layout.Type" xml:space="preserve">
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_layout.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;_layout.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="_layout.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="_busyHider" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_buttons" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="Percent,100,AutoSize,0,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
<value>16, 31</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>333, 310</value>
<value>889, 739</value>
</data>
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
<value>6, 5, 6, 5</value>
</data>
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
<value>348, 345</value>
<value>884, 727</value>
</data>
<data name="$this.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
<value>10, 9, 10, 9</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterParent</value>
@ -688,6 +706,6 @@
<value>OutOfOfficeDialog</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>Acacia.UI.KopanoDialog, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</value>
<value>Acacia.Controls.KDialogNew, Kopano, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -187,6 +187,15 @@ namespace Acacia.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to There are unsaved changes. Do you really want to to discard these?.
/// </summary>
internal static string OOF_Unsaved_Changes {
get {
return ResourceManager.GetString("OOF_Unsaved_Changes", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unable to retrieve Out of Office settings. You can still enable or disable Out of Office, but applying the settings might fail..
/// </summary>

View File

@ -454,4 +454,7 @@
<data name="SignaturesSync_Title" xml:space="preserve">
<value>Signatures</value>
</data>
<data name="OOF_Unsaved_Changes" xml:space="preserve">
<value>There are unsaved changes. Do you really want to to discard these?</value>
</data>
</root>

View File

@ -23,6 +23,7 @@ using System.Windows.Forms;
namespace Acacia.UI
{
// TODO: remove when Debug and SettingsDialog are rewritten.
public class KopanoDialog : Form
{
public KopanoDialog()

View File

@ -92,6 +92,21 @@ namespace Acacia.Utils
public class OOFMessage
{
public string Message { get; set; }
public override bool Equals(object obj)
{
if (obj is string)
return Message.Equals(obj);
else if (obj is OOFMessage)
return Message.Equals(((OOFMessage)obj).Message);
else
return false;
}
public override int GetHashCode()
{
return Message.GetHashCode();
}
}
public class SettingsOOF : Response
@ -99,9 +114,54 @@ namespace Acacia.Utils
public OOFState State { get; set; }
public DateTime? From { get; set; }
public DateTime? Till { get; set; }
public OOFMessage[] Message {get; set;}
public OOFMessage[] Message {get; private set;}
public bool? SupportsTimes { get; set; }
public SettingsOOF()
{
}
public SettingsOOF(bool initMessage)
{
if (initMessage)
Message = new OOFMessage[3];
}
public override bool Equals(object obj)
{
SettingsOOF rhs = obj as SettingsOOF;
if (rhs == null)
return false;
if (State != rhs.State)
return false;
// Check the times only if they are used
if (State == OOFState.EnabledTimeBased)
{
if (!From.Equals(rhs.From))
return false;
if (!Till.Equals(rhs.Till))
return false;
}
// Check the messages only if they are used
if (State != OOFState.Disabled)
{
// Only one entry is effectively used
if (!Message[0].NullSafeEquals(rhs.Message[0]))
return false;
}
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
protected override void ParseResponseBody(ActiveSync.RequestBase request, ZPushConnection.Response response)
{
// Check capabilities

View File

@ -24,6 +24,28 @@ namespace Acacia.Utils
{
public static class CollectionUtil
{
public static bool EnumEquals<TValue>(this IEnumerable<TValue> first, IEnumerable<TValue> second)
{
if (first == second) return true;
if ((first == null) || (second == null)) return false;
var i1 = first.GetEnumerator();
var i2 = second.GetEnumerator();
while (i1.MoveNext())
{
if (!i2.MoveNext())
return false;
if (!i1.Current.NullSafeEquals(i2.Current))
return false;
}
if (i2.MoveNext())
return false;
return true;
}
/// <summary>
/// Checks if both collections contain the same elements, not necessarily in the same order.
/// </summary>

View File

@ -29,7 +29,7 @@ namespace Acacia.Utils
{
public static class Util
{
public static bool NullSafeEquals<ObjType>(ObjType a, ObjType b)
public static bool NullSafeEquals<ObjType>(this ObjType a, ObjType b)
{
if (System.Object.ReferenceEquals(a, b))
{