Skip to content
This repository was archived by the owner on Oct 3, 2022. It is now read-only.

Commit 7a2777b

Browse files
authored
Merge pull request #44 from BinderDyn/Enable-menu-navigation-by-arrow-keys-and-enter-key
Navigation via keys
2 parents 8a5a805 + e455f09 commit 7a2777b

21 files changed

+195
-23
lines changed

TakeMyTime.WPF/Assignments/AssignmentOverview.xaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@
77
xmlns:resources="clr-namespace:TakeMyTime.WPF.Resources"
88
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
99
mc:Ignorable="d"
10-
d:DesignHeight="450" d:DesignWidth="800"
10+
d:DesignHeight="600" d:DesignWidth="800"
1111
Title="AssignmentOverview"
1212
Background="{StaticResource BackgroundGrey}">
1313
<Grid>
1414
<Grid.RowDefinitions>
15+
<RowDefinition Height="50"></RowDefinition>
1516
<RowDefinition Height="70"></RowDefinition>
1617
<RowDefinition Height="*"></RowDefinition>
1718
<RowDefinition Height="70"></RowDefinition>
1819
<RowDefinition Height="70"></RowDefinition>
1920
</Grid.RowDefinitions>
2021
<Grid.ColumnDefinitions>
2122
</Grid.ColumnDefinitions>
23+
<Label
24+
Foreground="{StaticResource LightWhite}"
25+
FontSize="22"
26+
FontWeight="Bold"
27+
Content="{x:Static resources:AssignmentOverview.Title}"
28+
></Label>
2229
<Border x:Name="b_Toolbar"
23-
Grid.Row="0"
30+
Grid.Row="1"
2431
BorderBrush="Transparent"
2532
Visibility="Visible">
2633
<StackPanel Margin="3"
@@ -110,7 +117,7 @@
110117
<ListView x:Name="lv_Assignments"
111118
ItemsSource="{Binding FilteredAssignmentViewModels}"
112119
HorizontalAlignment="Stretch"
113-
Grid.Row="1"
120+
Grid.Row="2"
114121
Foreground="{StaticResource LightWhite}"
115122
Margin="18"
116123
Visibility="Visible"
@@ -201,7 +208,7 @@
201208
</GridView>
202209
</ListView.View>
203210
</ListView>
204-
<Border Grid.Row="2">
211+
<Border Grid.Row="3">
205212
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
206213
<Button x:Name="btn_PagingBack" Background="Black" Click="btn_PagingBack_Click">
207214
<materialDesign:PackIcon Kind="ArrowLeft"></materialDesign:PackIcon>
@@ -216,7 +223,7 @@
216223
</StackPanel>
217224
</Border>
218225
<StackPanel
219-
Grid.Row="3"
226+
Grid.Row="4"
220227
Orientation="Horizontal"
221228
HorizontalAlignment="Center">
222229
<Button x:Name="btn_SetDone"

TakeMyTime.WPF/Entries/EntryOverview.xaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111
Background="{StaticResource BackgroundGrey}">
1212
<Grid>
1313
<Grid.RowDefinitions>
14+
<RowDefinition Height="50"></RowDefinition>
1415
<RowDefinition Height="50"></RowDefinition>
1516
<RowDefinition Height="30"></RowDefinition>
1617
<RowDefinition Height="*"></RowDefinition>
1718
<RowDefinition Height="60"></RowDefinition>
1819
</Grid.RowDefinitions>
19-
<Border Grid.Row="0">
20+
<Label
21+
FontWeight="Bold"
22+
FontSize="22"
23+
Content="{x:Static resources:EntryOverview.Title}"
24+
Foreground="{StaticResource LightWhite}"
25+
></Label>
26+
<Border Grid.Row="1">
2027
<StackPanel Margin="3"
2128
Orientation="Horizontal"
2229
HorizontalAlignment="Left"
@@ -49,7 +56,7 @@
4956
</ComboBox>
5057
</StackPanel>
5158
</Border>
52-
<StackPanel Grid.Row="1"
59+
<StackPanel Grid.Row="2"
5360
Orientation="Horizontal"
5461
HorizontalAlignment="Right"
5562
>
@@ -74,7 +81,7 @@
7481
Orientation="Vertical">-->
7582
<ListView x:Name="lv_Entries"
7683
SelectionChanged="lv_Entries_SelectionChanged"
77-
Grid.Row="2" Background="{StaticResource BackgroundGrey}" Foreground="{StaticResource LightWhite}" ScrollViewer.CanContentScroll="False">
84+
Grid.Row="3" Background="{StaticResource BackgroundGrey}" Foreground="{StaticResource LightWhite}" ScrollViewer.CanContentScroll="False">
7885
<ListView.View>
7986
<GridView>
8087
<GridView.Columns>
@@ -96,7 +103,7 @@
96103
</GridView>
97104
</ListView.View>
98105
</ListView>
99-
<Border Grid.Row="3">
106+
<Border Grid.Row="4">
100107
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
101108
<Button x:Name="btn_PagingBack" Background="Black" Click="btn_PagingBack_Click">
102109
<materialDesign:PackIcon Kind="ArrowLeft"></materialDesign:PackIcon>

TakeMyTime.WPF/MainWindow.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
AllowsTransparency="True"
1919
ResizeMode="CanResizeWithGrip"
2020
>
21+
<Window.InputBindings>
22+
<KeyBinding Command="{Binding DashboardCommand}" Modifiers="Ctrl" Key="D"></KeyBinding>
23+
<KeyBinding Command="{Binding AssignmentOverviewCommand}" Modifiers="Ctrl" Key="A"></KeyBinding>
24+
<KeyBinding Command="{Binding EntryCommand}" Modifiers="Ctrl" Key="E"></KeyBinding>
25+
<KeyBinding Command="{Binding AboutCommand}" Modifiers="Ctrl" Key="X"></KeyBinding>
26+
<KeyBinding Command="{Binding ProjectTypeCommand}" Modifiers="Ctrl" Key="T"></KeyBinding>
27+
<KeyBinding Command="{Binding ProjectOverviewCommand}" Modifiers="Ctrl" Key="P"></KeyBinding>
28+
</Window.InputBindings>
2129
<Grid>
2230
<Grid.Resources>
2331
<Storyboard x:Key="MenuOpen">

TakeMyTime.WPF/MainWindow.xaml.cs

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using TakeMyTime.WPF.ProjectTypes;
1111
using TakeMyTime.WPF.Statistics;
1212
using TakeMyTime.WPF.Utility;
13+
using TakeMyTime.WPF.Utility.Commands;
1314

1415
namespace TakeMyTime.WPF
1516
{
@@ -39,6 +40,7 @@ public MainWindow()
3940

4041
InitDataDirectory();
4142
InitializeComponent();
43+
DataContext = this;
4244
txt_Title.Text = "TakeMyTime " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Substring(0, 5);
4345
tb_CalendarWeek.Text = this.CurrentCalendarWeek;
4446
fr_Content.Navigate(new Dashboard());
@@ -104,40 +106,81 @@ private void btn_ToggleWindow_Click(object sender, RoutedEventArgs e)
104106

105107
private void btn_Projects_Click(object sender, RoutedEventArgs e)
106108
{
107-
fr_Content.Navigate(new Projects.ProjectOverview());
109+
NavigateToProjectOverview();
108110
}
109111

110112
private void btn_Assignments_Click(object sender, RoutedEventArgs e)
111113
{
112-
fr_Content.Navigate(new Assignments.AssignmentOverview());
114+
NavigateToAssignmentOverview();
113115
}
114116

115117
private void btn_LogEntries_Click(object sender, RoutedEventArgs e)
116118
{
117-
fr_Content.Navigate(new Entries.EntryOverview());
119+
NavigateToEntryOverview();
118120
}
119121

120122
private void btn_Dashboard_Click(object sender, RoutedEventArgs e)
121123
{
122-
fr_Content.Navigate(new Dashboard());
124+
NavigateToDashboardOverview();
123125
}
124126

125127
private void btn_Settings_Click(object sender, RoutedEventArgs e)
126128
{
127-
fr_Content.Navigate(new ProjectTypeOverview());
129+
NavigateToProjectTypes();
128130
}
129131

130132
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()
131163
{
132164
fr_Content.Navigate(new About.About());
133165
}
134166

167+
168+
135169
#endregion
136170

137171
#endregion
138172

139173
public string CurrentCalendarWeek { get => string.Format("{0}: {1}", ResourceStringManager.GetResourceByKey("CalendarWeek"), DateTimeCultureConverter.GetCalendarWeek()); }
140174

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
142185
}
143186
}

TakeMyTime.WPF/ProjectTypes/ProjectTypeOverview.xaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
Title="ProjectTypeOverview">
1414
<Grid>
1515
<Grid.RowDefinitions>
16+
<RowDefinition Height="60"></RowDefinition>
1617
<RowDefinition Height="60"></RowDefinition>
1718
<RowDefinition Height="*"></RowDefinition>
1819
<RowDefinition Height="60"></RowDefinition>
1920
</Grid.RowDefinitions>
20-
<Border Grid.Row="0">
21+
<Label Grid.Row="0" HorizontalAlignment="Left"
22+
FontSize="22"
23+
FontWeight="Bold"
24+
Foreground="{StaticResource LightWhite}"
25+
Content="{x:Static resource:ProjectTypeOverview.Title}"></Label>
26+
<Border Grid.Row="1">
2127
<StackPanel HorizontalAlignment="Right"
2228
Orientation="Horizontal">
2329
<Button x:Name="btn_AddProjectType"
@@ -46,7 +52,7 @@
4652
</StackPanel>
4753
</Border>
4854
<ListView x:Name="dg_ProjectTypes" SelectionChanged="dg_ProjectTypes_SelectionChanged"
49-
Grid.Row="1"
55+
Grid.Row="2"
5056
Background="{StaticResource BackgroundGrey}"
5157
Foreground="{StaticResource LightWhite}">
5258
<ListView.View>
@@ -58,7 +64,7 @@
5864
</GridView>
5965
</ListView.View>
6066
</ListView>
61-
<Border Grid.Row="2">
67+
<Border Grid.Row="3">
6268
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
6369
<Button x:Name="btn_PagingBack" Background="Black" Click="btn_PagingBack_Click">
6470
<materialDesign:PackIcon Kind="ArrowLeft"></materialDesign:PackIcon>

TakeMyTime.WPF/Projects/ProjectOverview.xaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,19 @@
1313

1414
<Grid>
1515
<Grid.RowDefinitions>
16+
<RowDefinition Height="50"></RowDefinition>
1617
<RowDefinition Height="70"></RowDefinition>
1718
<RowDefinition Height="*"></RowDefinition>
1819
<RowDefinition Height="70"></RowDefinition>
1920
</Grid.RowDefinitions>
21+
<Label
22+
Grid.Row="0" HorizontalAlignment="Left"
23+
FontSize="22"
24+
FontWeight="Bold"
25+
Foreground="{StaticResource LightWhite}"
26+
Content="{x:Static resources:ProjectOverview.Title}"></Label>
2027
<Border x:Name="b_Toolbar"
21-
Grid.Row="0"
28+
Grid.Row="1"
2229
BorderBrush="Transparent"
2330
Visibility="Visible">
2431
<StackPanel Margin="3"
@@ -71,7 +78,7 @@
7178
<ListView x:Name="lv_Projects"
7279
ItemsSource="{Binding Projects}"
7380
HorizontalAlignment="Stretch"
74-
Grid.Row="1"
81+
Grid.Row="2"
7582
Foreground="{StaticResource LightWhite}"
7683
Margin="18"
7784
Visibility="Visible"
@@ -151,7 +158,7 @@
151158
</GridView>
152159
</ListView.View>
153160
</ListView>
154-
<Border Grid.Row="2">
161+
<Border Grid.Row="3">
155162
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
156163
<Button x:Name="btn_PagingBack" Background="Black" Click="btn_PagingBack_Click">
157164
<materialDesign:PackIcon Kind="ArrowLeft"></materialDesign:PackIcon>

TakeMyTime.WPF/Projects/ProjectOverview.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class ProjectOverview : Page
2323
public ProjectOverview()
2424
{
2525
InitializeComponent();
26-
PagingManager = new PagingManager<ProjectViewModel>();
26+
PagingManager = new PagingManager<ProjectViewModel>(18);
2727
Load();
2828
RefreshBindings(1);
2929
}

TakeMyTime.WPF/Resources/AssignmentOverview.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TakeMyTime.WPF/Resources/AssignmentOverview.de-DE.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,7 @@
171171
<data name="ProjectsAll" xml:space="preserve">
172172
<value>Alle Projekte</value>
173173
</data>
174+
<data name="Title" xml:space="preserve">
175+
<value>Aufgaben</value>
176+
</data>
174177
</root>

TakeMyTime.WPF/Resources/AssignmentOverview.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,7 @@
177177
<data name="ProjectsAll" xml:space="preserve">
178178
<value>All projects</value>
179179
</data>
180+
<data name="Title" xml:space="preserve">
181+
<value>Assignments</value>
182+
</data>
180183
</root>

0 commit comments

Comments
 (0)