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); } } } }
public static SmartGroupPropertiesDialog NewPropertiesDialog(SmartGroup group, Form parentForm) { SmartGroupPropertiesDialog smartGroupPropertiesDialog = new SmartGroupPropertiesDialog(group, group.Text + " Smart Group Properties", "OK", parentForm); smartGroupPropertiesDialog.CreateControls(group); smartGroupPropertiesDialog.PropertiesPage.PopulateParentDropDown(group, group.Parent as GroupBase); return(smartGroupPropertiesDialog); }
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 SmartGroup Create(SmartGroupPropertiesDialog dlg) { SmartGroup smartGroup = dlg.AssociatedNode as SmartGroup; smartGroup.UpdateSettings(dlg); smartGroup.FinishConstruction(dlg.PropertiesPage.ParentGroup); smartGroup.Refresh(); return(smartGroup); }
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 static SmartGroupPropertiesDialog NewAddDialog(GroupBase parent) { SmartGroup smartGroup = SmartGroup.CreateForAdd(); SmartGroupPropertiesDialog smartGroupPropertiesDialog = new SmartGroupPropertiesDialog(smartGroup, "Add Smart Group", "Add", null); if (parent != null && !parent.CanAddGroups()) { parent = null; } smartGroupPropertiesDialog.CreateControls(smartGroup); if (!smartGroupPropertiesDialog.PropertiesPage.PopulateParentDropDown(null, parent)) { smartGroupPropertiesDialog.Dispose(); return(null); } return(smartGroupPropertiesDialog); }
public static FileGroup OpenFile(string filename) { using (Helpers.Timer("reading {0}", filename)) { XmlDocument xmlDocument = new XmlDocument(); XmlTextReader xmlTextReader = null; XmlNode topNode; try { xmlTextReader = new XmlTextReader(filename); xmlTextReader.WhitespaceHandling = WhitespaceHandling.None; xmlTextReader.MoveToContent(); topNode = xmlDocument.ReadNode(xmlTextReader); } catch (Exception ex) { FormTools.ErrorDialog(ex.Message); return(null); } finally { xmlTextReader?.Close(); } if (topNode == null) { throw new FileLoadException(filename + ": File format error"); } FileGroup fileGroup = new FileGroup(filename); FileGroup fileGroup2 = (from f in ServerTree.Instance.Nodes.OfType <FileGroup>() where f.Pathname.Equals(fileGroup.Pathname, StringComparison.OrdinalIgnoreCase) select f).FirstOrDefault(); if (fileGroup2 == null) { try { List <string> errors = new List <string>(); ServerTree.Instance.Operation((OperationBehavior)31, delegate { ServerTree.Instance.AddNode(fileGroup, ServerTree.Instance.RootNode); if (!ReadXml(topNode, fileGroup, errors)) { throw new Exception(string.Empty); } }); if (errors.Count > 0) { StringBuilder stringBuilder = new StringBuilder("The following errors were encountered:").AppendLine().AppendLine(); foreach (string item in errors) { stringBuilder.AppendLine(item); } stringBuilder.AppendLine().Append("The file was not loaded completely. If it is saved it almost certainly means losing information. Continue?"); DialogResult dialogResult = FormTools.ExclamationDialog(stringBuilder.ToString(), MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { throw new Exception(string.Empty); } } using (Helpers.Timer("sorting root, builtin groups and file")) { ServerTree.Instance.SortRoot(); foreach (GroupBase builtInVirtualGroup in Program.BuiltInVirtualGroups) { ServerTree.Instance.SortGroup(builtInVirtualGroup); ServerTree.Instance.OnGroupChanged(builtInVirtualGroup, ChangeType.TreeChanged); } ServerTree.Instance.SortGroup(fileGroup, recurse: true); ServerTree.Instance.OnGroupChanged(fileGroup, ChangeType.TreeChanged); } SmartGroup.RefreshAll(fileGroup); fileGroup.VisitNodes(delegate(RdcTreeNode node) { GroupBase groupBase = node as GroupBase; if (groupBase != null && groupBase.Properties.Expanded.Value) { groupBase.Expand(); } }); Encryption.DecryptPasswords(); fileGroup.CheckCredentials(); fileGroup.VisitNodes(delegate(RdcTreeNode n) { n.ResetInheritance(); }); fileGroup.HasChangedSinceWrite = false; Program.Preferences.NeedToSave = true; return(fileGroup); } catch (Exception ex2) { if (!string.IsNullOrEmpty(ex2.Message)) { FormTools.ErrorDialog(ex2.Message); } ServerTree.Instance.RemoveNode(fileGroup); return(null); } } FormTools.InformationDialog("{0} is already open as '{1}'".CultureFormat(fileGroup.Pathname, fileGroup2.Text)); return(fileGroup2); } }
protected SmartGroupPropertiesDialog(SmartGroup group, string dialogTitle, string acceptButtonText, Form parentForm) : base(group, dialogTitle, acceptButtonText, parentForm) { }