Exemple #1
0
        /// <summary>
        /// 通过_sysRect来给该图形的图元分配矩形容器
        /// 分配规则:
        /// 1)_sysRect是该系统对应的矩形外边框;该系统对应的机箱数量为CntsNum;
        /// 2)首先:机箱的排列方向按照垂直方向排列;按照垂直方向把_sysRext分为CntsNum份;每一份为_sysRectChild;
        /// 3)其次:一个_sysRectChild的包含一个cntRect,其中宽度占9/10;
        /// </summary>
        private void AssignCntRects()
        {
            int cntsNum     = _sys.CntsNum; //机箱的数量
            int childHeight = base._rect.Height / cntsNum;

            //cntRect的高,宽,X坐标都恒定,Y会有变化
            int height = (int)(childHeight * _cntScale);
            int width  = (int)(base._rect.Width * _cntScale);
            int pointX = base._rect.X;
            int pointY = base._rect.Y + (int)(childHeight * (1 - _cntScale));

            for (int i = 0; i < cntsNum; i++)
            {
                CntRects[i] = new Rectangle(pointX, pointY, width, height);
                var cnt = ModelFactory <Container> .CreateByName(_sys.CntNames[i]);

                CntsArray[i] = new ContainerViewModel(cnt, CntRects[i]);//创建对应机箱的画图器
                pointY      += childHeight;
            }
        }
Exemple #2
0
        /// <summary>
        /// 分配点的规则说明:
        /// 1)分配的link这里分为两大类:EtherNet,RapidIO;
        /// 2) 这些links在list的里面的排布是按照机箱号来递增的;
        /// 3)一条link对应有4个点:机1外连接区-》机1垂直走线区-》机2垂直走线区-》机2外连接区
        /// </summary>
        /// <param name="type"></param>
        /// <param name="links"></param>
        private void AssignLinksPoints(LinkType type, List <SystemStruLink> links)
        {
            int linksNum    = links.Count;                                                     //连接的数量
            int pointXWidth = (int)(base._rect.Width * (1 - _cntScale) / 2);                   //pointX所在区域的宽度
            int areaBase    = (int)(base._rect.X + base._rect.Width * _cntScale);              //走线区的起始位置
            int pointXBase  = (type == LinkType.EtherNet ? areaBase : areaBase + pointXWidth); //pointX的起始位置

            foreach (var link in links)
            {
                ContainerViewModel cnt1  = CntsArray[link.FirstEndId];
                ContainerViewModel cnt2  = CntsArray[link.SecondEndId];
                double             scale = (links.IndexOf(link) + 1.0) / (linksNum + 1.0);

                Point p1 = cnt1._bpView.GetInterfacePoint(type);
                Point p4 = cnt2._bpView.GetInterfacePoint(type);
                Point p2 = new Point((int)(pointXBase + pointXWidth * scale), p1.Y);
                Point p3 = new Point(p2.X, p4.Y);
                LinkDir.Add(link, new Point[] { p1, p2, p3, p4 });
            }
        }
Exemple #3
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);
        }