Ejemplo n.º 1
0
        public void Redraw()
        {
            if (this.m_image != null)
            {
                this.m_image.Dispose();
                this.m_image = null;
            }

            this.m_rcSelection = Rectangle.Empty;
            this.m_rcHighlight = Rectangle.Empty;
            this.m_hitmap.Clear();
            if (this.m_template != null && this.m_project != null)
            {
                this.m_image = FormatPNG.CreateTemplateDiagram(this.m_template, this.m_hitmap, this.m_project, this.m_instance);
                if (this.m_image != null)
                {
                    this.AutoScrollMinSize = new Size(this.m_image.Width, this.m_image.Height);
                }
            }
            else if (this.m_conceptroot != null && this.m_project != null && this.m_conceptroot.ApplicableEntity != null)
            {
                DocModelView docView = null;
                foreach (DocModelView eachView in this.m_project.ModelViews)
                {
                    if (eachView.ConceptRoots.Contains(this.m_conceptroot))
                    {
                        docView = eachView;
                        break;
                    }
                }

                this.m_image = FormatPNG.CreateConceptDiagram(this.m_conceptroot.ApplicableEntity, docView, this.m_hitmap, this.m_project, this.m_instance);
                if (this.m_image != null)
                {
                    this.AutoScrollMinSize = new Size(this.m_image.Width, this.m_image.Height);
                }
            }

            this.Invalidate();
        }
Ejemplo n.º 2
0
        public void Render()
        {
            if (this.m_image != null)
            {
                this.m_image.Dispose();
                this.m_image = null;
            }

            Dictionary <DocObject, bool> included = null;

            if (this.m_modelview != null)
            {
                included = new Dictionary <DocObject, bool>();
                this.m_project.RegisterObjectsInScope(this.m_modelview, included);
            }

            this.m_hitmap = new Dictionary <Rectangle, DocEntity>();
            this.m_image  = FormatPNG.CreateInheritanceDiagram(this.m_project, included, this.m_entity, null, this.Font, this.m_hitmap);
            if (this.m_image != null)
            {
                this.AutoScrollMinSize = new Size(this.m_image.Width, this.m_image.Height);
            }
            this.Invalidate();
        }
Ejemplo n.º 3
0
        private SEntity Pick(Point pt, out int iAttr, out DocAttribute docAttribute, out Rectangle rc)
        {
            docAttribute = null;
            iAttr        = -1;
            rc           = new Rectangle();

            foreach (Rectangle rect in this.m_hitmap.Keys)
            {
                if (rect.Contains(pt))
                {
                    rc    = rect;
                    iAttr = (pt.Y - rc.Top) / FormatPNG.CY - 1;

                    SEntity sel = this.m_hitmap[rc];

                    if (sel is DocTemplateDefinition)
                    {
                        return(sel);
                    }
                    else
                    {
                        DocModelRuleEntity ruleEntity = sel as DocModelRuleEntity;

                        DocEntity docEntity = null;
                        if (ruleEntity != null)
                        {
                            DocObject docObjRef = null;

                            if (this.m_template != null && !String.IsNullOrEmpty(this.m_template.Code))
                            {
                                foreach (DocSection docSection in this.m_project.Sections)
                                {
                                    foreach (DocSchema docSchema in docSection.Schemas)
                                    {
                                        if (docSchema.Name.Equals(this.m_template.Code, StringComparison.OrdinalIgnoreCase))
                                        {
                                            docObjRef = docSchema.GetDefinition(ruleEntity.Name);
                                            break;
                                        }
                                    }
                                }
                            }

                            if (docObjRef == null)
                            {
                                docObjRef = this.m_project.GetDefinition(ruleEntity.Name);
                            }

                            if (docObjRef is DocEntity)
                            {
                                docEntity = (DocEntity)docObjRef;
                                List <DocAttribute> listAttr = new List <DocAttribute>();
                                FormatPNG.BuildAttributeList(docEntity, listAttr, this.m_project);

                                if (iAttr >= 0 && iAttr < listAttr.Count)
                                {
                                    docAttribute = listAttr[iAttr];
                                    foreach (DocModelRule ruleAttr in ruleEntity.Rules)
                                    {
                                        if (ruleAttr is DocModelRuleAttribute && ruleAttr.Name.Equals(docAttribute.Name))
                                        {
                                            return(ruleAttr);
                                        }
                                    }
                                }
                            }
                        }
                        else if (this.m_template != null)
                        {
                            docEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity;
                            List <DocAttribute> listAttr = new List <DocAttribute>();
                            FormatPNG.BuildAttributeList(docEntity, listAttr, this.m_project);

                            if (iAttr >= 0 && iAttr < listAttr.Count)
                            {
                                docAttribute = listAttr[iAttr];
                                if (this.m_template.Rules != null)
                                {
                                    foreach (DocModelRule ruleAttr in this.m_template.Rules)
                                    {
                                        if (ruleAttr is DocModelRuleAttribute && ruleAttr.Name.Equals(docAttribute.Name))
                                        {
                                            return(ruleAttr);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    return(sel);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            if (this.m_image == null && this.m_schema != null && this.m_map != null)
            {
                this.m_image           = FormatPNG.CreateSchemaDiagram(this.m_schema, this.m_map);
                this.AutoScrollMinSize = new Size(this.m_image.Width, this.m_image.Height);
            }

            if (this.m_image != null)
            {
                Graphics g = pe.Graphics;
                g.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
                g.DrawImage(this.m_image, Point.Empty);

                using (Pen pen = new Pen(Color.Maroon, 5.0f))
                {
                    foreach (DocDefinition docDef in this.m_multiselect)
                    {
                        DrawObjectBorder(g, docDef, pen);
                    }
                }

                if (this.m_selection != null)
                {
                    using (Pen pen = new Pen(Color.Red, 5.0f))
                    {
                        if (this.m_lineselection != null)
                        {
                            DrawObjectBorder(g, this.m_lineselection, pen);
                        }
                        else
                        {
                            DrawObjectBorder(g, this.m_selection, pen);
                        }
                    }
                }

                if (this.m_highlight != null)
                {
                    using (Pen pen = new Pen(Color.Orange, 3.0f))
                    {
                        if (this.m_linehighlight != null)
                        {
                            DrawObjectBorder(g, this.m_linehighlight, pen);
                        }
                        else
                        {
                            DrawObjectBorder(g, this.m_highlight, pen);
                        }
                    }
                }

                g.TranslateTransform(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);

                // draw link line
                if (this.m_mousedown && this.m_toolmode == ToolMode.Link)
                {
                    g.DrawLine(Pens.Red, this.m_ptDown, this.m_ptMove);
                }

                if (this.m_mousedown && this.m_toolmode == ToolMode.Move && this.m_selection == null)
                {
                    // draw selection box
                    Rectangle rc = CreateNormalizedRectangle(this.m_ptDown, this.m_ptMove);
                    g.DrawRectangle(Pens.Red, rc);
                }
                else if (this.m_selection == null && this.m_toolmode == ToolMode.Move)
                {
                    // draw insertion point
                    int rad = 16;
                    g.DrawLine(Pens.Red, this.m_ptDown.X - rad, this.m_ptDown.Y, this.m_ptDown.X + rad, this.m_ptDown.Y);
                    g.DrawLine(Pens.Red, this.m_ptDown.X, this.m_ptDown.Y - rad, this.m_ptDown.X, this.m_ptDown.Y + rad);
                }
            }
        }