I need this functionality
if(Timer.Started) Timer.Stop(); else() Timer.Start();




Posted 12 October 2012 - 04:14 PM
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Playing_with_words
{
public partial class Form1 : Form
{
// This has the list of char of all letter of the alphabet in uppercase
List<char> bigLettersOfAlphabet = new List<char>();
int counter = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
for (int i = 65; i <= 90; i++)
{
char c = Convert.ToChar(i);
bigLettersOfAlphabet.Add(c);
}
}
/// <summary>
/// For every tick i assaign the next letter to the button.text
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
LoopLetters(bigLettersOfAlphabet[counter]);
}
private void LoopLetters(char p)
{
char letter = bigLettersOfAlphabet[counter];
foreach (Control ctrl in Controls)
{
if (ctrl is Button)
{
((Button)(ctrl)).Text = letter.ToString();
}
}
counter++;
if (counter == bigLettersOfAlphabet.Count)
{
counter = 0;
LoopLetters(bigLettersOfAlphabet[counter]); //Recursion is only for looping over and over untill the timer.stop is called
}
}
private void StopLetter(object sender, EventArgs e)
{
string btn = ((Button)sender).Text;
((Button) sender).Text = btn;
}
}
}
This post has been edited by Michael26: 12 October 2012 - 04:15 PM
Posted 12 October 2012 - 04:24 PM
Quote
Quote
Posted 12 October 2012 - 04:38 PM
Posted 12 October 2012 - 04:52 PM
This post has been edited by Michael26: 12 October 2012 - 04:55 PM
Posted 13 October 2012 - 06:32 AM
Quote
if (timer1.Enabled)
{
timer1.Stop();
}
else
{
timer1.Start();
}
This post has been edited by Michael26: 13 October 2012 - 06:38 AM
Posted 13 October 2012 - 01:44 PM
Quote
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
