I wrote this class
class CLine
{
public float sX,sY,dX,dY,m,x,y;
public void Draw (PaintEventArgs g)
{
//Graphics g = this.CreateGraphics
();
Bitmap bm=new Bitmap(1,1);
bm.SetPixel(0,0,Color.Black);
m = (dY-sY)/(dX-sX);
if (m<=1)
{
for (x=sX;x<=dX;x++)
{
y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x)
+512,-1*Convert.ToInt32(Math.Round(y))+384);
}
}
else
{
for (y=sY;y<=dY;y++)
{
x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32
(Math.Round(x))+512,-1*Convert.ToInt32(y)+384);
}
}
}
}
What should I do if I wanna call Draw method? I've tried
below code but it doesn't work.
CLine first = new CLine();
first.sX = 0; first.sY = 0; first.dX = 300; first.dY = -
500;
first.Draw(); <== Problem's here!
Thank in advance for your help. 6 1761
The only problem I see here is that you call method
public void Draw (PaintEventArgs g)
without a PaintEventArgs object: first.Draw(); <== Problem's here!
Hans.
-----Original Message----- I wrote this class
class CLine { public float sX,sY,dX,dY,m,x,y; public void Draw (PaintEventArgs g) { //Graphics g = this.CreateGraphics (); Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Black); m = (dY-sY)/(dX-sX); if (m<=1) { for (x=sX;x<=dX;x++) { y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x) +512,-1*Convert.ToInt32(Math.Round(y))+384); } } else { for (y=sY;y<=dY;y++) { x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32 (Math.Round(x))+512,-1*Convert.ToInt32(y)+384); } } } }
What should I do if I wanna call Draw method? I've tried below code but it doesn't work.
CLine first = new CLine(); first.sX = 0; first.sY = 0; first.dX = 300; first.dY = - 500; first.Draw(); <== Problem's here!
Thank in advance for your help. .
which is the problem ? do you got an error ?
class CLine has no constructor, you could create a constructor an pass your
members value through it...
"John" <an*******@discussions.microsoft.com> ha scritto nel messaggio
news:09****************************@phx.gbl... I wrote this class
class CLine { public float sX,sY,dX,dY,m,x,y; public void Draw (PaintEventArgs g) { //Graphics g = this.CreateGraphics (); Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Black); m = (dY-sY)/(dX-sX); if (m<=1) { for (x=sX;x<=dX;x++) { y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x) +512,-1*Convert.ToInt32(Math.Round(y))+384); } } else { for (y=sY;y<=dY;y++) { x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32 (Math.Round(x))+512,-1*Convert.ToInt32(y)+384); } } } }
What should I do if I wanna call Draw method? I've tried below code but it doesn't work.
CLine first = new CLine(); first.sX = 0; first.sY = 0; first.dX = 300; first.dY = - 500; first.Draw(); <== Problem's here!
Thank in advance for your help.
Draw expects to be passed a PaintEventArgs. You can get this from
OnPaint, or you can rewrite it to use a graphics object and create the
graphics object before calling Draw.
Graphics g = this.CreateGraphics(); // this assumes you are calling draw
from a windows form/control
Draw(g);
g.Dispose();
rewrite Draw to
public void Draw(Graphics g)
and change all references to g.Graphics in Draw to g
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
So how to fixed it? -----Original Message----- The only problem I see here is that you call method
public void Draw (PaintEventArgs g)
without a PaintEventArgs object:
>first.Draw(); <== Problem's here!
Hans.
-----Original Message----- I wrote this class
class CLine { public float sX,sY,dX,dY,m,x,y; public void Draw (PaintEventArgs g) { //Graphics g = this.CreateGraphics (); Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Black); m = (dY-sY)/(dX-sX); if (m<=1) { for (x=sX;x<=dX;x++) { y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x) +512,-1*Convert.ToInt32(Math.Round(y))+384); } } else { for (y=sY;y<=dY;y++) { x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32 (Math.Round(x))+512,-1*Convert.ToInt32(y)+384); } } } }
What should I do if I wanna call Draw method? I've tried below code but it doesn't work.
CLine first = new CLine(); first.sX = 0; first.sY = 0; first.dX = 300; first.dY = - 500; first.Draw(); <== Problem's here!
Thank in advance for your help. . .
Yeah, I got an error. I think I can pass member value by
use this line, "first.sX = 0; first.sY = 0; first.dX =
300; first.dY = - 500;". So how can I fix it? -----Original Message----- which is the problem ? do you got an error ?
class CLine has no constructor, you could create a
constructor an pass yourmembers value through it...
"John" <an*******@discussions.microsoft.com> ha scritto
nel messaggionews:09****************************@phx.gbl... I wrote this class
class CLine { public float sX,sY,dX,dY,m,x,y; public void Draw (PaintEventArgs g) { //Graphics g = this.CreateGraphics (); Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Black); m = (dY-sY)/(dX-sX); if (m<=1) { for (x=sX;x<=dX;x++) { y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x) +512,-1*Convert.ToInt32(Math.Round(y))+384); } } else { for (y=sY;y<=dY;y++) { x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32 (Math.Round(x))+512,-1*Convert.ToInt32(y)+384); } } } }
What should I do if I wanna call Draw method? I've tried below code but it doesn't work.
CLine first = new CLine(); first.sX = 0; first.sY = 0; first.dX = 300; first.dY = - 500; first.Draw(); <== Problem's here!
Thank in advance for your help.
.
private void YourPaintEvent(object sender,
System.Windows.Forms.PaintEventArgs e)
{
CLine first = new CLine();
first.Draw(e.Graphics);
} -----Original Message----- So how to fixed it?
-----Original Message----- The only problem I see here is that you call method
public void Draw (PaintEventArgs g)
without a PaintEventArgs object:
>first.Draw(); <== Problem's here!
Hans.
-----Original Message----- I wrote this class
class CLine { public float sX,sY,dX,dY,m,x,y; public void Draw (PaintEventArgs g) { //Graphics g = this.CreateGraphics (); Bitmap bm=new Bitmap(1,1); bm.SetPixel(0,0,Color.Black); m = (dY-sY)/(dX-sX); if (m<=1) { for (x=sX;x<=dX;x++) { y=sY+(x+sX)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32(x) +512,-1*Convert.ToInt32(Math.Round(y))+384); } } else { for (y=sY;y<=dY;y++) { x=sX+(y+sY)*m;
g.Graphics.DrawImageUnscaled(bm,Convert.ToInt32 (Math.Round(x))+512,-1*Convert.ToInt32(y)+384); } } } }
What should I do if I wanna call Draw method? I've
triedbelow code but it doesn't work.
CLine first = new CLine(); first.sX = 0; first.sY = 0; first.dX = 300; first.dY
= -500; first.Draw(); <== Problem's here!
Thank in advance for your help. . . . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin |
last post by:
I'd like to be able to get the name of an object instance from within
a call to a method of that same object. Is this at all possible?
The example below works by passing in the name of the object...
|
by: keith |
last post by:
I created a class libery which has name space Assembly
and class Assembly and compiled it.
Then created a C# project and called a method in
the external class
e.g.
Assembly dll;...
|
by: Cordell Lawrence |
last post by:
Okay guys,
We are wondering if this is a bug in Framework 2.0.40607 and
looking for some clarification on the issue. Take a look at the folowing
code.
public delegate bool BoundryTest(int...
|
by: juli jul |
last post by:
Hello I want to write get method of some object I create in other class:
I am doing some like that:
public ABC
{
get
{
return ABC;
}
|
by: JohnR |
last post by:
From reading the documentation, this should be a relatively easy thing. I
have an arraylist of custom class instances which I want to search with
an"indexof" where I'm passing an instance if the...
| |
by: Doru Roman |
last post by:
Hi,
Can somebody explain please the meaning and use of a STATIC method?
Thanks,
Doru
|
by: zzw8206262001 |
last post by:
Hi,I find a way to make javescript more like c++ or pyhon
There is the sample code:
function Father(self) //every contructor may have "self"
argument
{
self=self?self:this; ...
|
by: VK |
last post by:
<OT>I am finishing TransModal 0.1 so planning to move it from alpha to
beta stage.<OT>
Besides that I am planning to write an introductory to inheritance
schema currently used in Javascript...
|
by: Gabriel Genellina |
last post by:
En Tue, 29 Jul 2008 08:45:02 -0300, Themis Bourdenas <bourdenas@gmail.com>
escribi�:
In a very strict sense, I'd say that all those references to "method
decorators" are wrong - because...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |