Beispiel #1
0
        /// <summary>
        /// Collaps the node for the given <see cref="ObjectField"/>.
        /// </summary>
        /// <param name="otherField">The node of this <see cref="ObjectField"/> will be collapsed if found.</param>
        public void Collapse(ObjectField otherField)
        {
            TreeNodeAdv node = trvTree.FindNodeByTag(otherField);

            if (node != null)
            {
                node.Collapse();
            }
        }
        private void treeViewAdv1_DoubleClick(object sender, EventArgs e)
        {
            TreeNodeAdv selected = treeViewAdvOPC.SelectedNode;

            if (selected == null)
            {
                return;
            }

            Node svrnode = selected.Tag as Node;

            if (svrnode.Tag is Opc.Server)
            {
                Opc.Server    opcserver = svrnode.Tag as Opc.Server;
                Opc.Da.Server daserver  = (Opc.Da.Server)opcserver;
                if (svrnode.IsChecked == false)
                {
                    if (daserver.IsConnected == false)
                    {
                        try
                        {
                            daserver.Connect();
                            OPCServer newserver = new OPCServer(this.CurrentController);
                            newserver.SetServer(daserver);
                            this.OPCServerList.Add(newserver);

                            CommonController.Instance.BrowseChildren(newserver, svrnode.Nodes, null);

                            //svrnode.Image = this.imageList1.Images[3];
                            svrnode.Image = Properties.Resources.server_link;
                            selected.ExpandAll();
                            selected.Collapse();
                        }
                        catch
                        {
                            if (daserver.IsConnected)
                            {
                                daserver.Disconnect();
                            }
                            //svrnode.Image = this.imageList1.Images[10];
                            svrnode.Image     = Properties.Resources.server_error;
                            svrnode.IsChecked = true;
                        }
                    }
                }
            }
        }
        private void restoreExpandCollapseState(TreeNodeAdv node)
        {
            if (CollapseExpandManager == null)
            {
                return;
            }
            bool expanded = CollapseExpandManager.restoreNodeState(node.Tag);

            if (expanded)
            {
                node.Expand(true);
            }
            else
            {
                node.Collapse(true);
            }
        }
Beispiel #4
0
        void Tree_NodeMouseDoubleClick(object sender, TreeNodeAdvMouseEventArgs e)
        {
            DataNode node = e.Node.Tag as ContinuedDataNode;

            if (node != null)
            {
                e.Handled = true;
                _tree.BeginUpdate();
                (node.Parent as ValueNode).ChildrenShowLimit += 500;
                TreeNodeAdv parent = e.Node.Parent;
                int         ind    = e.Node.Index;
                parent.Collapse(true);
                node.Parent.Nodes.Clear();
                parent.Expand(true);
                _tree.EndUpdate();
                if (parent.Children.Count > ind)
                {
                    _tree.ScrollTo(parent.Children[ind]);
                }
            }
        }