Browse Source

Added always start on today check box

Kenric Nugteren 1 year ago
parent
commit
e82f7723a3

+ 14 - 1
prs.desktop/Components/Calendar/Calendar.xaml

@@ -120,6 +120,7 @@
                     <RowDefinition Height="Auto" />                
                     <RowDefinition Height="Auto" />
                     <RowDefinition Height="Auto" />
+                    <RowDefinition Height="Auto" />
                 </Grid.RowDefinitions>
                 
                 <DockPanel 
@@ -299,7 +300,19 @@
                     <TextBox x:Name="ZoomSelector" IsReadOnly="True" DockPanel.Dock="Left" BorderThickness="0,0.75,0,0.75"
                              BorderBrush="Gray" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                 </DockPanel>
-                
+
+                <DockPanel Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2"
+                           Margin="0,5,0,0">
+                    <CheckBox DockPanel.Dock="Right"
+                              x:Name="AlwaysTodayBox"
+                              Checked="AlwaysTodayBox_Checked"
+                              Unchecked="AlwaysTodayBox_Checked"
+                              VerticalAlignment="Center"/>
+                    <Label Content="Always Start On Today" DockPanel.Dock="Left"
+                           VerticalContentAlignment="Center"/>
+                </DockPanel>
+
+
             </Grid>
             
        </dynamicGrid:DynamicSplitPanel.Detail>

+ 10 - 1
prs.desktop/Components/Calendar/Calendar.xaml.cs

@@ -721,7 +721,7 @@ namespace PRSDesktop
                 Properties = LoadSettings?.Invoke(this) ?? new CalendarSettings();
                 SetCalendarView(Properties.CalendarView);
                 SetSettingsVisibility(Properties.SettingsVisible);
-                SetSelectedDate(Properties.Date);
+                SetSelectedDate(Properties.AlwaysStartOnToday ? DateTime.Today : Properties.Date);
                 SetStartHour(Properties.StartHour);
                 SetEndHour(Properties.EndHour);
                 SetTimeInterval(Properties.TimeInterval);
@@ -732,6 +732,7 @@ namespace PRSDesktop
                 EmployeeSelector.Setup();
                 SetEmployeeSettings(Properties.EmployeeSelector);
                 SetEmployeeSelection(Properties.EmployeeSelection);
+                AlwaysTodayBox.IsChecked = Properties.AlwaysStartOnToday;
                 
                 _employees = EmployeeSelector.GetEmployeeData((row, rosters) => new EmployeeResourceModel(row, rosters));
                 
@@ -1642,5 +1643,13 @@ namespace PRSDesktop
                 return;
             SelectedDate = e.VisibleDateRange.StartDate.Date;
         }
+
+        private void AlwaysTodayBox_Checked(object sender, RoutedEventArgs e)
+        {
+            if (EventSuppressor.IsSet(Suppress.Events)) return;
+
+            Properties.AlwaysStartOnToday = AlwaysTodayBox.IsChecked == true;
+            SaveSettings?.Invoke(this, Properties);
+        }
     }
 }

+ 1 - 0
prs.desktop/Components/Calendar/CalendarSettings.cs

@@ -6,6 +6,7 @@ namespace PRSDesktop
 {
     public class CalendarSettings : IUserConfigurationSettings, IDashboardProperties
     {
+        public bool AlwaysStartOnToday { get; set; } = false;
         
         public CalendarViewType CalendarView { get; set; }
         public DateTime Date { get; set; }