|
10 | 10 | using TakeMyTime.WPF.ProjectTypes; |
11 | 11 | using TakeMyTime.WPF.Statistics; |
12 | 12 | using TakeMyTime.WPF.Utility; |
| 13 | +using TakeMyTime.WPF.Utility.Commands; |
13 | 14 |
|
14 | 15 | namespace TakeMyTime.WPF |
15 | 16 | { |
@@ -39,6 +40,7 @@ public MainWindow() |
39 | 40 |
|
40 | 41 | InitDataDirectory(); |
41 | 42 | InitializeComponent(); |
| 43 | + DataContext = this; |
42 | 44 | txt_Title.Text = "TakeMyTime " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5); |
43 | 45 | tb_CalendarWeek.Text = this.CurrentCalendarWeek; |
44 | 46 | fr_Content.Navigate(new Dashboard()); |
@@ -104,40 +106,81 @@ private void btn_ToggleWindow_Click(object sender, RoutedEventArgs e) |
104 | 106 |
|
105 | 107 | private void btn_Projects_Click(object sender, RoutedEventArgs e) |
106 | 108 | { |
107 | | - fr_Content.Navigate(new Projects.ProjectOverview()); |
| 109 | + NavigateToProjectOverview(); |
108 | 110 | } |
109 | 111 |
|
110 | 112 | private void btn_Assignments_Click(object sender, RoutedEventArgs e) |
111 | 113 | { |
112 | | - fr_Content.Navigate(new Assignments.AssignmentOverview()); |
| 114 | + NavigateToAssignmentOverview(); |
113 | 115 | } |
114 | 116 |
|
115 | 117 | private void btn_LogEntries_Click(object sender, RoutedEventArgs e) |
116 | 118 | { |
117 | | - fr_Content.Navigate(new Entries.EntryOverview()); |
| 119 | + NavigateToEntryOverview(); |
118 | 120 | } |
119 | 121 |
|
120 | 122 | private void btn_Dashboard_Click(object sender, RoutedEventArgs e) |
121 | 123 | { |
122 | | - fr_Content.Navigate(new Dashboard()); |
| 124 | + NavigateToDashboardOverview(); |
123 | 125 | } |
124 | 126 |
|
125 | 127 | private void btn_Settings_Click(object sender, RoutedEventArgs e) |
126 | 128 | { |
127 | | - fr_Content.Navigate(new ProjectTypeOverview()); |
| 129 | + NavigateToProjectTypes(); |
128 | 130 | } |
129 | 131 |
|
130 | 132 | private void btn_About_Click(object sender, RoutedEventArgs e) |
| 133 | + { |
| 134 | + NavigateToAbout(); |
| 135 | + } |
| 136 | + |
| 137 | + public void NavigateToProjectOverview() |
| 138 | + { |
| 139 | + fr_Content.Navigate(new Projects.ProjectOverview()); |
| 140 | + } |
| 141 | + |
| 142 | + public void NavigateToAssignmentOverview() |
| 143 | + { |
| 144 | + fr_Content.Navigate(new Assignments.AssignmentOverview()); |
| 145 | + } |
| 146 | + |
| 147 | + public void NavigateToEntryOverview() |
| 148 | + { |
| 149 | + fr_Content.Navigate(new Entries.EntryOverview()); |
| 150 | + } |
| 151 | + |
| 152 | + public void NavigateToDashboardOverview() |
| 153 | + { |
| 154 | + fr_Content.Navigate(new Dashboard()); |
| 155 | + } |
| 156 | + |
| 157 | + public void NavigateToProjectTypes() |
| 158 | + { |
| 159 | + fr_Content.Navigate(new ProjectTypeOverview()); |
| 160 | + } |
| 161 | + |
| 162 | + public void NavigateToAbout() |
131 | 163 | { |
132 | 164 | fr_Content.Navigate(new About.About()); |
133 | 165 | } |
134 | 166 |
|
| 167 | + |
| 168 | + |
135 | 169 | #endregion |
136 | 170 |
|
137 | 171 | #endregion |
138 | 172 |
|
139 | 173 | public string CurrentCalendarWeek { get => string.Format("{0}: {1}", ResourceStringManager.GetResourceByKey("CalendarWeek"), DateTimeCultureConverter.GetCalendarWeek()); } |
140 | 174 |
|
141 | | - |
| 175 | + #region Commands |
| 176 | + |
| 177 | + public NavigationCommand DashboardCommand { get => new NavigationCommand(() => this.NavigateToDashboardOverview()); } |
| 178 | + public NavigationCommand ProjectOverviewCommand { get => new NavigationCommand(() => this.NavigateToProjectOverview()); } |
| 179 | + public NavigationCommand ProjectTypeCommand { get => new NavigationCommand(() => this.NavigateToProjectTypes()); } |
| 180 | + public NavigationCommand AssignmentOverviewCommand { get => new NavigationCommand(() => this.NavigateToAssignmentOverview()); } |
| 181 | + public NavigationCommand EntryCommand { get => new NavigationCommand(() => this.NavigateToEntryOverview()); } |
| 182 | + public NavigationCommand AboutCommand { get => new NavigationCommand(() => this.NavigateToAbout()); } |
| 183 | + |
| 184 | + #endregion |
142 | 185 | } |
143 | 186 | } |
0 commit comments