private void AddFolderNode(KTreeNode node, KTreeNodes children, AvailableFolder folder) { StoreTreeNode rootNode = (StoreTreeNode)this.Children.Parent; // Create the tree node SharedFolder share = rootNode.GetInitialShareState(folder); FolderTreeNode child = new FolderTreeNode(rootNode, folder, share); ApplyReadOnly(child, child.IsReadOnly); // Add children.Add(child); // Add the children foreach (AvailableFolder childFolder in folder.Children.OrderBy(f => f, new FolderComparer(false))) { AddFolderNode(child, child.Children, childFolder); } // Set the initial share state if (share != null) { child.IsChecked = true; } // Add the share; it might have become checked by any of the child nodes if (child.IsShared) { rootNode.AddShare(folder, share); } }
protected override void OnCheckStateChanged() { // Update share state if (CheckState == System.Windows.Forms.CheckState.Unchecked) { _store.RemoveShare(_folder); } else { _share = _store.AddShare(_folder, _share); } base.OnCheckStateChanged(); }