aboutsummaryrefslogtreecommitdiffstats
path: root/WarframeClock/SettingsWindow.xaml.cs
blob: 10778c13a15bb329b78cca8f02485fb9dab54e61 (plain)
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
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Navigation;

namespace WarframeClock
{
    /// <summary>
    /// Interaction logic for SettingsWindow.xaml
    /// </summary>
    public partial class SettingsWindow : Window
    {
        private readonly OverlayWindowViewModel _vm;

        public SettingsWindow(OverlayWindowViewModel vm)
        {
            DataContext = _vm = vm;
            InitializeComponent();
        }

        protected override void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);

            _vm.SettingsMode = true;
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            Settings.Save();
            _vm.SettingsMode = false;
        }

        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(e.Uri.AbsoluteUri);
        }

        private void FontSettingsButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new System.Windows.Forms.FontDialog
            {
                Font = new System.Drawing.Font(
                    new System.Drawing.FontFamily(Settings.FontFamilyName),
                    (float)(Settings.FontSize * 72.0 / 96.0))
            };
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Settings.FontFamilyName = dialog.Font.FontFamily.Name;
                Settings.FontSize = dialog.Font.SizeInPoints / 72.0 * 96.0;
                _vm.RefreshFont();
            }
            dialog.Dispose();
        }
    }
}