From bed3fc397abb241dd1c2cbc3b696af55c7884b8c Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 12 Aug 2024 12:40:23 +0200 Subject: [PATCH] Add copy shipname button to search control --- ENI2/Properties/Resources.Designer.cs | 9 +++++++++ ENI2/Properties/Resources.resx | 3 +++ ENI2/SucheControl.xaml.cs | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/ENI2/Properties/Resources.Designer.cs b/ENI2/Properties/Resources.Designer.cs index a3598a87..b0785c7c 100644 --- a/ENI2/Properties/Resources.Designer.cs +++ b/ENI2/Properties/Resources.Designer.cs @@ -1631,6 +1631,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Copy ship name to clipboard. + /// + public static string textCopyShipnameClip { + get { + return ResourceManager.GetString("textCopyShipnameClip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Copy to {0}. /// diff --git a/ENI2/Properties/Resources.resx b/ENI2/Properties/Resources.resx index 934c48c6..90425238 100644 --- a/ENI2/Properties/Resources.resx +++ b/ENI2/Properties/Resources.resx @@ -1606,6 +1606,9 @@ Copy Id to clipboard + + Copy ship name to clipboard + Server status update diff --git a/ENI2/SucheControl.xaml.cs b/ENI2/SucheControl.xaml.cs index fae3ecfb..3bd879e1 100644 --- a/ENI2/SucheControl.xaml.cs +++ b/ENI2/SucheControl.xaml.cs @@ -46,16 +46,25 @@ namespace ENI2 this.dataGrid.ContextMenu = new ContextMenu(); this.dataGrid.CanUserAddRows = false; this.dataGrid.ContextMenuOpening += ContextMenu_ContextMenuOpening; + MenuItem addItem = new MenuItem(); addItem.Header = Properties.Resources.textCopyClip; addItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; addItem.Click += this.copyID; this.dataGrid.ContextMenu.Items.Add(addItem); + MenuItem copyIMOItem = new MenuItem(); copyIMOItem.Header = Properties.Resources.textCopyIMO; copyIMOItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/document_into.png")) }; copyIMOItem.Click += this.copyIMO; this.dataGrid.ContextMenu.Items.Add(copyIMOItem); + + MenuItem copyShipnameItem = new MenuItem(); + copyShipnameItem.Header = Properties.Resources.textCopyShipnameClip; + copyShipnameItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/documents.png")) }; + copyShipnameItem.Click += this.copyShipname; + this.dataGrid.ContextMenu.Items.Add(copyShipnameItem); + cancelItem = new MenuItem(); cancelItem.Header = Properties.Resources.textUndoCancel; cancelItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/delete.png")) }; @@ -302,6 +311,17 @@ namespace ENI2 } } + private void copyShipname(object sender, RoutedEventArgs e) + { + if (dataGrid.SelectedItem is MessageCore selectedCore) + { + if (selectedCore.Shipname != null) + { + Clipboard.SetText(selectedCore.Shipname); + } + } + } + private void copyIMO(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem is MessageCore selectedCore)