Пример #1
0
        public void EntitytoPage()
        {
            List <IVShape> shapes = new List <IVShape>();

            foreach (IVShape shape in this._application.ActivePage.Shapes)
            {
                if (shape.Name.Contains("Context Entity (CE)"))
                {
                    bool exists = false;
                    foreach (var s in shapes)
                    {
                        if (s.Text == shape.Text)
                        {
                            exists = true; System.Windows.Forms.MessageBox.Show(shape.Text +
                                                                                " already exists.");
                        }
                    }
                    if (exists == false)
                    {
                        shapes.Add(shape);
                    }
                }
            }
            if (shapes.Count >= 1)
            {
                foreach (var shape in shapes)
                {
                    IVPage page = this._application.ActiveDocument.Pages.Add();
                    page.Name = shape.Text;
                    IVDocument stencil      = this._application.Documents.OpenEx("SMT_BeC.vssx", 4);
                    IVMaster   masterentity = new IVMaster();
                    foreach (var m in stencil.Masters)
                    {
                        if (m.Name == "Context Entity/ Function")
                        {
                            masterentity = m;
                        }
                    }
                    IVShape shapeh = page.Drop(masterentity, 10.3 / 2.54, 20.5 / 2.54);
                    shapeh.Text = shape.Text;
                    shapeh.CellsSRC(1, 3, 0).FormulaU = "THEMEGUARD(RGB(255,255,255))";
                    IVHyperlink hl = shape.Hyperlinks.Add();
                    hl.SubAddress = page.Name;
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("No Context Entity found.");
            };
        }
Пример #2
0
        //createfor each Connection a Entry or Exit Point at the Boundary Shape
        /// <summary>
        /// erstellt input/output knoten am rand des interface automaten
        /// </summary>
        public void CreateInandOutput()
        {
            List <IVPage>  pagesBound = new List <IVPage>();
            List <IVShape> cons;
            IVMaster       input  = new IVMaster();
            IVMaster       output = new IVMaster();

            foreach (var item in this.ActiveMasters)
            {
                if (item.Name == "Input")
                {
                    input = item;
                }
                else if (item.Name == "Output")
                {
                    output = item;
                }
            }
            foreach (var item in this._application.ActiveDocument.Pages)
            {
                foreach (var shape in item.Shapes)
                {
                    if (shape.Name.Contains("Interface"))
                    {
                        pagesBound.Add(item);
                    }
                }
            }
            foreach (var item in pagesBound)
            {
                cons = new List <IVShape>();
                IVShape        boundary = new IVShape();
                List <IVShape> deleted  = new List <IVShape>();;
                foreach (var connects in item.Shapes)
                {
                    if (connects.Name.Contains("Connection"))
                    {
                        bool exists = false;
                        foreach (var c in cons)
                        {
                            if (c.Text == connects.Text)
                            {
                                exists = true;
                            }
                        }
                        if (exists == false)
                        {
                            cons.Add(connects);
                        }
                    }
                    ;
                    if (connects.Name.Contains("Interface"))
                    {
                        boundary = connects;
                    }
                    if (connects.Name.Contains("Output"))
                    {
                        deleted.Add(connects);
                    }
                    if (connects.Name.Contains("Input"))
                    {
                        deleted.Add(connects);
                    }
                }
                foreach (var d in deleted)
                {
                    d.Delete();
                }
                string xs = boundary.CellsSRC(1, 1, 0).FormulaU.Substring(0, boundary.CellsSRC(1, 1, 0).FormulaU.IndexOf(' '));
                string ys = boundary.CellsSRC(1, 1, 1).FormulaU.Substring(0, boundary.CellsSRC(1, 1, 1).FormulaU.IndexOf(' '));
                string ws = boundary.CellsSRC(1, 1, 2).FormulaU.Substring(0, boundary.CellsSRC(1, 1, 2).FormulaU.IndexOf(' '));
                string hs = boundary.CellsSRC(1, 1, 3).FormulaU.Substring(0, boundary.CellsSRC(1, 1, 3).FormulaU.IndexOf(' '));

                double xvalue = (Convert.ToDouble(xs.Replace('.', ','))) / 10;
                double yvalue = (Convert.ToDouble(ys.Replace('.', ','))) / 10;
                double weight = (Convert.ToDouble(ws.Replace('.', ','))) / 10;
                double height = (Convert.ToDouble(hs.Replace('.', ','))) / 10;
                int    count  = 1;

                foreach (var inout in cons)
                {
                    {
                        if (inout.Text.Contains("?"))
                        {
                            double  x          = (((xvalue - (weight / 2.05)) + ((weight / (cons.Count + 1)) * count)));
                            double  y          = (yvalue + (height / 2) + 0.25);
                            IVShape inputshape = item.Drop(input, x / 2.54, y / 2.54);
                            foreach (var g in inputshape.Shapes)
                            {
                                if (g.Text.Contains("Input"))
                                {
                                    g.Text = inout.Text.Substring(0, inout.Text.IndexOf("?"));
                                }
                            }
                        }
                        else if (inout.Text.Contains("!"))
                        {
                            double  x           = (((xvalue - (weight / 2.05)) + ((weight / (cons.Count + 1)) * count)));
                            double  y           = (yvalue + (height / 2) + 0.25);
                            IVShape outputshape = item.Drop(output, x / 2.54, y / 2.54);
                            foreach (var g in outputshape.Shapes)
                            {
                                if (g.Text.Contains("Output"))
                                {
                                    g.Text = inout.Text.Substring(0, inout.Text.IndexOf("!"));
                                }
                            }
                        }
                    }
                    count++;
                }
            }
        }