//利用界面填入的信息来刷新一个SystemStru
        private void ReFreshSys(SystemStru sys)
        {
            //刷新基本信息
            sys.Name = _typeTb.Text;
            sys.Type = _typeTb.Text;

            //刷新机箱信息
            foreach (DataGridViewRow row in _consDgv.Rows)
            {
                var cntSn   = int.Parse((string)row.Cells[0].Value); //机箱序号
                var cntName = (string)row.Cells[1].Value;            //机箱的名字
                sys.CntNames[cntSn] = cntName;
            }

            //刷新机箱连接信息
            for (int i = 0; i < _dgvsOpt.DataGridViweList.Count; i++)
            {
                var curDgv   = _dgvsOpt.DataGridViweList[i];
                var linkList = new List <SystemStruLink>();//连接集合
                foreach (DataGridViewRow row in curDgv.Rows)
                {
                    var sysLink = new SystemStruLink(
                        int.Parse((string)row.Cells[_dgvColumnTitle_end1CntNum].Value),
                        int.Parse((string)row.Cells[_dgvColumnTitle_end1PosNum].Value),
                        int.Parse((string)row.Cells[_dgvColumnTitle_end2CntNum].Value),
                        int.Parse((string)row.Cells[_dgvColumnTitle_end2PosNum].Value),
                        (LinkType)Enum.Parse(typeof(LinkType), (string)row.Cells[_dgvColumnTitle_linkType].Value),
                        (LinkLanes)Enum.Parse(typeof(LinkLanes), (string)row.Cells[_dgvColumnTitle_dataWidth].Value));
                    linkList.Add(sysLink);
                }
                sys.LinksArray[i] = linkList;
            }
        }
        void _yesBtn_Click(object sender, EventArgs e)
        {
            //可以先检查数据有效性
            if (!CheckDataValid())
            {
                return;
            }

            SystemStru sys = new SystemStru(CntNum);

            ReFreshSys(sys);
            sys.SaveXmlByName();
            this.DialogResult = DialogResult.Yes;
        }
 public StaticTopo(SystemStru sys)
 {
     System = sys;
     InitNodeNum();
 }
 public StaticTopo(SystemStru sys, Rectangle rect)
 {
     System = sys;
     InitNodeNum();
     Init(rect);
 }
Example #5
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);
        }
Example #6
0
 public SystemStruViewModel(SystemStru sys)
 {
     _sys = sys;
 }
Example #7
0
        }                                                                           //包含的连接及对应的点

        public SystemStruViewModel(SystemStru sys, Rectangle rect)
        {
            _sys = sys;
            Init(rect);
        }