-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStopwatchForm.cs
More file actions
151 lines (129 loc) · 4.52 KB
/
StopwatchForm.cs
File metadata and controls
151 lines (129 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace DigitalClock_StopWatch_FormsApp
{
public partial class StopwatchForm : Form
{
private bool drag = false;
private Point startpoint = new Point(0, 0);
private Stopwatch stopwatch;
String recordInfo = "{0,-10}{1,-20}{2,-20}{3,-20}{4,-20}{5,-20}{6,-20}";
public StopwatchForm()
{
InitializeComponent();
}
private void SWBackButton_Click(object sender, EventArgs e)
{
var home = new HomeForm();
if (WindowState == FormWindowState.Maximized)
{
WindowState = FormWindowState.Normal;
home.WindowState = FormWindowState.Maximized;
;
home.Show();
this.Hide();
}
else
{
home.WindowState = FormWindowState.Normal;
home.StartPosition = FormStartPosition.CenterScreen;
home.Show();
this.Hide();
}
}
private void StopwatchForm_Load(object sender, EventArgs e)
{
SWLaplistBox.Items.Add(string.Format(recordInfo, "Record#", " ", " ", " ", " ", " ", "Time"));
stopwatch = new Stopwatch();
}
private void SWMinButton_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
private void SWMaxButton_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
{
WindowState = FormWindowState.Maximized;
}
else
{
WindowState = FormWindowState.Normal;
}
}
private void SWExitButton_Click(object sender, EventArgs e)
{
DialogResult iExit;
iExit = MessageBox.Show("Confirm if you want to exit", "TimeMaster Pro",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (iExit == DialogResult.Yes)
{
Application.Exit();
}
}
private void SWStartButton_Click(object sender, EventArgs e)
{
stopwatch.Start();
}
private void SWStopButton_Click(object sender, EventArgs e)
{
stopwatch.Stop();
}
private void Clearbutton_Click(object sender, EventArgs e)
{
stopwatch.Reset();
SWLaplistBox.Items.Clear();
SWLaplistBox.Items.Add(string.Format(recordInfo, "Record#", " ", " ", " ", " ", " ", " Time"));
}
private void SWResetButton_Click(object sender, EventArgs e)
{
stopwatch.Reset();
/*DialogResult iReset;
iReset = MessageBox.Show("Would you like to Reset just the stopwatch or also the Record List\n\n 'Yes' for just the stopwatch\n 'No' for everthing", "TimeMaster Pro",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (iReset == DialogResult.Yes)
{
stopwatch.Reset();
}
else
{
stopwatch.Reset();
SWLaplistBox.Items.Clear();
}*/
}
private void SWSaveTimebutton_Click(object sender, EventArgs e)
{
SWLaplistBox.Items.Add(string.Format(recordInfo, SWLaplistBox.Items.Count , " ", " ", " ", " ", " ", Timelabel.Text));
/*SWLaplistBox.Items.Add($"Record {SWLaplistBox.Items.Count +1} Time:({Timelabel.Text})");*/
}
private void SWtimer_Tick(object sender, EventArgs e)
{
this.Timelabel.Text = stopwatch.Elapsed.ToString("mm\\:ss\\.ff");
}
private void StopwatchForm_MouseDown(object sender, MouseEventArgs e)
{
drag = true;
startpoint = new Point(e.X, e.Y);
}
private void StopwatchForm_MouseUp(object sender, MouseEventArgs e)
{
drag = false;
}
private void StopwatchForm_MouseMove(object sender, MouseEventArgs e)
{
if (drag)
{
Point p = PointToScreen(e.Location);
Location = new Point(p.X - this.startpoint.X, p.Y - this.startpoint.Y);
}
}
}
}