Example #1
0
        public static ServerPropertiesDialog NewPropertiesDialog(Server server, Form parentForm)
        {
            ServerPropertiesDialog serverPropertiesDialog = new ServerPropertiesDialog(server, server.DisplayName + " 配置", "OK", parentForm);

            serverPropertiesDialog.CreateServerPropertiesPage(server);
            serverPropertiesDialog.CreateControls(server);
            if (server.FileGroup == null)
            {
                serverPropertiesDialog.PropertiesPage.SetParentDropDown(server.Parent as GroupBase);
            }
            serverPropertiesDialog.PropertiesPage.PopulateParentDropDown(null, server.Parent as GroupBase);
            return(serverPropertiesDialog);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        public static void ImportServersDialog(TreeNode parentGroup)
        {
            if (!ServerTree.Instance.AnyOpenedEditableFiles())
            {
                NotifyUserFileNeeded();
                return;
            }
            ServerPropertiesDialog dlg = ServerPropertiesDialog.NewImportDialog(GetParentGroupForServerAdd(parentGroup));

            try
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    GroupBase group = dlg.PropertiesPage.ParentGroup;
                    ServerTree.Instance.Operation(OperationBehavior.SuspendSort | OperationBehavior.SuspendUpdate | OperationBehavior.SuspendGroupChanged, delegate
                    {
                        Server server = dlg.AssociatedNode as Server;
                        server.UpdateSettings(dlg);
                        foreach (string serverName in (dlg.PropertiesPage as ImportServersPropertiesPage).ExpandedServerNames)
                        {
                            IEnumerable <Server> source   = group.Nodes.OfType <Server>();
                            Func <Server, bool> predicate = (Server s) => s.ServerName == serverName;
                            Server server2 = source.Where(predicate).FirstOrDefault();
                            if (server2 != null)
                            {
                                server2.UpdateFromTemplate(server);
                            }
                            else
                            {
                                Server.Create(serverName, dlg);
                            }
                        }
                    });
                    FinishAddServers(group);
                }
            }
            finally
            {
                if (dlg != null)
                {
                    ((IDisposable)dlg).Dispose();
                }
            }
        }
Example #5
0
 public static void AddServersDialog(TreeNode suggestedParentNode)
 {
     if (!ServerTree.Instance.AnyOpenedEditableFiles())
     {
         NotifyUserFileNeeded();
     }
     else if (ServerTree.Instance.Nodes.OfType <FileGroup>().Any() || FormTools.YesNoDialog("RDCMan不允许混合使用服务器和组。 如果将服务器添加到顶级组,则将无法将任何组添加到该文件。 继续吗?") == DialogResult.Yes)
     {
         GroupBase groupBase        = GetParentGroupForServerAdd(suggestedParentNode);
         ServerPropertiesDialog dlg = ServerPropertiesDialog.NewAddDialog(groupBase);
         if (dlg == null)
         {
             FormTools.InformationDialog(info1);
             return;
         }
         using (dlg)
         {
             if (dlg.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             groupBase = dlg.PropertiesPage.ParentGroup;
             Server server = dlg.AssociatedNode as Server;
             server.UpdateSettings(dlg);
             ServerTree.Instance.Operation(OperationBehavior.SuspendSort | OperationBehavior.SuspendUpdate | OperationBehavior.SuspendGroupChanged, delegate
             {
                 List <string> expandedServerNames = (dlg.PropertiesPage as ServerPropertiesTabPage).ExpandedServerNames;
                 if (expandedServerNames.Count == 1)
                 {
                     Server.Create(dlg);
                 }
                 else
                 {
                     foreach (string item in expandedServerNames)
                     {
                         Server.Create(item, dlg);
                     }
                 }
             });
         }
         FinishAddServers(groupBase);
     }
 }