-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
120 lines (102 loc) · 3.94 KB
/
Copy pathMainWindow.xaml.cs
File metadata and controls
120 lines (102 loc) · 3.94 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
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WpfApp
{
/// create the main window and pages and initialize
public partial class MainWindow : Window
{
public static Info showData = new Info();
public static SignIn SignInWindow = new SignIn(); // all the sign in and sign up and sql connection
public static CreateSchedule CreateWindow = new CreateSchedule(); // MainProgram.data... creates the page1 window and everything else
public static ShowSchedule showScheduleLive = new ShowSchedule(); // shows the schedule results
public static ScheduleDays showScheduleDays = new ScheduleDays();// shows the schedule by days
public MainWindow()
{
InitializeComponent();
MainFrame.Navigate(SignInWindow);
DisplayTestDataMsg();
}
// Close the application
private void CloseApp(object sender, MouseButtonEventArgs e)
{
try
{
SignInWindow.connection.Close();
Application.Current.Shutdown();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
// Move the window
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Initiate the dragging of the window
DragMove();
}
// Minimize the window
private void Minimize(object sender, MouseButtonEventArgs e)
{
try
{
WindowState = WindowState.Minimized;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//change color of the selected button and show the selected page
private void RadioButton_Click(object sender, RoutedEventArgs e)
{
// Assuming you have a reference to your original style and the highlighted style
Style originalStyle = FindResource("CustomRadioButtonStyle") as Style;
Style highlightedStyle = FindResource("CustomRadioButtonStyleHighlighted") as Style;
// Reset all RadioButtons to original style
foreach (var child in MyStackPanel.Children) // MyStackPanel is the x:Name of your StackPanel
{
if (child is RadioButton rb)
{
rb.Style = originalStyle;
}
}
// Apply the highlighted style to the clicked RadioButton
RadioButton clickedRadioButton = sender as RadioButton;
if (clickedRadioButton != null)
{
clickedRadioButton.Style = highlightedStyle;
}
RadioButton radioButton = (RadioButton)sender;
switch (radioButton.Content.ToString())
{
case "Home":
MainFrame.Navigate(showScheduleDays);
break;
case "Sign-In":
MainFrame.Navigate(SignInWindow);
break;
case "Create":
MainFrame.Navigate(CreateWindow);
break;
case "Info":
MainFrame.Navigate(showData); // can also be MainFrame.Navigate(new otherPage1());
break;
default:
MainFrame.Content = SignInWindow;
break;
}
}
private void DisplayTestDataMsg()
{
MessageBoxResult result = MessageBox.Show("Welcome to the Schedule Manager. You can load the test data(Click Yes) or create your own(Click No)",
"Information", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
MainProgram.data.AddDefaultData();
}
}
}
}