Exemple #1
0
        void FillAll(TreeNode node)
        {
            Fill(node);

            TreeNodeCollection children = null;

            if (node == null)
            {
                children = this.Nodes;
            }
            else
            {
                node.Expand();
                children = node.Nodes;
            }

            for (int i = 0; i < children.Count; i++)
            {
                TreeNode child = children[i];
                // 需要展开
                if (ResTree.IsLoading(child) == true)
                {
                    FillAll(child);
                }
            }
        }
Exemple #2
0
        private void ResRightTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            TreeNode node = e.Node;

            if (node == null)
            {
                return;
            }

            // 需要展开
            if (ResTree.IsLoading(node) == true)
            {
                Fill(node);
            }
        }
Exemple #3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenResDlg));
     this.resTree         = new DigitalPlatform.rms.Client.ResTree();
     this.label1          = new System.Windows.Forms.Label();
     this.textBox_resPath = new System.Windows.Forms.TextBox();
     this.button_OK       = new System.Windows.Forms.Button();
     this.button_Cancel   = new System.Windows.Forms.Button();
     this.SuspendLayout();
     //
     // resTree
     //
     this.resTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                  | System.Windows.Forms.AnchorStyles.Left)
                                                                 | System.Windows.Forms.AnchorStyles.Right)));
     this.resTree.HideSelection      = false;
     this.resTree.ImageIndex         = 0;
     this.resTree.Location           = new System.Drawing.Point(12, 12);
     this.resTree.Name               = "resTree";
     this.resTree.SelectedImageIndex = 0;
     this.resTree.Size               = new System.Drawing.Size(496, 224);
     this.resTree.TabIndex           = 0;
     this.resTree.AfterCheck        += new System.Windows.Forms.TreeViewEventHandler(this.resTree_AfterCheck);
     this.resTree.AfterSelect       += new System.Windows.Forms.TreeViewEventHandler(this.resTree_AfterSelect);
     //
     // label1
     //
     this.label1.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(10, 253);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(77, 12);
     this.label1.TabIndex = 1;
     this.label1.Text     = "资源路径(&P):";
     //
     // textBox_resPath
     //
     this.textBox_resPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                                                                         | System.Windows.Forms.AnchorStyles.Right)));
     this.textBox_resPath.Location  = new System.Drawing.Point(12, 268);
     this.textBox_resPath.Multiline = true;
     this.textBox_resPath.Name      = "textBox_resPath";
     this.textBox_resPath.Size      = new System.Drawing.Size(415, 48);
     this.textBox_resPath.TabIndex  = 2;
     //
     // button_OK
     //
     this.button_OK.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.button_OK.Location = new System.Drawing.Point(433, 266);
     this.button_OK.Name     = "button_OK";
     this.button_OK.Size     = new System.Drawing.Size(75, 23);
     this.button_OK.TabIndex = 3;
     this.button_OK.Text     = "确定";
     this.button_OK.Click   += new System.EventHandler(this.button_OK_Click);
     //
     // button_Cancel
     //
     this.button_Cancel.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.button_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.button_Cancel.Location     = new System.Drawing.Point(433, 293);
     this.button_Cancel.Name         = "button_Cancel";
     this.button_Cancel.Size         = new System.Drawing.Size(75, 23);
     this.button_Cancel.TabIndex     = 4;
     this.button_Cancel.Text         = "取消";
     this.button_Cancel.Click       += new System.EventHandler(this.button_Cancel_Click);
     //
     // OpenResDlg
     //
     this.AcceptButton      = this.button_OK;
     this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
     this.CancelButton      = this.button_Cancel;
     this.ClientSize        = new System.Drawing.Size(520, 328);
     this.Controls.Add(this.button_Cancel);
     this.Controls.Add(this.button_OK);
     this.Controls.Add(this.textBox_resPath);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.resTree);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name          = "OpenResDlg";
     this.ShowInTaskbar = false;
     this.Text          = "指定资源路径";
     this.Closed       += new System.EventHandler(this.OpenResDlg_Closed);
     this.Load         += new System.EventHandler(this.OpenResDlg_Load);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Exemple #4
0
        // 递归
        public int Fill(TreeNode node)
        {
            TreeNodeCollection children = null;

            if (node == null)
            {
                children = this.Nodes;
            }
            else
            {
                children = node.Nodes;
            }

            int i;


            // 填充根
            if (node == null)
            {
                children.Clear();

                TreeNode nodeNew = new TreeNode(this.ServerUrl, ResTree.RESTYPE_SERVER, ResTree.RESTYPE_SERVER);
                ResTree.SetLoading(nodeNew);

                NodeInfo nodeinfo = new NodeInfo();
                nodeinfo.TreeNode   = nodeNew;
                nodeinfo.Expandable = true;
                nodeinfo.DefElement = GetDefElementString(nodeNew.ImageIndex);
                nodeinfo.NodeState |= NodeState.Object;

                nodeNew.Tag = nodeinfo;


                if (EnabledIndices != null &&
                    StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false)
                {
                    nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor);
                }

                children.Add(nodeNew);
                return(0);
            }


            // 根以下的节点类型
            ResPath respath = new ResPath(node);

            string strPath = respath.Path;

            //if (node != null)
            //	strPath = TreeViewUtil.GetPath(node);

            this.channel = Channels.GetChannel(this.ServerUrl);

            Debug.Assert(channel != null, "Channels.GetChannel() 异常");

            ResInfoItem[] items = null;

            string strError = "";

            DigitalPlatform.Stop stop = null;

            if (stopManager != null)
            {
                stop = new DigitalPlatform.Stop();

                stop.Register(this.stopManager, true);  // 和容器关联

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在列目录: " + this.ServerUrl + "?" + strPath);
                stop.BeginLoop();
            }

            long lRet = channel.DoDir(strPath,
                                      this.Lang,
                                      null, // 不需要列出全部语言的名字
                                      out items,
                                      out strError);

            if (stopManager != null)
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");

                stop.Unregister();      // 和容器关联
            }

            this.channel = null;

            if (lRet == -1)
            {
                try
                {
                    MessageBox.Show(this, "Channel::DoDir() Error: " + strError);
                }
                catch
                {
                    // this可能已经不存在
                    return(-1);
                }

                if (node != null)
                {
                    ResTree.SetLoading(node);   // 出错的善后处理,重新出现+号
                    node.Collapse();
                }
                return(-1);
            }


            if (items != null)
            {
                children.Clear();

                for (i = 0; i < items.Length; i++)
                {
                    // 忽略from类型节点
                    if (items[i].Type == ResTree.RESTYPE_FROM)
                    {
                        continue;
                    }

                    TreeNode nodeNew = new TreeNode(items[i].Name, items[i].Type, items[i].Type);


                    NodeInfo nodeinfo = new NodeInfo();
                    nodeinfo.TreeNode   = nodeNew;
                    nodeinfo.Expandable = items[i].HasChildren;
                    nodeinfo.DefElement = GetDefElementString(nodeNew.ImageIndex);
                    nodeinfo.NodeState |= NodeState.Object;
                    nodeinfo.Style      = items[i].Style;
                    nodeNew.Tag         = nodeinfo;

                    if (items[i].HasChildren)
                    {
                        ResTree.SetLoading(nodeNew);
                    }

                    if (EnabledIndices != null &&
                        StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false)
                    {
                        nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor);
                    }

                    children.Add(nodeNew);
                }
            }

            return(0);
        }
Exemple #5
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
     this.mainMenu1                   = new System.Windows.Forms.MainMenu(this.components);
     this.menuItem2                   = new System.Windows.Forms.MenuItem();
     this.menuItem_serversCfg         = new System.Windows.Forms.MenuItem();
     this.menuItem_cfgLinkInfo        = new System.Windows.Forms.MenuItem();
     this.menuItem3                   = new System.Windows.Forms.MenuItem();
     this.menuItem_exit               = new System.Windows.Forms.MenuItem();
     this.menuItem1                   = new System.Windows.Forms.MenuItem();
     this.menuItem_accountManagement  = new System.Windows.Forms.MenuItem();
     this.menuItem_databaseManagement = new System.Windows.Forms.MenuItem();
     this.menuItem_newDatabase        = new System.Windows.Forms.MenuItem();
     this.menuItem_deleteDatabase     = new System.Windows.Forms.MenuItem();
     this.menuItem_refresh            = new System.Windows.Forms.MenuItem();
     this.menuItem_test               = new System.Windows.Forms.MenuItem();
     this.toolBar1                  = new System.Windows.Forms.ToolBar();
     this.toolBarButton_stop        = new System.Windows.Forms.ToolBarButton();
     this.imageList_toolbar         = new System.Windows.Forms.ImageList(this.components);
     this.treeView_res              = new DigitalPlatform.rms.Client.ResTree();
     this.statusStrip_main          = new System.Windows.Forms.StatusStrip();
     this.toolStripStatusLabel_main = new System.Windows.Forms.ToolStripStatusLabel();
     this.toolStripProgressBar_main = new System.Windows.Forms.ToolStripProgressBar();
     this.statusStrip_main.SuspendLayout();
     this.SuspendLayout();
     //
     // mainMenu1
     //
     this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.menuItem2,
         this.menuItem1
     });
     //
     // menuItem2
     //
     this.menuItem2.Index = 0;
     this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.menuItem_serversCfg,
         this.menuItem_cfgLinkInfo,
         this.menuItem3,
         this.menuItem_exit
     });
     this.menuItem2.Text = "文件(&F)";
     //
     // menuItem_serversCfg
     //
     this.menuItem_serversCfg.Index  = 0;
     this.menuItem_serversCfg.Text   = "缺省帐户管理(&A)...";
     this.menuItem_serversCfg.Click += new System.EventHandler(this.menuItem_serversCfg_Click);
     //
     // menuItem_cfgLinkInfo
     //
     this.menuItem_cfgLinkInfo.Index   = 1;
     this.menuItem_cfgLinkInfo.Text    = "配置关联目录(&L)...";
     this.menuItem_cfgLinkInfo.Visible = false;
     this.menuItem_cfgLinkInfo.Click  += new System.EventHandler(this.menuItem_cfgLinkInfo_Click);
     //
     // menuItem3
     //
     this.menuItem3.Index = 2;
     this.menuItem3.Text  = "-";
     //
     // menuItem_exit
     //
     this.menuItem_exit.Index  = 3;
     this.menuItem_exit.Text   = "退出(&X)";
     this.menuItem_exit.Click += new System.EventHandler(this.menuItem_exit_Click);
     //
     // menuItem1
     //
     this.menuItem1.Index = 1;
     this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.menuItem_accountManagement,
         this.menuItem_databaseManagement,
         this.menuItem_newDatabase,
         this.menuItem_deleteDatabase,
         this.menuItem_refresh,
         this.menuItem_test
     });
     this.menuItem1.Text = "功能(&U)";
     //
     // menuItem_accountManagement
     //
     this.menuItem_accountManagement.Index  = 0;
     this.menuItem_accountManagement.Text   = "帐户(&A)...";
     this.menuItem_accountManagement.Click += new System.EventHandler(this.menuItem_accountManagement_Click);
     //
     // menuItem_databaseManagement
     //
     this.menuItem_databaseManagement.Index  = 1;
     this.menuItem_databaseManagement.Text   = "数据库(&M)...";
     this.menuItem_databaseManagement.Click += new System.EventHandler(this.menuItem_databaseManagement_Click);
     //
     // menuItem_newDatabase
     //
     this.menuItem_newDatabase.Index  = 2;
     this.menuItem_newDatabase.Text   = "新建数据库(&N)...";
     this.menuItem_newDatabase.Click += new System.EventHandler(this.menuItem_newDatabase_Click);
     //
     // menuItem_deleteDatabase
     //
     this.menuItem_deleteDatabase.Index  = 3;
     this.menuItem_deleteDatabase.Text   = "删除数据库(&D)";
     this.menuItem_deleteDatabase.Click += new System.EventHandler(this.menuItem_deleteObject_Click);
     //
     // menuItem_refresh
     //
     this.menuItem_refresh.Index  = 4;
     this.menuItem_refresh.Text   = "刷新(&R)";
     this.menuItem_refresh.Click += new System.EventHandler(this.menuItem_refresh_Click);
     //
     // menuItem_test
     //
     this.menuItem_test.Index   = 5;
     this.menuItem_test.Text    = "test";
     this.menuItem_test.Visible = false;
     this.menuItem_test.Click  += new System.EventHandler(this.menuItem_test_Click);
     //
     // toolBar1
     //
     this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
     this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
         this.toolBarButton_stop
     });
     this.toolBar1.DropDownArrows = true;
     this.toolBar1.ImageList      = this.imageList_toolbar;
     this.toolBar1.Location       = new System.Drawing.Point(0, 0);
     this.toolBar1.Name           = "toolBar1";
     this.toolBar1.ShowToolTips   = true;
     this.toolBar1.Size           = new System.Drawing.Size(481, 34);
     this.toolBar1.TabIndex       = 2;
     this.toolBar1.ButtonClick   += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
     //
     // toolBarButton_stop
     //
     this.toolBarButton_stop.Enabled     = false;
     this.toolBarButton_stop.ImageIndex  = 0;
     this.toolBarButton_stop.Name        = "toolBarButton_stop";
     this.toolBarButton_stop.ToolTipText = "停止";
     //
     // imageList_toolbar
     //
     this.imageList_toolbar.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList_toolbar.ImageStream")));
     this.imageList_toolbar.TransparentColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(193)))));
     this.imageList_toolbar.Images.SetKeyName(0, "");
     this.imageList_toolbar.Images.SetKeyName(1, "");
     //
     // treeView_res
     //
     this.treeView_res.BorderStyle        = System.Windows.Forms.BorderStyle.None;
     this.treeView_res.Dock               = System.Windows.Forms.DockStyle.Fill;
     this.treeView_res.HideSelection      = false;
     this.treeView_res.ImageIndex         = 0;
     this.treeView_res.Location           = new System.Drawing.Point(0, 34);
     this.treeView_res.Name               = "treeView_res";
     this.treeView_res.SelectedImageIndex = 0;
     this.treeView_res.Size               = new System.Drawing.Size(481, 340);
     this.treeView_res.TabIndex           = 0;
     this.treeView_res.OnSetMenu         += new DigitalPlatform.GUI.GuiAppendMenuEventHandle(this.treeView_res_OnSetMenu);
     this.treeView_res.AfterSelect       += new System.Windows.Forms.TreeViewEventHandler(this.treeView_res_AfterSelect);
     //
     // statusStrip_main
     //
     this.statusStrip_main.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.toolStripStatusLabel_main,
         this.toolStripProgressBar_main
     });
     this.statusStrip_main.Location   = new System.Drawing.Point(0, 352);
     this.statusStrip_main.Name       = "statusStrip_main";
     this.statusStrip_main.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
     this.statusStrip_main.Size       = new System.Drawing.Size(481, 22);
     this.statusStrip_main.TabIndex   = 5;
     this.statusStrip_main.Text       = "statusStrip1";
     //
     // toolStripStatusLabel_main
     //
     this.toolStripStatusLabel_main.Name   = "toolStripStatusLabel_main";
     this.toolStripStatusLabel_main.Size   = new System.Drawing.Size(292, 17);
     this.toolStripStatusLabel_main.Spring = true;
     //
     // toolStripProgressBar_main
     //
     this.toolStripProgressBar_main.Name = "toolStripProgressBar_main";
     this.toolStripProgressBar_main.Size = new System.Drawing.Size(172, 16);
     //
     // MainForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(481, 374);
     this.Controls.Add(this.statusStrip_main);
     this.Controls.Add(this.treeView_res);
     this.Controls.Add(this.toolBar1);
     this.Icon     = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Menu     = this.mainMenu1;
     this.Name     = "MainForm";
     this.Text     = "dp2manager V2 -- 内核管理";
     this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
     this.Closed  += new System.EventHandler(this.Form1_Closed);
     this.Load    += new System.EventHandler(this.Form1_Load);
     this.statusStrip_main.ResumeLayout(false);
     this.statusStrip_main.PerformLayout();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Exemple #6
0
        public (string, string) Start()
        {
            for (int i = 0; i < Text.Length; i++)
            {
                if (FrequencyAlph.Keys.Contains(Text[i]))
                {
                    FrequencyAlph[Text[i]]++;
                }
                else
                {
                    FrequencyAlph.Add(Text[i], 1);
                }
            }

            foreach (var pair in FrequencyAlph)
            {
                Source.Add(new Node(pair.Key.ToString(), "", pair.Value));
                ResTree.Add(new Node(pair.Key.ToString(), "", pair.Value));
                tree.Add(new Node(pair.Key.ToString(), "", pair.Value));
            }

            while (tree.Count > 1)
            {
                SortTree();

                for (int i = 0; i < Source.Count; i++)
                {
                    if (tree[tree.Count - 2].Text.Contains(Source[i].Text))
                    {
                        ResTree[i] = new Node(ResTree[i].Text, "0" + ResTree[i].Code, ResTree[i].Frequency);
                    }
                    else if (tree[tree.Count - 1].Text.Contains(Source[i].Text))
                    {
                        ResTree[i] = new Node(ResTree[i].Text, "1" + ResTree[i].Code, ResTree[i].Frequency);
                    }
                }

                tree[tree.Count - 2] = new Node(tree[tree.Count - 2].Text + tree[tree.Count - 1].Text, "",
                                                tree[tree.Count - 2].Frequency + tree[tree.Count - 1].Frequency);
                tree.RemoveAt(tree.Count - 1);
            }

            var alph = "";

            for (int i = 0; i < Source.Count; i++)
            {
                alph += $"{ResTree[i].Text} ({ResTree[i].Code})\n";
            }

            var res = "";

            for (int i = 0; i < Text.Length; i++)
            {
                foreach (var node in ResTree)
                {
                    if (node.Text == Text[i].ToString())
                    {
                        res += node.Code;
                    }
                }
            }

            return(res, alph);
        }