Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Form1()
- {
- InitializeComponent();
- this.SerCorrespondingButtons();
- this.SetCorrespondingInitialButtonInscriptions();
- }
- System.Windows.Forms.Timer tmr = new System.Windows.Forms.Timer();
- private Dictionary<Button, Label> correspondingControls;
- private Dictionary<Button, string> initialButtonInscriptions;
- private List<string> sayingsList;
- private Button currentButton;
- private int i;
- private void SerCorrespondingButtons()
- {
- correspondingControls = new Dictionary<Button, Label>()
- {
- {this.button1, this.label1},
- {this.button2, this.label2},
- };
- }
- private void SetCorrespondingInitialButtonInscriptions()
- {
- this.initialButtonInscriptions = new Dictionary<Button, string>()
- {
- {this.button1, this.button1.Text},
- {this.button2, this.button2.Text}
- };
- }
- private void button2_Click(object sender, EventArgs e)
- {
- var button = sender as Button;
- if (this.currentButton != null)
- {
- this.currentButton.Enabled = true;
- this.currentButton.Text = this.initialButtonInscriptions[this.currentButton];
- this.currentButton.Click += this.button2_Click;
- tmr.Enabled = false;
- tmr.Tick -= timer2_Tick;
- }
- this.currentButton = button;
- var saying = this.correspondingControls[button];
- saying.Visible = true;
- button.Text = "Click To Hide Saying";
- button.Click -= button2_Click;
- button.Click += button2_Click2;
- }
- private void button2_Click2(object sender, EventArgs e)
- {
- var button = sender as Button;
- var saying = this.correspondingControls[button];
- saying.Visible = true;
- if (saying.Visible)
- {
- button.Enabled = false;
- saying.Visible = false;
- button.Text = "Reactivating in 5 seconds";
- tmr.Interval = 1000;
- button.Click -= button2_Click2;
- button.Click += button2_Click;
- this.i = 4;
- tmr.Tick += timer2_Tick;
- tmr.Enabled = true;
- }
- }
- private void timer2_Tick(object sender, EventArgs e)
- {
- if (i != 0)
- {
- this.currentButton.Text = "Reactivating in " + i + " seconds";
- i -= 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement