473,473 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Start and Pause buttons

17 New Member
Hi every one

I have 2 buttons on my form, by clicking on the first one a straight line begins to grow up, I am wondering how i can pause this process by clicking on the "pause" button?

any ideas / suggestions??
Thank u
Oct 26 '07 #1
2 1377
r035198x
13,262 MVP
Hi every one

I have 2 buttons on my form, by clicking on the first one a straight line begins to grow up, I am wondering how i can pause this process by clicking on the "pause" button?

any ideas / suggestions??
Thank u
I suppose you have some code that you are calling for drawing the line? Why don't you post that? Basically a bool flag should be able to do the job. The line continues to be drawn while the bool flag is true. If the Pause button is pressed, change the value of your boolean flag.
Oct 26 '07 #2
shimajavar
17 New Member
I suppose you have some code that you are calling for drawing the line? Why don't you post that? Basically a bool flag should be able to do the job. The line continues to be drawn while the bool flag is true. If the Pause button is pressed, change the value of your boolean flag.
I tries a flag,the problem is pause button isnt active while the line is growing...I'll copy the code..."Up"button makes the line grow up, and "start" button should make it stop.

class Program: Form
{
int x1;
int y1;
int x2;
int y2;
Button up = new Button();
bool upFlag = true;
Button start = new Button();
public Program()
{
Size=new Size(800,800);
x1 = 365;
y1 = 280;
x2 = 365;
y2 = 280;

/*Create Buttons*/


up.Text = "Up";
up.Click += new EventHandler(up_Click);
up.Location = new Point(340, 550);
up.Size = new Size(100, 40);

this.Controls.Add(up);


start.Text = "Start/"+"\n"+"Pause";
start.Click += new EventHandler(start_Click);
start.Location = new Point(340, 600);
start.Size = new Size(100, 40);
this.Controls.Add(start);

this.Paint += new PaintEventHandler(myform_Paint);

}
void up_Click(object sender, EventArgs e)
{
AnimateUp();
}

void start_Click(object sender, EventArgs e)
{
AnimateStart();
}

private void AnimateUp()
{

if (start.Text == "Assume")
start.Text = "Pause";
while (upFlag == true)
{
while (y2 > 24)
{

y2 = y2 - 10;
this.Invalidate();
this.Refresh();
System.Threading.Thread.Sleep(100);
}
x1 = x2;
y1 = y2;
MessageBox.Show("Game Over!!", "End of the game", MessageBoxButtons.OKCancel);
Application.Exit();
}
}

private void AnimateStart()
{
if(upFlag==true)
upFlag = false;
if (start.Text == "Start/" + "\n" + "Pause")
start.Text = "Pause";

else if (start.Text == "Pause")
start.Text = "Assume";
}

private void myform_Paint( object sender,PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush brush = new SolidBrush(Color.Black);
Pen pen = new Pen(brush, 4);
g.DrawRectangle(pen, 20, 20, 750, 500);

g.DrawLine(pen, x1, y1,x2, y2);
}


static void Main(string[] args)
{
Application.Run(new Program());
Application.Exit();
}
Oct 26 '07 #3

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

Similar topics

0
by: Andrew | last post by:
When will .NET have a low-pause-time garbage collector A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have...
5
by: Brian.Steele | last post by:
Greetings everyone. See http://www.spiceisle.com/cgi-bin/slideshow/slideshow.cgi?dir=brian/personal/2005/uk_trip/images&type=jpg The "Pause" button works in IE, but not in Firefox. Any ideas...
3
by: jdph40 | last post by:
In Access 2002, I designed a simple database for our Safety department to enter results of a survey. There are 41 true/false statements. I have a main form called frmSurvey with a subform called...
11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
3
by: EMW | last post by:
I have managed to create a page with some buttons on it. I want to create some little animation to those buttons, like just after the page is opened in IE, the user sees the buttons move from a...
38
by: Jackie | last post by:
I just want the programme to stop for a while. Thanks.
8
by: Lloydm | last post by:
I've used the command "pause" in batch files which works ok but I guess it's applied dirrently in c++. Using Dev C++ 4.0 and the following is my code #include<iostream> #include<iomanip>...
1
by: kimiraikkonen | last post by:
Hi, i have 2 forms, first form has a button that brings user to toggle second form, and second form contains a integrated web-browser component which has a auto-start flash (the flash contains...
0
by: Arun21084 | last post by:
Hi, Recently I installed an application HP SIP(Service Information Portal) on a Windows 2000 server.The application comes along with an installation of Tomcat 5.0.19. Already there was an Apache...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
1
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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 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.