[KOE-139] SharedFolderDialog now sets read-only flag on statically configured shared folders.

This commit is contained in:
Patrick Simpson 2017-11-08 14:39:52 +02:00
parent 7404b15d7a
commit b82e2ef839
6 changed files with 27 additions and 11 deletions

View File

@ -97,7 +97,7 @@ namespace Acacia.Controls
private void ToggleCheck(KTreeNode node)
{
if (_checkManager == null || node == null)
if (_checkManager == null || node == null || !node.CheckBoxEnabled)
return;
if (!SelectedNodes.Contains(node) || SelectedNodes.Count == 1)

View File

@ -127,6 +127,20 @@ namespace Acacia.Controls
}
}
private bool _checkBoxEnabled = true;
public bool CheckBoxEnabled
{
get { return _checkBoxEnabled; }
set
{
if (_checkBoxEnabled != value)
{
_checkBoxEnabled = value;
Owner?.Rerender(this);
}
}
}
private bool _isExpanded;
public bool IsExpanded
{

View File

@ -132,7 +132,7 @@ namespace Acacia.Controls
// Checkbox
if (_tree.CheckManager != null && node.HasCheckBox)
{
RenderCheckBox(graphics, node, dims.GetPartRect(KTreeNodeMeasurements.Part.CheckBox, true), highlight);
RenderCheckBox(graphics, node, dims.GetPartRect(KTreeNodeMeasurements.Part.CheckBox, true), highlight, node.CheckBoxEnabled);
}
// Images
@ -159,10 +159,12 @@ namespace Acacia.Controls
protected abstract void RenderNodeOutline(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
internal protected abstract void RenderNodeExpander(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight);
protected virtual void RenderCheckBox(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight)
protected virtual void RenderCheckBox(Graphics graphics, KTreeNode node, Rectangle rect, KTreeNodeMeasurements.Part? highlight, bool enabled)
{
int state = (int)node.CheckState * 4 + 1;
if (highlight != null && highlight.Value == KTreeNodeMeasurements.Part.CheckBox)
if (!enabled)
state += 3;
else if (highlight != null && highlight.Value == KTreeNodeMeasurements.Part.CheckBox)
state += 1;
CheckBoxRenderer.DrawCheckBox(graphics, rect.Location, (CheckBoxState)state);

View File

@ -30,7 +30,7 @@ namespace Acacia.Features.SharedFolders
private readonly StoreTreeNode _store;
private readonly AvailableFolder _folder;
private SharedFolder _share;
public bool IsReadOnly { get { return _store.IsReadOnly; } }
public readonly bool IsReadOnly;
public FolderTreeNode(StoreTreeNode store, AvailableFolder folder, SharedFolder share)
{
@ -40,7 +40,9 @@ namespace Acacia.Features.SharedFolders
this.Text = folder.Name;
HasCheckBox = !IsReadOnly;
IsReadOnly = share?.SyncId?.Kind == SyncKind.Configured;
HasCheckBox = true;
CheckBoxEnabled = !IsReadOnly;
// Image
// TODO: clean this up

View File

@ -261,8 +261,7 @@ namespace Acacia.Features.SharedFolders
// Add the node
node = new StoreTreeNode(_folders, gabLookup.GAB,
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>(),
false);
user, user.DisplayName, currentShares ?? new Dictionary<BackendId, SharedFolder>());
node.DirtyChanged += UserSharesChanged;
_userFolders.Add(user, node);
kTreeFolders.RootNodes.Add(node);

View File

@ -49,8 +49,7 @@ namespace Acacia.Features.SharedFolders
public readonly bool IsReadOnly;
public StoreTreeNode(SharedFoldersManager folders, GABHandler gab, GABUser user, string text,
Dictionary<BackendId, SharedFolder> currentFolders,
bool readOnly)
Dictionary<BackendId, SharedFolder> currentFolders)
:
base(text)
{
@ -58,7 +57,7 @@ namespace Acacia.Features.SharedFolders
this._feature = folders.Feature;
this._gab = gab;
this._user = user;
this.IsReadOnly = readOnly;
this.IsReadOnly = false;
// 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.