Source available

Advanced Paint Application

A desktop drawing application built in C# with .NET Windows Forms. Freehand and shape tools, a colour palette, and a full undo/redo history — written as a study in the command pattern, since undo is the feature that dictates a drawing app's entire architecture.

Role
Sole developer.
Year
2023
Stack
.NET, C#, Windows Forms

The problem

Undo is not a feature you add to a drawing app afterwards. If drawing operations mutate a bitmap directly there is nothing to reverse, so the history has to be designed in from the first commit. The interesting constraint was supporting unlimited undo without storing a full image per step.

How it was built

01Operations as reversible commands

Every action — a stroke, a shape, a fill — is an object that knows how to apply and how to reverse itself. Undo and redo become moving a pointer through a list rather than special-cased logic per tool, and a new tool inherits undo support by implementing the interface.

02Redrawing from history

The canvas is derived by replaying the command list rather than being the mutable source of truth. This is what keeps memory proportional to the number of operations instead of storing a bitmap snapshot per step.

03Tool abstraction

Tools share one interface for press, drag and release, so adding a shape means implementing three methods rather than extending a switch statement across the canvas event handlers.

Stack decisions

Why each piece was chosen, rather than just what was used.

C# / .NET

Strong typing and interfaces make the command pattern natural to express, which is the whole architectural point of the project.

Windows Forms

Direct access to GDI+ drawing primitives and low-level mouse events, which is what a canvas application needs.

What it does

  • Freehand and geometric shape tools
  • Customisable colour palette
  • Unlimited undo and redo via a command history
  • Canvas derived by replaying operations

Questions this raises

How do you implement undo/redo in a drawing application?

Model every operation as a command object that can apply and reverse itself, and derive the canvas by replaying that list rather than mutating a bitmap. Undo becomes moving a pointer through history. Retrofitting this later means rewriting the canvas, so it has to be the first architectural decision, not a later feature.

Building something similar?

Naman Gundaniya takes on full stack and AI projects like this one. Available for hire, replies within 24 hours.