Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/MainForm.cs Secret

Created Nov 10, 2018
Embed
What would you like to do?
public partial class MainForm : Form
{
// Code omitted for brevity
// The history list
private Stack<ICommand> _commands = new Stack<ICommand>();
// Code omitted for brevity
// Draws the shape on canvas
private void canvas_MouseDown(object sender, MouseEventArgs e)
{
// We get the command based on the shape selection
// and we draw it in the X, Y coordinates
var command = GetCommand(e.X, e.Y);
command.Draw();
// We store the command in the history list
_commands.Push(command);
// Refresh the UI (trivial code, omitted for brevity)
RefreshWindow();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment