Beispiel #1
0
 //public LineJoin linejoin;
 //public LineCap endcap;
 //public LineCap startcap;
 //public DashCap dashcap;
 public PenStyle(Color color, float width, DashStyle dashstyle, ArrowStyle arrowstyle)
 {
     this.color      = color;
     this.width      = width;
     this.dashstyle  = dashstyle;
     this.arrowstyle = arrowstyle;
 }
Beispiel #2
0
        private void Viewer_GraphLoadingEnded(object sender, EventArgs e)
        {
            ArrowStyle loadedGraphDirection =
                (sender as GViewer).Graph.Edges.Last().Attr.ArrowheadAtTarget;

            this.graph = new Frame.Models.DGraph(this.graph.EdgeArrowStyle);

            /*if (this.graph.EdgeArrowStyle != loadedGraphDirection)
             *      this.graph.EdgeArrowStyle = loadedGraphDirection;*/
            if (loadedGraphDirection == ArrowStyle.None)
            {
                this.undirectedGraphRadiobutton.Checked = true;
            }
            else
            {
                this.directedGraphRadioButton.Checked = true;
            }
            foreach (Node node in (sender as GViewer).Graph.Nodes)
            {
                this.graph.AddVertice(node.Id);
            }
            foreach (Edge edge in (sender as GViewer).Graph.Edges)
            {
                this.graph.AddEdge(edge.Source, edge.Target, edge.LabelText);
            }
            this.viewer.Graph = null;
            this.viewer.NeedToCalculateLayout = true;
            this.viewer.Graph = this.graph;
            this.viewer.NeedToCalculateLayout = false;
            this.ResetZoom();
        }
Beispiel #3
0
        private String EndCapToString(Pen pen)
        {
            if (pen.EndCap != LineCap.Custom)
            {
                return("");
            }
            ArrowStyle style = Hacks.GetLineCap(pen.CustomEndCap);

            switch (style)
            {
            case ArrowStyle.TinyArrow:
            case ArrowStyle.BigArrow:
            case ArrowStyle.LittleArrow:
            case ArrowStyle.LineArrow:
            case ArrowStyle.HollowArrow:
            case ArrowStyle.PointyArrow:
                arrowId++;
                defs.Add(String.Format("<marker id=\"arrow{1}\" viewBox=\"0 0 10 10\" refX=\"0\" refY=\"5\" stroke-width=\"1\" fill=\"rgb({0})\" orient=\"auto\">\n", ColorToRgb(pen.Color), arrowId) +
                         "<path d=\"M 0 0 L 10 5 L 0 10 L 0 0\" />\n" +
                         "</marker>");
                break;

            case ArrowStyle.None:
            default:
                return("");
            }
            return(String.Format(" marker-end=\"url(#arrow{0})\"", arrowId));
        }
        private static CustomLineCap GenerateLineCap(ArrowStyle style)
        {
            CustomLineCap clc = null;

            using (GraphicsPath gp = new GraphicsPath())
                switch (style)
                {
                case ArrowStyle.PointyArrow:
                    gp.AddPolygon(new PointF[] { new PointF(0f, -0f), new PointF(.1f, -.2f),
                                                 new PointF(0f, -.15f),
                                                 new PointF(-.10f, -.2f) });
                    clc            = new CustomLineCap(gp, null);
                    clc.WidthScale = 30;
                    clc.BaseInset  = .15f;
                    break;

                case ArrowStyle.HollowArrow:
                    gp.AddPolygon(new PointF[] { new PointF(0, -1f), new PointF(2f, -4f),
                                                 new PointF(-2f, -4f) });
                    clc           = new CustomLineCap(null, gp);
                    clc.BaseInset = 5.0f;
                    break;

                case ArrowStyle.BigArrow:
                    gp.AddPolygon(new PointF[] { new PointF(0, 0f), new PointF(.25f, -.4f),
                                                 new PointF(-.25f, -.4f) });
                    clc            = new CustomLineCap(gp, null);
                    clc.BaseInset  = .4f;
                    clc.WidthScale = 15;
                    break;

                case ArrowStyle.LineArrow:
                    gp.AddLine(new PointF(0, 0), new PointF(2.5f, -4f));
                    gp.AddLine(new PointF(0, 0), new PointF(-2.5f, -4f));
                    clc           = new CustomLineCap(null, gp);
                    clc.BaseInset = 3f;
                    break;

                case ArrowStyle.TinyArrow:
                    gp.AddPolygon(new PointF[] { new PointF(0, 0f), new PointF(.25f, -.4f),
                                                 new PointF(-.25f, -.4f) });
                    clc            = new CustomLineCap(gp, null);
                    clc.BaseInset  = .4f;
                    clc.WidthScale = 5;
                    break;

                case ArrowStyle.LittleArrow:
                    gp.AddPolygon(new PointF[] { new PointF(0, 0f), new PointF(.25f, -.4f),
                                                 new PointF(-.25f, -.4f) });
                    clc            = new CustomLineCap(gp, null);
                    clc.BaseInset  = .4f;
                    clc.WidthScale = 10;
                    break;

                default:
                    throw new Exception("Unexpected arrow type");
                }
            return(clc);
        }
Beispiel #5
0
		public ArrowUtils( ArrowStyle pstyle,  PointCollection pPoints )
		{
			points = pPoints.Clone();
			style = pstyle;
			//
			// TODO: Add constructor logic here
			//
		}
Beispiel #6
0
 public ArrowUtils(ArrowStyle pstyle, PointCollection pPoints)
 {
     points = pPoints.Clone();
     style  = pstyle;
     //
     // TODO: Add constructor logic here
     //
 }
Beispiel #7
0
 public virtual void AddLink(Node ToAddNode, Node FromAddNode, ArrowStyle Style, bool InLinks)
 {
     if (InLinks)
     {
         Link link = ToAddNode.InLinks.Add(FromAddNode);
         link.ArrowDst.Style = Style;
     }
     else
     {
         Link link = ToAddNode.OutLinks.Add(FromAddNode);
         link.ArrowDst.Style = Style;
     }
 }
Beispiel #8
0
        private static Pen GetArrowStyleSample(Color color, ArrowStyle ars)
        {
            Pen pen = new Pen(color, 2);

            if (ars == ArrowStyle.None)
            {
                pen.EndCap = LineCap.Flat;
            }
            else
            {
                pen.CustomEndCap = Hacks.GetLineCap(ars);
            }
            return(pen);
        }
        public static CustomLineCap GetLineCap(ArrowStyle style)
        {
            if (linecaps == null)
            {
                linecaps = new Dictionary <ArrowStyle, CustomLineCap>();
            }
            CustomLineCap clc;

            if (!linecaps.TryGetValue(style, out clc))
            {
                linecaps.Add(style, clc = GenerateLineCap(style));
            }
            return(clc);
        }
Beispiel #10
0
        private void arrowComboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            const int  margin = 5;
            ArrowStyle ds     = arrows[e.Index];

            using (Graphics g = e.Graphics)
            {
                using (Pen pen = GetArrowStyleSample(DrawItemStateToColor(e.State), ds))
                {
                    g.DrawLine(pen, new Point(e.Bounds.Left + margin, e.Bounds.Top + (e.Bounds.Height / 2)),
                               new Point(e.Bounds.Right - margin, e.Bounds.Top + (e.Bounds.Height / 2)));
                }
            }
        }
        public int AddArrow(string name, ArrowStyle style, int size, double x1, double y1, double x2, double y2)
        {
            ArrowAnnotation arrowAnnotation = new ArrowAnnotation();

            if (name.Length > 0)
            {
                arrowAnnotation.Name = name;
            }
            arrowAnnotation.X          = x1;
            arrowAnnotation.Y          = y1;
            arrowAnnotation.Width      = x2 - x1;
            arrowAnnotation.Height     = y2 - y1;
            arrowAnnotation.ArrowStyle = style;
            arrowAnnotation.ArrowSize  = size;
            return(base.List.Add(arrowAnnotation));
        }
        private void SetAnnotationStyle()
        {
            if (AnnotationStyle == null || AnnotationStyle.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value.ToLower().IndexOf("line") >= 0)
            {
                Chart1.Annotations[0].LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle.SelectedItem.Value);
            }

            else if (Annotation.SelectedItem.Value == "Text" ||
                     Annotation.SelectedItem.Value == "Rectangle" ||
                     Annotation.SelectedItem.Value == "Ellipse")
            {
                Chart1.Annotations[0].TextStyle =
                    (TextStyle)TextStyle.Parse(typeof(TextStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Arrow")
            {
                ((ArrowAnnotation)Chart1.Annotations[0]).ArrowStyle =
                    (ArrowStyle)ArrowStyle.Parse(typeof(ArrowStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Border3D")
            {
                ((Border3DAnnotation)Chart1.Annotations[0]).BorderSkin.SkinStyle =
                    (BorderSkinStyle)BorderSkinStyle.Parse(typeof(BorderSkinStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Callout")
            {
                ((CalloutAnnotation)Chart1.Annotations[0]).CalloutStyle =
                    (CalloutStyle)CalloutStyle.Parse(typeof(CalloutStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle.SelectedItem.Value));
            }
        }
Beispiel #13
0
        /// <summary>
        /// Creates a new <see cref="ShapeStyle"/> instance.
        /// </summary>
        /// <param name="name">The shape style name.</param>
        /// <param name="sa">The stroke color alpha channel.</param>
        /// <param name="sr">The stroke color red channel.</param>
        /// <param name="sg">The stroke color green channel.</param>
        /// <param name="sb">The stroke color blue channel.</param>
        /// <param name="fa">The fill color alpha channel.</param>
        /// <param name="fr">The fill color red channel.</param>
        /// <param name="fg">The fill color green channel.</param>
        /// <param name="fb">The fill color blue channel.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="textStyle">The text style.</param>
        /// <param name="lineStyle">The line style.</param>
        /// <param name="startArrowStyle">The start arrow style.</param>
        /// <param name="endArrowStyle">The end arrow style.</param>
        /// <param name="lineCap">The line cap.</param>
        /// <param name="dashes">The line dashes.</param>
        /// <param name="dashOffset">The line dash offset.</param>
        /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
        public static ShapeStyle Create(string name = "", byte sa = 0xFF, byte sr = 0x00, byte sg = 0x00, byte sb = 0x00, byte fa = 0xFF, byte fr = 0x00, byte fg = 0x00, byte fb = 0x00, double thickness = 2.0, TextStyle textStyle = null, LineStyle lineStyle = null, ArrowStyle startArrowStyle = null, ArrowStyle endArrowStyle = null, LineCap lineCap = LineCap.Round, string dashes = default(string), double dashOffset = 0.0)
        {
            var style = new ShapeStyle()
            {
                Name = name,
                Stroke = ArgbColor.Create(sa, sr, sg, sb),
                Fill = ArgbColor.Create(fa, fr, fg, fb),
                Thickness = thickness,
                LineCap = lineCap,
                Dashes = dashes,
                DashOffset = dashOffset,
                LineStyle = lineStyle ?? LineStyle.Create("Line"),
                TextStyle = textStyle ?? TextStyle.Create("Text")
            };

            style.StartArrowStyle = startArrowStyle ?? ArrowStyle.Create("Start", style);
            style.EndArrowStyle = endArrowStyle ?? ArrowStyle.Create("End", style);

            return style;
        }
Beispiel #14
0
        /// <summary>
        /// Creates a new <see cref="ShapeStyle"/> instance.
        /// </summary>
        /// <param name="name">The shape style name.</param>
        /// <param name="sa">The stroke color alpha channel.</param>
        /// <param name="sr">The stroke color red channel.</param>
        /// <param name="sg">The stroke color green channel.</param>
        /// <param name="sb">The stroke color blue channel.</param>
        /// <param name="fa">The fill color alpha channel.</param>
        /// <param name="fr">The fill color red channel.</param>
        /// <param name="fg">The fill color green channel.</param>
        /// <param name="fb">The fill color blue channel.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="textStyle">The text style.</param>
        /// <param name="lineStyle">The line style.</param>
        /// <param name="startArrowStyle">The start arrow style.</param>
        /// <param name="endArrowStyle">The end arrow style.</param>
        /// <param name="lineCap">The line cap.</param>
        /// <param name="dashes">The line dashes.</param>
        /// <param name="dashOffset">The line dash offset.</param>
        /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
        public static ShapeStyle Create(string name = "", byte sa = 0xFF, byte sr = 0x00, byte sg = 0x00, byte sb = 0x00, byte fa = 0xFF, byte fr = 0x00, byte fg = 0x00, byte fb = 0x00, double thickness = 2.0, TextStyle textStyle = null, LineStyle lineStyle = null, ArrowStyle startArrowStyle = null, ArrowStyle endArrowStyle = null, LineCap lineCap = LineCap.Round, string dashes = default(string), double dashOffset = 0.0)
        {
            var style = new ShapeStyle()
            {
                Name       = name,
                Stroke     = ArgbColor.Create(sa, sr, sg, sb),
                Fill       = ArgbColor.Create(fa, fr, fg, fb),
                Thickness  = thickness,
                LineCap    = lineCap,
                Dashes     = dashes,
                DashOffset = dashOffset,
                LineStyle  = lineStyle ?? LineStyle.Create("Line"),
                TextStyle  = textStyle ?? TextStyle.Create("Text")
            };

            style.StartArrowStyle = startArrowStyle ?? ArrowStyle.Create("Start", style);
            style.EndArrowStyle   = endArrowStyle ?? ArrowStyle.Create("End", style);

            return(style);
        }
Beispiel #15
0
        private void AnnotationStyle_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString().ToLower().IndexOf("line") >= 0)
            {
                Chart1.Annotations[0].LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Text" ||
                     Annotation.SelectedItem.ToString() == "Rectangle" ||
                     Annotation.SelectedItem.ToString() == "Ellipse")
            {
                //FIXFIX

                /*
                 *              Chart1.Annotations[0].TextStyle =
                 *                      (TextStyle)TextStyle.Parse(typeof(TextStyle), AnnotationStyle.SelectedItem.ToString());*/
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ((ArrowAnnotation)Chart1.Annotations[0]).ArrowStyle =
                    (ArrowStyle)ArrowStyle.Parse(typeof(ArrowStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                ((Border3DAnnotation)Chart1.Annotations[0]).BorderSkin.SkinStyle =
                    (BorderSkinStyle)BorderSkinStyle.Parse(typeof(BorderSkinStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                ((CalloutAnnotation)Chart1.Annotations[0]).CalloutStyle =
                    (CalloutStyle)CalloutStyle.Parse(typeof(CalloutStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle.SelectedItem.ToString()));
            }
        }
Beispiel #16
0
        public ArrowStyle GetLineArrowStyleValue()
        {
            ArrowStyle sReturnValue = ArrowStyle.Default;
            var        ListWidget   = GetEligibleWidgets_Toolbar(PropertyOption.Option_LineArrow);

            foreach (WidgetViewModBase data in ListWidget)
            {
                if (data is WidgetLineViewModeBase)
                {
                    if (sReturnValue == ArrowStyle.Default)
                    {
                        sReturnValue = ((WidgetLineViewModeBase)data).LineArrowStyle;
                    }
                    else if (sReturnValue != ((WidgetLineViewModeBase)data).LineArrowStyle)
                    {
                        sReturnValue = ArrowStyle.Default;
                        break;
                    }
                }
            }

            return(sReturnValue);
        }
Beispiel #17
0
        const double arrowAngle = 25.0;//degrees
        static internal void DrawArrow(Graphics g, Brush brush, P2 start, P2 end, int lineWidth, ArrowStyle arrowStyle)
        {
            switch (arrowStyle)
            {
            case ArrowStyle.NonSpecified:
            case ArrowStyle.Normal:

                DrawNormalArrow(g, brush, ref start, ref end, lineWidth);
                break;

            case ArrowStyle.Tee:
                DrawTeeArrow(g, brush, ref start, ref end, lineWidth);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #18
0
			public virtual void loadFrom(BinaryReader reader, PersistContext ctx)
			{
				backColor = ctx.loadColor();
				behavior = (BehaviorType)reader.ReadInt32();
				arrowHead = (ArrowHead)reader.ReadInt32();
				arrowBase = (ArrowHead)reader.ReadInt32();
				arrowInterm = (ArrowHead)reader.ReadInt32();
				arrowHeadSize = (float)reader.ReadDouble();
				arrowBaseSize = (float)reader.ReadDouble();
				arrowIntermSize = (float)reader.ReadDouble();
				shadowsStyle = (ShadowsStyle)reader.ReadInt32();
				boxFillColor = ctx.loadColor();
				arrowFillColor = ctx.loadColor();
				boxFrameColor = ctx.loadColor();
				arrowColor = ctx.loadColor();
				alignToGrid = reader.ReadBoolean();
				showGrid = reader.ReadBoolean();
				gridColor = ctx.loadColor();
				gridSize = (float)reader.ReadDouble();
				boxStyle = (BoxStyle)reader.ReadInt32();
				shadowColor = ctx.loadColor();
				imagePos = (ImageAlign)reader.ReadInt32();
				textColor = ctx.loadColor();
				activeMnpColor = ctx.loadColor();
				selMnpColor = ctx.loadColor();
				disabledMnpColor = ctx.loadColor();
				arrowStyle = (ArrowStyle)reader.ReadInt32();
				arrowSegments = reader.ReadInt16();
				scrollX = (float)reader.ReadDouble();
				scrollY = (float)reader.ReadDouble();

				// zoomFactor was a short, now it is a float
				if (ctx.FileVersion < 19)
					zoomFactor = reader.ReadInt16();
				else
					zoomFactor = reader.ReadSingle();

				penDashStyle = (DashStyle)reader.ReadInt32();
				penWidth = (float)reader.ReadDouble();
				int c = reader.ReadInt32();
				defPolyShape = reader.ReadBytes(c);
				docExtents = ctx.loadRectF();
				shadowOffsetX = (float)reader.ReadDouble();
				shadowOffsetY = (float)reader.ReadDouble();
				tableFillColor = ctx.loadColor();
				tableFrameColor = ctx.loadColor();
				tableRowsCount = reader.ReadInt32();
				tableColumnsCount = reader.ReadInt32();
				tableColWidth = (float)reader.ReadDouble();
				tableRowHeight = (float)reader.ReadDouble();
				tableCaptionHeight = (float)reader.ReadDouble();
				tableCaption = reader.ReadString();
				arrowCascadeOrientation = (Orientation)reader.ReadInt32();
				tableCellBorders = (CellFrameStyle)reader.ReadInt32();
				boxIncmAnchor = (ArrowAnchor)reader.ReadInt32();
				boxOutgAnchor = (ArrowAnchor)reader.ReadInt32();
				boxesExpandable = reader.ReadBoolean();
				tablesScrollable = reader.ReadBoolean();
			}
Beispiel #19
0
 //public LineJoin linejoin;
 //public LineCap endcap;
 //public LineCap startcap;
 //public DashCap dashcap;
 public PenStyle(Color color, float width, DashStyle dashstyle, ArrowStyle arrowstyle)
 {
     this.color = color;
     this.width = width;
     this.dashstyle = dashstyle;
     this.arrowstyle = arrowstyle;
 }
Beispiel #20
0
 private static CustomLineCap ArrowStyleToLineCap(ArrowStyle arrowstyle)
 {
     return Hacks.GetLineCap(arrowstyle);
 }
Beispiel #21
0
        const double arrowAngle = 25.0; //degrees

        internal static void DrawArrow(PathGeometry pg, MsaglPoint start, MsaglPoint end, double thickness, ArrowStyle arrowStyle, bool fill)
        {
            switch (arrowStyle)
            {
                case ArrowStyle.NonSpecified:
                case ArrowStyle.Normal:
                    DrawNormalArrow(pg, start, end, thickness, fill);
                    break;
                case ArrowStyle.Tee:
                    DrawTeeArrow(pg, start, end, fill);
                    break;
                case ArrowStyle.Diamond:
                    DrawDiamondArrow(pg, start, end);
                    break;
                case ArrowStyle.ODiamond:
                    throw new NotImplementedException();
                case ArrowStyle.Generalization:
                    throw new NotImplementedException();
                default:
                    throw new InvalidOperationException();
            }
        }
Beispiel #22
0
 private static CustomLineCap GenerateLineCap(ArrowStyle style)
 {
     CustomLineCap clc = null;
     using (GraphicsPath gp = new GraphicsPath())
         switch (style)
         {
             case ArrowStyle.PointyArrow:
                 gp.AddPolygon(new PointF[]{new PointF(0f,-0f),new PointF(.1f,-.2f),
                 new PointF(0f,-.15f),
                 new PointF(-.10f,-.2f)});
                 clc = new CustomLineCap(gp,null);
                 clc.WidthScale = 30;
                 clc.BaseInset = .15f;
                 break;
             case ArrowStyle.HollowArrow:
                 gp.AddPolygon(new PointF[] { new PointF(0,-1f),new PointF(2f,-4f),
             new PointF(-2f,-4f)});
                 clc = new CustomLineCap(null, gp);
                 clc.BaseInset = 5.0f;
                 break;
             case ArrowStyle.BigArrow:
                 gp.AddPolygon(new PointF[]{new PointF(0,0f),new PointF(.25f,-.4f),
                 new PointF(-.25f,-.4f)});
                 clc = new CustomLineCap(gp, null);
                 clc.BaseInset = .4f;
                 clc.WidthScale = 15;
                 break;
             case ArrowStyle.LineArrow:
                 gp.AddLine(new PointF(0,0),new PointF(2.5f,-4f));
                 gp.AddLine(new PointF(0,0),new PointF(-2.5f,-4f));
                 clc = new CustomLineCap(null,gp);
                 clc.BaseInset = 3f;
                 break;
             case ArrowStyle.TinyArrow:
                 gp.AddPolygon(new PointF[]{new PointF(0,0f),new PointF(.25f,-.4f),
                 new PointF(-.25f,-.4f)});
                 clc = new CustomLineCap(gp, null);
                 clc.BaseInset = .4f;
                 clc.WidthScale = 5;
                 break;
             case ArrowStyle.LittleArrow:
                 gp.AddPolygon(new PointF[]{new PointF(0,0f),new PointF(.25f,-.4f),
                 new PointF(-.25f,-.4f)});
                 clc = new CustomLineCap(gp, null);
                 clc.BaseInset = .4f;
                 clc.WidthScale = 10;
                 break;
             default:
                 throw new Exception("Unexpected arrow type");
         }
     return clc;
 }
Beispiel #23
0
 /// <summary>
 /// Creates a new <see cref="ShapeStyle"/> instance.
 /// </summary>
 /// <param name="name">The shape style name.</param>
 /// <param name="stroke">The stroke color.</param>
 /// <param name="fill">The fill color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="textStyle">The text style.</param>
 /// <param name="lineStyle">The line style.</param>
 /// <param name="startArrowStyle">The start arrow style.</param>
 /// <param name="endArrowStyle">The end arrow style.</param>
 /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
 public static ShapeStyle Create(string name, ArgbColor stroke, ArgbColor fill, double thickness, TextStyle textStyle, LineStyle lineStyle, ArrowStyle startArrowStyle, ArrowStyle endArrowStyle)
 {
     return(new ShapeStyle()
     {
         Name = name,
         Stroke = stroke,
         Fill = fill,
         Thickness = thickness,
         LineCap = LineCap.Round,
         Dashes = default(string),
         DashOffset = 0.0,
         LineStyle = lineStyle,
         TextStyle = textStyle,
         StartArrowStyle = startArrowStyle,
         EndArrowStyle = endArrowStyle
     });
 }
Beispiel #24
0
 /// <summary>
 /// Creates a new <see cref="ShapeStyle"/> instance.
 /// </summary>
 /// <param name="name">The shape style name.</param>
 /// <param name="stroke">The stroke color.</param>
 /// <param name="fill">The fill color.</param>
 /// <param name="thickness">The stroke thickness.</param>
 /// <param name="textStyle">The text style.</param>
 /// <param name="lineStyle">The line style.</param>
 /// <param name="startArrowStyle">The start arrow style.</param>
 /// <param name="endArrowStyle">The end arrow style.</param>
 /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns>
 public static ShapeStyle Create(string name, ArgbColor stroke, ArgbColor fill, double thickness, TextStyle textStyle, LineStyle lineStyle, ArrowStyle startArrowStyle, ArrowStyle endArrowStyle)
 {
     return new ShapeStyle()
     {
         Name = name,
         Stroke = stroke,
         Fill = fill,
         Thickness = thickness,
         LineCap = LineCap.Round,
         Dashes = default(string),
         DashOffset = 0.0,
         LineStyle = lineStyle,
         TextStyle = textStyle,
         StartArrowStyle = startArrowStyle,
         EndArrowStyle = endArrowStyle
     };
 }
        const double arrowAngle = 25.0; //degrees

        internal static void DrawArrow(PathGeometry pg, MsaglPoint start, MsaglPoint end, double thickness, ArrowStyle arrowStyle, bool fill)
        {
            switch (arrowStyle)
            {
            case ArrowStyle.NonSpecified:
            case ArrowStyle.Normal:
                DrawNormalArrow(pg, start, end, thickness, fill);
                break;

            case ArrowStyle.Tee:
                DrawTeeArrow(pg, start, end, fill);
                break;

            case ArrowStyle.Diamond:
                DrawDiamondArrow(pg, start, end);
                break;

            case ArrowStyle.ODiamond:
                DrawODiamondArrow(pg, start, end);
                break;

            case ArrowStyle.Generalization:
                DrawGeneralizationArrow(pg, start, end);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #26
0
        /// <summary>
        /// Initializes static designer context.
        /// </summary>
        /// <param name="renderer">The design time renderer instance.</param>
        /// <param name="clipboard">The design time clipboard instance.</param>
        /// <param name="jsonSerializer">The design time Json serializer instance.</param>
        /// <param name="xamlSerializer">The design time Xaml serializer instance.</param>
        /// <returns>The new instance of the <see cref="DesignerContext"/> class.</returns>
        public static void InitializeContext(ShapeRenderer renderer, ITextClipboard clipboard, ITextSerializer jsonSerializer, ITextSerializer xamlSerializer)
        {
            // Editor

            Editor = new ProjectEditor()
            {
                CurrentTool     = Tool.Selection,
                CurrentPathTool = PathTool.Line,
                CommandManager  = new DesignerCommandManager(),
                Renderers       = new ShapeRenderer[] { renderer },
                ProjectFactory  = new ProjectFactory(),
                TextClipboard   = clipboard,
                JsonSerializer  = jsonSerializer,
                XamlSerializer  = xamlSerializer
            }.Defaults();

            // Recent Projects
            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project"));
            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project"));

            // Commands

            Editor.InitializeCommands();
            InitializeCommands(Editor);
            Editor.CommandManager.RegisterCommands();

            // New Project

            Editor.OnNew(null);

            // Data

            var db      = XDatabase.Create("Db");
            var fields  = new string[] { "Column0", "Column1" };
            var columns = ImmutableArray.CreateRange(fields.Select(c => XColumn.Create(db, c)));

            db.Columns = columns;
            var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => XValue.Create(c));
            var record = XRecord.Create(
                db,
                db.Columns,
                ImmutableArray.CreateRange(values));

            db.Records       = db.Records.Add(record);
            db.CurrentRecord = record;

            Database = db;
            Data     = XContext.Create(record);
            Record   = record;

            // Project

            IProjectFactory factory = new ProjectFactory();

            Project = factory.GetProject();

            Template = XContainer.CreateTemplate();

            Page = XContainer.CreatePage();
            var layer = Page.Layers.FirstOrDefault();

            layer.Shapes      = layer.Shapes.Add(XLine.Create(0, 0, null, null));
            Page.CurrentLayer = layer;
            Page.CurrentShape = layer.Shapes.FirstOrDefault();
            Page.Template     = Template;

            Document = XDocument.Create();
            Layer    = XLayer.Create();
            Options  = XOptions.Create();

            // State

            State = ShapeState.Create();

            // Style

            ArgbColor       = ArgbColor.Create();
            ArrowStyle      = ArrowStyle.Create();
            FontStyle       = FontStyle.Create();
            LineFixedLength = LineFixedLength.Create();
            LineStyle       = LineStyle.Create();
            Style           = ShapeStyle.Create("Default");
            TextStyle       = TextStyle.Create();

            // Shapes

            Arc             = XArc.Create(0, 0, Style, null);
            CubicBezier     = XCubicBezier.Create(0, 0, Style, null);
            Ellipse         = XEllipse.Create(0, 0, Style, null);
            Group           = XGroup.Create(Constants.DefaulGroupName);
            Image           = XImage.Create(0, 0, Style, null, "key");
            Line            = XLine.Create(0, 0, Style, null);
            Path            = XPath.Create("Path", Style, null);
            Point           = XPoint.Create();
            QuadraticBezier = XQuadraticBezier.Create(0, 0, Style, null);
            Rectangle       = XRectangle.Create(0, 0, Style, null);
            Text            = XText.Create(0, 0, Style, null, "Text");

            // Path

            ArcSegment                 = XArcSegment.Create(XPoint.Create(), XPathSize.Create(), 180, true, XSweepDirection.Clockwise, true, true);
            CubicBezierSegment         = XCubicBezierSegment.Create(XPoint.Create(), XPoint.Create(), XPoint.Create(), true, true);
            LineSegment                = XLineSegment.Create(XPoint.Create(), true, true);
            PathFigure                 = XPathFigure.Create(XPoint.Create(), false, true);
            PathGeometry               = XPathGeometry.Create(ImmutableArray.Create <XPathFigure>(), XFillRule.EvenOdd);
            PathSize                   = XPathSize.Create();
            PolyCubicBezierSegment     = XPolyCubicBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            PolyLineSegment            = XPolyLineSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            PolyQuadraticBezierSegment = XPolyQuadraticBezierSegment.Create(ImmutableArray.Create <XPoint>(), true, true);
            QuadraticBezierSegment     = XQuadraticBezierSegment.Create(XPoint.Create(), XPoint.Create(), true, true);
        }
Beispiel #27
0
        private static void AddArrowWithStyle(StreamGeometryContext con, Point start, Point end, Point dir, ArrowStyle style)
        {
            Func <Point, System.Windows.Point> P2P = (Point p) => new System.Windows.Point(p.X, p.Y);

            switch (style)
            {
            case ArrowStyle.NonSpecified:
            case ArrowStyle.Normal:
            {
                dir = dir.Rotate(Math.PI / 2);
                Point s = dir * HalfArrowAngleTan;

                con.BeginFigure(Common.WpfPoint(start + s), true, true);
                con.LineTo(Common.WpfPoint(end), true, true);
                con.LineTo(Common.WpfPoint(start - s), true, true);
            }
            break;

            case ArrowStyle.None:
                break;

            case ArrowStyle.StraightLine:
                con.BeginFigure(Common.WpfPoint(start), false, false);
                con.LineTo(Common.WpfPoint(end), true, true);
                break;

            case ArrowStyle.Tee:
            {
                con.BeginFigure(Common.WpfPoint(start), false, false);         // .DrawLine(p, PointF(start), PointF(end));
                con.LineTo(Common.WpfPoint(end), true, true);

                dir = dir.Rotate90Cw();
                Point s = dir * HalfArrowAngleTan;
                con.BeginFigure(P2P(start + s), false, false);
                con.LineTo(P2P(start - s), true, true);
            }
            break;

            case ArrowStyle.Diamond:
            {
                dir = dir / 2;
                Point h = dir.Rotate90Ccw() * Math.Tan(ArrowAngle * Math.PI / 180.0);
                con.BeginFigure(P2P(start), true, true);
                con.LineTo(P2P(start + dir + h), true, true);
                con.LineTo(P2P(end), true, true);
                con.LineTo(P2P(start + dir - h), true, true);
            }
            break;

            case ArrowStyle.ODiamond:
            {
                dir = dir / 2;      /// dir.Rotate90Ccw()/2;
                Point h = dir.Rotate90Ccw() * Math.Tan(ArrowAngle * Math.PI / 180.0);
                con.BeginFigure(P2P(start), false, true);
                con.LineTo(P2P(start + dir + h), true, true);
                con.LineTo(P2P(end), true, true);
                con.LineTo(P2P(start + dir - h), true, true);
            }
            break;

            case ArrowStyle.Generalization:
            {
                Point h = dir.Rotate90Ccw() * Math.Tan(ArrowAngle * Math.PI / 180.0);
                con.BeginFigure(P2P(start + h), false, true);
                con.LineTo(P2P(end), true, true);
                con.LineTo(P2P(start - h), true, true);
            }
            break;

            case ArrowStyle.Circle:
            {
                con.BeginFigure(P2P(start), false, true);
                var r = dir.Length / 2;
                //drawing a complete circle by two part arc
                con.ArcTo(P2P(end), new Size(r, r), 180, true, SweepDirection.Clockwise, true, true);
                con.ArcTo(P2P(start), new Size(r, r), 180, true, SweepDirection.Clockwise, true, true);
            }
            break;

            case ArrowStyle.Vee:
            {
                Point h = dir.Rotate90Ccw() * Math.Tan(ArrowAngle * Math.PI / 180.0);
                con.BeginFigure(P2P(start + h), false, false);
                con.LineTo(P2P(end), true, true);
                con.LineTo(P2P(start - h), true, true);
            }
            break;

            case ArrowStyle.Triangle:
            {
                Point h = dir.Rotate90Ccw() * Math.Tan(ArrowAngle * Math.PI / 180.0);
                con.BeginFigure(P2P(end + h), false, true);
                con.LineTo(P2P(end - h), true, true);
                con.LineTo(P2P(start), true, true);
            }
            break;

            default:
                break;
            }
        }
Beispiel #28
0
        /// <summary>
        /// Initializes static designer context.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public static void InitializeContext(IServiceProvider serviceProvider)
        {
            // Editor

            Editor = serviceProvider.GetService <ProjectEditor>();

            // Recent Projects

            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project"));
            Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project"));

            // New Project

            Editor.OnNewProject();

            // Transform

            Transform = MatrixObject.Identity;

            // Data

            var db      = Database.Create("Db");
            var fields  = new string[] { "Column0", "Column1" };
            var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c)));

            db.Columns = columns;
            var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c));
            var record = Record.Create(
                db,
                ImmutableArray.CreateRange(values));

            db.Records       = db.Records.Add(record);
            db.CurrentRecord = record;

            Database = db;
            Data     = Context.Create(record);
            Record   = record;

            // Project

            IProjectFactory factory = new ProjectFactory();

            Project = factory.GetProject();

            Template = PageContainer.CreateTemplate();

            Page = PageContainer.CreatePage();
            var layer = Page.Layers.FirstOrDefault();

            layer.Shapes      = layer.Shapes.Add(LineShape.Create(0, 0, null, null));
            Page.CurrentLayer = layer;
            Page.CurrentShape = layer.Shapes.FirstOrDefault();
            Page.Template     = Template;

            Document = DocumentContainer.Create();
            Layer    = LayerContainer.Create();
            Options  = Options.Create();

            // State

            State = ShapeState.Create();

            // Style

            ArgbColor       = ArgbColor.Create(128, 255, 0, 0);
            ArrowStyle      = ArrowStyle.Create();
            FontStyle       = FontStyle.Create();
            LineFixedLength = LineFixedLength.Create();
            LineStyle       = LineStyle.Create();
            Style           = ShapeStyle.Create("Default");
            TextStyle       = TextStyle.Create();

            // Shapes

            Arc             = ArcShape.Create(0, 0, Style, null);
            CubicBezier     = CubicBezierShape.Create(0, 0, Style, null);
            Ellipse         = EllipseShape.Create(0, 0, Style, null);
            Group           = GroupShape.Create(Constants.DefaulGroupName);
            Image           = ImageShape.Create(0, 0, Style, null, "key");
            Line            = LineShape.Create(0, 0, Style, null);
            Path            = PathShape.Create(Style, null);
            Point           = PointShape.Create();
            QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null);
            Rectangle       = RectangleShape.Create(0, 0, Style, null);
            Text            = TextShape.Create(0, 0, Style, null, "Text");

            // Path

            ArcSegment                 = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true);
            CubicBezierSegment         = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true);
            LineSegment                = LineSegment.Create(PointShape.Create(), true, true);
            PathFigure                 = PathFigure.Create(PointShape.Create(), false, true);
            PathGeometry               = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd);
            PathSize                   = PathSize.Create();
            PolyCubicBezierSegment     = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true);
            PolyLineSegment            = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true);
            PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true);
            QuadraticBezierSegment     = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true);
        }
Beispiel #29
0
 public LineArrowStyleDate(Uri uri, ArrowStyle style)
 {
     PngUri   = uri;
     BLStyle  = style;
     ShowText = false;
 }
Beispiel #30
0
        private static PointF DrawLineArrowInternal(Graphics gfx, Pen pen, Brush brush, float x, float y, float angle, ArrowStyle style)
        {
            PointF pt;
            var    rt = new Matrix();

            rt.RotateAt(angle, new PointF(x, y));
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                pt = new PointF(x, y);
            }
            break;

            case ArrowType.Rectangle:
            {
                var pts = new PointF[] { new PointF(x - (float)sx, y) };
                rt.TransformPoints(pts);
                pt = pts[0];
                var rect = new Rect2(x - sx, y - ry, sx, sy);
                var gs   = gfx.Save();
                gfx.MultiplyTransform(rt);
                DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                gfx.Restore(gs);
            }
            break;

            case ArrowType.Ellipse:
            {
                var pts = new PointF[] { new PointF(x - (float)sx, y) };
                rt.TransformPoints(pts);
                pt = pts[0];
                var gs = gfx.Save();
                gfx.MultiplyTransform(rt);
                var rect = new Rect2(x - sx, y - ry, sx, sy);
                DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                gfx.Restore(gs);
            }
            break;

            case ArrowType.Arrow:
            {
                var pts = new PointF[]
                {
                    new PointF(x, y),
                    new PointF(x - (float)sx, y + (float)sy),
                    new PointF(x, y),
                    new PointF(x - (float)sx, y - (float)sy),
                    new PointF(x, y)
                };
                rt.TransformPoints(pts);
                pt = pts[0];
                var p11 = pts[1];
                var p21 = pts[2];
                var p12 = pts[3];
                var p22 = pts[4];
                DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
                DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
            }
            break;
            }

            return(pt);
        }
        private static XPoint DrawLineArrowInternal(XGraphics gfx, XPen pen, XSolidBrush brush, double x, double y, double angle, ArrowStyle style)
        {
            XPoint pt;
            var    rt = new XMatrix();
            var    c  = new XPoint(x, y);

            rt.RotateAtPrepend(angle, c);
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                pt = new XPoint(x, y);
            }
            break;

            case ArrowType.Rectangle:
            {
                pt = rt.Transform(new XPoint(x - sx, y));
                var rect = new XRect(x - sx, y - ry, sx, sy);
                gfx.Save();
                gfx.RotateAtTransform(angle, c);
                DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                gfx.Restore();
            }
            break;

            case ArrowType.Ellipse:
            {
                pt = rt.Transform(new XPoint(x - sx, y));
                gfx.Save();
                gfx.RotateAtTransform(angle, c);
                var rect = new XRect(x - sx, y - ry, sx, sy);
                DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                gfx.Restore();
            }
            break;

            case ArrowType.Arrow:
            {
                pt = rt.Transform(new XPoint(x, y));
                var p11 = rt.Transform(new XPoint(x - sx, y + sy));
                var p21 = rt.Transform(new XPoint(x, y));
                var p12 = rt.Transform(new XPoint(x - sx, y - sy));
                var p22 = rt.Transform(new XPoint(x, y));
                DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
                DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
            }
            break;
            }

            return(pt);
        }
Beispiel #32
0
		internal override void restoreState(ItemState state)
		{
			base.restoreState(state);

			ArrowState astate = (ArrowState)state;
			style = astate.style;
			segmentCount = astate.segmentCount;
			points = astate.points.Clone();
			reflexive = astate.reflexive;
			cascadeStartHorizontal = astate.cascadeStartHorizontal;

			if (orgnLink != astate.orgnLink)
			{
				orgnLink.removeArrowFromObj();
				orgnLink = astate.orgnLink;
				orgnLink.addArrowToObj();
			}
			orgnAnchor = astate.orgnAnchor;

			if (destLink != astate.destLink)
			{
				destLink.removeArrowFromObj();
				destLink = astate.destLink;
				destLink.addArrowToObj();
			}
			destAnchor = astate.destAnchor;

			updateFromPoints(false);

			if (subordinateGroup != null)
				subordinateGroup.onRestoreState();

			orgnLink.RelativePosition = astate.orgnPoint;
			destLink.RelativePosition = astate.destPoint;

			resetCrossings();
			updateText();
		}
Beispiel #33
0
        static void AddArrow(StreamGeometryContext context, Point start, Point end, double thickness, ArrowStyle arrowStyle)
        {
            if (thickness > 1)
            {
                Point  dir = end - start;
                Point  h   = dir;
                double dl  = dir.Length;
                if (dl < 0.001)
                {
                    return;
                }
                dir /= dl;

                var    s  = new Point(-dir.Y, dir.X);
                double w  = 0.5 * thickness;
                Point  s0 = w * s;

                s *= h.Length * HalfArrowAngleTan;
                s += s0;

                double rad = w / HalfArrowAngleCos;

                context.BeginFigure(Common.WpfPoint(start + s), true, true);
                context.LineTo(Common.WpfPoint(start - s), true, false);
                context.LineTo(Common.WpfPoint(end - s0), true, false);
                context.ArcTo(Common.WpfPoint(end + s0), new Size(rad, rad),
                              Math.PI - ArrowAngle, false, SweepDirection.Clockwise, true, false);
            }
            else
            {
                Point  dir = end - start;
                double dl  = dir.Length;
                //take into account the widths
                double delta = Math.Min(dl / 2, thickness + thickness / 2);
                dir *= (dl - delta) / dl;
                end  = start + dir;
                AddArrowWithStyle(context, start, end, dir, arrowStyle);
                //dir = dir.Rotate(Math.PI / 2);
                //Point s = dir * HalfArrowAngleTan;

                //context.BeginFigure(Common.WpfPoint(start + s),true,true);
                //context.LineTo(Common.WpfPoint(end),true,true);
                //context.LineTo(Common.WpfPoint(start - s),true,true);
            }
        }
Beispiel #34
0
        internal static Geometry DefiningTargetArrowHead(EdgeGeometry edgeGeometry, double thickness, ArrowStyle arrowStyle)
        {
            if (edgeGeometry.TargetArrowhead == null || edgeGeometry.Curve == null)
            {
                return(null);
            }
            var streamGeometry = new StreamGeometry();

            using (StreamGeometryContext context = streamGeometry.Open()) {
                AddArrow(context, edgeGeometry.Curve.End,
                         edgeGeometry.TargetArrowhead.TipPosition, thickness, arrowStyle);
                return(streamGeometry);
            }
        }
Beispiel #35
0
 private static Pen GetArrowStyleSample(Color color, ArrowStyle ars)
 {
     Pen pen = new Pen(color, 2);
     if (ars == ArrowStyle.None)
         pen.EndCap = LineCap.Flat;
     else
     {
         pen.CustomEndCap = Hacks.GetLineCap(ars);
     }
     return pen;
 }
Beispiel #36
0
        private static A.Point DrawLineArrowInternal(AM.DrawingContext dc, AM.Pen pen, AM.IBrush brush, float x, float y, double angle, ArrowStyle style)
        {
            A.Point pt = default(A.Point);
            var     rt = APAZ.MatrixHelper.Rotation(angle, new A.Vector(x, y));
            double  rx = style.RadiusX;
            double  ry = style.RadiusY;
            double  sx = 2.0 * rx;
            double  sy = 2.0 * ry;

            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                pt = new A.Point(x, y);
            }
            break;

            case ArrowType.Rectangle:
            {
                pt = APAZ.MatrixHelper.TransformPoint(rt, new A.Point(x - (float)sx, y));
                var rect = new Rect2(x - sx, y - ry, sx, sy);
                using (var d = dc.PushPreTransform(rt))
                {
                    DrawRectangleInternal(dc, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                }
            }
            break;

            case ArrowType.Ellipse:
            {
                pt = APAZ.MatrixHelper.TransformPoint(rt, new A.Point(x - (float)sx, y));
                using (var d = dc.PushPreTransform(rt))
                {
                    var rect = new Rect2(x - sx, y - ry, sx, sy);
                    DrawEllipseInternal(dc, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                }
            }
            break;

            case ArrowType.Arrow:
            {
                var pts = new A.Point[]
                {
                    new A.Point(x, y),
                    new A.Point(x - (float)sx, y + (float)sy),
                    new A.Point(x, y),
                    new A.Point(x - (float)sx, y - (float)sy),
                    new A.Point(x, y)
                };
                pt = APAZ.MatrixHelper.TransformPoint(rt, pts[0]);
                var p11 = APAZ.MatrixHelper.TransformPoint(rt, pts[1]);
                var p21 = APAZ.MatrixHelper.TransformPoint(rt, pts[2]);
                var p12 = APAZ.MatrixHelper.TransformPoint(rt, pts[3]);
                var p22 = APAZ.MatrixHelper.TransformPoint(rt, pts[4]);
                DrawLineInternal(dc, pen, style.IsStroked, ref p11, ref p21);
                DrawLineInternal(dc, pen, style.IsStroked, ref p12, ref p22);
            }
            break;
            }

            return(pt);
        }
Beispiel #37
0
 public static CustomLineCap GetLineCap(ArrowStyle style)
 {
     if (linecaps==null)
     {
         linecaps = new Dictionary<ArrowStyle, CustomLineCap>();
     }
     CustomLineCap clc;
     if (!linecaps.TryGetValue(style,out clc))
         linecaps.Add(style,clc=GenerateLineCap(style));
     return clc;
 }
Beispiel #38
0
        private SKPoint DrawLineArrowInternal(SKCanvas canvas, SKPaint pen, SKPaint brush, float x, float y, double angle, ArrowStyle style)
        {
            SKPoint pt = default(SKPoint);
            var     rt = MatrixHelper.Rotation(angle, new SKPoint(x, y));
            double  rx = style.RadiusX;
            double  ry = style.RadiusY;
            double  sx = 2.0 * rx;
            double  sy = 2.0 * ry;

            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                pt = new SKPoint(x, y);
            }
            break;

            case ArrowType.Rectangle:
            {
                pt = MatrixHelper.TransformPoint(rt, new SKPoint(x - (float)sx, y));
                var rect  = ToSKRect(x - sx, y - ry, sx, sy);
                int count = canvas.Save();
                canvas.SetMatrix(rt);
                DrawRectangleInternal(canvas, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                canvas.RestoreToCount(count);
            }
            break;

            case ArrowType.Ellipse:
            {
                pt = MatrixHelper.TransformPoint(rt, new SKPoint(x - (float)sx, y));
                int count = canvas.Save();
                canvas.SetMatrix(rt);
                var rect = ToSKRect(x - sx, y - ry, sx, sy);
                DrawEllipseInternal(canvas, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                canvas.RestoreToCount(count);
            }
            break;

            case ArrowType.Arrow:
            {
                var pts = new SKPoint[]
                {
                    new SKPoint(x, y),
                    new SKPoint(x - (float)sx, y + (float)sy),
                    new SKPoint(x, y),
                    new SKPoint(x - (float)sx, y - (float)sy),
                    new SKPoint(x, y)
                };
                pt = MatrixHelper.TransformPoint(rt, pts[0]);
                var p11 = MatrixHelper.TransformPoint(rt, pts[1]);
                var p21 = MatrixHelper.TransformPoint(rt, pts[2]);
                var p12 = MatrixHelper.TransformPoint(rt, pts[3]);
                var p22 = MatrixHelper.TransformPoint(rt, pts[4]);
                DrawLineInternal(canvas, pen, style.IsStroked, ref p11, ref p21);
                DrawLineInternal(canvas, pen, style.IsStroked, ref p12, ref p22);
            }
            break;
            }

            return(pt);
        }
Beispiel #39
0
 public DGraph(ArrowStyle edgeArrowStyle)
 {
     this.EdgeArrowStyle = edgeArrowStyle;
 }
Beispiel #40
0
        private static Point DrawLineArrowInternal(DrawingContext dc, double half, Pen pen, Brush brush, double x, double y, double angle, ArrowStyle style)
        {
            Point  pt;
            bool   doRectTransform = angle % 90.0 != 0.0;
            var    rt = new RotateTransform(angle, x, y);
            double rx = style.RadiusX;
            double ry = style.RadiusY;
            double sx = 2.0 * rx;
            double sy = 2.0 * ry;

            switch (style.ArrowType)
            {
            default:
            case ArrowType.None:
            {
                pt = new Point(x, y);
            }
            break;

            case ArrowType.Rectangle:
            {
                pt = rt.Transform(new Point(x - sx, y));
                var rect = new Rect(x - sx, y - ry, sx, sy);
                if (doRectTransform)
                {
                    dc.PushTransform(rt);
                    DrawRectangleInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref rect);
                    dc.Pop();
                }
                else
                {
                    var bounds = rt.TransformBounds(rect);
                    DrawRectangleInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref bounds);
                }
            }
            break;

            case ArrowType.Ellipse:
            {
                pt = rt.Transform(new Point(x - sx, y));
                dc.PushTransform(rt);
                var c = new Point(x - rx, y);
                DrawEllipseInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref c, rx, ry);
                dc.Pop();
            }
            break;

            case ArrowType.Arrow:
            {
                pt = rt.Transform(new Point(x, y));
                var p11 = rt.Transform(new Point(x - sx, y + sy));
                var p21 = rt.Transform(new Point(x, y));
                var p12 = rt.Transform(new Point(x - sx, y - sy));
                var p22 = rt.Transform(new Point(x, y));
                DrawLineInternal(dc, half, pen, style.IsStroked, ref p11, ref p21);
                DrawLineInternal(dc, half, pen, style.IsStroked, ref p12, ref p22);
            }
            break;
            }

            return(pt);
        }
Beispiel #41
0
        public void Inherits_From_ObservableObject()
        {
            var target = new ArrowStyle();

            Assert.True(target is BaseStyle);
        }
Beispiel #42
0
		/// <summary>
		/// Gets rectangle of the arrow text
		/// </summary>
		/// <param name="g">GraphicsPath</param>
		/// <param name="style">Style of the arrow</param>
		/// <param name="textStyle">Style of the arrow text</param>
		/// <param name="points">Arrow's point collection</param>
		/// <param name="textColor">Text color</param>
		/// <param name="segmentCount">Arrow segments count</param>
		/// <param name="text">Arrow's text itself</param>
		/// <param name="textFont">Arrow's text font</param>
		/// <param name="rect">Bounding rect</param>
		/// <param name="a">Text's rotation angle to be returned</param>
		/// <returns>Arrow text's rectangle</returns>
		private RectangleF getTextRect(Graphics g , ArrowStyle style, ArrowTextStyle textStyle, PointCollection points , Color textColor ,int segmentCount , 
			string text , Font textFont , RectangleF rect , ref float a )
		{
			// DrawString crashes with a too small PageScale
			if (g.PageScale < 0.01) return RectangleF.Empty;

			System.Drawing.Brush brText = new System.Drawing.SolidBrush(textColor);
			StringFormat sf = StringFormat.GenericDefault;
			sf.Alignment = StringAlignment.Center;
			sf.LineAlignment = StringAlignment.Far;

			float x =0 , y = 0;

			a  = 0;
			ArrowUtils au = new ArrowUtils(style,points );
			System.Drawing.SizeF textSize = g.MeasureString(text, textFont);

			if (textStyle == ArrowTextStyle.Rotate)
			{
				// Find the segment near which the text will be drawn
				int pt = points.Count / 2 - 1;
				int jump = 1;
				int ptBest = pt;
				float r = 0,  rBest = 0;
				if (style != ArrowStyle.Bezier)
				{
					if (style == ArrowStyle.Cascading ||
						(style == ArrowStyle.Polyline && segmentCount % 2 == 1))
					{
						do
						{
							MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
								points[pt], points[pt + 1], ref a, ref r);
							if (r > rBest)
							{
								rBest = r;
								ptBest = pt;
							}
							pt = pt + jump;
							jump = -Math.Sign(jump) * (Math.Abs(jump) + 1);
							if(pt < 0 || pt >= points.Count - 1)
								break;
						}
						while(textSize.Width > r);
						pt = ptBest;
						x = (points[pt].X + points[pt + 1].X) / 2;
						y = (points[pt].Y + points[pt + 1].Y) / 2;
					}
					else
					{
						pt = pt + 1;
						x = points[pt].X;
						y = points[pt].Y;
					}
				}
				else
				{
					if(segmentCount % 2 == 1)
					{
						pt = (pt + 1) / 4;
						PointF ptMid = ArrowUtils.GetBezierPt(points, pt, 0.5f);
						x = ptMid.X;
						y = ptMid.Y;
					}
					else
					{
						pt = (pt + 1) / 4;
						PointF ptMid = points[(pt + 1) * 3];
						x = ptMid.X;
						y = ptMid.Y;
					}
				}

						
				// Find out the angle
				if (style != ArrowStyle.Bezier)
				{
					if( style == ArrowStyle.Cascading ||
						(style == ArrowStyle.Polyline && segmentCount % 2 == 1))
					{
						PointF pt1 = points[pt];
						PointF pt2 = points[pt + 1];
						MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
							pt1, pt2, ref a, ref r);
					}
					else
					{
						float r1 = 0, a1 = 0;
						MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
							points[pt - 1], points[pt], ref a, ref r);
						MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
							points[pt], points[pt + 1], ref a1, ref r1);
						a = (a + a1) / 2;
					}
				}
				else
				{
					if (segmentCount % 2 == 1)
					{
						PointF pt1 = ArrowUtils.GetBezierPt(points, pt, 0.45f);
						PointF pt2 = ArrowUtils.GetBezierPt(points, pt, 0.55f);
						MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
							pt1, pt2, ref a, ref r);
					}
					else
					{
						PointF pt1 = ArrowUtils.GetBezierPt(points, pt, 0.95f);
						PointF pt2 = ArrowUtils.GetBezierPt(points, pt + 1, 0.05f);
						MindFusion.Geometry.Geometry2D.Convert.DekartToPolar(
							pt1, pt2, ref a, ref r);
					}
				}

				a = 180 - a;
				if (a > 90 && a < 270)
					a -= 180;
					
			
			}
			else if (textStyle == ArrowTextStyle.Center)
			{
				if(points.Count % 2 == 1)
				{
					x = points[points.Count / 2].X;
					y = points[points.Count / 2].Y;
				}
				else
				{
					x = points[points.Count / 2 - 1].X + points[points.Count / 2].X;
					y = points[points.Count / 2 - 1].Y + points[points.Count / 2].Y;
					x /= 2;
					y /= 2;
				}

				//g.DrawString(text, textFont, brText, new PointF(x, y), sf);
			}
			else if (textStyle == ArrowTextStyle.OverLongestSegment)
			{
				
				// find the center point of longest segment
				int longest = au.getLongestSegment();
				PointF center = au.getSegmentCenter(longest);

				// see how much space the text requires
				StringFormat cf = m_FlowChart.TextFormat;
				SizeF size = g.MeasureString(text, textFont);
				size.Width += ArrowUtils.getMillimeter(m_FlowChart.MeasureUnit);
				size.Height += ArrowUtils.getMillimeter(m_FlowChart.MeasureUnit);

				
			
			}

			brText.Dispose();

			RectangleF rc = new RectangleF(x - textSize.Width/2 ,y - textSize.Height/2,textSize.Width, textSize.Height);
			return rc;

		}
        internal const double ArrowAngle = 25.0; //degrees

        internal static void DrawArrow(Graphics g, Brush brush, P2 start, P2 end, double lineWidth,
                                       ArrowStyle arrowStyle){
            switch (arrowStyle){
                case ArrowStyle.NonSpecified:
                case ArrowStyle.Normal:

                    DrawNormalArrow(g, brush, ref start, ref end, lineWidth);
                    break;
                case ArrowStyle.Tee:
                    DrawTeeArrow(g, brush, ref start, ref end, lineWidth);
                    break;
                case ArrowStyle.Diamond:
                    DrawDiamondArrow(g, brush, ref start, ref end, lineWidth);
                    break;
                case ArrowStyle.ODiamond:
                    DrawODiamondArrow(g, brush, ref start, ref end, lineWidth);
                    break;
                case ArrowStyle.Generalization:
                    DrawGeneralizationArrow(g, brush, ref start, ref end, lineWidth);
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }