diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs index fa1e4599..325415f6 100644 --- a/ENI-2/ENI2/ENI2/App.xaml.cs +++ b/ENI-2/ENI2/ENI2/App.xaml.cs @@ -6,6 +6,9 @@ using System.Windows; using System.Windows.Markup; using bsmd.database; +using System.Windows.Controls; +using System.Windows.Input; +using System; namespace ENI2 { @@ -35,15 +38,42 @@ namespace ENI2 foreach (int key in cargoHandlingDict.Keys) LADG.CargoHandlingDict.Add(key, cargoHandlingDict[key]); - + EventManager.RegisterClassHandler(typeof(DatePicker), DatePicker.PreviewKeyDownEvent, new KeyEventHandler(this.DatePicker_PreviewKeyDown)); } - private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { string errorMessage = string.Format("An unhandled exception occurred: {0}\r\n{1}", e.Exception.Message, e.Exception.StackTrace); MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Handled = true; } + + private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) + { + var dp = sender as DatePicker; + if (dp == null) return; + + if (e.Key == Key.D && Keyboard.Modifiers == ModifierKeys.Control) + { + e.Handled = true; + dp.SetValue(DatePicker.SelectedDateProperty, DateTime.Today); + return; + } + + if (!dp.SelectedDate.HasValue) return; + + var date = dp.SelectedDate.Value; + if (e.Key == Key.Up) + { + e.Handled = true; + dp.SetValue(DatePicker.SelectedDateProperty, date.AddDays(1)); + } + else if (e.Key == Key.Down) + { + e.Handled = true; + dp.SetValue(DatePicker.SelectedDateProperty, date.AddDays(-1)); + } + } + } } diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs index fdcf6dca..0b59f80e 100644 --- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs +++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs @@ -4,15 +4,10 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Controls; using bsmd.database; using System.Windows.Media.Imaging; -using System.Windows; -using System.Windows.Input; namespace ENI2 { @@ -21,6 +16,8 @@ namespace ENI2 protected bool _initialized = false; + #region enum + protected enum LocodeState { UNKNOWN, @@ -30,6 +27,18 @@ namespace ENI2 } + #endregion + + #region events + + /// + /// Mit diesem event kann ein Listenelement den programmatischen Sprung auf ein anderes Listenelement auslösen + /// (das wird zunächst nur vom Overview -> Auswahl Meldeklasse verwendet) + /// + public event Action JumpToListElementRequest; + + #endregion + #region Properties public MessageCore Core { get; set; } @@ -45,7 +54,11 @@ namespace ENI2 } - + + protected virtual void OnJumpToListElementRequest(int index) + { + this.JumpToListElementRequest?.Invoke(index); + } protected void SetLocodeStateImage(Image stateImage, LocodeState state) { diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs index ecb4a829..9f09799e 100644 --- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs @@ -4,18 +4,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using bsmd.database; using ENI2.DetailViewControls; @@ -58,7 +47,7 @@ namespace ENI2 this.listBoxMessages.ItemsSource = this._listBoxList; _messages = DBManager.Instance.GetMessagesForCore(_core, DBManager.MessageLoad.ALL); - + Dispatcher.BeginInvoke((Action)(() => this.listBoxMessages.SelectedIndex = 0)); } #region class MessageGroup @@ -85,6 +74,12 @@ namespace ENI2 DetailBaseControl detailControl = (DetailBaseControl) Activator.CreateInstance(mg.MessageGroupControlType); detailControl.Core = _core; detailControl.Messages = _messages; + detailControl.JumpToListElementRequest += (index) => { + if((index >= 0) && (index < _listBoxList.Count)) + { + this.listBoxMessages.SelectedIndex = index; + } + }; detailControl.Initialize(); // plug it in ;-) detailView.Children.Clear(); diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml index cf877955..2235de96 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml @@ -4,7 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" + xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:enictrl="clr-namespace:ENI2.Controls" xmlns:p="clr-namespace:ENI2.Properties" xmlns:local="clr-namespace:ENI2.DetailViewControls" @@ -25,7 +25,7 @@ -