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

[KOE-124] UI improvements

This commit is contained in:
Patrick Simpson 2017-12-01 12:22:22 +02:00
parent 6d50679269
commit 3736d8d320
9 changed files with 192 additions and 37 deletions

View File

@ -49,6 +49,7 @@
this.checkReminders = new System.Windows.Forms.CheckBox();
this._labelPermissions = new System.Windows.Forms.Label();
this.dialogButtons = new Acacia.Controls.KDialogButtons();
this._labelRestartRequired = new System.Windows.Forms.Label();
this._layout.SuspendLayout();
this._mainBusyHider.SuspendLayout();
this._layoutMain.SuspendLayout();
@ -136,7 +137,7 @@
resources.ApplyResources(this._layoutOptions, "_layoutOptions");
this._layoutOptions.Controls.Add(this._labelWholeStore, 0, 0);
this._layoutOptions.Controls.Add(this.checkWholeStore, 1, 0);
this._layoutOptions.Controls.Add(this.labelPermissionsValue, 0, 4);
this._layoutOptions.Controls.Add(this.labelPermissionsValue, 1, 4);
this._layoutOptions.Controls.Add(this._labelName, 0, 1);
this._layoutOptions.Controls.Add(this.textName, 1, 1);
this._layoutOptions.Controls.Add(this._labelSendAs, 0, 2);
@ -144,6 +145,7 @@
this._layoutOptions.Controls.Add(this._labelReminders, 0, 3);
this._layoutOptions.Controls.Add(this.checkReminders, 1, 3);
this._layoutOptions.Controls.Add(this._labelPermissions, 0, 4);
this._layoutOptions.Controls.Add(this._labelRestartRequired, 2, 0);
this._layoutOptions.Name = "_layoutOptions";
//
// _labelWholeStore
@ -154,6 +156,7 @@
// checkWholeStore
//
resources.ApplyResources(this.checkWholeStore, "checkWholeStore");
this.checkWholeStore.ForeColor = System.Drawing.SystemColors.ControlText;
this.checkWholeStore.Name = "checkWholeStore";
this.checkWholeStore.UseVisualStyleBackColor = true;
this.checkWholeStore.CheckedChanged += new System.EventHandler(this.checkWholeStore_CheckedChanged);
@ -161,6 +164,7 @@
// labelPermissionsValue
//
resources.ApplyResources(this.labelPermissionsValue, "labelPermissionsValue");
this._layoutOptions.SetColumnSpan(this.labelPermissionsValue, 2);
this.labelPermissionsValue.Name = "labelPermissionsValue";
//
// _labelName
@ -170,6 +174,7 @@
//
// textName
//
this._layoutOptions.SetColumnSpan(this.textName, 2);
resources.ApplyResources(this.textName, "textName");
this.textName.Name = "textName";
this.textName.TextChanged += new System.EventHandler(this.textName_TextChanged);
@ -214,6 +219,11 @@
this.dialogButtons.Name = "dialogButtons";
this.dialogButtons.Apply += new System.EventHandler(this.dialogButtons_Apply);
//
// _labelRestartRequired
//
resources.ApplyResources(this._labelRestartRequired, "_labelRestartRequired");
this._labelRestartRequired.Name = "_labelRestartRequired";
//
// SharedFoldersDialog
//
resources.ApplyResources(this, "$this");
@ -259,5 +269,6 @@
private System.Windows.Forms.CheckBox checkReminders;
private System.Windows.Forms.CheckBox checkWholeStore;
private System.Windows.Forms.Label labelPermissionsValue;
private System.Windows.Forms.Label _labelRestartRequired;
}
}

View File

@ -93,10 +93,17 @@ namespace Acacia.Features.SharedFolders
private readonly ZPushAccount _account;
private readonly SharedFoldersManager _folders;
private readonly SyncId _initialSyncId;
private ZPushAccount _initialAccount;
private SharedFolder _initialFolder;
public SharedFoldersDialog(FeatureSharedFolders feature, ZPushAccount account, SyncId initial = null)
{
// If this is a shared store, open the account it's a share for, with the request account as the initial
if (account.ShareFor != null)
{
_initialAccount = account;
account = account.ShareForAccount;
}
this._account = account;
this._folders = feature.Manage(account);
this._initialSyncId = initial;
@ -142,6 +149,7 @@ namespace Acacia.Features.SharedFolders
.New((ctx) =>
{
// TODO: bind cancellation token to Cancel button
// Fetch current shares
ICollection<SharedFolder> folders = _folders.GetCurrentShares(ctx.CancellationToken);
@ -175,12 +183,18 @@ namespace Acacia.Features.SharedFolders
// Add public folders
Dictionary<BackendId, SharedFolder> publicShares;
shares.TryGetValue(GABUser.USER_PUBLIC, out publicShares);
AddUserFolders(GABUser.USER_PUBLIC, publicShares, false);
AddUserFolders(GABUser.USER_PUBLIC, false, publicShares, false);
// Add shared stores
foreach (ZPushAccount shared in _account.SharedAccounts)
{
AddUserFolders(new GABUser(shared.ShareUserName), true, null, false);
}
// Add any users for which we have shared folders
foreach (KeyValuePair<GABUser, Dictionary<BackendId, SharedFolder>> entry in shares.OrderBy(x => x.Key.DisplayName))
if (GABUser.USER_PUBLIC != entry.Key)
AddUserFolders(entry.Key, entry.Value, false);
AddUserFolders(entry.Key, false, entry.Value, false);
}
finally
{
@ -206,6 +220,14 @@ namespace Acacia.Features.SharedFolders
}
SetInitialFocus(kTreeFolders);
}
else if (_initialAccount != null)
{
StoreTreeNode node;
if (_userFolders.TryGetValue(new GABUser(_initialAccount.ShareUserName), out node))
{
FocusNode(node, true);
}
}
else
{
SetInitialFocus(gabLookup);
@ -237,6 +259,7 @@ namespace Acacia.Features.SharedFolders
foreach (StoreTreeNode storeNode in _userFolders.Values)
{
// Check modified folders
if (storeNode.IsDirty)
{
ctx.AddBusy(1);
@ -245,6 +268,7 @@ namespace Acacia.Features.SharedFolders
_folders.SetSharesForStore(storeNode.User, storeNode.CurrentShares, ctx.CancellationToken);
}
// And modified stores
if (storeNode.IsWholeStoreDirty)
{
state.stores.Add(storeNode);
@ -273,26 +297,44 @@ namespace Acacia.Features.SharedFolders
if (state.stores.Count > 0)
{
bool restart = MessageBox.Show(ThisAddIn.Instance.Window,
"Outlook will be restarted to open the new stores",
"Open stores",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Information
) == DialogResult.OK;
List<StoreTreeNode> add = new List<StoreTreeNode>();
// Reset state. Also do this when restarting, to avoid warning message about unsaved changes
foreach (StoreTreeNode node in state.stores)
node.WantShare = node.IsShared;
// Remove any unshared store
foreach (StoreTreeNode store in state.stores)
{
if (store.WantShare)
{
add.Add(store);
continue;
}
if (!restart)
return;
// Restart
IRestarter restarter = ThisAddIn.Instance.Restarter();
restarter.CloseWindows = true;
foreach (StoreTreeNode node in state.stores)
restarter.OpenShare(_account, node.User);
restarter.Restart();
}
// Check for any new stores
if (add.Count > 0)
{
bool restart = MessageBox.Show(ThisAddIn.Instance.Window,
"Outlook will be restarted to open the new stores",
"Open stores",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Information
) == DialogResult.OK;
// Reset state. Also do this when restarting, to avoid warning message about unsaved changes
foreach (StoreTreeNode node in state.stores)
node.WantShare = node.IsShared;
if (!restart)
return;
// Restart
IRestarter restarter = ThisAddIn.Instance.Restarter();
restarter.CloseWindows = true;
foreach (StoreTreeNode node in state.stores)
restarter.OpenShare(_account, node.User);
restarter.Restart();
}
}
}, true)
.OnError((x) =>
@ -311,7 +353,7 @@ namespace Acacia.Features.SharedFolders
private void buttonOpenUser_Click(object sender, EventArgs e)
{
AddUserFolders(gabLookup.SelectedUser, null, true);
AddUserFolders(gabLookup.SelectedUser, false, null, true);
}
private void gabLookup_SelectedUserChanged(object source, GABLookupControl.SelectedUserEventArgs e)
@ -320,7 +362,7 @@ namespace Acacia.Features.SharedFolders
if (e.IsChosen)
{
AddUserFolders(e.SelectedUser, null, true);
AddUserFolders(e.SelectedUser, false, null, true);
}
}
@ -338,7 +380,7 @@ namespace Acacia.Features.SharedFolders
private readonly Dictionary<GABUser, StoreTreeNode> _userFolders = new Dictionary<GABUser, StoreTreeNode>();
private void AddUserFolders(GABUser user, Dictionary<BackendId, SharedFolder> currentShares, bool select)
private void AddUserFolders(GABUser user, bool wholeStore, Dictionary<BackendId, SharedFolder> currentShares, bool select)
{
if (user == null)
return;
@ -355,7 +397,9 @@ namespace Acacia.Features.SharedFolders
// Add the node
node = new StoreTreeNode(_folders, gabLookup.GAB,
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>());
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>(),
wholeStore);
if (wholeStore)
node.DirtyChanged += UserSharesChanged;
node.CheckStateChanged += WholeStoreShareChanged;
_userFolders.Add(user, node);

View File

@ -307,7 +307,7 @@
<value>GrowAndShrink</value>
</data>
<data name="_layoutOptions.ColumnCount" type="System.Int32, mscorlib">
<value>2</value>
<value>3</value>
</data>
<data name="_labelWholeStore.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -402,9 +402,6 @@
<data name="labelPermissionsValue.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="labelPermissionsValue.Text" xml:space="preserve">
<value>Share as</value>
</data>
<data name="labelPermissionsValue.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
@ -648,6 +645,39 @@
<data name="&gt;&gt;_labelPermissions.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<data name="_labelRestartRequired.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_labelRestartRequired.Location" type="System.Drawing.Point, System.Drawing">
<value>123, 0</value>
</data>
<data name="_labelRestartRequired.Size" type="System.Drawing.Size, System.Drawing">
<value>322, 27</value>
</data>
<data name="_labelRestartRequired.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="_labelRestartRequired.Text" xml:space="preserve">
<value>(Requires restart)</value>
</data>
<data name="_labelRestartRequired.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="_labelRestartRequired.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="&gt;&gt;_labelRestartRequired.Name" xml:space="preserve">
<value>_labelRestartRequired</value>
</data>
<data name="&gt;&gt;_labelRestartRequired.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;_labelRestartRequired.Parent" xml:space="preserve">
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelRestartRequired.ZOrder" xml:space="preserve">
<value>10</value>
</data>
<data name="_layoutOptions.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
@ -679,7 +709,7 @@
<value>2</value>
</data>
<data name="_layoutOptions.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="_labelWholeStore" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkWholeStore" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelPermissionsValue" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_labelName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="textName" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelSendAs" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkSendAs" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelReminders" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkReminders" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelPermissions" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0" /&gt;&lt;/TableLayoutSettings&gt;</value>
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="_labelWholeStore" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkWholeStore" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="labelPermissionsValue" Row="4" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="_labelName" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="textName" Row="1" RowSpan="1" Column="1" ColumnSpan="2" /&gt;&lt;Control Name="_labelSendAs" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkSendAs" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelReminders" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkReminders" Row="3" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelPermissions" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="_labelRestartRequired" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="AutoSize,0,AutoSize,0,Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="_layoutMain.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>

View File

@ -47,9 +47,10 @@ namespace Acacia.Features.SharedFolders
private readonly GABUser _user;
public readonly bool IsReadOnly;
public readonly bool IsShared;
public StoreTreeNode(SharedFoldersManager folders, GABHandler gab, GABUser user, string text,
Dictionary<BackendId, SharedFolder> currentFolders)
Dictionary<BackendId, SharedFolder> currentFolders, bool isShared)
:
base(text)
{
@ -58,6 +59,7 @@ namespace Acacia.Features.SharedFolders
this._gab = gab;
this._user = user;
this.IsReadOnly = false;
this.IsShared = isShared;
// Create an empty current state. When loading the nodes, the shares will be added. This has the benefit of
// cleaning up automatically any obsolote shares.
@ -80,6 +82,9 @@ namespace Acacia.Features.SharedFolders
ChildLoader.Reload();
};
Control = _reloader;
// Set up sharing
WantShare = isShared;
}
private static void ApplyReadOnly(KTreeNode node, bool isReadOnly)
@ -92,11 +97,6 @@ namespace Acacia.Features.SharedFolders
get { return ((UserFolderLoader)ChildLoader).User; }
}
public bool IsShared
{
get { return false; }
}
public bool WantShare
{
get

View File

@ -46,6 +46,7 @@ namespace Acacia
public const string REG_VAL_CURRENT_SIGNATURE = "KOE Signature Digest";
public const string REG_VAL_NEXT_ACCOUNT_ID = "NextAccountID";
public const string REG_VAL_KOE_SHARE_FOR = "KOE Share For";
#endregion

View File

@ -72,5 +72,7 @@ namespace Acacia.Stubs
get;
set;
}
string ShareFor {get;}
}
}

View File

@ -284,6 +284,14 @@ namespace Acacia.Stubs.OutlookWrappers
}
}
public string ShareFor
{
get
{
return RegistryUtil.GetValueString(_regPath, OutlookConstants.REG_VAL_KOE_SHARE_FOR, null);
}
}
#endregion
}
}

View File

@ -36,10 +36,12 @@ namespace Acacia.ZPush
{
#region Miscellaneous
private readonly ZPushAccounts _zPushAccounts;
private readonly IAccount _account;
internal ZPushAccount(IAccount account)
internal ZPushAccount(ZPushAccounts zPushAccounts, IAccount account)
{
this._zPushAccounts = zPushAccounts;
this._account = account;
}
@ -206,5 +208,62 @@ namespace Acacia.ZPush
}
#endregion
#region Account sharing
public string ShareFor
{
get { return Account.ShareFor; }
}
public string ShareUserName
{
get
{
if (ShareFor == null)
return null;
int index = Account.UserName.IndexOf("+share+");
if (index < 0)
return null;
return Account.UserName.Substring(index + 7);
}
}
[Browsable(false)]
public ZPushAccount ShareForAccount
{
get
{
if (Account.ShareFor == null)
return null;
return _zPushAccounts.GetAccount(Account.ShareFor);
}
}
[Browsable(false)]
public ZPushAccount[] SharedAccounts
{
get
{
if (ShareFor != null)
return new ZPushAccount[0];
List<ZPushAccount> shares = new List<ZPushAccount>();
foreach (ZPushAccount account in _zPushAccounts.GetAccounts())
{
if (account == this)
continue;
if (account.ShareFor != null && account.ShareFor == this.Account.SmtpAddress)
shares.Add(account);
}
return shares.ToArray();
}
}
#endregion
}
}

View File

@ -94,7 +94,7 @@ namespace Acacia.ZPush
// Only EAS accounts can be zpush accounts
if (account.AccountType == AccountType.EAS)
{
ZPushAccount zpush = new ZPushAccount(account);
ZPushAccount zpush = new ZPushAccount(this, account);
_accountsByStoreId.Add(account.StoreID, zpush);
_accountsBySmtp.Add(account.SmtpAddress, zpush);
Logger.Instance.Trace(this, "ZPush account: {0}", zpush);