Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SelectItemDialog.xaml.cs
1using System;
2using System.Windows;
3using System.Windows.Controls;
4using System.Windows.Input;
6
8{
12 public partial class SelectItemDialog : Window
13 {
14 public SelectItemDialog(string Title, string Header, string OkTooltip, string TypeHeader, string ValueHeader, params LocalizedString[] Items)
15 : base()
16 {
18
19 if (this.ItemsView.View is GridView GridView)
20 {
21 GridView.Columns[0].Header = TypeHeader;
22 GridView.Columns[1].Header = ValueHeader;
23 }
24
25 this.Title = Title;
26 this.Label.Content = Header;
27 this.OkButton.ToolTip = OkTooltip;
28
29 foreach (LocalizedString Item in Items)
30 this.ItemsView.Items.Add(new Item(Item));
31 }
32
33 public class Item
34 {
35 private LocalizedString s;
36
37 public Item(LocalizedString String)
38 {
39 this.s = String;
40 }
41
42 public LocalizedString LocalizedString => this.s;
43 public string Localized => this.s.Localized;
44 public string Unlocalized => this.s.Unlocalized;
45 }
46
47 private void CancelButton_Click(object Sender, RoutedEventArgs e)
48 {
49 this.DialogResult = false;
50 }
51
52 private void OkButton_Click(object Sender, RoutedEventArgs e)
53 {
54 this.DialogResult = true;
55 }
56
57 public LocalizedString? SelectedItem
58 {
59 get
60 {
61 if (this.ItemsView.SelectedItem is Item Item)
62 return Item.LocalizedString;
63 else
64 return null;
65 }
66 }
67
68 private void ItemsView_SelectionChanged(object Sender, SelectionChangedEventArgs e)
69 {
70 this.OkButton.IsEnabled = !(this.ItemsView.SelectedItem is null);
71 }
72
73 private void ItemsView_MouseDoubleClick(object Sender, MouseButtonEventArgs e)
74 {
75 if (!(this.ItemsView.SelectedItem is null))
76 this.DialogResult = true;
77 }
78 }
79}
Interaction logic for SelectItemDialog.xaml
string Localized
Localized (human readable) string.