-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
109 lines (92 loc) · 2.8 KB
/
MainForm.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ScreenTime
{
public partial class MainForm : Form
{
//private HomeControl homeControl;
public MainForm()
{
InitializeComponent();
//DatabaseHelper.InitializeDatabase();
settingsControl1.Hide();
aboutControl1.Hide();
reportsControl1.Hide();
homeControl1.Show();
homeControl1.BringToFront();
//homeControl = FindHomeControl();
this.FormClosing += MainForm_FormClosing;
this.Text = "ScreenTime";
}
private void ShowHome()
{
settingsControl1.Hide();
aboutControl1.Hide();
homeControl1.Show();
homeControl1.BringToFront();
}
private void ShowSettings()
{
homeControl1.Hide();
aboutControl1.Hide();
settingsControl1.Show();
settingsControl1.BringToFront();
}
private void ShowAbout()
{
homeControl1.Hide();
settingsControl1.Hide();
aboutControl1.Show();
aboutControl1.BringToFront();
}
private void ShowReports()
{
homeControl1.Hide();
settingsControl1.Hide();
aboutControl1.Hide();
reportsControl1.Show();
reportsControl1.BringToFront();
}
private void homeToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowHome();
}
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowSettings();
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private HomeControl FindHomeControl()
{
// This method finds the HomeControl in the form's controls
return this.Controls.OfType<HomeControl>().FirstOrDefault()
?? this.Controls.Cast<Control>().SelectMany(c => c.Controls.OfType<HomeControl>()).FirstOrDefault();
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
homeControl1.HandleFormClosing();
}
private void settingsControl1_Load(object sender, EventArgs e)
{
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowAbout();
}
private void reportsToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowReports();
}
}
}