-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
85 lines (78 loc) · 3.07 KB
/
MainWindow.xaml.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
using System.Windows;
using System.Windows.Controls;
namespace BauphysikToolWPF
{
/*
* THIS IS THE MAIN WINDOW WHICH CONTAINS ALL PAGES AND CONTENT
*
* Contains the Navigation Box on the left and the Content Pages on the right side
*/
// Top-level type. Defined outside of class. Part of namespace BauphysikToolWPF. Accessible from whole application
public enum NavigationContent
{
// see in MainWindow.xaml the List of ItemsSource for indices of the ListBoxItems (Pages)
ProjectPage,
LandingPage,
SetupLayer,
SetupEnv,
TemperatureCurve,
GlaserCurve
}
public partial class MainWindow : Window
{
// TODO add back button based on previously used page
public static NavigationContent lastRoutedPage;
public static ListBox? navigationMenuListBox;
public static Border? projectBoxHeader;
public MainWindow()
{
InitializeComponent();
navigationMenuListBox = this.NavigationMenuListBox;
projectBoxHeader = this.ProjectBoxHeader;
}
public static void SetPage(NavigationContent page)
{
if (navigationMenuListBox is null || projectBoxHeader is null)
return;
/*
* MainWindow.xaml changes the ContentPage based on the 'SelectedItem' string when toggled from 'NavigationListBox'
* The string values of the SelectedItem are defined at 'NavigationMenuItems'
*
* Alternatively: MainWindow.xaml changes the ContentPage based on the 'Tag' string when NOT toggled from 'NavigationListBox'
* Set 'SelectedItem' or 'SelectedIndex' to null / -1 before!
*/
switch (page)
{
case NavigationContent.ProjectPage:
navigationMenuListBox.SelectedIndex = -1;
projectBoxHeader.Tag = "ProjectPage";
break;
case NavigationContent.LandingPage:
navigationMenuListBox.SelectedIndex = -1;
projectBoxHeader.Tag = "LandingPage";
break;
//
case NavigationContent.SetupLayer:
navigationMenuListBox.SelectedItem = "SetupLayer";
break;
case NavigationContent.SetupEnv:
navigationMenuListBox.SelectedItem = "SetupEnv";
break;
case NavigationContent.TemperatureCurve:
navigationMenuListBox.SelectedItem = "Temperature";
break;
case NavigationContent.GlaserCurve:
navigationMenuListBox.SelectedItem = "Moisture";
break;
default:
navigationMenuListBox.SelectedItem = "LandingPage";
break;
}
}
// Exposes default Close() Method as static Method
public static new void Close()
{
Close();
}
}
}