public static void RenderArrow(this DrawingContext dc, Point pos, double height, Color color, Direcion dir, double scale) { var h = height; var r = h * 0.40f * scale; Point center = pos + new Vector(h * 0.50f, h * 0.50f * scale); Vector a, b, c; switch (dir) { case Direcion.Up: case Direcion.Down: if (dir == Direcion.Up) { r = -r; } a = new Vector(+0.000f, +0.750f) * r; b = new Vector(-0.866f, -0.750f) * r; c = new Vector(+0.866f, -0.750f) * r; break; case Direcion.Left: case Direcion.Right: if (dir == Direcion.Left) { r = -r; } a = new Vector(+0.750f, +0.000f) * r; b = new Vector(-0.750f, +0.866f) * r; c = new Vector(-0.750f, -0.866f) * r; break; default: throw new ArgumentOutOfRangeException(nameof(dir)); } var A = center + a; var B = center + b; var C = center + c; PathFigure figure = new PathFigure(A, new[] { new LineSegment(B, false), new LineSegment(C, false), new LineSegment(A, false) }, true); figure.IsFilled = true; PathGeometry path = new PathGeometry(); path.Figures.Add(figure); dc.DrawGeometry(new Brush(color), new Pen(Color.Black, 1), path); }
private static PathGeometry CreateArrowGeometry(Point pos, double height, Color color, Direcion dir, double scale) { var h = height; var r = h * 0.40f * scale; Point center = pos + new Vector(h * 0.50f, h * 0.50f * scale); Vector a, b, c; switch (dir) { case Direcion.Up: case Direcion.Down: if (dir == Direcion.Up) { r = -r; } a = new Vector(+0.000f, +0.750f) * r; b = new Vector(-0.866f, -0.750f) * r; c = new Vector(+0.866f, -0.750f) * r; break; case Direcion.Left: case Direcion.Right: if (dir == Direcion.Left) { r = -r; } a = new Vector(+0.750f, +0.000f) * r; b = new Vector(-0.750f, +0.866f) * r; c = new Vector(-0.750f, -0.866f) * r; break; default: throw new ArgumentOutOfRangeException(nameof(dir)); } var A = center + a; var B = center + b; var C = center + c; PathFigure figure = new PathFigure(A, new[] { new LineSegment(B, false), new LineSegment(C, false), new LineSegment(A, false) }, true); figure.IsFilled = true; PathGeometry path = new PathGeometry(); path.Figures.Add(figure); return(path); }
static void Go(Direcion direcion) { Console.WriteLine(string.Format("{0} gone.", direcion.ToString())); }