Greetings. I wrote a Paint Application in C#, here is a summary of it:
It is a Multiple-Document Interface application - The Image forms are MdiChildren of the Main application form.
According to this, the main menu is merged with a non-visible MenuStrip on the Image form.
The various tool windows are owned by the Main application form.
The featured tools are: Select, Pencil (1px free-draw), Brush, Eraser, Rectangle, Circle, Fill and Pipette (color picker).
The different parameters for each tool are displayed in the Tool Options window.
Each tool's options are arranged on a dedicated panel on this form. When a tool is chosen, its' options panel toggles to the only visible panel.
The edited image is displayed inside a PictureBox control.
All drawing actions are done in the course of the MouseDown, MouseMove and MouseUp events of that PictureBox.
A boolean named isDragging is turned true on MouseDown event, and false on MouseUp event, thus enabling continuous drawing actions.
Selection definition, dragging and dropping is done in a similar way, based on four selection states listed in an enum.
The algorithm for the flood fill tool is taken from this tutorial.
Two image filters are available from the Image menu - Brightness and Invert, and can also be applied to selections.
Brightness also features a dialog for setting the filter level, with a small preview of its' effect.
The data for the multiple undo and redo features is stored in Stacks.
Image files can be loaded and saved in the various ImageFormats provided by .NET.
Here are a couple of screenshots:
And here is the code for the Image form:
No comments:
Post a Comment