コード例 #1
0
ファイル: Common.cs プロジェクト: algz/FlowNetExt
        /// <summary>
        /// 从文件中加载流程节点
        /// </summary>
        /// <param name="flowChart1"></param>
        /// <param name="filePath"></param>
        public static void loadBoxToINI(FlowChart flowChart1, string filePath)
        {
            if (!File.Exists(filePath))
            {
                MessageBox.Show("流程参数文件没找到.");
                return;
            }
            StringBuilder s = new StringBuilder(1024);

            #region 加载全局参数
            GlobalParam globalParam = new GlobalParam();
            GetPrivateProfileString("GlobalParam", "top_param1", "", s, 1024, filePath);
            globalParam.top_param1 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param2", "", s, 1024, filePath);
            globalParam.top_param2 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param3", "", s, 1024, filePath);
            globalParam.top_param3 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param4", "", s, 1024, filePath);
            globalParam.top_param4 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param5", "", s, 1024, filePath);
            globalParam.top_param5 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param6", "", s, 1024, filePath);
            globalParam.top_param6 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param7", "", s, 1024, filePath);
            globalParam.top_param7 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param8", "", s, 1024, filePath);
            globalParam.top_param8 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param9", "", s, 1024, filePath);
            globalParam.top_param9 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param10", "", s, 1024, filePath);
            globalParam.top_param10 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param11", "", s, 1024, filePath);
            globalParam.top_param11 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param12", "", s, 1024, filePath);
            globalParam.top_param12 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param13", "", s, 1024, filePath);
            globalParam.top_param13 = s.ToString();
            GetPrivateProfileString("GlobalParam", "top_param14", "", s, 1024, filePath);
            globalParam.top_param14 = s.ToString();

            GetPrivateProfileString("GlobalParam", "bottom_param1", "", s, 1024, filePath);
            globalParam.bottom_param1 = s.ToString();
            GetPrivateProfileString("GlobalParam", "bottom_param2", "", s, 1024, filePath);
            globalParam.bottom_param2 = s.ToString();
            GetPrivateProfileString("GlobalParam", "bottom_param3", "", s, 1024, filePath);
            globalParam.bottom_param3 = s.ToString();
            GetPrivateProfileString("GlobalParam", "bottom_param4", "", s, 1024, filePath);
            globalParam.bottom_param4 = s.ToString();
            GetPrivateProfileString("GlobalParam", "bottom_param5", "", s, 1024, filePath);
            globalParam.bottom_param5 = s.ToString();
            GetPrivateProfileString("GlobalParam", "bottom_param6", "", s, 1024, filePath);
            globalParam.bottom_param6 = s.ToString();

            flowChart1.Tag = globalParam;
            #endregion

            //加载所有流程节点的相关数据
            foreach (Box box in flowChart1.Boxes)
            {
                BoxPropertiesExt pro = new BoxPropertiesExt();
                s = new StringBuilder(1024);

                GetPrivateProfileString(box.Text, "model", "", s, 1024, filePath);
                pro.model = s.ToString();
                string typeName = "FlowNetExt.Elements.";
                switch (pro.model)
                {
                    case "0":
                        typeName += "General.StartElement";
                        MainFormExt.StartElements.Add(box);
                        break;
                    case "-1":
                        typeName += "General.EndElement";
                        MainFormExt.EndElements.Add(box);
                        break;
                    case "-2":
                        typeName += "General.ConnectorElement";
                        MainFormExt.ConnectorElements.Add(box);
                        break;
                    default:
                        typeName += "Component.Element" + pro.model;
                        MainFormExt.ComponentElements.Add(box);
                        break;
                }
                Element e = (Element)Activator.CreateInstance(Type.GetType(typeName));

                GetPrivateProfileString(box.Text, "AA", "",s,1024, filePath);
                e.AA = s.ToString();

                GetPrivateProfileString(box.Text, "GEO1","",s, 1024, filePath);
                e.GEO1 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO2", "",s,1024, filePath);
                e.GEO2 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO3","",s,1024, filePath);
                e.GEO3 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO4", "",s,1024, filePath);
                e.GEO4 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO5", "", s, 1024, filePath);
                e.GEO5 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO6", "", s, 1024, filePath);
                e.GEO6 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO7", "", s, 1024, filePath);
                e.GEO7 = s.ToString();

                GetPrivateProfileString(box.Text, "GEO8", "", s, 1024, filePath);
                e.GEO8 = s.ToString();

                GetPrivateProfileString(box.Text, "KG", "", s, 1024, filePath);
                e.KG = s.ToString();

                GetPrivateProfileString(box.Text, "param1", "", s, 1024, filePath);
                e.param1 = s.ToString();

                GetPrivateProfileString(box.Text, "param2", "", s, 1024, filePath);
                e.param2 = s.ToString();

                GetPrivateProfileString(box.Text, "TTI", "", s, 1024, filePath);
                e.TTI = s.ToString();

                GetPrivateProfileString(box.Text, "TTE", "", s, 1024, filePath);
                e.TTE = s.ToString();

                GetPrivateProfileString(box.Text, "PSI", "", s, 1024, filePath);
                e.PSI = s.ToString();

                GetPrivateProfileString(box.Text, "PSE", "", s, 1024, filePath);
                e.PSE = s.ToString();

                GetPrivateProfileString(box.Text, "FH1", "", s, 1024, filePath);
                e.FH1 = s.ToString();

                GetPrivateProfileString(box.Text, "FH2", "", s, 10242, filePath);
                e.FH2 = s.ToString();

                GetPrivateProfileString(box.Text, "FH3", "", s, 1024, filePath);
                e.FH3 = s.ToString();

                GetPrivateProfileString(box.Text, "FH4", "", s, 1024, filePath);
                e.FH4 = s.ToString();

                GetPrivateProfileString(box.Text, "RME", "", s, 1024, filePath);
                e.RME = s.ToString();

                GetPrivateProfileString(box.Text, "RMI", "", s, 1024, filePath);
                e.RMI = s.ToString();

                GetPrivateProfileString(box.Text, "DOEL", "", s, 1024, filePath);
                e.DOEL = s.ToString();

                GetPrivateProfileString(box.Text, "AKG", "", s, 1024, filePath);
                e.AKG = s.ToString();

                pro.property = e;
                box.Tag = pro;
            }
        }
コード例 #2
0
ファイル: Common.cs プロジェクト: algz/FlowNetExt
        /// <summary>
        /// 创建流程节点
        /// </summary>
        /// <param name="flowChart1"></param>
        /// <param name="boxItem"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="imageList1"></param>
        /// <returns></returns>
        public static Box CreateBox(FlowChart flowChart1, ToolboxItem boxItem, float x, float y, ImageList imageList1)
        {
            Box box = flowChart1.CreateBox(x, y, 13, 13);//x坐标,y坐标,宽度,高度
            box.Transparent = true;
            box.MnpHandlesMask = 1 << 8; // 禁止改变大小
            //node.HyperLink = type;
            box.TextFormat.Alignment = StringAlignment.Center;
            box.TextFormat.LineAlignment = StringAlignment.Far;
            box.PicturePos = EImagePos.imgTopCenter;
            box.Picture = boxItem.Image;// imageList1.Images[boxItem.ImageIndex];

            //通过类型反射创建对象
            string typeName = "FlowNetExt.Elements."+boxItem.Parent.Tag+"." + boxItem.Tag.ToString();
            BoxPropertiesExt pro = new BoxPropertiesExt();
            pro.property = (Element)Activator.CreateInstance(Type.GetType(typeName));

            switch (boxItem.Parent.Tag.ToString())
            {
                case "Component":
                    //普通元件
                    MainFormExt.ComponentElements.Add(box);
                    if (MainFormExt.ComponentElements.Count == 1)
                    {
                        box.Text = "1";
                    }
                    else
                    {
                        box.Text = (Convert.ToInt32(MainFormExt.ComponentElements[MainFormExt.ComponentElements.Count - 2].Text) + 1).ToString();
                    }

                    // 取出字符串中的数字
                    System.Text.RegularExpressions.Match mstr = Regex.Match(boxItem.Showtext, @"(\d+)");
                    pro.model = mstr.Groups[1].Value.ToString();
                    //pro.model = boxItem.Showtext;//.Substring(2);
                    break;
                case "General":
                    //通用元件
                    if (boxItem.Tag.ToString() == "StartElement")
                    {
                        MainFormExt.StartElements.Add(box);
                        if (MainFormExt.StartElements.Count == 1)
                        {
                            box.Text = "S1";
                        }
                        else
                        {
                            box.Text = "S" + (Convert.ToInt32(MainFormExt.StartElements[MainFormExt.StartElements.Count - 2].Text.Substring(1)) + 1);
                        }
                        pro.model = "0";
                    }
                    else if (boxItem.Tag.ToString() == "EndElement")
                    {
                        MainFormExt.EndElements.Add(box);
                        if (MainFormExt.EndElements.Count == 1)
                        {
                            box.Text = "E21";
                        }
                        else
                        {
                            box.Text = "E" + (Convert.ToInt32(MainFormExt.EndElements[MainFormExt.EndElements.Count - 2].Text.Substring(1)) + 1);
                        }
                        pro.model = "-1";
                    }
                    else if (boxItem.Tag.ToString() == "ConnectorElement")
                    {
                        MainFormExt.ConnectorElements.Add(box);
                        if (MainFormExt.ConnectorElements.Count == 1)
                        {
                            box.Text = "C201";
                        }
                        else
                        {
                            box.Text = "C" + (Convert.ToInt32(MainFormExt.ConnectorElements[MainFormExt.ConnectorElements.Count - 2].Text.Substring(1)) + 1).ToString();
                        }
                        pro.model = "-2";
                    }
                    break;
            }
            box.Tag = pro;
            return box;
        }
コード例 #3
0
ファイル: MainFormExt.cs プロジェクト: algz/FlowNetExt
        /// <summary>
        /// 箭头绘画
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void flowChart1_ArrowCreating(object sender, AttachConfirmArgs e)
        {
            Box destBox = (Box)e.Destination;
            Box originBox=(Box)e.Origin;

            //判断连接点的输入元件类型是否相同,相同则不允许连接
            if (MainFormExt.ConnectorElements.Contains(destBox))
            {
                foreach (Arrow arrow in destBox.IncomingArrows)
                {
                    Box box = (Box)arrow.Destination;
                    if (box.Text == destBox.Text)
                    {
                        e.Confirm = false;
                        return;
                    }
                }

            }

            if (MainFormExt.ComponentElements.Contains(originBox)&&
                MainFormExt.ComponentElements.Contains(destBox) &&
                (originBox.OutgoingArrows.Count > 0 || destBox.IncomingArrows.Count > 0))
            {
                e.Confirm = false;
                return;
            }
            else if (MainFormExt.StartElements.Contains(originBox) &&
                //originBox.OutgoingArrows.Count<=0&&
                MainFormExt.ComponentElements.Contains(destBox))
            {
                e.Confirm = true;
            }
            else if (MainFormExt.ConnectorElements.Contains(originBox) &&
                MainFormExt.ComponentElements.Contains(destBox))
            {
                e.Confirm = true;
            }
            else if (MainFormExt.ComponentElements.Contains(originBox) &&
                       (MainFormExt.ComponentElements.Contains(destBox) ||
                           (MainFormExt.EndElements.Contains(destBox)
                //&&destBox.IncomingArrows.Count<=0
                           ) ||
                           MainFormExt.ConnectorElements.Contains(destBox)
                       )
                   )
            {
                e.Confirm = true;
            }
            else
            {
                e.Confirm = false;
                return;
            }

            BoxPropertiesExt pro = new BoxPropertiesExt();
            pro.property = (Element)new ArrowElement();
            pro.model = "-3";
            e.Arrow.Tag = pro;

            ArrowConfirmArgs args = new ArrowConfirmArgs(e.Arrow);
            flowChart1_ArrowSelecting(this.propertyGrid1, args);
            //this.propertyGrid1.SelectedObject = pro;
        }