示例#1
0
        public static void LayoutLine(DocDefinition defA, DocDefinition defB, List <DocPoint> list)
        {
            if (list == null)
            {
                return;
            }

            while (list.Count > 3)
            {
                list[list.Count - 1].Delete();
                list.RemoveAt(list.Count - 1);
            }
            while (list.Count < 3)
            {
                list.Add(new DocPoint());
            }
            DocPoint ptA = list[0];
            DocPoint ptM = list[1];
            DocPoint ptB = list[2];

            DocRectangle rB = null;

            if (defB != null)
            {
                rB = defB.DiagramRectangle;
            }

            LayoutLine(defA.DiagramRectangle, rB, ptA, ptM, ptB);
        }
        protected override IElementFrame CreateBinding(TextView view, DocPoint start, DocPoint end)
        {
            if (!IsVisibleInView(view))
                return null;

            return new TileElementFrame(base.CreateBinding(view, start, start)) { XOffset = -30, TileWidth = 11, TileHeight = 11 };
        }
示例#3
0
        private void PlugIn1_DecorateLanguageElement(object sender, DecorateLanguageElementEventArgs args)
        {
            LanguageElement element = args.LanguageElement;

            if (_DisplayTile && element.ElementType == LanguageElementType.Method && CanBeRun((Method)element))
            {
                DocPoint start = new DocPoint(element.StartLine, element.StartOffset);
                args.AddAdornment(new RunMethodTileDocumentAdornment(start, start, this, (Method)element));
            }
        }
        protected override IElementFrame CreateBinding(TextView view, DocPoint start, DocPoint end)
        {
            if (!IsVisibleInView(view))
            {
                return(null);
            }

            return(new TileElementFrame(base.CreateBinding(view, start, start))
            {
                XOffset = -41, TileWidth = 16, TileHeight = 16
            });
        }
示例#5
0
        private void SaveTree(g group, List <DocLine> tree, DocPoint prev, bool bold)
        {
            foreach (DocLine docLine in tree)
            {
                SaveLine(group, docLine.DiagramLine, prev, bold);

                DocPoint next = null;
                if (docLine.DiagramLine != null && docLine.DiagramLine.Count > 0)
                {
                    next = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                }

                SaveTree(group, docLine.Tree, next, bold);
            }
        }
示例#6
0
        private void LoadPoints(polyline p, List <DocPoint> listPoints)
        {
            if (p.points == null)
            {
                return;
            }

            string[] points = p.points.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string point in points)
            {
                string[] coords = point.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                DocPoint docPoint = new DocPoint();
                docPoint.X = Double.Parse(coords[0]) / CtlExpressG.Factor;
                docPoint.Y = Double.Parse(coords[1]) / CtlExpressG.Factor;
                listPoints.Add(docPoint);
            }
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="group"></param>
        /// <param name="line"></param>
        /// <param name="prev"></param>
        /// <param name="bold">True for bold; False for regular; null for dash</param>
        private void SaveLine(g group, List <DocPoint> line, DocPoint prev, bool?bold)
        {
            polyline p = new polyline();

            group.polyline.Add(p);

            StringBuilder sb = new StringBuilder();

            if (prev != null)
            {
                sb.Append(prev.X * CtlExpressG.Factor);
                sb.Append(",");
                sb.Append(prev.Y * CtlExpressG.Factor);
                sb.Append(" ");
            }

            foreach (DocPoint docLine in line)
            {
                sb.Append(docLine.X * CtlExpressG.Factor);
                sb.Append(",");
                sb.Append(docLine.Y * CtlExpressG.Factor);
                sb.Append(" ");
            }
            p.points = sb.ToString();
            p.stroke = "black";
            p.fill   = "none";

            if (bold == true)
            {
                if (this.m_format == DiagramFormat.ExpressG)
                {
                    p.stroke_width = "3";
                }
            }
            else if (bold == null)
            {
                p.stroke_dasharray = "1,1";
            }
        }
示例#8
0
        private void DrawObjectBorder(Graphics g, SEntity obj, Pen pen)
        {
            if (obj is DocDefinition && ((DocDefinition)obj).DiagramRectangle != null)
            {
                DocRectangle docRect = ((DocDefinition)obj).DiagramRectangle;

                Rectangle rc = new Rectangle(
                    (int)(docRect.X * Factor),
                    (int)(docRect.Y * Factor),
                    (int)(docRect.Width * Factor),
                    (int)(docRect.Height * Factor));
                rc.Inflate(-2, -2);

                g.DrawRectangle(pen, rc);
            }
            else if (obj is DocAttribute)
            {
                DocAttribute docAttr = (DocAttribute)obj;
                if (docAttr.DiagramLine != null)
                {
                    for (int i = 0; i < docAttr.DiagramLine.Count - 1; i++)
                    {
                        g.DrawLine(pen,
                                   new Point((int)(docAttr.DiagramLine[i].X * Factor), (int)(docAttr.DiagramLine[i].Y * Factor)),
                                   new Point((int)(docAttr.DiagramLine[i + 1].X * Factor), (int)(docAttr.DiagramLine[i + 1].Y * Factor)));
                    }
                }
            }
            else if (obj is DocLine)
            {
                // tree point
                DocLine   docLine  = (DocLine)obj;
                DocPoint  docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                Rectangle rc       = new Rectangle((int)(docPoint.X * Factor), (int)(docPoint.Y * Factor), 0, 0);
                rc.Inflate(6, 6);
                g.DrawEllipse(pen, rc);
            }
        }
示例#9
0
        private void SaveTree(g group, List <DocLine> tree, DocPoint prev, bool bold)
        {
            if (this.m_format == DiagramFormat.UML && prev == null)
            {
                foreach (DocLine docLine in tree)
                {
                    if (docLine.DiagramLine != null && docLine.DiagramLine.Count > 0)
                    {
                        // arrow head
                        double x = docLine.DiagramLine[0].X;
                        double y = docLine.DiagramLine[0].Y;

                        DocPoint        ptArrowL  = new DocPoint(x - 8, y + 16);
                        DocPoint        ptArrowR  = new DocPoint(x + 8, y + 16);
                        List <DocPoint> listPoint = new List <DocPoint>();
                        listPoint.Add(ptArrowL);
                        listPoint.Add(tree[0].DiagramLine[0]);
                        listPoint.Add(ptArrowR);
                        SaveLine(group, listPoint, null, false);
                    }
                }
            }

            foreach (DocLine docLine in tree)
            {
                SaveLine(group, docLine.DiagramLine, prev, bold);

                DocPoint next = null;
                if (docLine.DiagramLine != null && docLine.DiagramLine.Count > 0)
                {
                    next = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                }

                SaveTree(group, docLine.Tree, next, bold);
            }
        }
示例#10
0
        private g SaveDefinition(DocObject docObj, string displayname)
        {
            g group = new g();

            group.id = docObj.Name;

            DocDefinition docDef = docObj as DocDefinition;

            if (docDef == null || docDef.DiagramRectangle == null)
            {
                return(group);
            }

            double x  = docDef.DiagramRectangle.X * CtlExpressG.Factor;
            double y  = docDef.DiagramRectangle.Y * CtlExpressG.Factor;
            double cx = docDef.DiagramRectangle.Width * CtlExpressG.Factor;
            double cy = docDef.DiagramRectangle.Height * CtlExpressG.Factor;

            rect r = new rect();

            r.x      = x.ToString();
            r.y      = y.ToString();
            r.width  = cx.ToString();
            r.height = cy.ToString();
            r.stroke = "black";
            group.rect.Add(r);

            text t = new text();

            t.x    = (x + cx * 0.5).ToString();
            t.y    = (y + cy * 0.5).ToString();
            t.fill = "black";
            t.alignment_baseline = "middle";
            t.text_anchor        = "middle";
            t.font_size          = "10";
            t.font_family        = "Arial, Helvetica, sans-serif";
            if (displayname != null)
            {
                t.value = displayname;
            }
            else
            {
                t.value = docDef.Name;
            }

            group.text.Add(t);

            if (this.m_format == DiagramFormat.UML)
            {
                y += 10;

                group.fill           = "lightyellow";
                t.y                  = y.ToString();
                t.alignment_baseline = "top";
                t.font_weight        = "bold";
                t.value              = docDef.Name;

                // separator line
                y += 2;
                List <DocPoint> listPoint = new List <DocPoint>();
                listPoint.Add(new DocPoint(x / CtlExpressG.Factor, y / CtlExpressG.Factor));
                listPoint.Add(new DocPoint((x + cx) / CtlExpressG.Factor, y / CtlExpressG.Factor));
                SaveLine(group, listPoint, null, false);
                y += 2;

                // add attributes
                if (docDef is DocDefinitionRef)
                {
                    DocDefinitionRef docDefRef = (DocDefinitionRef)docDef;

                    DocObject docObjRef = this.m_project.GetDefinition(docDefRef.Name);
                    if (docObjRef is DocEntity)
                    {
                        DocEntity docEnt = (DocEntity)docObjRef;
                        foreach (DocAttribute docAtt in docEnt.Attributes)
                        {
                            if (docAtt.Derived == null && docAtt.Inverse == null)
                            {
                                DocObject docAttrType = this.m_project.GetDefinition(docAtt.DefinedType);

                                // include native types, enumerations, and defined types
                                if (docAttrType == null || docAttrType is DocEnumeration || docAttrType is DocDefined)
                                {
                                    y += 12;

                                    string agg = "[1]";
                                    if (docAtt.AggregationType != 0)
                                    {
                                        string lower = docAtt.AggregationLower;
                                        string upper = docAtt.AggregationUpper;
                                        if (String.IsNullOrEmpty(lower))
                                        {
                                            lower = "0";
                                        }
                                        if (String.IsNullOrEmpty(upper) || upper == "0")
                                        {
                                            upper = "*";
                                        }

                                        agg = "[" + lower + ".." + upper + "]";
                                    }
                                    else if (docAtt.IsOptional)
                                    {
                                        agg = "[0..1]";
                                    }


                                    text ta = new text();
                                    ta.x    = (x + 4).ToString();
                                    ta.y    = y.ToString();
                                    ta.fill = "black";
                                    ta.alignment_baseline = "top";
                                    ta.text_anchor        = "start";
                                    ta.font_size          = "9";
                                    ta.font_family        = "Arial, Helvetica, sans-serif";
                                    ta.value = docAtt.Name + agg + " : " + docAtt.DefinedType;
                                    group.text.Add(ta);
                                }
                            }
                        }


                        // UML only (not in original EXPRESS-G diagrams)
                        foreach (DocAttributeRef docAttrRef in docDefRef.AttributeRefs)
                        {
                            DocAttribute docAtt = docAttrRef.Attribute;

                            //if (docAtt.Inverse == null)
                            {
                                //... also need to capture attribute name...
                                //DrawLine(g, Pens.Black, docAttrRef.DiagramLine, format);
                                SaveLine(group, docAttrRef.DiagramLine, null, false);

                                // draw diamond at beginning of line
#if false /// not yet correct
                                if (this.m_format == DiagramFormat.UML)
                                {
                                    DocPoint ptHead = docAttrRef.DiagramLine[0];
                                    DocPoint ptNext = docAttrRef.DiagramLine[1];
                                    double   ux     = ptNext.X - ptHead.X;
                                    double   uy     = ptNext.Y - ptHead.Y;
                                    double   uv     = Math.Sqrt(ux * ux + uy * uy);
                                    ux = ux / uv;
                                    uy = uy / uv;
                                    DocPoint        ptR   = new DocPoint(ptHead.X + uy * 8, ptHead.Y + ux * 8);
                                    DocPoint        ptF   = new DocPoint(ptHead.X + ux * 16, ptHead.Y + uy * 8);
                                    DocPoint        ptL   = new DocPoint(ptHead.X + uy * 8, ptHead.Y - ux * 8);
                                    List <DocPoint> listP = new List <DocPoint>();
                                    listP.Add(ptHead);
                                    listP.Add(ptR);
                                    listP.Add(ptF);
                                    listP.Add(ptL);
                                    listP.Add(ptHead);
                                    SaveLine(group, listP, null, false);
                                }
#endif
                                if (docAtt.Name == "Items")
                                {
                                    docAtt.ToString();
                                }

                                string agg = "[1]";
                                if (docAtt.AggregationType != 0)
                                {
                                    string lower = docAtt.AggregationLower;
                                    string upper = docAtt.AggregationUpper;
                                    if (String.IsNullOrEmpty(lower))
                                    {
                                        lower = "0";
                                    }
                                    if (String.IsNullOrEmpty(upper))
                                    {
                                        upper = "*";
                                    }

                                    agg = "[" + lower + ".." + upper + "]";
                                }
                                else if (docAtt.IsOptional)
                                {
                                    agg = "[0..1]";
                                }


                                double ty = docAttrRef.DiagramLine[0].Y * CtlExpressG.Factor;
                                if (docAttrRef.DiagramLine[1].Y > docAttrRef.DiagramLine[0].Y)
                                {
                                    ty -= 10;
                                }
                                else
                                {
                                    ty += 10;
                                }

                                text tr = new text();
                                tr.x = (docAttrRef.DiagramLine[0].X * CtlExpressG.Factor + 4).ToString();
                                tr.y = (ty).ToString();


                                tr.fill = "black";
                                tr.alignment_baseline = "top";
                                tr.text_anchor        = "start";
                                tr.font_size          = "9";
                                tr.font_family        = "Arial, Helvetica, sans-serif";
                                tr.value = docAtt.Name + agg;
                                group.text.Add(tr);
                            }
                        }
                    }
                }
            }
            else
            {
                if (docDef is DocEntity)
                {
                    group.fill = "yellow";
                }
                else if (docDef is DocType)
                {
                    group.fill = "green";
                }
                else if (docDef is DocPageTarget)
                {
                    group.fill = "blue";
                    r.rx       = "10";
                    r.ry       = "10";
                }
                else if (docDef is DocPageSource)
                {
                    group.fill = "silver";
                    r.rx       = "10";
                    r.ry       = "10";
                }
                else
                {
                    group.fill = "grey";
                }
            }


            return(group);
        }
示例#11
0
        private void toolStripMenuItemDiagramFormatTree_Click(object sender, EventArgs e)
        {
            IDocTreeHost docDefinition = (IDocTreeHost)this.treeView.SelectedNode.Tag;
            List<DocLine> list = docDefinition.Tree;

            // add/remove tree
            if (list != null)
            {
                if (list.Count > 0 && list[0].Definition == null)
                {
                    // remove tree(s)
                    for (int iTree = list.Count - 1; iTree >= 0; iTree--)
                    {
                        DocLine docTree = list[0];
                        for(int iNode = docTree.Tree.Count-1; iNode >= 0; iNode--)
                        {
                            DocLine docNode = docTree.Tree[iNode];
                            docTree.Tree.RemoveAt(iNode);
                            list.Add(docNode);
                        }

                        list.RemoveAt(iTree);
                        docTree.Delete();
                    }

                    this.ctlExpressG.LayoutDefinition((DocDefinition)docDefinition);
                }
                else if(list.Count > 0)
                {
                    // add tree -- make node half-way along first link

                    // clean up any page refs
                    for(int i = 0; i < list.Count; i++)
                    {
                        if(list[i].Definition is DocPageSource)
                        {
                            DocPageSource docPageSource = (DocPageSource)list[i].Definition;

                            // does page source still exist
                            bool exists = false;
                            foreach(DocPageTarget docPageTarget in this.ctlExpressG.Schema.PageTargets)
                            {
                                if(docPageTarget.Sources.Contains(docPageSource))
                                {
                                    exists = true;
                                    break;
                                }
                            }

                            if(!exists)
                            {
                                string[] parts = docPageSource.Name.Split();
                                if (parts.Length == 2)
                                {
                                    DocDefinition docDef = this.ctlExpressG.Schema.GetDefinition(parts[1]);
                                    if (docDef != null)
                                    {
                                        list[i].Definition.Delete();
                                        list[i].Definition = docDef;
                                    }
                                }
                            }
                        }
                    }

                    DocLine docNode = list[0];
                    DocPoint docPos = new DocPoint(
                        (docNode.DiagramLine[0].X + docNode.DiagramLine[docNode.DiagramLine.Count - 1].X) * 0.5,
                        (docNode.DiagramLine[0].Y + docNode.DiagramLine[docNode.DiagramLine.Count - 1].Y) * 0.5);

                    DocLine docTree = new DocLine();
                    docTree.DiagramLine.Add(new DocPoint()); // will get positioned upon layout
                    docTree.DiagramLine.Add(new DocPoint()); // will get positioned upon layout
                    docTree.DiagramLine.Add(docPos);

                    for(int iNode = list.Count-1; iNode >= 0; iNode--)
                    {
                        docTree.Tree.Add(list[iNode]);
                        list.RemoveAt(iNode);
                    }

                    list.Add(docTree);

                    this.ctlExpressG.LayoutDefinition((DocDefinition)docDefinition);
                    foreach(DocLine docLine in docTree.Tree)
                    {
                        this.ctlExpressG.LayoutDefinition(docLine.Definition);
                    }
                }
            }

            this.ctlExpressG.Redraw();
        }
 public FailedTestInspectorDocumentAdornment(DocPoint start, DocPoint end, CoreEventHub master, ArrowDescription arrow)
     : base(start, end, master, arrow)
 {
 }
示例#13
0
        /// <summary>
        /// Finds object at absolute point (regardless of scroll position or page)
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        private DocObject Pick(Point pt, out DocLine line, out ResizeHandle handle)
        {
            line   = null;
            handle = ResizeHandle.None;

            if (this.m_schema == null)
            {
                return(null);
            }

            pt.X -= this.AutoScrollPosition.X;
            pt.Y -= this.AutoScrollPosition.Y;

            PointF ptFloat = new PointF(pt.X, pt.Y);

            foreach (DocType docType in this.m_schema.Types)
            {
                if (HitTest(docType.DiagramRectangle, pt, out handle))
                {
                    return(docType);
                }

                if (docType is DocSelect)
                {
                    DocSelect docSel = (DocSelect)docType;
                    foreach (DocLine docLine in docSel.Tree)
                    {
                        DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                        PointF   ptA      = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor);
                        if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5)
                        {
                            handle = ResizeHandle.Move;
                            line   = docLine;
                            return(docType);
                        }
                    }
                }
            }

            foreach (DocEntity docType in this.m_schema.Entities)
            {
                if (HitTest(docType.DiagramRectangle, pt, out handle))
                {
                    return(docType);
                }

                foreach (DocAttribute docAttr in docType.Attributes)
                {
                    if (docAttr.DiagramLine != null)
                    {
                        for (int i = 0; i < docAttr.DiagramLine.Count - 1; i++)
                        {
                            PointF ptA = new PointF((float)(docAttr.DiagramLine[i].X * Factor), (float)docAttr.DiagramLine[i].Y * Factor);
                            PointF ptB = new PointF((float)(docAttr.DiagramLine[i + 1].X * Factor), (float)docAttr.DiagramLine[i + 1].Y * Factor);

                            PointF ptClosest = new PointF();
                            double distance  = FindDistanceToSegment(ptFloat, ptA, ptB, out ptClosest);
                            if (distance < 3.0)
                            {
                                return(docAttr);
                            }
                        }
                    }
                }

                foreach (DocLine docLine in docType.Tree)
                {
                    if (docLine.DiagramLine.Count > 0)
                    {
                        DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                        PointF   ptA      = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor);
                        if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5)
                        {
                            line   = docLine;
                            handle = ResizeHandle.Move;
                            return(docType);
                        }
                    }
                }
            }

            foreach (DocComment docType in this.m_schema.Comments)
            {
                if (HitTest(docType.DiagramRectangle, pt, out handle))
                {
                    return(docType);
                }
            }

            foreach (DocPageTarget docType in this.m_schema.PageTargets)
            {
                if (HitTest(docType.DiagramRectangle, pt, out handle))
                {
                    return(docType);
                }

                foreach (DocPageSource docSource in docType.Sources)
                {
                    if (HitTest(docSource.DiagramRectangle, pt, out handle))
                    {
                        return(docSource);
                    }
                }
            }

            foreach (DocPrimitive docType in this.m_schema.Primitives)
            {
                if (HitTest(docType.DiagramRectangle, pt, out handle))
                {
                    return(docType);
                }
            }

            foreach (DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs)
            {
                foreach (DocDefinitionRef docType in docSchemaRef.Definitions)
                {
                    if (HitTest(docType.DiagramRectangle, pt, out handle))
                    {
                        return(docType);
                    }

                    foreach (DocLine docLine in docType.Tree)
                    {
                        DocPoint docPoint = docLine.DiagramLine[docLine.DiagramLine.Count - 1];
                        PointF   ptA      = new PointF((float)(docPoint.X * Factor), (float)docPoint.Y * Factor);
                        if (Math.Abs(ptFloat.X - ptA.X) < 4 && Math.Abs(ptFloat.Y - ptA.Y) <= 5)
                        {
                            handle = ResizeHandle.Move;
                            line   = docLine;
                            return(docType);
                        }
                    }
                }
            }

            return(null);
        }
 public RunMethodTileDocumentAdornment(DocPoint start, DocPoint end, CoreEventHub master, Method target)
     : base(start, end, master, target)
 {
     this.target = target;
 }
示例#15
0
        private void CtlExpressG_MouseMove(object sender, MouseEventArgs e)
        {
            this.m_ptMove = e.Location;

            if (this.m_mousedown && this.m_toolmode == ToolMode.Move)
            {
                UpdateCursor(this.m_handle);

                Point ptLocation = e.Location;
                if (ptLocation.X < 0)
                {
                    ptLocation.X = 0;
                }
                if (ptLocation.Y < 0)
                {
                    ptLocation.Y = 0;
                }

                if (this.m_lineselection != null && this.m_selection is DocDefinition)
                {
                    // moving tree node
                    DocPoint docPoint = m_lineselection.DiagramLine[m_lineselection.DiagramLine.Count - 1];
                    docPoint.X = (ptLocation.X - this.AutoScrollPosition.X) / Factor;
                    docPoint.Y = (ptLocation.Y - this.AutoScrollPosition.Y) / Factor;

                    // layout the owning element
                    LayoutDefinition((DocDefinition)this.m_selection);

                    // layout lines to all subtypes
                    foreach (DocLine docSub in this.m_lineselection.Tree)
                    {
                        LayoutNode(this.m_lineselection, docSub);
                    }

                    this.Redraw();
                }
                else if (this.m_selection is DocDefinition)
                {
                    float dx = (float)(ptLocation.X - this.m_ptDown.X);
                    float dy = (float)(ptLocation.Y - this.m_ptDown.Y);

                    // move or resize the object...
                    DocDefinition docSelection = (DocDefinition)this.m_selection;
                    if (this.m_pointmap.ContainsKey(docSelection))
                    {
                        PointF ptSelection = this.m_pointmap[docSelection];

                        if ((this.m_handle & ResizeHandle.North) != 0)
                        {
                            double yTail = docSelection.DiagramRectangle.Y + docSelection.DiagramRectangle.Height;
                            docSelection.DiagramRectangle.Y      = ptSelection.Y + dy / Factor;
                            docSelection.DiagramRectangle.Height = yTail - docSelection.DiagramRectangle.Y;
                        }
                        else if ((this.m_handle & ResizeHandle.South) != 0)
                        {
                            docSelection.DiagramRectangle.Height = m_selectionsize.Height + dy / Factor;
                        }

                        if ((this.m_handle & ResizeHandle.West) != 0)
                        {
                            double xTail = docSelection.DiagramRectangle.X + docSelection.DiagramRectangle.Width;
                            docSelection.DiagramRectangle.X     = ptSelection.X + dx / Factor;
                            docSelection.DiagramRectangle.Width = xTail - docSelection.DiagramRectangle.X;
                        }
                        else if ((this.m_handle & ResizeHandle.East) != 0)
                        {
                            docSelection.DiagramRectangle.Width = m_selectionsize.Width + dx / Factor;
                        }

                        if (this.m_handle == ResizeHandle.Move)
                        {
                            docSelection.DiagramRectangle.X = ptSelection.X + dx / Factor;
                            docSelection.DiagramRectangle.Y = ptSelection.Y + dy / Factor;
                        }

                        if (this.m_selection is DocDefinition)
                        {
                            LayoutDefinition((DocDefinition)this.m_selection);
                        }
                    }

                    this.Redraw();
                }
                else if (this.m_selection == null)
                {
                    // draw box and highlight multiple within region
                    this.m_multiselect.Clear();
                    Rectangle rc = CreateNormalizedRectangle(this.m_ptDown, this.m_ptMove);
                    foreach (DocEntity docEntity in this.m_schema.Entities)
                    {
                        SelectWithinRectangle(docEntity, rc);
                    }
                    foreach (DocType docType in this.m_schema.Types)
                    {
                        SelectWithinRectangle(docType, rc);
                    }
                    foreach (DocPrimitive docType in this.m_schema.Primitives)
                    {
                        SelectWithinRectangle(docType, rc);
                    }
                    foreach (DocPageTarget docTarget in this.m_schema.PageTargets)
                    {
                        SelectWithinRectangle(docTarget, rc);
                        foreach (DocPageSource docSource in docTarget.Sources)
                        {
                            SelectWithinRectangle(docSource, rc);
                        }
                    }
                    foreach (DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs)
                    {
                        foreach (DocDefinitionRef docRef in docSchemaRef.Definitions)
                        {
                            SelectWithinRectangle(docRef, rc);
                        }
                    }
                    // don't select comments

                    this.Invalidate();
                }
            }
            else
            {
                ResizeHandle handle    = ResizeHandle.None;
                DocObject    highlight = this.Pick(e.Location, out this.m_linehighlight, out handle);
                if (this.m_highlight != highlight)
                {
                    this.m_highlight = highlight;
                    this.Invalidate();
                }

                if (this.m_mousedown && this.m_toolmode == ToolMode.Link)
                {
                    this.Invalidate();
                }

                UpdateCursor(handle);
            }
        }
 public RunMethodTileDocumentAdornment(DocPoint start, DocPoint end, CoreEventHub master, Method target)
     : base(start, end, master, target)
 {
     this.target = target;
 }
示例#17
0
        /// <summary>
        /// Lays out points for connectors using straight segments where possible, falling back on elbows if below
        /// </summary>
        /// <param name="rcA">The source rectangle</param>
        /// <param name="rcB">The target rectangle - optional; if null then only the first point is resized</param>
        /// <param name="ptA">The source point, which is positioned along the perimeter of the source rectangle.</param>
        /// <param name="ptM">The elbow point, which may be the same as the source point (if none), or different if an elbow is needed.</param>
        /// <param name="ptB">The target point, which is positioned at the midpoint of one of the four edges of the target rectangle.</param>
        private static void LayoutLine(DocRectangle rcA, DocRectangle rcB, DocPoint ptA, DocPoint ptM, DocPoint ptB)
        {
            if (rcA == null || rcB == null)
                return;

            if (rcB.X > rcA.X + rcA.Width)
            {
                // to right
                ptB.X = rcB.X;
                ptB.Y = rcB.Y + rcB.Height / 2;
                ptA.X = rcA.X + rcA.Width;
                ptA.Y = ptB.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.Y > rcA.Y + rcA.Height)
                {
                    // below
                    ptA.Y = rcA.Y + rcA.Height;
                }
                else if (ptA.Y < rcA.Y)
                {
                    // above
                    ptA.Y = rcA.Y;
                }
            }
            else if (rcB.X + rcB.Width < rcA.X)
            {
                // to left
                ptB.X = rcB.X + rcB.Width;
                ptB.Y = rcB.Y + rcB.Height / 2;
                ptA.X = rcA.X;
                ptA.Y = ptB.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.Y > rcA.Y + rcA.Height)
                {
                    // below
                    ptA.Y = rcA.Y + rcA.Height;
                }
                else if (ptA.Y < rcA.Y)
                {
                    // above
                    ptA.Y = rcA.Y;
                }
            }
            else if (rcB.Y > rcA.Y + rcA.Height)
            {
                // to down
                ptB.X = rcB.X + rcB.Width / 2;
                ptB.Y = rcB.Y;
                ptA.X = ptB.X;
                ptA.Y = rcA.Y + rcA.Height;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.X > rcA.X + rcA.Width)
                {
                    // right
                    ptA.X = rcA.X + rcA.Width;
                }
                else if (ptA.X < rcA.X)
                {
                    // left
                    ptA.X = rcA.X;
                }
            }
            else if (rcB.Y + rcB.Height < rcA.Y)
            {
                // to up
                ptB.X = rcB.X + rcB.Width / 2;
                ptB.Y = rcB.Y + rcB.Height;
                ptA.X = ptB.X;
                ptA.Y = rcA.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.X > rcA.X + rcA.Width)
                {
                    // right
                    ptA.X = rcA.X + rcA.Width;
                }
                else if (ptA.X < rcA.X)
                {
                    // left
                    ptA.X = rcA.X;
                }
            }
        }
示例#18
0
        /// <summary>
        /// Lays out points for connectors using straight segments where possible, falling back on elbows if below
        /// </summary>
        /// <param name="rcA">The source rectangle</param>
        /// <param name="rcB">The target rectangle - optional; if null then only the first point is resized</param>
        /// <param name="ptA">The source point, which is positioned along the perimeter of the source rectangle.</param>
        /// <param name="ptM">The elbow point, which may be the same as the source point (if none), or different if an elbow is needed.</param>
        /// <param name="ptB">The target point, which is positioned at the midpoint of one of the four edges of the target rectangle.</param>
        private static void LayoutLine(DocRectangle rcA, DocRectangle rcB, DocPoint ptA, DocPoint ptM, DocPoint ptB)
        {
            if (rcA == null || rcB == null)
            {
                return;
            }

            if (rcB.X > rcA.X + rcA.Width)
            {
                // to right
                ptB.X = rcB.X;
                ptB.Y = rcB.Y + rcB.Height / 2;
                ptA.X = rcA.X + rcA.Width;
                ptA.Y = ptB.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.Y > rcA.Y + rcA.Height)
                {
                    // below
                    ptA.Y = rcA.Y + rcA.Height;
                }
                else if (ptA.Y < rcA.Y)
                {
                    // above
                    ptA.Y = rcA.Y;
                }
            }
            else if (rcB.X + rcB.Width < rcA.X)
            {
                // to left
                ptB.X = rcB.X + rcB.Width;
                ptB.Y = rcB.Y + rcB.Height / 2;
                ptA.X = rcA.X;
                ptA.Y = ptB.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.Y > rcA.Y + rcA.Height)
                {
                    // below
                    ptA.Y = rcA.Y + rcA.Height;
                }
                else if (ptA.Y < rcA.Y)
                {
                    // above
                    ptA.Y = rcA.Y;
                }
            }
            else if (rcB.Y > rcA.Y + rcA.Height)
            {
                // to down
                ptB.X = rcB.X + rcB.Width / 2;
                ptB.Y = rcB.Y;
                ptA.X = ptB.X;
                ptA.Y = rcA.Y + rcA.Height;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.X > rcA.X + rcA.Width)
                {
                    // right
                    ptA.X = rcA.X + rcA.Width;
                }
                else if (ptA.X < rcA.X)
                {
                    // left
                    ptA.X = rcA.X;
                }
            }
            else if (rcB.Y + rcB.Height < rcA.Y)
            {
                // to up
                ptB.X = rcB.X + rcB.Width / 2;
                ptB.Y = rcB.Y + rcB.Height;
                ptA.X = ptB.X;
                ptA.Y = rcA.Y;
                ptM.X = ptA.X;
                ptM.Y = ptA.Y;
                if (ptA.X > rcA.X + rcA.Width)
                {
                    // right
                    ptA.X = rcA.X + rcA.Width;
                }
                else if (ptA.X < rcA.X)
                {
                    // left
                    ptA.X = rcA.X;
                }
            }
        }
示例#19
0
        private DocDefinition CreateLink(DocDefinition target, DocPoint docPoint)
        {
            if (target is DocPageTarget)
            {
                DocPageTarget docPageTarget = (DocPageTarget)target;
                DocPageSource docPageSource = new DocPageSource();
                docPageTarget.Sources.Add(docPageSource);

                //docPageSource.Target = docPageTarget;
                docPageSource.DiagramRectangle = new DocRectangle();
                docPageSource.DiagramRectangle.X = docPoint.X + 400.0;
                docPageSource.DiagramRectangle.Y = docPoint.Y;
                docPageSource.DiagramRectangle.Width = 400.0;
                docPageSource.DiagramRectangle.Height = 100.0;

                int px = (int)(docPageSource.DiagramRectangle.X / CtlExpressG.PageX);
                int py = (int)(docPageSource.DiagramRectangle.Y / CtlExpressG.PageY);
                int page = 1 + py * this.ctlExpressG.Schema.DiagramPagesHorz + px;
                docPageSource.DiagramNumber = page;

                return docPageSource;
            }
            else
            {
                return target;
            }
        }
 private void PlugIn1_DecorateLanguageElement(object sender, DecorateLanguageElementEventArgs args)
 {
     LanguageElement element = args.LanguageElement;
     if (_DisplayTile && element.ElementType == LanguageElementType.Method && CanBeRun((Method)element))
     {
         DocPoint start = new DocPoint(element.StartLine, element.StartOffset);
         args.AddAdornment(new RunMethodTileDocumentAdornment(start, start, this, (Method)element));
     }
 }