-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dashboard.xaml.cs
73 lines (62 loc) · 2.43 KB
/
Dashboard.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
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
namespace BOTWToolset
{
/// <summary>
/// Interaction logic for Dashboard.xaml
/// </summary>
public partial class Dashboard : Window
{
// Get the app version from the assembly info
public static readonly string VERSION = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
// Get the user's desktop path
public static readonly string UserDesktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
// All tabs used in the toolset
// Adding a new tool to the program requires its tab control to be added here
public static readonly UserControl[] toolsetTabs = new UserControl[]
{
new Control.TabTSCB(),
new Control.TabYaz0(),
new Control.TabSARC(),
new Control.TabRSTB()
};
public Dashboard()
{
InitializeComponent();
LabelVersion.Content = $"Version v{VERSION}";
// Initialize and add all tool tabs to the tab controller
foreach (UserControl tab in toolsetTabs)
{
// Initialize the new tab
TabItem tabItem = new TabItem
{
// Set the tab's content to whatever the tool's control is
Content = tab,
// Give the header (tab name) a proper name based off its class name
Header = tab.GetType().Name.Replace("Tab", "")
};
TabController.Items.Add(tabItem);
}
}
/// <summary>
/// Selects the tab depending on what control was clicked on.
/// </summary>
private void TabSelect(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var sender_border = (Border)sender;
// Get the name of the tab from the dashboard button's name
string tab_name = sender_border.Name.Replace("DashboardButton", "");
foreach (TabItem tab in TabController.Items)
{
string tab_control_name = tab.Content.GetType().Name.Replace("Tab", "");
if (tab_name == tab_control_name)
{
tab.IsSelected = true;
break;
}
}
}
}
}