Toggle() публичный Метод

public Toggle ( ) : void
Результат void
Пример #1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            mouseDownAtNode = GetNodeAt(e.Location);
            if (mouseDownAtNode == null)
            {
                return;
            }

            // Try to toggle node with mouse.
            if (mouseDownAtNode.Nodes.Count > 0 &&
                e.X >= mouseDownAtNode.Bounds.X &&
                e.X <= mouseDownAtNode.Bounds.X + arrowSize)
            {
                mouseDownAtNode.Toggle();
                mouseDownAtNode = null; // Prevent node from being selected.
                return;
            }

            drag         = true;
            dragNode     = mouseDownAtNode;
            dragPosition = e.Location;
        }
 private bool OpenTreeViewNode(TreeNode curNode, bool toggle)
 {
     if (curNode.Tag is PackageRelationship)
     {
         PackageRelationship rel = (PackageRelationship)curNode.Tag;
         if (rel.TargetMode == TargetMode.Internal)
         {
             Uri target = System.IO.Packaging.PackUriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
             DocumentPart docPart = docPkg.DocParts[target.ToString()];
             Debug.Assert(docPart != null);
             if (docPart != null)
             {
                 TreeNode[] nodes = treeView.Nodes.Find(docPart.Path, true);
                 Debug.Assert(nodes.Length == 1);
                 if (nodes.Length > 0)
                 {
                     TreeNode node = nodes[0];
                     treeView.SelectedNode = node;
                 }
             }
         }
         else
         {
             // follow external link
             if (MessageBox.Show(
                 this,
                 "Are you sure you want to follow this external link?",
                 AboutForm.AssemblyTitle,
                 MessageBoxButtons.YesNo,
                 MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 System.Diagnostics.Process.Start(rel.TargetUri.ToString());
             }
         }
         return true;
     }
     else if (curNode.Tag is DocumentPart)
     {
         DocumentPart part = (DocumentPart)curNode.Tag;
         OpenPartEditor(part);
         return true;
     }
     else if ((curNode.Tag is DocumentPackage || curNode.Tag == null) && toggle)
     {
         // folder or document
         curNode.Toggle();
         return true;
     }
     return false;
 }
Пример #3
0
        private void Form2_Load(object sender, EventArgs e)
        {
            TreeNode root = new TreeNode(db.getDbName());
            DataSet ds = db.Select("SELECT tablename FROM pg_tables WHERE schemaname = 'public' ");

            this.treeView1.Nodes.Add(root);
            for (int i = 0; i <  ds.Tables[0].Rows.Count; i++) {
                root.Nodes.Add(ds.Tables[0].Rows[i][0].ToString(),ds.Tables[0].Rows[i][0].ToString(),1,2);
            }
            root.Toggle();

            setMsg( root.Text + " ���سɹ������ݱ����" + ds.Tables[0].Rows.Count + "��");

            listView1.Columns.Add("�ֶ�", 200);
            listView1.Columns.Add("����", 300);
            listView1.CheckBoxes = true;
            listView1.View = View.Details;
        }
Пример #4
0
        void AddFile(TreeNode snode, string name)
        {
            #region 检查文件名是否已存在

            foreach (TreeNode nd in snode.Nodes)
            {
                if (nd.Tag is GFile)
                {
                    var fle = nd.Tag as GFile;
                    if (fle.Text.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                    {
                        KryptonMessageBox.Show("文件名已存在!");
                        return;
                    }
                }
            }

            #endregion

            var path = string.Empty;
            if (snode.Tag is GProject)
            {
                path = (snode.Tag as GProject).SPath + "\\" + name;
            }
            else
            {
                path = (snode.Tag as GFolder).SPath + "\\" + name;
            }

            var tab = tabControl.AddNewTab(name, path);
            WebBrowser browser = new WebBrowser();
            var defaultPage = ConfigurationManager.AppSettings["defaultPage"];
            if (defaultPage == null || defaultPage.Length == 0)
            {
                throw new Exception("系统配置错误,初始页面不能为空,请检查配置文件!");
            }
            browser.Url = new Uri(defaultPage);
            browser.ObjectForScripting = this;
            browser.Dock = DockStyle.Fill;
            tab.Container.Controls.Add(browser);

            var file = new GFile(path) { Text = name, Tab = tab };
            if (snode.Tag is GProject)
            {
                (snode.Tag as GProject).Files.Add(file);
            }
            else
            {
                (snode.Tag as GFolder).Files.Add(file);
            }

            var node = new TreeNode(name) { Tag = file };
            node.ImageIndex = (int)ImageListEnum.File;
            node.SelectedImageIndex = node.ImageIndex;
            snode.Nodes.Add(node);
            snode.Toggle();
            fileTree.SelectedNode = node;
        }
Пример #5
0
        void AddProject(TreeNode snode, string name)
        {
            var path = (snode.Tag as GSolution).SPath + "\\" + name;
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var project = new GProject(path) { Text = name };
            _solution.Projects.Add(project);

            var node = new TreeNode(name) { Tag = project };
            node.ImageIndex = (int)ImageListEnum.Project;
            node.SelectedImageIndex = node.ImageIndex;
            snode.Nodes.Add(node);
            snode.Toggle();
            fileTree.SelectedNode = node;
        }
Пример #6
0
        void AddFolder(TreeNode snode, string name)
        {
            #region 检查文件夹名称是否已存在

            foreach (TreeNode nd in snode.Nodes)
            {
                if (nd.Tag is GFolder)
                {
                    var fld = nd.Tag as GFolder;
                    if (fld.Text.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                    {
                        KryptonMessageBox.Show("文件夹名称已存在!");
                        return;
                    }
                }
            }

            #endregion

            var path = (snode.Tag as GProject).SPath + "\\" + name;
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            var folder = new GFolder(path) { Text = name };
            (snode.Tag as GProject).Folders.Add(folder);

            var node = new TreeNode(name) { Tag = folder };
            node.ImageIndex = (int)ImageListEnum.Folder;
            node.SelectedImageIndex = node.ImageIndex;
            snode.Nodes.Add(node);
            snode.Toggle();
            fileTree.SelectedNode = node;
        }