From 344b511ae1ba90c218be8a3fa939894859ea5819 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sun, 7 May 2017 11:37:08 +0000 Subject: [PATCH] =?UTF-8?q?Tabs=20statt=20ersetzte=20Windows,=20MainFrame?= =?UTF-8?q?=20bereinigt,=20L=C3=B6sung=20f=C3=BCr=20lokalisierte=20Lookups?= =?UTF-8?q?=20in=20der=20SQLite=20Datenbank=20gefunden!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ENI-2/ENI2/ENI2/App.xaml.cs | 20 +++- ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs | 91 ++++++++++++++++++ .../PortNotificationDetailControl.xaml | 2 +- ENI-2/ENI2/ENI2/ENI2.csproj | 2 + ENI-2/ENI2/ENI2/LocalizedLookup.cs | 44 +++++++++ ENI-2/ENI2/ENI2/MainWindow.xaml | 13 ++- ENI-2/ENI2/ENI2/MainWindow.xaml.cs | 46 ++++++--- .../ENI2/Properties/Resources.Designer.cs | 9 ++ ENI-2/ENI2/ENI2/Properties/Resources.de.resx | 3 + ENI-2/ENI2/ENI2/Properties/Resources.resx | 3 + ENI-2/ENI2/ENI2/SucheControl.xaml.cs | 1 + ENI-2/ENI2/ENI2/Themes/Generic.xaml | 15 +++ Stundensheet.xlsx | Bin 29994 -> 30116 bytes .../bsmd.ExcelReadService/ExcelReader.cs | 48 ++++++++- nsw/Source/bsmd.database/LADG.cs | 24 ++++- .../Properties/AssemblyProductInfo.cs | 2 +- .../Properties/AssemblyProjectInfo.cs | 2 +- nsw/Source/misc/db.sqlite | Bin 11993088 -> 11997184 bytes 18 files changed, 302 insertions(+), 23 deletions(-) create mode 100644 ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs create mode 100644 ENI-2/ENI2/ENI2/LocalizedLookup.cs diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs index f978a99d..fa1e4599 100644 --- a/ENI-2/ENI2/ENI2/App.xaml.cs +++ b/ENI-2/ENI2/ENI2/App.xaml.cs @@ -1,9 +1,12 @@ // Copyright (c) 2017 Informatibüro Daniel Schick +using System.Collections.Generic; using System.Globalization; using System.Windows; using System.Windows.Markup; +using bsmd.database; + namespace ENI2 { /// @@ -17,10 +20,25 @@ namespace ENI2 this.Dispatcher.UnhandledException += Dispatcher_UnhandledException; FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), - new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); + new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); + } + + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + // initialize static / localized lookups from sqlite database + + string langKey = CultureInfo.CurrentCulture.TwoLetterISOLanguageName; + + Dictionary cargoHandlingDict = LocalizedLookup.getLADGCargoHandlingStrings(langKey); + foreach (int key in cargoHandlingDict.Keys) + LADG.CargoHandlingDict.Add(key, cargoHandlingDict[key]); + } + 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); diff --git a/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs new file mode 100644 index 00000000..59682f0c --- /dev/null +++ b/ENI-2/ENI2/ENI2/Controls/ClosableTabItem.cs @@ -0,0 +1,91 @@ +// Copyright (c) 2017 schick Informatik +// Description: Custom tab item +// + +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; + +namespace ENI2.Controls +{ + /// + /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file. + /// + /// Step 1a) Using this custom control in a XAML file that exists in the current project. + /// Add this XmlNamespace attribute to the root element of the markup file where it is + /// to be used: + /// + /// xmlns:MyNamespace="clr-namespace:ENI2.Controls" + /// + /// + /// Step 1b) Using this custom control in a XAML file that exists in a different project. + /// Add this XmlNamespace attribute to the root element of the markup file where it is + /// to be used: + /// + /// xmlns:MyNamespace="clr-namespace:ENI2.Controls;assembly=ENI2.Controls" + /// + /// You will also need to add a project reference from the project where the XAML file lives + /// to this project and Rebuild to avoid compilation errors: + /// + /// Right click on the target project in the Solution Explorer and + /// "Add Reference"->"Projects"->[Browse to and select this project] + /// + /// + /// Step 2) + /// Go ahead and use your control in the XAML file. + /// + /// + /// + /// + public class ClosableTabItem : TabItem + { + /* + static ClosableTabItem() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(ClosableTabItem), new FrameworkPropertyMetadata(typeof(ClosableTabItem))); + } + */ + + public void SetHeaderText(string headerText) + { + // Container for header controls + var dockPanel = new DockPanel(); + var header = new TextBlock { Text = headerText }; + dockPanel.Children.Add(header); + + // Close button to remove the tab + var closeButton = new Button(); + closeButton.Content = "X"; + closeButton.Margin = new Thickness(5, 0, 0, 0); + closeButton.Foreground = Brushes.Red; + closeButton.Height = 18; + closeButton.Width = 15; + closeButton.Opacity = 0.2; + closeButton.FontSize = 8; + closeButton.FontWeight = FontWeights.Bold; + + closeButton.MouseEnter += (sender, e) => { + DoubleAnimation animation = new DoubleAnimation(0.2, 1.0, new TimeSpan(0, 0, 0, 0, 500)); + closeButton.BeginAnimation(Button.OpacityProperty, animation); + }; + closeButton.MouseLeave += (sender, e) => { + DoubleAnimation animation = new DoubleAnimation(1.0, 0.2, new TimeSpan(0, 0, 0, 0, 500)); + closeButton.BeginAnimation(Button.OpacityProperty, animation); + }; + + closeButton.Click += + (sender, e) => + { + var tabControl = Parent as ItemsControl; + tabControl.Items.Remove(this); + }; + dockPanel.Children.Add(closeButton); + + // Set the header + Header = dockPanel; + } + + } +} diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml index dfc63057..49049f65 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml +++ b/ENI-2/ENI2/ENI2/DetailViewControls/PortNotificationDetailControl.xaml @@ -80,7 +80,7 @@ - + diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 3d5b4898..32300cde 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -159,6 +159,7 @@ Locode\LocodeDB.cs + @@ -217,6 +218,7 @@ EditSERVDialog.xaml + SucheControl.xaml diff --git a/ENI-2/ENI2/ENI2/LocalizedLookup.cs b/ENI-2/ENI2/ENI2/LocalizedLookup.cs new file mode 100644 index 00000000..c1f6f633 --- /dev/null +++ b/ENI-2/ENI2/ENI2/LocalizedLookup.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2017 schick Informatik +// Description: Alle Lookup-Tabellen für das Display statisch aus der SQLite Datenbank initialisieren +// + +using System.Data; +using System.Data.SQLite; +using System.Collections.Generic; + +namespace ENI2 +{ + static class LocalizedLookup + { + private static SQLiteConnection _con; + private const string _locode_DB_NAME = "db.sqlite"; + + static LocalizedLookup() + { + _con = new SQLiteConnection(string.Format("data source={0}; Version=3;", _locode_DB_NAME)); + _con.Open(); + } + + public static Dictionary getLADGCargoHandlingStrings(string languageCode) + { + Dictionary result = new Dictionary(); + string query = string.Format("SELECT key, text FROM LADG_CargoHandlingCodes WHERE langKey = '{0}'", languageCode); + + SQLiteCommand cmd = new SQLiteCommand(query, _con); + IDataReader reader = cmd.ExecuteReader(); + int key; + string text; + while (reader.Read()) + { + key = reader.GetInt32(0); + text = reader.GetString(1); + result[key] = text; + } + reader.Close(); + return result; + } + + + + } +} diff --git a/ENI-2/ENI2/ENI2/MainWindow.xaml b/ENI-2/ENI2/ENI2/MainWindow.xaml index 550c6c4d..f41b791c 100644 --- a/ENI-2/ENI2/ENI2/MainWindow.xaml +++ b/ENI-2/ENI2/ENI2/MainWindow.xaml @@ -16,9 +16,10 @@ -