Пример #1
0
        private void Init()
        {
            //初始化背板画图对象
            var bp = ModelFactory <BackPlane> .CreateByName(_container.BackPlaneName);

            _boardViews = new PlaneVpx[bp.SlotsNum];
            _bpView     = new BackPlaneViewModel(bp, base._rect);
            _boardRects = _bpView.SlotRects;

            //初始化_boardViews
            foreach (var pair in _container.BoardNameDir)
            {
                var rect = _boardRects[pair.Key];
                if (_container.IsContainBoard(pair.Value))
                {
                    _boardViews[pair.Key] = new BoardVpx(rect, pair.Value);
                }
                else
                {
                    _boardViews[pair.Key] = new EmptySlotVpx(rect, pair.Value);
                }
            }

            //分配连接
            _links = new Dictionary <ContainerLink, Point[]>();
            foreach (var linkPair in _bpView.LinkDir)
            {
                BackPlaneLink link = linkPair.Key;
                _links.Add(new ContainerLink(link, IsValidLine(link)), linkPair.Value);
            }
        }
Пример #2
0
        public const int ViewMargin = 100;//边距100

        public ShowViewPanel(TreeNode node)
        {
            //初始化成员变量
            this.DoubleBuffered = true;//重绘双缓冲开启,防止界面闪烁
            base.AutoScroll     = true;
            _treeNode           = node;
            NodeInfo info = (NodeInfo)node.Tag;

            FormType    = info._formType;
            ZoomFactor  = 1;
            _viewOffset = new PointF();

            switch (FormType)
            {
            case Princeple.FormType.PPC:
                PPC ppc = ModelFactory <PPC> .CreateByName(node.Text);

                ShowView = new PPCViewModel(ppc);
                break;

            case Princeple.FormType.FPGA:
                FPGA fpga = ModelFactory <FPGA> .CreateByName(node.Text);

                ShowView = new FPGAViewModel(fpga);
                break;

            case Princeple.FormType.ZYNQ:
                ZYNQ zynq = ModelFactory <ZYNQ> .CreateByName(node.Text);

                ShowView = new ZYNQViewModel(zynq);
                break;

            case Princeple.FormType.BOARD:
                Board board = ModelFactory <Board> .CreateByName(node.Text);

                ShowView = new BoardViewModel(board);
                break;

            case Princeple.FormType.BACKPLANE:
                BackPlane bp = ModelFactory <BackPlane> .CreateByName(node.Text);

                ShowView = new BackPlaneViewModel(bp);
                break;

            case Princeple.FormType.CONTIANER:
                Container ctn = ModelFactory <Container> .CreateByName(node.Text);

                ShowView = new ContainerViewModel(ctn);
                break;

            case Princeple.FormType.COMPONENT:
                Component cmp = ModelFactory <Component> .CreateByName(node.Text);

                ShowView = new ComponentViewModel(cmp);
                break;

            case Princeple.FormType.SYSTEM:
                SystemStru sys = ModelFactory <SystemStru> .CreateByName(node.Text);

                ShowView = new SystemStruViewModel(sys);
                break;

            case Princeple.FormType.TOPO:
                var        sysName = node.Text.Substring(node.Text.IndexOf(':') + 1);
                SystemStru sys2    = ModelFactory <SystemStru> .CreateByName(sysName);

                ShowView = new StaticTopo(sys2);
                break;

            case Princeple.FormType.APP:
                var        sysNode  = node.Parent.Nodes[0];
                var        sysSName = sysNode.Text.Substring(sysNode.Text.IndexOf(':') + 1);
                SystemStru sys3     = ModelFactory <SystemStru> .CreateByName(sysSName);

                var sysStatic = new StaticTopo(sys3);

                ShowView = new DynamicTopo(sysStatic);
                ((DynamicTopo)ShowView).Components = (GetNodeCmps(node));
                break;

            case Princeple.FormType.STATUS:
                ShowView = new Status();
                break;

            default:    //无对应界面类型退出
                return;
            }
            SetViewSize();

            //绑定界面点击事件的处理
            if (ShowView as IDrawerChoosed != null)
            {
                this.MouseClick += new MouseEventHandler(((IDrawerChoosed)ShowView).MouseEventHandler);
            }
            if (ShowView as IDrawerNotify != null)
            {
                info.NodeInfoChanged += new Action <TargetNode>(((IDrawerNotify)ShowView).OnNodeInfoChanged);
            }
            ShowView.RedrawRequst += new Action(OnShowViewRedrawRequst);
            this.Scroll           += new ScrollEventHandler(ShowViewPanel_Scroll);
            this.MouseWheel       += new MouseEventHandler(ShowViewPanel_MouseWheel);
        }