-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCanvasItem.cs
58 lines (50 loc) · 1.41 KB
/
CanvasItem.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using System.Net.Mime;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace GCEd
{
abstract class CanvasItem : IDisposable
{
public GOperation Operation { get; set; }
public RectangleF AbsBoundingBox { get; protected set; }
public bool Selected { get; set; }
public bool Hovered { get; set; }
public CanvasItem(GOperation operation)
{
Operation = operation;
OperationChanged();
}
public virtual void OperationChanged()
{
}
public virtual void ViewMatrixChanged(Matrix viewMatrix)
{
}
public virtual void Draw(Graphics g, CanvasStyle style)
{
}
public virtual float Distance(Vector2 p)
{
return Single.PositiveInfinity;
}
public virtual void Dispose()
{
}
public static CanvasItem? FromOperation(GOperation operation)
{
if (operation.Line.IsLine) return new CanvasItemLine(operation);
else if (operation.Line.IsArc) return new CanvasItemArc(operation);
else if (operation.Line.Directive == Directive.Background) return new CanvasItemBackground(operation);
else if (operation.Line.Directive == Directive.Line) return new CanvasItemGuideLine(operation);
else if (operation.Line.Directive == Directive.Circle) return new CanvasItemGuideCircle(operation);
else return null;
}
}
}