forked from henryshunt/dcim-ingester
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
91 lines (79 loc) · 3.14 KB
/
App.xaml.cs
File metadata and controls
91 lines (79 loc) · 3.14 KB
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
85
86
87
88
89
90
91
using DcimIngester.Windows;
using Hardcodet.Wpf.TaskbarNotification;
using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
namespace DcimIngester
{
public partial class App : Application
{
private MainWindow? mainWindow = null;
/// <summary>
/// Indicates whether the settings window is currently open.
/// </summary>
public bool IsSettingsOpen { get; private set; } = false;
private void Application_Startup(object sender, StartupEventArgs e)
{
if (DcimIngester.Properties.Settings.Default.Destination.Length == 0)
{
if (new Settings().ShowDialog() == false)
Shutdown();
}
TaskbarIcon taskbarIcon = new TaskbarIcon
{
ToolTip = "DCIM Ingester",
ContextMenu = (ContextMenu)FindResource("TaskbarIconContextMenu")
};
using (Stream stream = GetResourceStream(new Uri(
"pack://application:,,,/DcimIngester;component/Icon.ico")).Stream)
{
taskbarIcon.Icon = new Icon(stream);
}
taskbarIcon.Visibility = Visibility.Visible;
mainWindow = new MainWindow();
// Need to show the window to get the Loaded event to trigger
mainWindow.Show();
mainWindow.Hide();
}
private void MenuItemSettings_Click(object sender, RoutedEventArgs e)
{
if (mainWindow!.IngestsInWork > 0)
{
MessageBox.Show("Dismiss all ingests before opening Settings.", "DCIM Ingester",
MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK,
MessageBoxOptions.DefaultDesktopOnly);
}
else
{
IsSettingsOpen = true;
Settings settings = new Settings();
settings.Closed += delegate { IsSettingsOpen = false; };
settings.ShowDialog();
}
}
private void MenuItemAbout_Click(object sender, RoutedEventArgs e)
{
FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);
string versionString = string.Format("{0} V{1}. Created by {2}.",
versionInfo.ProductName, versionInfo.FileVersion, versionInfo.CompanyName);
MessageBox.Show(versionString, "DCIM Ingester", MessageBoxButton.OK,
MessageBoxImage.Information, MessageBoxResult.OK,
MessageBoxOptions.DefaultDesktopOnly);
}
private void MenuItemExit_Click(object sender, RoutedEventArgs e)
{
if (mainWindow!.IngestsInWork > 0)
{
MessageBox.Show("Dismiss all ingests before exiting.", "DCIM Ingester",
MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK,
MessageBoxOptions.DefaultDesktopOnly);
}
else Shutdown();
}
}
}