I have this function that will fill the ellipse every 10 seconds with
specific x,y,w,h.
Now I want do the the reverse, to clear the ellipse with given x,y
using Timer at every 30s.
Or I have put these (x,y,w,h) to an array?
Later go back the array and fill ellipse with the same color as
background?
Is there an easy way?
Thanks..
//Sample code that draw with timer
private void drawNote(int x, int y, int width, int height,
SolidBrush brush)
{
Graphics graphicGlobal = this.CreateGrap hics();
this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
drawNote(x_glob al, y_global, width_global, height_global,
colorBrush);
drawNote(x_glob al + 15, y_global + 15, width_global,
height_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
} 11 6732
I think you need to dispose of graphicGlobal.
"Slickuser" <sl*********@gm ail.comwrote in message
news:51******** *************** ***********@d4g 2000prg.googleg roups.com...
>I have this function that will fill the ellipse every 10 seconds with
specific x,y,w,h.
Now I want do the the reverse, to clear the ellipse with given x,y
using Timer at every 30s.
Or I have put these (x,y,w,h) to an array?
Later go back the array and fill ellipse with the same color as
background?
Is there an easy way?
Thanks..
//Sample code that draw with timer
private void drawNote(int x, int y, int width, int height,
SolidBrush brush)
{
Graphics graphicGlobal = this.CreateGrap hics();
this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
drawNote(x_glob al, y_global, width_global, height_global,
colorBrush);
drawNote(x_glob al + 15, y_global + 15, width_global,
height_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
"Slickuser" wrote:
I have this function that will fill the ellipse every 10 seconds with
specific x,y,w,h.
Now I want do the the reverse, to clear the ellipse with given x,y
using Timer at every 30s.
Or I have put these (x,y,w,h) to an array?
Later go back the array and fill ellipse with the same color as
background?
Is there an easy way?
Thanks..
//Sample code that draw with timer
private void drawNote(int x, int y, int width, int height,
SolidBrush brush)
{
Graphics graphicGlobal = this.CreateGrap hics();
this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
drawNote(x_glob al, y_global, width_global, height_global,
colorBrush);
drawNote(x_glob al + 15, y_global + 15, width_global,
height_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
Reread the advise to you in your post yesterday. It looks like you are
going back to drawing graphics outside the paint event.
If I use that way, I need some how to pass in a PaintEvents to draw.
That how why I choose doing this way.
On Nov 30, 4:53 am, Family Tree Mike
<FamilyTreeM... @discussions.mi crosoft.comwrot e:
"Slickuser" wrote:
I have this function that will fill the ellipse every 10 seconds with
specific x,y,w,h.
Now I want do the the reverse, to clear the ellipse with given x,y
using Timer at every 30s.
Or I have put these (x,y,w,h) to an array?
Later go back the array and fill ellipse with the same color as
background?
Is there an easy way?
Thanks..
//Sample code that draw with timer
private void drawNote(int x, int y, int width, int height,
SolidBrush brush)
{
Graphics graphicGlobal = this.CreateGrap hics();
this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
drawNote(x_glob al, y_global, width_global, height_global,
colorBrush);
drawNote(x_glob al + 15, y_global + 15, width_global,
height_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
Reread the advise to you in your post yesterday. It looks like you are
going back to drawing graphics outside the paint event.- Hide quoted text -
- Show quoted text -
On Fri, 30 Nov 2007 17:14:42 -0800, Slickuser <sl*********@gm ail.com
wrote:
I am looking through examples right now.
Eventually, you should find a discussion of the Paint event and what
PaintEventArgs contains.
Can you give me example that let call(or not) a function which draw at
x,y,w,h with PaintEventArgs?
In that discussion, you will find that the PaintEventArgs. Graphics member
provides the Graphics instance to which you need to draw.
I still want to call this function with this argument when I want it
to draw: drawNote(int x, int y, int width, int height, SolidBrush
brush)
Since the PaintEventArgs. Graphics member is the Graphics instance to which
you need to draw, that means that you need to pass the Graphics instance
from PaintEventArgs to any code that wants to draw. The simplest way to
do that would be to include it as a parameter to the method called from
the OnPaint() method or the Paint event handler (however you've decided to
implement it).
So:
private void drawNote(int x, int y, int width, int
height,SolidBru sh brush)
becomes:
private void drawNote(Graphi cs gfx, int x, int y, int width, int
height,SolidBru sh brush)
and the method body:
{
////PaintEventArg?? ?
//Graphics graphicGlobal = this.CreateGrap hics();
/// this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
becomes:
{
gfx.FillEllipse (brush, x, y, width, height);
}
Hope that helps.
Pete
Which in that case, now I need to pass in Graphics as input argument
to call drawNote (5 input arguments)?
How can I achieve with my timer? Thank you so much for your help.
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
//drawNote(x_glob al, y_global, width_global,
height_global,c olorBrush);
//drawNote(x_glob al + 15, y_global + 15,
width_global,he ight_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
On Nov 30, 5:23 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Fri, 30 Nov 2007 17:14:42 -0800, Slickuser <slick.us...@gm ail.com>
wrote:
I am looking through examples right now.
Eventually, you should find a discussion of the Paint event and what
PaintEventArgs contains.
Can you give me example that let call(or not) a function which draw at
x,y,w,h with PaintEventArgs?
In that discussion, you will find that the PaintEventArgs. Graphics member
provides the Graphics instance to which you need to draw.
I still want to call this function with this argument when I want it
to draw: drawNote(int x, int y, int width, int height, SolidBrush
brush)
Since the PaintEventArgs. Graphics member is the Graphics instance to which
you need to draw, that means that you need to pass the Graphics instance
from PaintEventArgs to any code that wants to draw. The simplest way to
do that would be to include it as a parameter to the method called from
the OnPaint() method or the Paint event handler (however you've decided to
implement it).
So:
private void drawNote(int x, int y, int width, int
height,SolidBru sh brush)
becomes:
private void drawNote(Graphi cs gfx, int x, int y, int width, int
height,SolidBru sh brush)
and the method body:
{
////PaintEventArg?? ?
//Graphics graphicGlobal = this.CreateGrap hics();
/// this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
becomes:
{
gfx.FillEllipse (brush, x, y, width, height);
}
Hope that helps.
Pete
I should use ??
protected override void OnPaint(PaintEv entArgs e)
{
// If there is an image and it has a location,
// paint it when the Form is repainted.
base.OnPaint(e) ;
//base.Invalidate ();
}
On Nov 30, 5:48 pm, Slickuser <slick.us...@gm ail.comwrote:
Which in that case, now I need to pass in Graphics as input argument
to call drawNote (5 input arguments)?
How can I achieve with my timer? Thank you so much for your help.
// Timer to draw
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
//drawNote(x_glob al, y_global, width_global,
height_global,c olorBrush);
//drawNote(x_glob al + 15, y_global + 15,
width_global,he ight_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
On Nov 30, 5:23 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Fri, 30 Nov 2007 17:14:42 -0800, Slickuser <slick.us...@gm ail.com>
wrote:
I am looking through examples right now.
Eventually, you should find a discussion of the Paint event and what
PaintEventArgs contains.
Can you give me example that let call(or not) a function which draw at
x,y,w,h with PaintEventArgs?
In that discussion, you will find that the PaintEventArgs. Graphics member
provides the Graphics instance to which you need to draw.
I still want to call this function with this argument when I want it
to draw: drawNote(int x, int y, int width, int height, SolidBrush
brush)
Since the PaintEventArgs. Graphics member is the Graphics instance to which
you need to draw, that means that you need to pass the Graphics instance
from PaintEventArgs to any code that wants to draw. The simplest way to
do that would be to include it as a parameter to the method called from
the OnPaint() method or the Paint event handler (however you've decided to
implement it).
So:
private void drawNote(int x, int y, int width, int
height,SolidBru sh brush)
becomes:
private void drawNote(Graphi cs gfx, int x, int y, int width, int
height,SolidBru sh brush)
and the method body:
{
////PaintEventArg?? ?
//Graphics graphicGlobal = this.CreateGrap hics();
/// this.Show();
graphicGlobal.F illEllipse(brus h, x, y, width, height);
}
becomes:
{
gfx.FillEllipse (brush, x, y, width, height);
}
Hope that helps.
Pete
On Fri, 30 Nov 2007 17:48:37 -0800, Slickuser <sl*********@gm ail.com>
wrote:
Which in that case, now I need to pass in Graphics as input argument
to call drawNote (5 input arguments)?
Yes. If it bothers you and your drawing code is complex enough, you may
find it makes sense to create a class instantiated for each time you draw
and to which you pass the Graphics instance as well as any other
frequently-used data items you might want access to from the drawing code.
How can I achieve with my timer? Thank you so much for your help.
You don't draw in response to a timer. You can update your data, and then
invalidate the area of the control/form that needs to be redrawn
(depending on the data and what you're drawing, this might just be the
whole control or form).
Pete
On Fri, 30 Nov 2007 17:51:37 -0800, Slickuser <sl*********@gm ail.com>
wrote:
I should use ??
protected override void OnPaint(PaintEv entArgs e)
{
// If there is an image and it has a location,
// paint it when the Form is repainted.
base.OnPaint(e) ;
//base.Invalidate ();
}
That depends. Are you putting the drawing code into the same class as
that which represents the control or form into which the drawing is
actually being done? If so, then yes...I personally feel that writing an
override for OnPaint() is more appropriate than handling the Paint event.
Note: you almost always will want to call the base.OnPaint() as you've
shown there. However, you should _never_ call Invalidate() from within
OnPaint() or a Paint event handler. I realize the line is commented out
here, but it should never have been there in the first place.
Pete
On Nov 30, 6:07 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.com>
wrote:
On Fri, 30 Nov 2007 17:48:37 -0800, Slickuser <slick.us...@gm ail.com>
wrote:
Which in that case, now I need to pass in Graphics as input argument
to call drawNote (5 input arguments)?
Yes. If it bothers you and your drawing code is complex enough, you may
find it makes sense to create a class instantiated for each time you draw
and to which you pass the Graphics instance as well as any other
frequently-used data items you might want access to from the drawing code.
How can I achieve with my timer? Thank you so much for your help.
You don't draw in response to a timer. You can update your data, and then
invalidate the area of the control/form that needs to be redrawn
(depending on the data and what you're drawing, this might just be the
whole control or form).
Pete
Update my data of x,y,...?
Here is my code so far..
//code
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
namespace fill3
{
public partial class Form1 : Form
{
int x_global = 10;
int y_global = 10;
int width_global = 50;
int height_global = 50;
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
}
private void timer_note_Tick (object sender, EventArgs e)
{
SolidBrush colorBrush = new SolidBrush(Colo r.Cyan);
SolidBrush colorBrush2 = new SolidBrush(Colo r.Magenta);
//drawNote(x_glob al, y_global, width_global,
height_global, colorBrush);
//drawNote(x_glob al + 15, y_global + 15, width_global,
height_global, colorBrush2);
x_global = x_global + 30;
y_global = y_global + 30;
}
private void drawNote(Graphi cs gfx, int x, int y, int width,
int height,SolidBru sh brush)
{
gfx.FillEllipse (brush, x, y, width, height);
gfx.Dispose();
this.Invalidate ();
}
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Trimboli |
last post by:
At http://www.trimboli.name/ I've created a list of the contents of the
site, using graphics as the list bullets by including style attributes
in the HTML. What I want to do is make the graphic top and the link top
line up with each other, then make the description sit immediately
underneath the link, with no space between them. The text of the
description should remain to the right of the graphic; it should not
wrap under the graphic if...
|
by: William Schubert |
last post by:
Is there a common defintion of Clear that applies to both
objects and collections? If so, where is it documented.
My preconceived notion is that Clear means "reset the
object to its initial state" and this applies to both
collections and objects. The problem is that I cannot
find anything in the literature supporting this. That
would be ok, but I cannot find anything at all.
|
by: Tomomichi Amano |
last post by:
Hello
How can I delete (clear) lines that were made useing Graphics.DrawLine() ?
Thanks in advance! Have a nice day!
|
by: Daniel |
last post by:
how come when i do oGraphics.FillEllipse it draws blury? is there anyway to
adjust this default compression to not be blury when drawing a simple
ellipse?
|
by: moondaddy |
last post by:
I'm painting images onto a windows form using this method:
e.Graphics.DrawImageUnscaled(m_ItemImage, x, y)
every time I select a product. However, some products don't have an image
so when a user selects a different product from a list and that product
doesn't have an image, I need to clear the image from the previous product
that was painted onto the form.
I was thinking of creating a clear image and using the DrawImageUnscaled
| |
by: JD |
last post by:
Is it possible to have a clear backstyle for a lable
control? I want to write some text on a lable and I want
the background of the label to match the color of the
control I am placing the label on where the color of that
control will be changing will be changing. Is this
doable? If not, is there a control I can do this with? to
have a clear/see through backstyle?
Thanks,
JD
|
by: =?Utf-8?B?R3VzIENodWNo?= |
last post by:
I got a simple line of code that paints on a panel. I would like to add a
clear button to clear the panel but I’m not to sure how.
Panel.MouseMove
Dim g As Graphics = Me.Panel1.CreateGraphics()
g.FillEllipse(New SolidBrush(Value), e.X, e.Y, SizePt, SizePt)
g.Dispose()
cmdClear_Click
Me.Panel.?????
|
by: Kid Programmer |
last post by:
Hello guys. I was wondering how you can clear the screen in a java program. Here is the code for my program:
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
public class GUI {
|
by: kspiros |
last post by:
I have a picture box which contains an image and some drawn ellipses. while a thread pass by the ellipses increase the alpha of the ellipse but when the tread leaves the ellipse range i can't change the alpha value because it paints it over. how can I erase only the ellipse without touching anything else in the image.
image linksimage1 image2
my code
public void work()
{
Graphics xGraph;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: 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 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...
| |