Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Simple Paint app in winforms

Simple Paint app in winforms

Scheduled Pinned Locked Moved C#
csharpwinforms
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Aafaan_Jii
    wrote on last edited by
    #1

    Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also. In simple words, it should have: (rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes) Using : C#- Winforms

    OriginalGriffO P D L 4 Replies Last reply
    0
    • A Aafaan_Jii

      Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also. In simple words, it should have: (rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes) Using : C#- Winforms

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      And? What have you tried? Where are you stuck? What help do you need? While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in! Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did. If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • A Aafaan_Jii

        Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also. In simple words, it should have: (rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes) Using : C#- Winforms

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        This sounds like you are planning to have some fun writing code. Before you start writing any code, make a list of your requirements so that you don't lose focus. A word of advice; when dealing with shapes, make them separate shape classes, and make it so that the responsibility of drawing the shape belongs with the shape itself. I would tend to start with an abstract shape class, like this:

        public abstract class BaseShape
        {
        public event EventHandler ShapeInvalidated;
        private int? x;
        public int? X
        {
        get { x = value; }
        set
        {
        x = value;
        Invalidate();
        }
        }
        private int? y;
        public int? Y
        {
        get { y = value; }
        set
        {
        y = value;
        Invalidate();
        }
        }
        private int? width;
        public int? Width
        {
        get { width = value; }
        set
        {
        width = value;
        Invalidate();
        }
        }
        private int? height;
        public int? Height
        {
        get { height = value; }
        set
        {
        height = value;
        Invalidate();
        }
        }

        private int zorder;
        public int ZOrder
        {
        get { zorder = value; }
        set
        {
        zorder = value;
        Invalidate();
        }
        }

        private bool CanPaint()
        {
        return x.HasValue and y.HasValue && height.HasValue && width.HasValue && height.Value > 0 && width.Value > 0;
        }

        public void Invalidate()
        {
        if (CanPaint)
        {
        ShapeInvalidated?.Invoke(this, null);
        }
        }

        public abstract void Paint();
        }

        public class Rectangle : BaseShape
        {
        public override void Paint()
        {
        // Draw the rectangle based on the graphic context
        }
        }

        In general, you would want a shape manager class to actually manage the shapes on the screen. The shape manager would receive the ShapeInvalidated event and call the Paint method on each shape using the ZOrder to control the order the items are painted so you can create overlapping shapes.

        Advanced TypeScript Programming Projects

        1 Reply Last reply
        0
        • A Aafaan_Jii

          Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also. In simple words, it should have: (rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes) Using : C#- Winforms

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Be careful. Just because you put the word "simple" in your app description, that in no way means writing the code will be "simple". To start with, I would just start with an app that lets you drop a couple of shapes on the canvas and lets you move them around. Once you get this done correctly, the rest becomes easier.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          1 Reply Last reply
          0
          • A Aafaan_Jii

            Hello there , I want to create a simple paint application (photo editor tool) in winforms C# which should draw basic shapes (Rectangle, Ellipse, Line and Arrow only). Also, it should draw a transparent text box to write text and all these shapes including the text should be draggable or movable i.e. we should be able to select a shape or text and move it to other location on the screen. Further more it should have undo, redo, save and save as options also. In simple words, it should have: (rectangle, ellipse, line , arrow, text , undo, redo, save, save as, movement of shapes) Using : C#- Winforms

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Since there was no question, one wonders why you posted in the first place. [Simple Paint Application in C#](https://www.codeproject.com/Tips/811495/Simple-Paint-Application-in-Csharp)

            "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups