Ejemplo n.º 1
0
        private void OnDelDevice(object sender, EventArgs e)
        {
            AbstractTreeNode node = _treeView.SelectedNode as AbstractTreeNode;

            if (node != null)
            {
                string path       = node.Path;
                bool   ret        = _mainWindow.PageManager.CloseRightPage(path);
                int    childCount = node.Nodes.Count;
                if (ret)
                {
                    _treeView.SelectedNode = node.PrevNode;
                    node.Remove();
                }
                else if (childCount == 0 && !(node is TreeLocalHost))
                {
                    node.Remove();
                }
                //登出设备
                string[] pathParts = path.Split('_');
                if (pathParts.Length > 1)
                {
                    AbstractBus bus = App.Instance.FlightBusManager.GetBus(pathParts[1]);
                    if (pathParts.Length > 2)
                    {
                        bus.Logout(pathParts[2]);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新设备树。
        /// 设备树只有在登录的时候才更新
        /// </summary>
        private void OnUpdateDeviceTree(IDeviceInfo info)
        {
            flag = true;//这里判断设备是不是登陆了
            //此处界面以boardType,boardNo,channelType,channelCount来标识唯一性。
            //core中bus,device等也应该包含这个几个属性,用它来标识唯一性
            AbstractTreeNode parentNode   = (AbstractTreeNode)_treeView.TopNode;
            string           boardType    = info.BoardType.ToString();
            string           boardNo      = info.BoardNo.ToString();
            string           channelType  = info.ChannelType.ToString();
            string           channelCount = info.ChannelCount.ToString();

            //Bus级
            if (!parentNode.Nodes.ContainsKey(boardType))
            {
                AbstractTreeNode node = new TreeBusNode(boardType);
                parentNode.AddChildNode(node);
            }
            //Device 级
            parentNode = (AbstractTreeNode)parentNode.Nodes[boardType];
            if (!parentNode.Nodes.ContainsKey(boardNo))
            {
                AbstractTreeNode node = new TreeDeviceNode(boardNo);
                parentNode.AddChildNode(node);
            }
        }
Ejemplo n.º 3
0
        private void OnTreeViewAfterSelect(object sender, EventArgs e)
        {
            AbstractTreeNode node = _treeView.SelectedNode as AbstractTreeNode;

            if (node != null)
            {
                if (node.Path == TreeLocalHost.PathString)
                {
                    _mainWindow.TopMenu.MenuEnable(false);
                    return;
                }
                string path = node.Path;
                if (path.Contains(BoardType.A429.ToString()))
                {
                    _delDevice429Btn.Visible  = true;
                    _delDevice1553Btn.Visible = false;
                    _mainWindow.TopMenu.ShowA429Menu();
                    _mainWindow.TopMenu.MenuEnable(true);
                }
                else if (path.Contains(BoardType.A1553.ToString()))
                {
                    _delDevice429Btn.Visible  = false;
                    _delDevice1553Btn.Visible = true;
                    _mainWindow.TopMenu.ShowA1553Menu();
                    _mainWindow.TopMenu.MenuEnable(true);
                }
                node.OnClick(_mainWindow.PageManager);
            }
        }
Ejemplo n.º 4
0
        public virtual void AddChildNode(TreeNode node)
        {
            this.Nodes.Add(node);
            this.ExpandAll();
            AbstractTreeNode child = (AbstractTreeNode)node;

            child.Path = this.Path + "_" + child.Name;
        }
Ejemplo n.º 5
0
        private void OnAddChannel(object sender, EventArgs e)
        {
            AbstractTreeNode parentNode = (AbstractTreeNode)_treeView.TopNode;

            if (parentNode is TreeChannels)
            {
            }
        }
Ejemplo n.º 6
0
        public override void AddChildNode(TreeNode node)
        {
            int index = FindProperIndex(node.Name);

            this.Nodes.Insert(index, node);
            AbstractTreeNode child = (AbstractTreeNode)node;

            child.Path = this.Path + "_" + child.Name;
        }
Ejemplo n.º 7
0
        private void OnTabSelectedDeviceChanged(string path)
        {
            if (_treeView.SelectedNode != null)
            {
                AbstractTreeNode node0 = _treeView.SelectedNode as AbstractTreeNode;
                if (node0 != null &&
                    node0.Path == path)
                {
                    return;
                }
            }
            TreeNode node = _treeView.TopNode;

            node = FindeTreeNodeByPath(node, path);
            if (node != null)
            {
                _treeView.SelectedNode = node;
            }
        }
Ejemplo n.º 8
0
        private void OnDelChannel(object sender, EventArgs e)
        {
            AbstractTreeNode node = _treeView.SelectedNode as AbstractTreeNode;

            if (node != null)
            {
                string path = node.Path;
                //bool ret = _mainWindow.PageManager.CloseRightPage(path);
                //int childCount = node.Nodes.Count;
                //if (ret)
                //{
                //    _treeView.SelectedNode = node.PrevNode;
                //    node.Remove();
                //}
                //else if (childCount == 0 && !(node is TreeLocalHost))
                //{
                //    node.Remove();
                //}
            }
        }
Ejemplo n.º 9
0
        public AbstractTreeNode FindeTreeNodeByPath(AbstractTreeNode node, string path)
        {
            if (node == null)
            {
                return(null);
            }
            if (node.Path == path)
            {
                return(node);
            }
            foreach (AbstractTreeNode nodeItem in node.Nodes)
            {
                AbstractTreeNode findNode = FindeTreeNodeByPath(nodeItem, path);
                if (findNode != null)
                {
                    return(findNode);
                }
            }

            return(null);
        }