mirror of
				https://github.com/Kopano-dev/kopano-ol-extension.git
				synced 2023-10-10 11:37:40 +00:00 
			
		
		
		
	[KOE-139] SharedFolderDialog now sets read-only flag on statically configured shared folders.
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user