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

[KOE-124] Added UI support for opening whole stores

This commit is contained in:
Patrick Simpson 2017-11-29 11:18:10 +02:00
parent f70e320d85
commit ae076fe12f
7 changed files with 525 additions and 195 deletions

View File

@ -29,7 +29,8 @@ namespace Acacia.Controls
TwoState,
ThreeState,
Recursive,
RecursiveThreeState
RecursiveThreeState,
Custom
}
abstract public class KCheckManager
@ -119,7 +120,7 @@ namespace Acacia.Controls
// Set the check state recursively
node.Owner?.BeginUpdate();
SetNodeCheckState(node, NextCheckState(node.CheckState));
SetNodeCheckState(node, NextCheckState(node));
// Update the parent state
SetParentCheckState(node.Parent, node.CheckState);
@ -130,12 +131,12 @@ namespace Acacia.Controls
}
}
protected virtual CheckState NextCheckState(CheckState checkState)
protected virtual CheckState NextCheckState(KTreeNode node)
{
return (checkState == CheckState.Checked) ? CheckState.Unchecked : CheckState.Checked;
return (node.CheckState == CheckState.Checked) ? CheckState.Unchecked : CheckState.Checked;
}
protected void SetParentCheckState(KTreeNode parent, CheckState childCheckState)
protected virtual void SetParentCheckState(KTreeNode parent, CheckState childCheckState)
{
if (parent == null)
return;
@ -174,11 +175,18 @@ namespace Acacia.Controls
SetParentCheckState(parent.Parent, parent.CheckState);
}
private void SetNodeCheckState(KTreeNode node, CheckState checkState)
protected virtual void SetChildrenCheckState(KTreeNode parent, CheckState checkState)
{
foreach (KTreeNode child in parent.Children)
SetNodeCheckState(child, checkState != CheckState.Indeterminate ? checkState : CheckState.Unchecked);
}
protected virtual void SetNodeCheckState(KTreeNode node, CheckState checkState)
{
// Apply the children first, otherwise the node's check state will be based on that again
foreach (KTreeNode child in node.Children)
SetNodeCheckState(child, checkState != CheckState.Indeterminate ? checkState : CheckState.Unchecked);
SetChildrenCheckState(node, checkState);
// Set the node now
node.CheckState = checkState;
}
@ -252,9 +260,9 @@ namespace Acacia.Controls
SetParentCheckState(node.Parent, state);
}
protected override CheckState NextCheckState(CheckState checkState)
protected override CheckState NextCheckState(KTreeNode node)
{
switch(checkState)
switch(node.CheckState)
{
case CheckState.Unchecked:
return CheckState.Indeterminate;

View File

@ -197,6 +197,11 @@ namespace Acacia.Controls
EndLoading(node);
}
public void Reset()
{
State = LoadingState.NotLoaded;
}
public void Reload()
{
if (State != LoadingState.Loading)

View File

@ -29,7 +29,6 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SharedFoldersDialog));
Acacia.Controls.KCheckManager.RecursiveThreeState recursiveThreeState1 = new Acacia.Controls.KCheckManager.RecursiveThreeState();
this._layout = new System.Windows.Forms.TableLayoutPanel();
this._mainBusyHider = new Acacia.Controls.KBusyHider();
this._layoutMain = new System.Windows.Forms.TableLayoutPanel();
@ -39,6 +38,9 @@
this.buttonOpenUser = new System.Windows.Forms.Button();
this.kTreeFolders = new Acacia.Controls.KTree();
this._layoutOptions = new System.Windows.Forms.TableLayoutPanel();
this._labelWholeStore = new System.Windows.Forms.Label();
this.checkWholeStore = new System.Windows.Forms.CheckBox();
this.labelPermissionsValue = new System.Windows.Forms.Label();
this._labelName = new System.Windows.Forms.Label();
this.textName = new System.Windows.Forms.TextBox();
this._labelSendAs = new System.Windows.Forms.Label();
@ -46,7 +48,6 @@
this._labelReminders = new System.Windows.Forms.Label();
this.checkReminders = new System.Windows.Forms.CheckBox();
this._labelPermissions = new System.Windows.Forms.Label();
this.labelPermissionsValue = new System.Windows.Forms.Label();
this.dialogButtons = new Acacia.Controls.KDialogButtons();
this._layout.SuspendLayout();
this._mainBusyHider.SuspendLayout();
@ -118,8 +119,8 @@
//
this.kTreeFolders.BackColor = System.Drawing.SystemColors.Window;
this.kTreeFolders.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.kTreeFolders.CheckManager = recursiveThreeState1;
this.kTreeFolders.CheckStyle = Acacia.Controls.KCheckStyle.RecursiveThreeState;
this.kTreeFolders.CheckManager = null;
this.kTreeFolders.CheckStyle = Acacia.Controls.KCheckStyle.None;
resources.ApplyResources(this.kTreeFolders, "kTreeFolders");
this.kTreeFolders.FullRowSelect = true;
this.kTreeFolders.Images = null;
@ -129,21 +130,39 @@
this.kTreeFolders.NodePadding = new System.Windows.Forms.Padding(2, 4, 2, 4);
this.kTreeFolders.CheckStateChanged += new Acacia.Controls.KTree.CheckStateChangedHandler(this.kTreeFolders_CheckStateChanged);
this.kTreeFolders.SelectionChanged += new Acacia.Controls.KTree.SelectionChangedDelegate(this.kTreeFolders_SelectionChanged);
this.kTreeFolders.DoubleClick += new System.EventHandler(this.kTreeFolders_DoubleClick);
//
// _layoutOptions
//
resources.ApplyResources(this._layoutOptions, "_layoutOptions");
this._layoutOptions.Controls.Add(this._labelName, 0, 0);
this._layoutOptions.Controls.Add(this.textName, 1, 0);
this._layoutOptions.Controls.Add(this._labelSendAs, 0, 1);
this._layoutOptions.Controls.Add(this.checkSendAs, 1, 1);
this._layoutOptions.Controls.Add(this._labelReminders, 0, 2);
this._layoutOptions.Controls.Add(this.checkReminders, 1, 2);
this._layoutOptions.Controls.Add(this._labelPermissions, 0, 3);
this._layoutOptions.Controls.Add(this.labelPermissionsValue, 1, 3);
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._labelName, 0, 1);
this._layoutOptions.Controls.Add(this.textName, 1, 1);
this._layoutOptions.Controls.Add(this._labelSendAs, 0, 2);
this._layoutOptions.Controls.Add(this.checkSendAs, 1, 2);
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.Name = "_layoutOptions";
//
// _labelWholeStore
//
resources.ApplyResources(this._labelWholeStore, "_labelWholeStore");
this._labelWholeStore.Name = "_labelWholeStore";
//
// checkWholeStore
//
resources.ApplyResources(this.checkWholeStore, "checkWholeStore");
this.checkWholeStore.Name = "checkWholeStore";
this.checkWholeStore.UseVisualStyleBackColor = true;
this.checkWholeStore.CheckedChanged += new System.EventHandler(this.checkWholeStore_CheckedChanged);
//
// labelPermissionsValue
//
resources.ApplyResources(this.labelPermissionsValue, "labelPermissionsValue");
this.labelPermissionsValue.Name = "labelPermissionsValue";
//
// _labelName
//
resources.ApplyResources(this._labelName, "_labelName");
@ -185,11 +204,6 @@
resources.ApplyResources(this._labelPermissions, "_labelPermissions");
this._labelPermissions.Name = "_labelPermissions";
//
// labelPermissionsValue
//
resources.ApplyResources(this.labelPermissionsValue, "labelPermissionsValue");
this.labelPermissionsValue.Name = "labelPermissionsValue";
//
// dialogButtons
//
resources.ApplyResources(this.dialogButtons, "dialogButtons");
@ -237,11 +251,13 @@
private System.Windows.Forms.Label _labelSendAs;
private System.Windows.Forms.CheckBox checkSendAs;
private System.Windows.Forms.Label _labelPermissions;
private System.Windows.Forms.Label labelPermissionsValue;
private System.Windows.Forms.Label _labelWholeStore;
private Controls.KBusyHider _mainBusyHider;
private Controls.KDialogButtons dialogButtons;
private UI.GABLookupControl gabLookup;
private System.Windows.Forms.Label _labelReminders;
private System.Windows.Forms.CheckBox checkReminders;
private System.Windows.Forms.CheckBox checkWholeStore;
private System.Windows.Forms.Label labelPermissionsValue;
}
}

View File

@ -16,6 +16,7 @@
using Acacia.Controls;
using Acacia.Features.GAB;
using Acacia.Stubs;
using Acacia.UI;
using Acacia.UI.Outlook;
using Acacia.ZPush;
@ -37,6 +38,58 @@ namespace Acacia.Features.SharedFolders
{
public partial class SharedFoldersDialog : KDialogNew
{
/// <summary>
/// Check manager that makes the store check box independent of the folder checkboxes, which are
/// still applied recursively
/// </summary>
private class ShareCheckManager : KCheckManager.RecursiveThreeState
{
public override KCheckStyle CheckStyle { get { return KCheckStyle.Custom; } }
protected override void SetParentCheckState(KTreeNode parent, CheckState childCheckState)
{
// The store node state is independent of the rest
if (parent == null || parent is StoreTreeNode)
return;
base.SetParentCheckState(parent, childCheckState);
}
protected override void SetNodeCheckState(KTreeNode node, CheckState checkState)
{
// The store node state is independent of the rest
if (node is StoreTreeNode)
node.CheckState = checkState;
else
base.SetNodeCheckState(node, checkState);
}
protected override CheckState NextCheckState(KTreeNode node)
{
if (node is StoreTreeNode)
{
// The store node has a two-state checkbox
return (node.CheckState == CheckState.Checked) ? CheckState.Unchecked : CheckState.Checked;
}
else
{
return base.NextCheckState(node);
}
}
public override void SetCheck(KTreeNode node, CheckState state)
{
if (node is StoreTreeNode)
{
node.CheckStateDirect = state;
}
else
{
base.SetCheck(node, state);
}
}
}
private readonly ZPushAccount _account;
private readonly SharedFoldersManager _folders;
private readonly SyncId _initialSyncId;
@ -67,6 +120,9 @@ namespace Acacia.Features.SharedFolders
).Images;
// Set the check manager
kTreeFolders.CheckManager = new ShareCheckManager();
// Add the email address to the title
Text = string.Format(Text, account.Account.SmtpAddress);
@ -143,10 +199,10 @@ namespace Acacia.Features.SharedFolders
{
KTreeNode folderNode = node.FindNode(_initialFolder);
if (folderNode != null)
FocusNode(folderNode);
FocusNode(folderNode, true);
context.AddBusy(-1);
};
FocusNode(node);
FocusNode(node, true);
}
SetInitialFocus(kTreeFolders);
}
@ -165,41 +221,77 @@ namespace Acacia.Features.SharedFolders
});
}
private class ApplyState
{
public int folders;
public readonly List<StoreTreeNode> stores = new List<StoreTreeNode>();
}
private void dialogButtons_Apply(object sender, EventArgs e)
{
BusyText = Properties.Resources.SharedFolders_Applying_Label;
KUITask.New((ctx) =>
{
// We reuse the same busy indicationg for all calls. A count is kept to ensure it's removed.
int count = 0;
ApplyState state = new ApplyState();
foreach (StoreTreeNode storeNode in _userFolders.Values)
{
if (storeNode.IsDirty)
{
ctx.AddBusy(1);
++count;
++state.folders;
_folders.SetSharesForStore(storeNode.User, storeNode.CurrentShares, ctx.CancellationToken);
}
if (storeNode.IsWholeStoreDirty)
{
state.stores.Add(storeNode);
}
}
return count;
return state;
})
.OnSuccess((ctx, count) =>
.OnSuccess((ctx, state) =>
{
// Update UI state
foreach (StoreTreeNode storeNode in _userFolders.Values)
if (storeNode.IsDirty)
storeNode.ChangesApplied();
ctx.AddBusy(-count);
ctx.AddBusy(-state.folders);
// Sync account
_account.Account.SendReceive();
if (state.folders != 0)
{
// Sync account
_account.Account.SendReceive();
// Show success
ShowCompletion(Properties.Resources.SharedFolders_Applying_Success);
// Show success
ShowCompletion(Properties.Resources.SharedFolders_Applying_Success);
}
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;
// 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;
restarter.Restart();
}
}, true)
.OnError((x) =>
{
@ -263,23 +355,24 @@ namespace Acacia.Features.SharedFolders
node = new StoreTreeNode(_folders, gabLookup.GAB,
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>());
node.DirtyChanged += UserSharesChanged;
node.CheckStateChanged += WholeStoreShareChanged;
_userFolders.Add(user, node);
kTreeFolders.RootNodes.Add(node);
}
if (select)
{
FocusNode(node);
FocusNode(node, false);
}
}
private void FocusNode(KTreeNode node)
private void FocusNode(KTreeNode node, bool expand)
{
// Scroll it to the top of the window
kTreeFolders.SelectNode(node, KTree.ScrollMode.Top);
// Start loading folders
node.IsExpanded = true;
// Start loading folders if requested
node.IsExpanded = expand;
// Clear any selected user
gabLookup.SelectedUser = null;
@ -288,12 +381,25 @@ namespace Acacia.Features.SharedFolders
kTreeFolders.Focus();
}
private readonly Dictionary<string, bool> _dirtyUsers = new Dictionary<string, bool>();
private readonly Dictionary<GABUser, bool> _dirtyWholeStores = new Dictionary<GABUser, bool>();
private readonly Dictionary<GABUser, bool> _dirtyUsers = new Dictionary<GABUser, bool>();
private void UserSharesChanged(StoreTreeNode node)
{
_dirtyUsers[node.User.UserName] = node.IsDirty;
dialogButtons.IsDirty = _dirtyUsers.Values.Any((x) => x);
_dirtyUsers[node.User] = node.IsDirty;
CheckDirty();
}
private void WholeStoreShareChanged(KTreeNode node)
{
StoreTreeNode storeNode = (StoreTreeNode)node;
_dirtyWholeStores[storeNode.User] = storeNode.IsWholeStoreDirty;
CheckDirty();
}
private void CheckDirty()
{
dialogButtons.IsDirty = _dirtyUsers.Values.Any((x) => x) || _dirtyWholeStores.Values.Any((x) => x);
}
#region Advanced options
@ -392,6 +498,25 @@ namespace Acacia.Features.SharedFolders
}
private readonly List<FolderTreeNode> _optionPermissionNodes = new List<FolderTreeNode>();
private CheckState? OptionWholeStore
{
get
{
if (checkWholeStore.Visible)
return checkWholeStore.CheckState;
return null;
}
set
{
_labelWholeStore.Visible = checkWholeStore.Visible = value != null;
if (value != null)
checkWholeStore.CheckState = value.Value;
}
}
private readonly List<StoreTreeNode> _optionWholeStoreNodes = new List<StoreTreeNode>();
private readonly List<bool> _optionWholeStoreNodesInitial = new List<bool>();
private void ShowOptions(KTreeNode[] nodes)
{
try
@ -404,102 +529,146 @@ namespace Acacia.Features.SharedFolders
_optionRemindersNodes.Clear();
_optionRemindersInitial.Clear();
_optionPermissionNodes.Clear();
_optionWholeStoreNodes.Clear();
_optionWholeStoreNodesInitial.Clear();
OptionName = null;
OptionTrackName = null;
OptionSendAs = null;
OptionReminders = null;
OptionPermissions = null;
OptionWholeStore = null;
bool readOnly = false;
bool haveStoreNodes = false;
bool haveFolderNodes = false;
foreach (KTreeNode node in nodes)
{
// Ignore the root nodes
if (node is StoreTreeNode)
continue;
FolderTreeNode folderNode = (FolderTreeNode)node;
// Can only set options for shared folders
if (!folderNode.IsShared)
continue;
// Set all controls to read-only if any of the nodes is read-only
if (folderNode.IsReadOnly)
readOnly = true;
SharedFolder share = folderNode.SharedFolder;
AvailableFolder folder = folderNode.AvailableFolder;
// Assume we will edit the name for this node; cleared below if there are multiple
_optionNameNode = folderNode;
if (folder.Type.IsMail())
{
// Show send as if there are any mail folders
_optionSendAsNodes.Add(folderNode);
_optionSendAsInitial.Add(folderNode.SharedFolder.FlagSendAsOwner);
}
else if (folder.Type.IsAppointment())
{
// Show reminders for appointment folders
_optionRemindersNodes.Add(folderNode);
_optionRemindersInitial.Add(folderNode.SharedFolder.FlagCalendarReminders);
}
if (!_folders.SupportsWholeStore)
continue;
// Show permissions for all shared nodes
_optionPermissionNodes.Add(folderNode);
StoreTreeNode storeNode = (StoreTreeNode)node;
haveStoreNodes = true;
_optionWholeStoreNodes.Add(storeNode);
_optionWholeStoreNodesInitial.Add(storeNode.IsShared);
}
else
{
FolderTreeNode folderNode = (FolderTreeNode)node;
// Can only set options for shared folders
if (!folderNode.IsShared)
continue;
haveFolderNodes = true;
// Set all controls to read-only if any of the nodes is read-only
if (folderNode.IsReadOnly)
readOnly = true;
SharedFolder share = folderNode.SharedFolder;
AvailableFolder folder = folderNode.AvailableFolder;
// Assume we will edit the name for this node; cleared below if there are multiple
_optionNameNode = folderNode;
if (folder.Type.IsMail())
{
// Show send as if there are any mail folders
_optionSendAsNodes.Add(folderNode);
_optionSendAsInitial.Add(folderNode.SharedFolder.FlagSendAsOwner);
}
else if (folder.Type.IsAppointment())
{
// Show reminders for appointment folders
_optionRemindersNodes.Add(folderNode);
_optionRemindersInitial.Add(folderNode.SharedFolder.FlagCalendarReminders);
}
// Show permissions for all shared nodes
_optionPermissionNodes.Add(folderNode);
}
}
// Now check consistency of the options
// Only show the name if there is a single node.
// We do that here so there doesn't have to be duplication if testing if it's sharedd,
// ect
if (_optionNameNode != null && nodes.Length == 1)
if (haveFolderNodes && haveStoreNodes)
{
OptionName = _optionNameNode.SharedFolder.Name;
OptionTrackName = _optionNameNode.SharedFolder.FlagUpdateShareName;
// Mixed nodes, no options
return;
}
if (haveStoreNodes)
{
if (_optionWholeStoreNodes.Count > 0)
{
bool isShared = _optionWholeStoreNodes.First().WantShare;
if (_optionWholeStoreNodes.All(x => x.WantShare == isShared))
{
OptionWholeStore = isShared ? CheckState.Checked : CheckState.Unchecked;
checkWholeStore.ThreeState = false;
}
else
{
OptionWholeStore = CheckState.Indeterminate;
checkWholeStore.ThreeState = true;
}
}
}
else
{
_optionNameNode = null;
}
// Permissions shown if all are the same
if (_optionPermissionNodes.Count > 0)
{
Permission? permissions = _optionPermissionNodes.First().SharedFolder.Permissions;
if (_optionPermissionNodes.All(x => x.SharedFolder.Permissions == permissions))
OptionPermissions = permissions;
}
// Send as shown if any node supports it
if (_optionSendAsNodes.Count > 0)
{
bool sendAs = _optionSendAsNodes.First().SharedFolder.FlagSendAsOwner;
if (_optionSendAsNodes.All(x => x.SharedFolder.FlagSendAsOwner == sendAs))
// Only show the name if there is a single node.
// We do that here so there doesn't have to be duplication if testing if it's sharedd,
// ect
if (_optionNameNode != null && nodes.Length == 1)
{
OptionSendAs = sendAs ? CheckState.Checked : CheckState.Unchecked;
checkSendAs.ThreeState = false;
OptionName = _optionNameNode.SharedFolder.Name;
OptionTrackName = _optionNameNode.SharedFolder.FlagUpdateShareName;
}
else
{
OptionSendAs = CheckState.Indeterminate;
checkSendAs.ThreeState = true;
_optionNameNode = null;
}
}
// Reminders shown if any node supports it
if (_optionRemindersNodes.Count > 0)
{
bool reminders = _optionRemindersNodes.First().SharedFolder.FlagCalendarReminders;
if (_optionRemindersNodes.All(x => x.SharedFolder.FlagCalendarReminders == reminders))
// Permissions shown if all are the same
if (_optionPermissionNodes.Count > 0)
{
OptionReminders = reminders ? CheckState.Checked : CheckState.Unchecked;
checkReminders.ThreeState = false;
Permission? permissions = _optionPermissionNodes.First().SharedFolder.Permissions;
if (_optionPermissionNodes.All(x => x.SharedFolder.Permissions == permissions))
OptionPermissions = permissions;
}
else
// Send as shown if any node supports it
if (_optionSendAsNodes.Count > 0)
{
OptionReminders = CheckState.Indeterminate;
checkReminders.ThreeState = true;
bool sendAs = _optionSendAsNodes.First().SharedFolder.FlagSendAsOwner;
if (_optionSendAsNodes.All(x => x.SharedFolder.FlagSendAsOwner == sendAs))
{
OptionSendAs = sendAs ? CheckState.Checked : CheckState.Unchecked;
checkSendAs.ThreeState = false;
}
else
{
OptionSendAs = CheckState.Indeterminate;
checkSendAs.ThreeState = true;
}
}
// Reminders shown if any node supports it
if (_optionRemindersNodes.Count > 0)
{
bool reminders = _optionRemindersNodes.First().SharedFolder.FlagCalendarReminders;
if (_optionRemindersNodes.All(x => x.SharedFolder.FlagCalendarReminders == reminders))
{
OptionReminders = reminders ? CheckState.Checked : CheckState.Unchecked;
checkReminders.ThreeState = false;
}
else
{
OptionReminders = CheckState.Indeterminate;
checkReminders.ThreeState = true;
}
}
}
@ -538,6 +707,23 @@ namespace Acacia.Features.SharedFolders
}
}
private void checkWholeStore_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < _optionWholeStoreNodes.Count; ++i)
{
StoreTreeNode node = _optionWholeStoreNodes[i];
bool wholeStore = false;
switch (checkWholeStore.CheckState)
{
case CheckState.Checked: wholeStore = true; break;
case CheckState.Indeterminate: wholeStore = _optionWholeStoreNodesInitial[i]; break;
case CheckState.Unchecked: wholeStore = false; break;
}
node.WantShare = wholeStore;
}
}
private void checkSendAs_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < _optionSendAsNodes.Count; ++i)
@ -586,22 +772,5 @@ namespace Acacia.Features.SharedFolders
#endregion
private void kTreeFolders_DoubleClick(object sender, EventArgs e)
{
// TODO: This is some testing code for [KOE-123]
/*
if (ModifierKeys.HasFlag(Keys.Shift) && kTreeFolders.SelectedNodes.Count == 1)
{
KTreeNode selected = kTreeFolders.SelectedNodes.First();
if (selected is StoreTreeNode)
{
// Open store for user
Acacia.Stubs.IRestarter restarter = ThisAddIn.Instance.Restarter();
restarter.CloseWindows = true;
restarter.OpenShare(this._account, ((StoreTreeNode)selected).User);
restarter.Restart();
}
}*/
}
}
}

View File

@ -283,7 +283,7 @@
<value>3, 38</value>
</data>
<data name="kTreeFolders.Size" type="System.Drawing.Size, System.Drawing">
<value>442, 277</value>
<value>442, 250</value>
</data>
<data name="kTreeFolders.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -309,6 +309,117 @@
<data name="_layoutOptions.ColumnCount" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="_labelWholeStore.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="_labelWholeStore.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_labelWholeStore.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="_labelWholeStore.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
</data>
<data name="_labelWholeStore.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 4, 0, 3</value>
</data>
<data name="_labelWholeStore.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 27</value>
</data>
<data name="_labelWholeStore.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="_labelWholeStore.Text" xml:space="preserve">
<value>Open whole store</value>
</data>
<data name="_labelWholeStore.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;_labelWholeStore.Name" xml:space="preserve">
<value>_labelWholeStore</value>
</data>
<data name="&gt;&gt;_labelWholeStore.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;_labelWholeStore.Parent" xml:space="preserve">
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelWholeStore.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="checkWholeStore.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="checkWholeStore.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
</data>
<data name="checkWholeStore.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="checkWholeStore.Location" type="System.Drawing.Point, System.Drawing">
<value>102, 4</value>
</data>
<data name="checkWholeStore.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 4, 3, 3</value>
</data>
<data name="checkWholeStore.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 3, 0, 3</value>
</data>
<data name="checkWholeStore.Size" type="System.Drawing.Size, System.Drawing">
<value>15, 20</value>
</data>
<data name="checkWholeStore.TabIndex" type="System.Int32, mscorlib">
<value>9</value>
</data>
<data name="&gt;&gt;checkWholeStore.Name" xml:space="preserve">
<value>checkWholeStore</value>
</data>
<data name="&gt;&gt;checkWholeStore.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;checkWholeStore.Parent" xml:space="preserve">
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;checkWholeStore.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="labelPermissionsValue.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelPermissionsValue.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="labelPermissionsValue.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="labelPermissionsValue.Location" type="System.Drawing.Point, System.Drawing">
<value>99, 107</value>
</data>
<data name="labelPermissionsValue.Size" type="System.Drawing.Size, System.Drawing">
<value>346, 20</value>
</data>
<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>
<data name="&gt;&gt;labelPermissionsValue.Name" xml:space="preserve">
<value>labelPermissionsValue</value>
</data>
<data name="&gt;&gt;labelPermissionsValue.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;labelPermissionsValue.Parent" xml:space="preserve">
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;labelPermissionsValue.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="_labelName.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -316,10 +427,10 @@
<value>Fill</value>
</data>
<data name="_labelName.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 0</value>
<value>3, 27</value>
</data>
<data name="_labelName.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 26</value>
<value>90, 26</value>
</data>
<data name="_labelName.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -340,19 +451,19 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelName.ZOrder" xml:space="preserve">
<value>0</value>
<value>3</value>
</data>
<data name="textName.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="textName.Location" type="System.Drawing.Point, System.Drawing">
<value>94, 3</value>
<value>102, 30</value>
</data>
<data name="textName.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 3, 3, 3</value>
</data>
<data name="textName.Size" type="System.Drawing.Size, System.Drawing">
<value>351, 20</value>
<value>343, 20</value>
</data>
<data name="textName.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -367,7 +478,7 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;textName.ZOrder" xml:space="preserve">
<value>1</value>
<value>4</value>
</data>
<data name="_labelSendAs.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -376,10 +487,10 @@
<value>Fill</value>
</data>
<data name="_labelSendAs.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 26</value>
<value>3, 53</value>
</data>
<data name="_labelSendAs.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 27</value>
<value>90, 27</value>
</data>
<data name="_labelSendAs.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -400,7 +511,7 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelSendAs.ZOrder" xml:space="preserve">
<value>2</value>
<value>5</value>
</data>
<data name="checkSendAs.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -409,7 +520,7 @@
<value>Left</value>
</data>
<data name="checkSendAs.Location" type="System.Drawing.Point, System.Drawing">
<value>94, 30</value>
<value>102, 57</value>
</data>
<data name="checkSendAs.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 4, 3, 3</value>
@ -433,7 +544,7 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;checkSendAs.ZOrder" xml:space="preserve">
<value>3</value>
<value>6</value>
</data>
<data name="_labelReminders.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -442,10 +553,10 @@
<value>Fill</value>
</data>
<data name="_labelReminders.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 53</value>
<value>3, 80</value>
</data>
<data name="_labelReminders.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 27</value>
<value>90, 27</value>
</data>
<data name="_labelReminders.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -466,7 +577,7 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelReminders.ZOrder" xml:space="preserve">
<value>4</value>
<value>7</value>
</data>
<data name="checkReminders.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -475,7 +586,7 @@
<value>Left</value>
</data>
<data name="checkReminders.Location" type="System.Drawing.Point, System.Drawing">
<value>94, 57</value>
<value>102, 84</value>
</data>
<data name="checkReminders.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>6, 4, 3, 3</value>
@ -499,7 +610,7 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;checkReminders.ZOrder" xml:space="preserve">
<value>5</value>
<value>8</value>
</data>
<data name="_labelPermissions.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
@ -508,13 +619,13 @@
<value>Fill</value>
</data>
<data name="_labelPermissions.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 80</value>
<value>3, 107</value>
</data>
<data name="_labelPermissions.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 4, 0, 3</value>
</data>
<data name="_labelPermissions.Size" type="System.Drawing.Size, System.Drawing">
<value>82, 20</value>
<value>90, 20</value>
</data>
<data name="_labelPermissions.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
@ -535,61 +646,22 @@
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;_labelPermissions.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="labelPermissionsValue.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="labelPermissionsValue.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="labelPermissionsValue.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="labelPermissionsValue.Location" type="System.Drawing.Point, System.Drawing">
<value>91, 80</value>
</data>
<data name="labelPermissionsValue.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 4, 0, 3</value>
</data>
<data name="labelPermissionsValue.Size" type="System.Drawing.Size, System.Drawing">
<value>354, 20</value>
</data>
<data name="labelPermissionsValue.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="labelPermissionsValue.Text" xml:space="preserve">
<value>Permissions</value>
</data>
<data name="labelPermissionsValue.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;labelPermissionsValue.Name" xml:space="preserve">
<value>labelPermissionsValue</value>
</data>
<data name="&gt;&gt;labelPermissionsValue.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;labelPermissionsValue.Parent" xml:space="preserve">
<value>_layoutOptions</value>
</data>
<data name="&gt;&gt;labelPermissionsValue.ZOrder" xml:space="preserve">
<value>7</value>
<value>9</value>
</data>
<data name="_layoutOptions.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
<data name="_layoutOptions.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 318</value>
<value>0, 291</value>
</data>
<data name="_layoutOptions.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>0, 0, 0, 0</value>
</data>
<data name="_layoutOptions.RowCount" type="System.Int32, mscorlib">
<value>4</value>
<value>5</value>
</data>
<data name="_layoutOptions.Size" type="System.Drawing.Size, System.Drawing">
<value>448, 100</value>
<value>448, 127</value>
</data>
<data name="_layoutOptions.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -607,7 +679,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="_labelName" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="textName" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelSendAs" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkSendAs" Row="1" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelReminders" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="checkReminders" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /&gt;&lt;Control Name="_labelPermissions" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="labelPermissionsValue" Row="3" RowSpan="1" Column="1" 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,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="_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>
</data>
<data name="_layoutMain.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>

View File

@ -41,6 +41,11 @@ namespace Acacia.Features.SharedFolders
_query.Dispose();
}
public bool SupportsWholeStore
{
get { return true; } // TODO: use capability
}
public FeatureSharedFolders Feature { get { return _feature; } }
#region API

View File

@ -65,7 +65,7 @@ namespace Acacia.Features.SharedFolders
ChildLoader = new UserFolderLoader(this, folders, user);
ChildLoader.ReloadOnCloseOpen = true;
HasCheckBox = false;
HasCheckBox = folders.SupportsWholeStore;
ApplyReadOnly(this, IsReadOnly);
// TODO: better icons, better way of handling this
@ -92,6 +92,38 @@ namespace Acacia.Features.SharedFolders
get { return ((UserFolderLoader)ChildLoader).User; }
}
public bool IsShared
{
get { return false; }
}
public bool WantShare
{
get
{
return CheckState != System.Windows.Forms.CheckState.Unchecked;
}
set
{
CheckState = value ? System.Windows.Forms.CheckState.Checked : System.Windows.Forms.CheckState.Unchecked;
}
}
protected override void OnCheckStateChanged()
{
base.OnCheckStateChanged();
if (WantShare)
{
// Reload, this will return no children
ChildLoader.Reload();
}
else
{
ChildLoader.Reset();
}
}
#region Share management
/// <summary>
@ -204,6 +236,14 @@ namespace Acacia.Features.SharedFolders
}
}
public bool IsWholeStoreDirty
{
get
{
return WantShare != IsShared;
}
}
public void ChangesApplied()
{
// Save a copy of current folders to initial folders
@ -232,6 +272,8 @@ namespace Acacia.Features.SharedFolders
protected override object DoLoadChildren(KTreeNode node)
{
if (!WantsChildren(node))
return null;
return _folders.GetStoreFolders(User);
}
@ -257,8 +299,19 @@ namespace Acacia.Features.SharedFolders
}
}
private static bool WantsChildren(KTreeNode node)
{
// No children if we're sharing the whole store
if (node is StoreTreeNode)
return !((StoreTreeNode)node).WantShare;
return true;
}
protected override void DoRenderChildren(KTreeNode node, object loaded, KTreeNodes children)
{
if (!WantsChildren(node))
return;
List<AvailableFolder> folders = (List<AvailableFolder>)loaded;
foreach (AvailableFolder folder in folders.OrderBy(f => f, new FolderComparer(true)))
{
@ -319,6 +372,8 @@ namespace Acacia.Features.SharedFolders
case KTreeNodeLoader.LoadingState.Loading:
return Properties.Resources.SharedFolders_Loading;
case KTreeNodeLoader.LoadingState.Loaded:
if (!WantsChildren(children.Parent))
return null;
if (children.Count == 0)
return Properties.Resources.SharedFolders_None;
return null;