Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm trying to practice programing by creating a simple application which, I think, I can manage to do in .Net C# in VisualStudio 2010.

I'm working on simple application which will let me to create small pictures (icons) in sizes such as 8x8, 16x16, 32x32 (ect) pixels. I will be creating a grid representing each size by scaling to amount of pixels. Each pixel will be represented in a small square which will be able to click to change color ect.

So here's my question regarding what elements such app should have:

  • What VS tool would let me to create a grid for my project? Keeping in mind that each small square should be generated automatically by using X/Y size provided by user and boxes should be clickable. Also, I probably should be able to be able to click one pixel and drag mouse to select other pixels.

  • What simple functions should such small app have? Ex. choosing colors.

  • What minimal functions should I have?

I hope this is place for such question. I'm trying to get the general idea of how to make such small app work and what user might expect when opening small, icon creating, application.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You will probably have to create a Custom Control for the drawing surface. If you are creating a WinForms application, you can start by inheriting from System.Windows.Forms.Control. Then you override the OnPaint method and draw pixels as desired. I gave this advice to someone wanting to draw a LED-board, which looks pretty much like a zoomed icon. Here is the original answer with a VB example.

Here the translated example in C#

public class LedBoard : Control
{
    private Random _rand = new Random();

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        e.Graphics.FillRectangle(Brushes.Black, 0, 0, Width, Height);

        const int nx = 40;
        const int ny = 25;

        int w = (Width - 1) / nx - 1;
        int h = (Height - 1) / ny - 1;
        for (int x = 0; x <= nx - 1; x++) {
            for (int y = 0; y <= ny - 1; y++) {
                if (_rand.NextDouble() < 0.8) {
                    e.Graphics.FillRectangle(Brushes.Red, x * (w + 1) + 1, y * (h + 1) + 1, w, h);
                }
            }
        }
    }
}

It is just to give you an idea. If you want to "draw" an icon with buttons or labels for each pixel, you will need 32 x 32 = 1024 controls! A Custom Control allows you to do more than just draw the pixels of the icon. You could also draw selection marks, for instance.


Start with a minimum of functions. Color selection and drawing single pixels is enough for the beginning. Then add the functions that you miss most.

share|improve this answer

Without getting into the specifics for your particular application, I think you should just create the application with the core functionality first, then add more features later. Make a list of what the application needs to do at a minimum and implement the items in that list first. Make another list of what the application can or should also have and then implement the items in that list next.

For reference, look at the MoSCoW method for creating these lists.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.