-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAboutWindow.xaml.cs
84 lines (69 loc) · 2.61 KB
/
AboutWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using Hardcodet.Wpf.TaskbarNotification;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace PC2MQTT
{
/// <summary>
/// Interaction logic for AboutWindow.xaml
/// </summary>
public partial class AboutWindow : Window
{
#region Private Fields
private TaskbarIcon _notifyIcon;
private MqttService _mqttService;
private List<string> _entityNames;
#endregion Private Fields
#region Public Constructors
public AboutWindow(string deviceId, TaskbarIcon notifyIcon, List<string> entityNames)
{
InitializeComponent();
DataContext = this;
_notifyIcon = notifyIcon;
_entityNames = entityNames;
EntitiesListBox.ItemsSource = _entityNames;
SetVersionInfo();
}
#endregion Public Constructors
#region Private Methods
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void CopyMenuItem_Click(object sender, RoutedEventArgs e)
{
if (sender is MenuItem menuItem && menuItem.CommandParameter is string textToCopy)
{
Clipboard.SetText(textToCopy);
// Show the balloon tip
_notifyIcon.ShowBalloonTip("Copied to Clipboard", textToCopy + " has been copied to your clipboard.", BalloonIcon.Info);
}
}
private void EntitiesListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (sender is System.Windows.Controls.ListBox listBox && listBox.SelectedItem != null)
{
string selectedEntity = listBox.SelectedItem.ToString();
System.Windows.Clipboard.SetText(selectedEntity);
// Show balloon tip
_notifyIcon.ShowBalloonTip("Copied to Clipboard", selectedEntity + " has been copied to your clipboard.", BalloonIcon.Info);
}
}
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = e.Uri.AbsoluteUri,
UseShellExecute = true
});
e.Handled = true;
}
private void SetVersionInfo()
{
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
this.VersionTextBlock.Text = $"Version: {version}";
}
#endregion Private Methods
}
}