private void UpdateStencil(ModelStencil modelStencil) { double minX = float.MaxValue; double maxX = float.MinValue; double minY = float.MaxValue; double maxY = float.MinValue; UpdateStencil(modelStencil.Elements, ref minX, ref minY, ref maxX, ref maxY); UpdateStencil(modelStencil.Decorations, ref minX, ref minY, ref maxX, ref maxY); double anchorMinX = minX; double anchorMaxX = maxX; double anchorMinY = minY; double anchorMaxY = maxY; UpdateStencil(modelStencil.Anchors, ref anchorMinX, ref anchorMinY, ref anchorMaxX, ref anchorMaxY); ScaleStencil(modelStencil.Elements, minX, minY, maxX, maxY); ScaleStencil(modelStencil.Decorations, minX, minY, maxX, maxY); ScaleStencil(modelStencil.Anchors, minX, minY, maxX, maxY); double scale = 1000.0F / Math.Max((maxX - minX), (maxY - minY)); SysCAD.Protocol.Rectangle rect = new SysCAD.Protocol.Rectangle(minX * scale, minY * scale, (maxX - minX) * scale, (maxY - minY) * scale); box2.BoundingRect = rect; { int i; ModelStencil stencil = modelStencil; bool mirrorX = false; bool mirrorY = false; ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; i = 0; foreach (Element element in stencil.Elements) { if (element is Arc) { Arc arc = element as Arc; elementTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s); } if (element is Line) { Line line = element as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0F - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; elementTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (element is Bezier) { Bezier bezier = element as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; elementTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; i = 0; foreach (Element decoration in stencil.Decorations) { if (decoration is Arc) { Arc arc = decoration as Arc; decorationTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s); } if (decoration is Line) { Line line = decoration as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0 - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; decorationTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (decoration is Bezier) { Bezier bezier = decoration as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; decorationTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } box2.Shape = (new ShapeTemplate(elementTemplate, decorationTemplate, null, stencil.FillMode, stencil.Tag)); } SysCAD.Protocol.Rectangle anchorRect = new SysCAD.Protocol.Rectangle(anchorMinX * scale, anchorMinY * scale, (anchorMaxX - anchorMinX) * scale, (anchorMaxY - anchorMinY) * scale); foreach (Box box in anchorPointBoxes) flowChart2.DeleteObject(box); anchorPointBoxes.Clear(); foreach (Anchor anchor in modelStencil.Anchors) { RectangleF displayRect = new RectangleF((float)(((anchor.Positions[0] as SysCAD.Protocol.Point).X / 100.0F * (maxX - minX) + minX) * scale), (float)(((anchor.Positions[0] as SysCAD.Protocol.Point).Y / 100.0F * (maxY - minY) + minY) * scale), 0.0F, 0.0F); displayRect.Inflate(20.0F, 20.0F); Box box = flowChart2.CreateBox(displayRect.X, displayRect.Y, displayRect.Width, displayRect.Height); anchorPointBoxes.Add(box); box.Style = BoxStyle.Ellipse; box.ZTop(); box.FillColor = Color.Red; box.FillColor = Color.FromArgb(100, box.FillColor); } anchorRect.Inflate((maxX - minX) * scale / 10.0F, (maxY - minY) * scale / 10.0F); flowChart2.DocExtents = anchorRect; flowChart2.ZoomToRect(anchorRect); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { elementTextBox.Text = ""; decorationTextBox.Text = ""; tagAreaTextBox.Text = ""; Text = "*Untitled*"; graphicStencil.Elements = new System.Collections.ArrayList(); graphicStencil.Decorations = new System.Collections.ArrayList(); modelStencil.Elements = new System.Collections.ArrayList(); modelStencil.Decorations = new System.Collections.ArrayList(); modelStencil.Anchors = new System.Collections.ArrayList(); flowChart1.DocExtents = new RectangleF(-1.0F, -1.0F, 2.0F, 2.0F); flowChart1.ZoomToRect(new RectangleF(-1.0F, -1.0F, 2.0F, 2.0F)); box1 = flowChart1.CreateBox(-1.0F, -1.0F, 2.0F, 2.0F); box1.Locked = true; box1.Style = MindFusion.FlowChartX.BoxStyle.Shape; { GraphicStencil stencil = graphicStencil; bool mirrorX = false; bool mirrorY = false; ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; { int i = 0; foreach (Element element in stencil.Elements) { if (element is Arc) { elementTemplate[i] = new ArcTemplate( (float)(element as Arc).x, (float)(element as Arc).y, (float)(element as Arc).w, (float)(element as Arc).h, (float)(element as Arc).a, (float)(element as Arc).s); } if (element is Line) { Line line = element as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0 - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; elementTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (element is Bezier) { Bezier bezier = element as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; elementTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; { int i = 0; foreach (Element decoration in stencil.Decorations) { if (decoration is Arc) { decorationTemplate[i] = new ArcTemplate( (float)(decoration as Arc).x, (float)(decoration as Arc).y, (float)(decoration as Arc).w, (float)(decoration as Arc).h, (float)(decoration as Arc).a, (float)(decoration as Arc).s); } if (decoration is Line) { decorationTemplate[i] = new LineTemplate( (float)(decoration as Line).x1, (float)(decoration as Line).y1, (float)(decoration as Line).x2, (float)(decoration as Line).y2); } if (decoration is Bezier) { decorationTemplate[i] = new BezierTemplate( (float)(decoration as Bezier).x1, (float)(decoration as Bezier).y1, (float)(decoration as Bezier).x2, (float)(decoration as Bezier).y2, (float)(decoration as Bezier).x3, (float)(decoration as Bezier).y3, (float)(decoration as Bezier).x4, (float)(decoration as Bezier).y4); } i++; } } box1.Shape = (new ShapeTemplate(elementTemplate, decorationTemplate, new ElementTemplate[0], stencil.fillMode, stencil.Tag)); } textBox1 = flowChart1.CreateBox(-1.0F, -1.0F, 2.0F, 2.0F); textBox1.Locked = true; //textBox1.Style = MindFusion.FlowChartX.BoxStyle.Shape; //textBox1.Shape = graphicStencil.TextShapeTemplate(false, false); textBox1.Shape = MindFusion.FlowChartX.ShapeTemplate.Decision; flowChart2.DocExtents = new RectangleF(-1.0F, -1.0F, 2.0F, 2.0F); flowChart2.ZoomToRect(new RectangleF(-1.0F, -1.0F, 2.0F, 2.0F)); box2 = flowChart2.CreateBox(-1.0F, -1.0F, 2.0F, 2.0F); box2.Locked = true; box2.Style = MindFusion.FlowChartX.BoxStyle.Shape; { int i; ModelStencil stencil = modelStencil; bool mirrorX = false; bool mirrorY = false; ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; i = 0; foreach (Element element in stencil.Elements) { if (element is Arc) { Arc arc = element as Arc; elementTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s); } if (element is Line) { Line line = element as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0 - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; elementTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (element is Bezier) { Bezier bezier = element as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; elementTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; i = 0; foreach (Element decoration in stencil.Decorations) { if (decoration is Arc) { Arc arc = decoration as Arc; decorationTemplate[i] = new ArcTemplate((float)arc.x, (float)arc.y, (float)arc.w, (float)arc.h, (float)arc.a, (float)arc.s); } if (decoration is Line) { Line line = decoration as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0 - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; decorationTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (decoration is Bezier) { Bezier bezier = decoration as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; decorationTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } box2.Shape = (new ShapeTemplate(elementTemplate, decorationTemplate, null, stencil.FillMode, stencil.Tag)); } }
private void UpdateStencil(GraphicStencil graphicStencil) { double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; UpdateStencil(graphicStencil.Elements, ref minX, ref minY, ref maxX, ref maxY); UpdateStencil(graphicStencil.Decorations, ref minX, ref minY, ref maxX, ref maxY); double textMinX = double.MaxValue; double textMaxX = double.MinValue; double textMinY = double.MaxValue; double textMaxY = double.MinValue; UpdateStencil(graphicStencil.TagArea, ref textMinX, ref textMinY, ref textMaxX, ref textMaxY); ScaleStencil(graphicStencil.Elements, minX, minY, maxX, maxY); ScaleStencil(graphicStencil.Decorations, minX, minY, maxX, maxY); double scale = 1000.0 / Math.Max((maxX - minX), (maxY - minY)); SysCAD.Protocol.Rectangle rect = new SysCAD.Protocol.Rectangle(minX * scale, minY * scale, (maxX - minX) * scale, (maxY - minY) * scale); graphicStencil.defaultSize = new SysCAD.Protocol.Size((maxX - minX), (maxY - minY)); box1.BoundingRect = rect; { GraphicStencil stencil = graphicStencil; bool mirrorX = false; bool mirrorY = false; ElementTemplate[] elementTemplate = new ElementTemplate[stencil.Elements.Count]; { int i = 0; foreach (Element element in stencil.Elements) { if (element is Arc) { elementTemplate[i] = new ArcTemplate( (float)(element as Arc).x, (float)(element as Arc).y, (float)(element as Arc).w, (float)(element as Arc).h, (float)(element as Arc).a, (float)(element as Arc).s); } if (element is Line) { Line line = element as Line; double x1, y1, x2, y2; if (mirrorX) x1 = 100.0 - line.x1; else x1 = line.x1; if (mirrorY) y1 = 100.0 - line.y1; else y1 = line.y1; if (mirrorX) x2 = 100.0 - line.x2; else x2 = line.x2; if (mirrorY) y2 = 100.0 - line.y2; else y2 = line.y2; elementTemplate[i] = new LineTemplate((float)x1, (float)y1, (float)x2, (float)y2); } if (element is Bezier) { Bezier bezier = element as Bezier; double x1, y1, x2, y2, x3, y3, x4, y4; if (mirrorX) x1 = 100.0 - bezier.x1; else x1 = bezier.x1; if (mirrorY) y1 = 100.0 - bezier.y1; else y1 = bezier.y1; if (mirrorX) x2 = 100.0 - bezier.x2; else x2 = bezier.x2; if (mirrorY) y2 = 100.0 - bezier.y2; else y2 = bezier.y2; if (mirrorX) x3 = 100.0 - bezier.x3; else x3 = bezier.x3; if (mirrorY) y3 = 100.0 - bezier.y3; else y3 = bezier.y3; if (mirrorX) x4 = 100.0 - bezier.x4; else x4 = bezier.x4; if (mirrorY) y4 = 100.0 - bezier.y4; else y4 = bezier.y4; elementTemplate[i] = new BezierTemplate((float)x1, (float)y1, (float)x2, (float)y2, (float)x3, (float)y3, (float)x4, (float)y4); } i++; } } ElementTemplate[] decorationTemplate = new ElementTemplate[stencil.Decorations.Count]; { int i = 0; foreach (Element decoration in stencil.Decorations) { if (decoration is Arc) { decorationTemplate[i] = new ArcTemplate( (float)(decoration as Arc).x, (float)(decoration as Arc).y, (float)(decoration as Arc).w, (float)(decoration as Arc).h, (float)(decoration as Arc).a, (float)(decoration as Arc).s); } if (decoration is Line) { decorationTemplate[i] = new LineTemplate( (float)(decoration as Line).x1, (float)(decoration as Line).y1, (float)(decoration as Line).x2, (float)(decoration as Line).y2); } if (decoration is Bezier) { decorationTemplate[i] = new BezierTemplate( (float)(decoration as Bezier).x1, (float)(decoration as Bezier).y1, (float)(decoration as Bezier).x2, (float)(decoration as Bezier).y2, (float)(decoration as Bezier).x3, (float)(decoration as Bezier).y3, (float)(decoration as Bezier).x4, (float)(decoration as Bezier).y4); } i++; } } box1.Shape = (new ShapeTemplate(elementTemplate, decorationTemplate, new ElementTemplate[0], stencil.fillMode, stencil.Tag)); } SysCAD.Protocol.Rectangle textRect = new SysCAD.Protocol.Rectangle(textMinX * scale, textMinY * scale, (textMaxX - textMinX) * scale, (textMaxY - textMinY) * scale); textBox1.BoundingRect = textRect; //textBox1.Shape = graphicStencil.TextShapeTemplate(false, false); textBox1.ZTop(); textBox1.FillColor = Color.FromArgb(100, Color.HotPink); double bothMinX = Math.Min(minX, textMinX); double bothMaxX = Math.Max(maxX, textMaxX); double bothMinY = Math.Min(minY, textMinY); double bothMaxY = Math.Max(maxY, textMaxY); SysCAD.Protocol.Rectangle bothRect = new SysCAD.Protocol.Rectangle(bothMinX * scale, bothMinY * scale, (bothMaxX - bothMinX) * scale, (bothMaxY - bothMinY) * scale); bothRect.Inflate((maxX - minX) * scale / 10.0F, (maxY - minY) * scale / 10.0F); flowChart1.DocExtents = bothRect; flowChart1.ZoomToRect(bothRect); }
public override object Clone() { BezierTemplate clone = new BezierTemplate(pts[0], pts[1], pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]); return clone; }