473,854 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw a line

10 New Member
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.


Dec 11 '09 #1
9 3046
3,525 Recognized Expert Specialist
"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.
Dec 11 '09 #2
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
Could you explain what is the actual problem.?

Have you written any code for it.?

Dheeraj Joshi
Dec 11 '09 #3
449 Recognized Expert Contributor
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
Dec 12 '09 #4
7 New Member
:) hahaha .
Dec 12 '09 #5
10 New Member
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 =)


Dec 13 '09 #6
102 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
  2. System.Drawing.Graphics formGraphics;
  3. formGraphics = this.CreateGraphics();
  4. formGraphics.DrawLine(myPen, 0, 0, 200, 200);
  5. myPen.Dispose();
  6. 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!
Dec 13 '09 #7
3,525 Recognized Expert Specialist
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.
Dec 13 '09 #8
10 New Member
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.

Dec 14 '09 #9
3,525 Recognized Expert Specialist
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.
Dec 14 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Matt | last post by:
I am writing a recursive program to draw the lines recursively, given the range and number of intervals (n) between the range. The problem is I don't know how to draw the line in point 0.375, as you see below. Please advise! Thanks! #include <iostream> using namespace std;
by: thomasp | last post by:
I found the following code on MSDN to draw a line in VB2005. Public Sub DrawLinePoint(ByVal e As PaintEventArgs) ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create points that define line. Dim point1 As New Point(100, 100) Dim point2 As New Point(500, 100)
by: dan heskett | last post by:
I am owner-drawing a listbox, in an attempt to create a nice list with some custom "fields" and text layout. Essentially it works, but I must be missing something big, conceptually, because I get all kinds of screen artifacts and weirdness. My general goal is: list item with a few areas for text, every other item shaded a light color for readability, font color changes with selection. The listbox is populated with custom structurs...
by: news | last post by:
If anyone can recommend a more appropriate newsgroup for this question? We recently upgraded from php 4.1.2 to php 4.3.9 and ImageMagick 5.5.7 to version 6.2.5. I have a script that creates a random number image as a Turing Test, and without changing that, it's stopped working right after the upgrade. But, only part of the mogrify command. Here's the line I'm using:
by: Jason Huang | last post by:
Hi, In my C# Windows Form, how do I draw a Line? Thanks for help. Jason
by: Rich | last post by:
Hello, I have a form with a panel which contains a radiobutton. When I click the radiobutton, I invoke the Paint event of the panel using me.Invalidate. The paint event gets called and runs through code to draw a line. But the line does not draw on the panel until I press either the Alt key or Tab key. Here is my code: Sub rad_Click(...)handles... Me.Invalidate()
by: balakrishnan.dinesh | last post by:
Hi frnds, Im creating function to plot line graph in javascript . I have marked the points in graph. but what i need to do is, i want to draw the line between those marked point, but i dont konw how to draw line betwwen the marked points The output for my function will be like this , So the marked point (*) should be connected through lines,
by: Daniel Mark | last post by:
Hello all: I am looking the sample code posted on PIL website http://www.pythonware.com/library/pil/handbook/imagedraw.htm ################################################ <<Draw a Grey Cross Over an Image>> import Image, ImageDraw
by: IvoShalev | last post by:
Hi there, I just want to give some sudgestions on how to draw some plain things only using the header file <graphics.hand of course the standart files <stdio.h<conio.h<stdlib.h>. First of All you have to load drivers for the graphic. -You must have the file EGAVGA.BGI to be in the same directory where your code is. -with this driver you will have 640/480 resolution with 16 colors 1 page or you can choose 320/280 16col with 2 video...
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a reference to a control or a form. I guess it means that lines can't be draw on blank area between two forms. Can anybody guarantee this for me? Is there any method can realize this function? I mainly want to draw a line from a button in form1 to...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.