forked from xzvfinet/OneLevelJson
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommand.cs
More file actions
88 lines (75 loc) · 2.31 KB
/
Command.cs
File metadata and controls
88 lines (75 loc) · 2.31 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OneLevel2D.CustomList;
using OneLevel2D.Model;
namespace OneLevel2D
{
public abstract class Command
{
public string Name { get; private set; }
public const string MOVE = "COMMAND_MOVE";
public const string ADD = "COMMAND_ADD";
public const string REMOVE = "COMMAND_REMOVE";
public const string RESIZE = "COMMAND_RESIZE";
protected Command(string name)
{
this.Name = name;
}
}
public class MoveCommand : Command
{
public List<CienBaseComponent> ComponentList { get; set; }
public Point StartPoint { get; set; }
public Point EndPoint { get; set; }
public MoveCommand(string name, List<CienBaseComponent> list) : base(name)
{
ComponentList = new List<CienBaseComponent>(list);
}
public bool IsMoved()
{
var offset = EndPoint - (Size) StartPoint;
return !offset.IsEmpty;
}
}
public class AddCommand : Command
{
public List<CienBaseComponent> ComponentList { get; set; }
public AddCommand(string name, List<CienBaseComponent> list)
: base(name)
{
ComponentList = new List<CienBaseComponent>(list);
}
}
public class RemoveCommand : Command
{
public List<CienBaseComponent> ComponentList { get; set; }
public RemoveCommand(string name, List<CienBaseComponent> list) : base(name)
{
ComponentList = new List<CienBaseComponent>(list);
}
}
public class ResizeCommand : Command
{
public CienBaseComponent Component { get; set; }
public Point StartPoint { get; set; }
public Point EndPoint { get; set; }
public ResizeCommand(string name, CienBaseComponent component) : base(name)
{
Component = component;
}
public bool IsResized()
{
var offset = EndPoint - (Size)StartPoint;
return !offset.IsEmpty;
}
public Size GetSizeOffset()
{
var offset = (Size)EndPoint - (Size)StartPoint;
return Component.GetSize() + offset;
}
}
}