Draw a line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephaniee
    New Member
    • Dec 2009
    • 10

    Draw a line

    Hi there,

    I wanna draw a line using read() method? After that I would need to read the HEX values which later be used as a point (x, y). From that point, it will create a line.

    Thanks




    Regards,
    Stephanie
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    "Wanna" ? Are you 10 years old?

    What HEX values?

    Draw using a read() method?

    This just makes no sense.

    I would suggest that when you have more than 30 seconds, you take some time to actually explain what it is you are trying to do and what problem you are running into.

    Comment

    • Dheeraj Joshi
      Recognized Expert Top Contributor
      • Jul 2009
      • 1129

      #3
      Could you explain what is the actual problem.?

      Have you written any code for it.?

      Regards
      Dheeraj Joshi

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        are you trying o draw a line on console..... or on a windows form...

        if console then you cant take x,y points..... if windows form then its possible

        Comment

        • Pr1nnyraid
          New Member
          • Dec 2009
          • 7

          #5
          :) hahaha .

          Comment

          • stephaniee
            New Member
            • Dec 2009
            • 10

            #6
            Hi all,

            Sorry for the kiddy way of expressing the program ;P

            I am using Microsoft Visual C# 2008 Express Edition. I want to write on windows form application. I am a newbie to programming, so I have no idea how to start it.


            The program look:
            By using serial port, the program can send and receive data. The user will be able to enter hexadecimal values and send it. By using readbyte() or read() method to read the hexadecimal values which later be used to get points (x,y). From that points, a line will be drawn.

            That's my task.

            Your help will be greatly appreciated =)

            Thanks.

            Regards,
            Stephanie

            Comment

            • sanjib65
              New Member
              • Nov 2009
              • 102

              #7
              Drawing on winform

              Though you are new to programming, I'd suggest you to always refer to MSDN. It's a good practice and you'll learn to experiment and make errors. Unless you make errors you'd never be programmer!

              So for the drawing part you consult these links:



              and Codes:

              Code:
              System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
              System.Drawing.Graphics formGraphics;
              formGraphics = this.CreateGraphics();
              formGraphics.DrawLine(myPen, 0, 0, 200, 200);
              myPen.Dispose();
              formGraphics.Dispose();
              Secondly, for the future reference you'd go to this very important link below. I think all the queries a new-bie has, are there:



              Happy programming!

              Comment

              • tlhintoq
                Recognized Expert Specialist
                • Mar 2008
                • 3532

                #8
                I am a newbie to programming, {...}
                The program look:
                By using serial port, the program can send and receive data. The user will be able to enter hexadecimal values and send it. By using readbyte() or read() method to read the hexadecimal values which later be used to get points (x,y). From that points, a line will be drawn.
                Sounds like a rather specific way to start learning.
                Hex values over a serial port? Why the 1998 approach? Sounds like a old-school serial port mouse, drawing tablet or joystick perhaps?

                I might suggest since you are new to programming that you break down the project into smaller areas of learning. Get one part down at a time and build up from there.

                Start with how to draw. You have been given some code for that.
                Then I would suggest drawing based on the regular mouse coordinates because they are easy to read. This will give you a system of input for x and y.
                Then worry about how to open and read the serial port, and translate your hex into x and y.

                Tip: Make the mouse reading a module that raises events. Make the drawing portion a module that subscribes to those events. When you are ready to make the serial part it can raise the same events that the mouse module does. This means you will be able to use both mouse and serial with the same drawing portion. This kind of "black box" approach is key to writing software that can be maintained and expanded easily for years.

                Comment

                • stephaniee
                  New Member
                  • Dec 2009
                  • 10

                  #9
                  Hi Sanjib65,

                  Thanks for the helpful links, I will read more on that. =)

                  Hi tlhintoq,

                  I have actually to draw the lines onto a "whiteboard ".
                  I was not allowed to use the mouse events, I have tried to do that by referring to "scribbles" , my partner insists on using the hexadecimal values that I have mentioned earlier.=(.

                  Thanks for the helpful tips.

                  Regards,
                  Stephanie

                  Comment

                  • tlhintoq
                    Recognized Expert Specialist
                    • Mar 2008
                    • 3532

                    #10
                    Bytes has a policy regarding assisting students with their homework.

                    The short version is that the volunteers here can't help you with schoolwork.
                    A) We don't know what material you have and have not learned in class.
                    B) We don't know the guidelines you must follow.
                    C) In the long run giving you the answers actually short changes your education.
                    This question is a good example of how little bits of the larger picture start trickling out... Oh, there is a {study/lab} partner. You aren't *allowed* to do mouse events.

                    If you are struggling with the assignment the best source to turn to is your professor.

                    Comment

                    Working...