2 * Copyright (C) 2013 FooProject
3 * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
6 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
9 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
12 using System.Collections.Generic;
17 using D2D = SharpDX.Direct2D1;
18 using DW = SharpDX.DirectWrite;
20 namespace FooEditEngine
22 interface IMarkerEffecter
24 void Draw(double x, double y, double width, double height);
27 abstract class SquilleLineMarker : IMarkerEffecter
29 public abstract void DrawLine(double x, double y, double tox, double toy);
30 public void Draw(double x, double y, double width, double height)
32 double lineWidthSize = Util.RoundUp(height / 24) + 1;
33 double lineLength = lineWidthSize + (lineWidthSize * 4);
34 double waveHeight = Util.RoundUp(height / 12) + 1;
35 double lineSpacing = lineWidthSize * 8;
37 double valleyY = Util.RoundUp(y + waveHeight);
38 double ridgeY = Util.RoundUp(y);
39 double endX = x + width - 1;
40 for (; x < endX; x += (waveHeight * 2))
42 double ridgeX = x + waveHeight;
43 double valleyX = ridgeX + waveHeight;
45 this.DrawLine(x, valleyY, ridgeX, ridgeY);
47 this.DrawLine(ridgeX, ridgeY, valleyX, valleyY);
52 sealed class D2DSquilleLineMarker : SquilleLineMarker
54 D2D.SolidColorBrush brush;
55 D2D.StrokeStyle stroke;
56 D2D.RenderTarget render;
58 public D2DSquilleLineMarker(D2D.RenderTarget render, D2D.SolidColorBrush brush, D2D.StrokeStyle stroke, float thickness)
62 this.thickness = thickness;
66 public override void DrawLine(double x, double y, double tox, double toy)
68 this.render.DrawLine(new Vector2((float)x, (float)y), new Vector2((float)tox, (float)toy), this.brush, this.thickness, this.stroke);
72 sealed class LineMarker : IMarkerEffecter
74 D2D.SolidColorBrush brush;
75 D2D.StrokeStyle stroke;
76 D2D.RenderTarget render;
78 public LineMarker(D2D.RenderTarget render, D2D.SolidColorBrush brush,D2D.StrokeStyle stroke, float thickness)
82 this.thickness = thickness;
86 public void Draw(double x, double y, double width, double height)
88 render.DrawLine(new Vector2((float)x, (float)(y)),
89 new Vector2((float)(x + width - 1), (float)(y)),
96 sealed class HilightMarker : IMarkerEffecter
98 D2D.SolidColorBrush brush;
99 D2D.RenderTarget render;
100 public HilightMarker(D2D.RenderTarget render,D2D.SolidColorBrush brush)
103 this.render = render;
106 public void Draw(double x, double y, double width, double height)
108 render.FillRectangle(new RectangleF((float)x, (float)y, (float)width, (float)height), brush);