-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
79 lines (72 loc) · 2.47 KB
/
App.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
using System;
using System.Configuration;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using NLog;
using WpfApp.Framework;
using WpfApp.Settings;
namespace WpfApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
/// <summary>Path to Camera.exe</summary>
public static readonly string WebcamPath = ConfigurationManager.AppSettings["WebcamPath"];
public const string WebcamArguments = "photo 1";
public static readonly Logger Logger = LogManager.GetLogger(string.Empty);
public App()
{
Startup += App_Startup;
Exit += App_Exit;
}
private void App_Startup(object sender, StartupEventArgs e)
{
Logger.Trace("On Startup");
WindowStateSaver.InitializeSettings();
var res = new ResourceDictionary {Source = GetFontsXamlUri()};
Resources.MergedDictionaries.Add(res);
}
private static void App_Exit(object sender, ExitEventArgs e)
{
WindowStateSaver.SaveAllSettings();
Logger.Trace("On Exit");
}
private static Uri GetFontsXamlUri()
{
var width = SystemParameters.PrimaryScreenWidth;
var height = SystemParameters.PrimaryScreenHeight;
string xaml;
if (width <= 1366 || height <= 768)
{
xaml = "/Dictionaries/Fonts_HD.xaml";
}
else if (width <= 1680 || height <= 1050)
{
xaml = "/Dictionaries/Fonts_HD2.xaml";
}
else
{
xaml = "/Dictionaries/Fonts_FullHD.xaml";
}
Console.WriteLine(xaml);
return new Uri(xaml, UriKind.Relative);
}
public static void EnsureAllDirectories()
{
if (Directory.Exists(AppFilePaths.PersonImages)) return;
Directory.CreateDirectory(AppFilePaths.PersonImages);
Logger.Trace("Directories was created");
}
public static SaveFileDialog GetDocumentSaveFileDialog(string fileName)
{
if (_documentSaveFileDialog == null)
_documentSaveFileDialog = new SaveFileDialog { Filter = "Word|*.docx" };
_documentSaveFileDialog.FileName = fileName;
return _documentSaveFileDialog;
}
private static SaveFileDialog _documentSaveFileDialog;
}
}