-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawCommandProcessor.cs
More file actions
49 lines (49 loc) · 1.58 KB
/
DrawCommandProcessor.cs
File metadata and controls
49 lines (49 loc) · 1.58 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
using System;
using System.Collections.Generic;
using Main;
class DrawCommandProcessor
{
public static bool CanvasExist
{
get
{
if (CanvasArea != null)
{
return true;
}
else
{
return false;
}
}
}
public static Canvas CanvasArea { get; set; }
public static void Execute(Command CommandReceived)
{
try
{
if (CommandReceived.CommandIdentifier == 'C' && !CanvasExist)
{
CanvasArea = new Canvas(CommandReceived.CommandParameters);
}
else if (CommandReceived.CommandIdentifier == 'C' && CanvasExist)
{
throw new Exception("Canvas already created, use another command");
}
else if (CommandReceived.CommandIdentifier != 'C' && !CanvasExist)
{
throw new Exception("No canvas for draw, create one first");
}
else if (CommandReceived.CommandIdentifier != 'C' && CanvasExist)
{
ObjectForCanvas oObjectForCanvas = ObjectForCanvasFactory.CreateInstance(CommandReceived);
oObjectForCanvas.Insert(CanvasArea);
CanvasArea.RefreshDraw();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}