public void AddNode(RdcTreeNode node, GroupBase parent) { if (node == null) { throw new ArgumentNullException("node"); } if (!(node is ServerBase) && !(node is GroupBase)) { throw new ArgumentOutOfRangeException("node", "Node must derive from ServerBase or GroupBase"); } if (parent == null) { throw new ArgumentNullException("parent"); } if (parent == RootNode) { base.Nodes.Add(node); } else { parent.Nodes.Add(node); this.SortGroup(parent); } OnGroupChanged(parent, ChangeType.TreeChanged); }
public void OnGroupChanged(GroupBase group, ChangeType changeType) { if (_noGroupChanged > 0 || group == null) { return; } Log.Write("OnGroupChanged({1}) {0}", group.Text, changeType); HashSet <RdcTreeNode> set = new HashSet <RdcTreeNode>(); if (group == RootNode) { if (changeType.HasFlag(ChangeType.PropertyChanged)) { base.Nodes.VisitNodes(delegate(RdcTreeNode n) { set.Add(n); }); } } else { group.CollectNodesToInvalidate(recurseChildren: true, set); group.VisitParents(delegate(RdcTreeNode parent) { parent.CollectNodesToInvalidate(recurseChildren: false, set); }); } InvalidateNodes(set); this.GroupChanged?.Invoke(new GroupChangedEventArgs(group, changeType)); }
public void ShowGroup(GroupBase group) { bool flag = true; if (_layout != null && _layout.Group == group) { flag = false; } if (!_layoutHash.TryGetValue(group, out _layout)) { _layout = CreateThumbnailLayout(group); _layoutHash.Add(group, _layout); } ComputeScrollBarLimits(); if (flag) { if (!_groupScrollPosition.TryGetValue(group, out int value)) { value = 0; } SetScrollPosition(value); } _thumbnailDrawn = new bool[_layout.NodeCount]; DrawThumbnails(group); }
public static void AddSmartGroupDialog(TreeNode suggestedParentNode) { if (!ServerTree.Instance.AnyOpenedEditableFiles()) { NotifyUserFileNeeded(); return; } GroupBase parentGroupForGroupAdd = GetParentGroupForGroupAdd(suggestedParentNode); SmartGroupPropertiesDialog smartGroupPropertiesDialog = SmartGroupPropertiesDialog.NewAddDialog(parentGroupForGroupAdd); if (smartGroupPropertiesDialog == null) { FormTools.InformationDialog(info1); } else { using (smartGroupPropertiesDialog) { if (smartGroupPropertiesDialog.ShowDialog() == DialogResult.OK) { ServerTree.Instance.SelectedNode = SmartGroup.Create(smartGroupPropertiesDialog); } } } }
private static void FinishAddServers(GroupBase parentGroup) { ServerTree.Instance.SortGroup(parentGroup); ServerTree.Instance.OnGroupChanged(parentGroup, ChangeType.TreeChanged); ServerTree.Instance.SelectedNode = parentGroup; parentGroup.Expand(); }
private List <ServerLabel> CreateThumbnailList() { List <ServerLabel> labelList = new List <ServerLabel>(); HashSet <Server> set = new HashSet <Server>(); bool useActualNode = Group is VirtualGroup; Group.VisitNodes(delegate(RdcTreeNode node) { GroupBase groupBase = node as GroupBase; if (groupBase != null) { groupBase.InheritSettings(); } else { ServerBase serverBase = node as ServerBase; Server serverNode = serverBase.ServerNode; if (!set.Contains(serverNode)) { groupBase = (serverNode.Parent as GroupBase); if (groupBase != null) { groupBase.InheritSettings(); if (groupBase.DisplaySettings.ShowDisconnectedThumbnails.Value || serverNode.IsConnected) { ServerLabel item = new ServerLabel(useActualNode ? serverBase : serverNode); labelList.Add(item); set.Add(serverNode); } } } } }); return(labelList); }
public void HideGroup(GroupBase group) { if (_layout != null) { if (_layout.Group != group) { return; } _groupScrollPosition[group] = _verticalScrollBar.Value; try { ServerLabel serverLabel = Program.TheForm.ActiveControl as ServerLabel; ServerLabel[] labelArray = _layout.LabelArray; foreach (ServerLabel serverLabel2 in labelArray) { if (serverLabel == serverLabel2) { Program.TheForm.ActiveControl = this; } serverLabel2.Server.Hide(); base.Controls.Remove(serverLabel2); } } finally { _layout = null; } } _verticalScrollBar.Hide(); }
internal static Group Create(XmlNode xmlNode, GroupBase parent, ICollection <string> errors) { Group group = new Group(); group.ReadXml(xmlNode, errors); group.FinishConstruction(parent); return(group); }
public static Group Create(string name, GroupBase parent) { Group group = new Group(); group.Properties.GroupName.Value = name; group.FinishConstruction(parent); return(group); }
public static SmartGroup Create(XmlNode xmlNode, GroupBase parent, ICollection <string> errors) { SmartGroup smartGroup = new SmartGroup(); smartGroup.FinishConstruction(parent); smartGroup.ReadXml(xmlNode, errors); smartGroup.Text = smartGroup.Properties.GroupName.Value; return(smartGroup); }
public static DefaultGroupPropertiesDialog NewPropertiesDialog(GroupBase group, Form parentForm) { DefaultGroupPropertiesDialog defaultGroupPropertiesDialog = new DefaultGroupPropertiesDialog(group, parentForm); defaultGroupPropertiesDialog.CreateControls(group); defaultGroupPropertiesDialog.PopulateCredentialsProfiles(null); defaultGroupPropertiesDialog.PopulateCredentialsManagementTab(Program.CredentialsProfiles); return(defaultGroupPropertiesDialog); }
protected void PopulateCredentialsProfiles(GroupBase group) { FileGroup file = group?.FileGroup; foreach (ICredentialsTabPage item in base.TabPages.OfType <ICredentialsTabPage>()) { item.PopulateCredentialsProfiles(file); } }
public static bool SortGroup(this ServerTree tree, GroupBase group, bool recurse) { bool result = false; if (group.AllowSort) { result = tree.SortHelper(group.Nodes, recurse); } return(result); }
private void DrawThumbnails(GroupBase group) { if (_layout.NodeCount != 0) { using (Helpers.Timer("drawing {0} ({1} thumbnails)", group.Text, _layout.NodeCount)) { DrawThumbnails(_verticalScrollBar.Value, _verticalScrollBar.Value, base.ClientSize.Height); } } }
private static void RefreshScope(GroupBase scope, Action <SmartGroup> process) { scope?.VisitParents(delegate(RdcTreeNode parent) { foreach (SmartGroup item in parent.Nodes.OfType <SmartGroup>()) { process(item); } }); }
internal void InheritSettings(RdcTreeNode node, ref bool anyInherited) { GroupBase inheritedSettingsNode = InheritSettingsType.GetInheritedSettingsNode(node); if (inheritedSettingsNode != null) { inheritedSettingsNode.InheritSettings(); Copy(inheritedSettingsNode); anyInherited = true; } }
protected override void OnClientSizeChanged(EventArgs e) { if (!Program.TheForm.IsFullScreen) { Size clientSize = base.ClientSize; try { TreeNode selectedNode = ServerTree.Instance.SelectedNode; GroupBase groupBase = selectedNode as GroupBase; if (groupBase == null) { ServerBase serverBase = selectedNode as ServerBase; if (serverBase != null) { if (serverBase.IsThumbnail) { throw new InvalidOperationException("Selected server is a thumbnail"); } serverBase.ServerNode.SetNormalView(); } ResetLayout(); } else if (_layout != null && _layout.Group == groupBase) { if (!Program.Preferences.ThumbnailSizeIsInPixels) { goto IL_00f8; } int width = Program.Preferences.ThumbnailSize.Width; if (ComputeNumAcross(clientSize.Width, width) != ComputeNumAcross(_savedSize.Width, width)) { goto IL_00f8; } if (_savedSize.Height != clientSize.Height) { int value = _verticalScrollBar.Value; ComputeScrollBarLimits(); DrawAndScroll(value, _verticalScrollBar.Value); } } goto end_IL_0014; IL_00f8: HideGroup(groupBase); ResetLayout(); ShowGroup(groupBase); end_IL_0014 :; } finally { _savedSize = clientSize; } } }
static GroupBase() { NodeActions = new Dictionary <string, Helpers.ReadXmlDelegate> { { "properties", delegate(XmlNode childNode, RdcTreeNode parent, ICollection <string> errors) { if (SchemaVersion <= 2) { (parent as GroupBase).ReadXml(PropertyActions, childNode, errors); } else { (parent as GroupBase).ReadXmlSettingsGroup(childNode, errors); } } }, { "server", delegate(XmlNode childNode, RdcTreeNode parent, ICollection <string> errors) { Server server = Server.Create(childNode, parent as GroupBase, errors); LongRunningActionForm.Instance.UpdateStatus(server.Properties.DisplayName.Value); } }, { "group", delegate(XmlNode childNode, RdcTreeNode parent, ICollection <string> errors) { GroupBase groupBase2 = Group.Create(childNode, parent as GroupBase, errors); LongRunningActionForm.Instance.UpdateStatus(groupBase2.Properties.GroupName.Value); } }, { "smartGroup", delegate(XmlNode childNode, RdcTreeNode parent, ICollection <string> errors) { GroupBase groupBase = SmartGroup.Create(childNode, parent as GroupBase, errors); LongRunningActionForm.Instance.UpdateStatus(groupBase.Properties.GroupName.Value); } } }; PropertyActions = new Dictionary <string, Helpers.ReadXmlDelegate> { { "name", delegate(XmlNode childNode, RdcTreeNode node, ICollection <string> errors) { (node as GroupBase).Properties.GroupName.Value = childNode.InnerText; } },
public override bool CanDropOnTarget(RdcTreeNode targetNode) { if (FileGroup == null) { GroupBase groupBase = (targetNode as GroupBase) ?? (targetNode.Parent as GroupBase); if (groupBase.DropBehavior() != DragDropEffects.Link) { return(groupBase.CanDropServers()); } return(false); } return(base.CanDropOnTarget(targetNode)); }
public static bool SortNode(this ServerTree tree, RdcTreeNode node) { GroupBase groupBase = node.Parent as GroupBase; if (groupBase != null) { return(tree.SortGroup(groupBase)); } if (node.Parent == null) { tree.SortRoot(); } return(false); }
private static GroupBase GetParentGroupForGroupAdd(TreeNode node) { GroupBase groupBase = null; if (node != null) { groupBase = ((node as GroupBase) ?? (node.Parent as GroupBase)); while (groupBase != null && !groupBase.CanAddGroups()) { groupBase = (groupBase.Parent as GroupBase); } } return(groupBase); }
private void DoRemoveChildren(RdcTreeNode node) { GroupBase groupBase = node as GroupBase; if (groupBase.Nodes.Count > 0) { DialogResult dialogResult = FormTools.YesNoDialog("删除 " + groupBase.Text + " 组中的所有子项?"); if (dialogResult != DialogResult.Yes) { return; } } groupBase.RemoveChildren(); }
public static ServerPropertiesDialog NewAddDialog(GroupBase parent) { Server server = Server.CreateForAddDialog(); ServerPropertiesDialog serverPropertiesDialog = new ServerPropertiesDialog(server, "添加服务器", "添加", null); //(server, "Add Server", "Add", null) serverPropertiesDialog.CreateServerPropertiesPage(server); serverPropertiesDialog.CreateControls(server); if (!serverPropertiesDialog.PropertiesPage.PopulateParentDropDown(null, parent)) { serverPropertiesDialog.Dispose(); return(null); } return(serverPropertiesDialog); }
public static ServerPropertiesDialog NewImportDialog(GroupBase parent) { Server server = Server.CreateForAddDialog(); ServerPropertiesDialog serverPropertiesDialog = new ServerPropertiesDialog(server, "导入服务器配置", "导入", null); //(server, "Import Servers", "Import", null) serverPropertiesDialog.CreateImportServersPage(server); serverPropertiesDialog.CreateControls(server); if (!serverPropertiesDialog.PropertiesPage.PopulateParentDropDown(null, parent)) { serverPropertiesDialog.Dispose(); return(null); } return(serverPropertiesDialog); }
public virtual bool AllowEdit(bool popUI) { GroupBase readOnlyParent = GetReadOnlyParent(); if (readOnlyParent != null) { if (popUI) { FormTools.InformationDialog("{0} '{1}' 是只读的,无法编辑".CultureFormat((readOnlyParent == this) ? "群组" : "父群组", readOnlyParent.Text)); } return(false); } return(true); }
protected override void OnDragDrop(DragEventArgs e) { base.OnDragDrop(e); Point pt = PointToClient(new Point(e.X, e.Y)); RdcTreeNode rdcTreeNode = GetNodeAt(pt) as RdcTreeNode; if (rdcTreeNode != null) { GroupBase groupBase = (rdcTreeNode as GroupBase) ?? (rdcTreeNode.Parent as GroupBase); if (groupBase != _draggedNode && groupBase != _draggedNode.Parent) { MoveNode(_draggedNode, groupBase); } } }
internal GroupBase GetReadOnlyParent() { TreeNode treeNode = this; do { GroupBase groupBase = treeNode as GroupBase; if (groupBase != null && groupBase.IsReadOnly) { return(groupBase); } treeNode = treeNode.Parent; }while (treeNode != null); return(null); }
private void PopulateParentDropDown(GroupBase excludeGroup) { ServerTree.Instance.Nodes.VisitNodes(delegate(RdcTreeNode node) { if (node == excludeGroup) { return(NodeVisitorResult.NoRecurse); } GroupBase groupBase = node as GroupBase; if (groupBase != null && CanBeParent(groupBase)) { _parentComboBox.AddItem(groupBase.FullPath, groupBase); } return(NodeVisitorResult.Continue); }); }
public static GroupPropertiesDialog NewAddDialog(GroupBase parent) { Group group = Group.CreateForAddDialog(); GroupPropertiesDialog groupPropertiesDialog = new GroupPropertiesDialog(group, "Add Group", "Add", null); groupPropertiesDialog.CreateControls(group); if (parent != null && !parent.CanAddGroups()) { parent = null; } if (!groupPropertiesDialog.PropertiesPage.PopulateParentDropDown(null, parent)) { groupPropertiesDialog.Dispose(); return(null); } return(groupPropertiesDialog); }
public bool PopulateParentDropDown(GroupBase excludeGroup, GroupBase defaultParent) { PopulateParentDropDown(excludeGroup); if (defaultParent != null && CanBeParent(defaultParent)) { _parentComboBox.SelectedValue = defaultParent; } else { if (_parentComboBox.ItemCount == 0) { return(false); } _parentComboBox.SelectedIndex = 0; } return(true); }