Private
Public Access
Renamed CommandParser to Commander
This commit is contained in:
1 parent
20ff4cadff
commit
c1e899e44b
2 files changed
+21
-18
No files matched your search
+1
-1
@@ -73,7 +73,7 @@
|
|||||||
<DependentUpon>About Window.cs</DependentUpon>
|
<DependentUpon>About Window.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Command.cs" />
|
<Compile Include="Command.cs" />
|
||||||
<Compile Include="CommandParser.cs" />
|
<Compile Include="Commander.cs" />
|
||||||
<Compile Include="DrawPreview.cs">
|
<Compile Include="DrawPreview.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
+20
-17
@@ -5,55 +5,54 @@ using System.Linq;
|
|||||||
using System.Runtime.Remoting.Messaging;
|
using System.Runtime.Remoting.Messaging;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering
|
namespace Advanced_Software_Engineering
|
||||||
{
|
{
|
||||||
class CommandParser
|
class Commander
|
||||||
{
|
{
|
||||||
|
|
||||||
Graphics graphics;
|
Graphics graphics;
|
||||||
List<Command> commands = new List<Command>();
|
List<Verb> commands = new List<Verb>();
|
||||||
Drawer drawer;
|
Drawer drawer;
|
||||||
|
|
||||||
void DrawAllCommands()
|
public void DrawAllCommands()
|
||||||
{
|
{
|
||||||
|
foreach(Verb verb in this.commands)
|
||||||
|
{
|
||||||
|
verb.ExecuteVerb();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandParser(Graphics graphics)
|
public Commander(Graphics graphics)
|
||||||
{
|
{
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.drawer = new Drawer(this.graphics);
|
this.drawer = new Drawer(this.graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandParser(Graphics graphics, string rawCommands)
|
public Commander(Graphics graphics, string rawCommands)
|
||||||
{
|
{
|
||||||
this.graphics = graphics;
|
this.graphics = graphics;
|
||||||
this.drawer = new Drawer(this.graphics);
|
this.drawer = new Drawer(this.graphics);
|
||||||
this.ProcessCommands(rawCommands);
|
this.ProcessCommands(rawCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddCommand(Command command)
|
public void AddCommand(Verb command)
|
||||||
{
|
{
|
||||||
commands.Add(command);
|
commands.Add(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessCommands(string rawCommands)
|
public void ProcessCommands(string rawCommands)
|
||||||
{
|
{
|
||||||
//ignore case
|
//ignore case
|
||||||
rawCommands = rawCommands.ToLower();
|
rawCommands = rawCommands.ToLower();
|
||||||
//isolate commands
|
//isolate commands
|
||||||
string[] commands = rawCommands.Split(Environment.NewLine.ToCharArray());
|
string[] commands = rawCommands.Split(Environment.NewLine.ToCharArray());
|
||||||
|
|
||||||
for(int i =0; i < commands.Length; i++)
|
|
||||||
{
|
|
||||||
commands[i] = SettingsAndHelperFunctions.StripSpaces(commands[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(string rawCommand in commands)
|
foreach(string rawCommand in commands)
|
||||||
{
|
{
|
||||||
//handle errors later
|
//handle errors later
|
||||||
this.commands.Add(new Command(drawer, rawCommand));
|
AddCommand(VerbFactory.MakeVerb(drawer, rawCommand));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -83,12 +82,16 @@ namespace Advanced_Software_Engineering
|
|||||||
this.penPosition = point;
|
this.penPosition = point;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isPenDown() => penDown;
|
public bool IsPenDown() => penDown;
|
||||||
public void PenUp() => penDown = false;
|
public void PenUp() => penDown = false;
|
||||||
public void PenDown() => penDown = true;
|
public void PenDown() => penDown = true;
|
||||||
public void setPen(bool down) => penDown = down;
|
public void SetPen(bool down) => penDown = down;
|
||||||
|
|
||||||
|
|
||||||
|
public void DrawLine(Point point)
|
||||||
|
{
|
||||||
|
graphics.DrawLine(pen, penPosition, point);
|
||||||
|
penPosition = point;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user