Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis
Created November 10, 2018 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdyrrahitis/9d3b40f745fc53516da6bf526b9e58b9 to your computer and use it in GitHub Desktop.
Save gdyrrahitis/9d3b40f745fc53516da6bf526b9e58b9 to your computer and use it in GitHub Desktop.
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