Esempio n. 1
0
        private void OpenFile(string file)
        {
            try
            {
                splitMain.Panel2Collapsed = true;
                treeModel.Nodes.Clear();

                model = BPMN.Model.Read(file);
                TreeNode node = ModelTree.AddElementToTree(treeModel, null, model.Root);
                if (node != null)
                {
                    node.Expand();
                }
                ctlElement.Init(model);
                splitMain.Panel2Collapsed = false;

                foreach (Diagram dia in model.Diagrams)
                {
                    comboDiagram.Items.Add(dia.Name);
                }
                if (comboDiagram.Items.Count > 0)
                {
                    comboDiagram.SelectedIndex = 0;
                }

                this.Text = "BPMN View - " + file;
            }
            catch (Exception ex)
            {
                this.Text = "BPMN View";
                MessageBox.Show("Error opening file!");
            }
        }
Esempio n. 2
0
        private void ElementsForm_Load(object sender, EventArgs e)
        {
            TreeNode node = ModelTree.AddElementToTree(treeElements, null, model.Root);

            if (node != null)
            {
                node.Expand();
            }
        }
Esempio n. 3
0
        public void ViewElement(Element el)
        {
            labelElement.Text = "";
            if (el == null)
            {
                return;
            }

            labelElement.Text = ModelTree.ElementTitle(el);

            if (el.Elements != null)
            {
                List <Element> elm      = new List <Element>();
                List <string>  elmNames = new List <string>();
                foreach (var elt in el.Elements)
                {
                    string name = elt.Key;
                    if (elt.Value != null)
                    {
                        foreach (Element ell in elt.Value)
                        {
                            elmNames.Add(name);
                            elm.Add(ell);
                        }
                    }
                    else
                    {
                        elmNames.Add(name);
                        elm.Add(null);
                    }
                }
                gridSubElements.DataSource = ElementsTable(elm, elmNames);
            }

            if (el.Properties != null)
            {
                Dictionary <string, string> props = new Dictionary <string, string>();
                foreach (var prop in el.Properties)
                {
                    string propList = "";
                    foreach (string pr in prop.Value)
                    {
                        if (!string.IsNullOrEmpty(propList))
                        {
                            propList += ", ";
                        }
                        propList += pr;
                    }
                    props.Add(prop.Key, propList);
                }
                gridProperties.DataSource = StringTable(props);
            }

            gridAttributes.DataSource = StringTable(el.Attributes);
        }
Esempio n. 4
0
        private void pictureDiagram_Click(object sender, EventArgs e)
        {
            MouseEventArgs me = (MouseEventArgs)e;
            Point          pt = me.Location;

            pt.X = (int)(pt.X / zoomRatio / scale);
            pt.Y = (int)(pt.Y / zoomRatio / scale);

            panelSelected.Visible = false;

            if (model != null)
            {
                int idx = comboDiagram.SelectedIndex;
                if (idx >= 0)
                {
                    string  id  = null;
                    Diagram dia = model.Diagrams[idx];

                    Shape shape = BPMN.Geometry.ShapeAtPoint(dia, pt);
                    if (shape != null)
                    {
                        id = shape.ElementRef;
                    }
                    else
                    {
                        List <Edge> edges = BPMN.Geometry.EdgesAtPoint(dia, pt, 1);
                        if (edges != null && edges.Count > 0)
                        {
                            id = edges[0].ElementRef;
                        }
                    }

                    Element element = ModelTree.ElementByID(model, id);
                    if (element != null && shape != null)
                    {
                        ctlElement.ViewElement(element);
                        ctlElement.Visible = true;

                        TreeNode node = ModelTree.NodeForElement(treeModel.Nodes[0], element);
                        if (node != null)
                        {
                            treeModel.SelectedNode = node;
                        }

                        Rectangle rect = shape.Bounds[0];
                        rect.X      = (int)(rect.X * zoomRatio * scale);
                        rect.Y      = (int)(rect.Y * zoomRatio * scale);
                        rect.Width  = (int)(rect.Width * zoomRatio * scale) + 2;
                        rect.Height = (int)(rect.Height * zoomRatio * scale) + 2;

                        panelSelected.Location = rect.Location;
                        panelSelected.Size     = rect.Size;
                        panelSelected.Visible  = true;
                    }
                    else
                    {
                        ctlElement.Visible = false;
                    }
                }
            }
        }