-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathMainWindow.xaml.cs
96 lines (86 loc) · 3.39 KB
/
MainWindow.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
85
86
87
88
89
90
91
92
93
94
95
96
using GalaSoft.MvvmLight.Ioc;
using GalaSoft.MvvmLight.Messaging;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using vMixController.Messages;
using vMixController.ViewModel;
namespace vMixController
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
bool _loading = false;
/// <summary>
/// Initializes a new instance of the MainWindow class.
/// </summary>
public MainWindow()
{
InitializeComponent();
Closing += (s, e) =>
{
Ookii.Dialogs.Wpf.TaskDialog dialog = new Ookii.Dialogs.Wpf.TaskDialog();
dialog.Buttons.Add(new Ookii.Dialogs.Wpf.TaskDialogButton(Ookii.Dialogs.Wpf.ButtonType.Yes));
dialog.Buttons.Add(new Ookii.Dialogs.Wpf.TaskDialogButton(Ookii.Dialogs.Wpf.ButtonType.No));
dialog.WindowTitle = Extensions.LocalizationManager.Get("Exit confirmation");
dialog.MainIcon = Ookii.Dialogs.Wpf.TaskDialogIcon.Warning;
dialog.MainInstruction = Extensions.LocalizationManager.Get("Do you really want to quit?");
if (dialog.ShowDialog(this).ButtonType == Ookii.Dialogs.Wpf.ButtonType.No)
{
e.Cancel = true;
}
else
{
vMixController.Properties.Settings.Default.Save();
ViewModelLocator.Cleanup();
App.Current.Shutdown();
}
};
Messenger.Default.Register<LoadingMessage>(this, (msg) =>
{
var fadein = (Storyboard)FindResource("StoryboardFadeIn");
var fadeout = (Storyboard)FindResource("StoryboardFadeOut");
if (msg.Loading && !_loading)
{
fadein.Begin(Loading);
_loading = true;
}
else if (!msg.Loading && _loading)
{
fadeout.Begin(Loading);
_loading = false;
}
});
}
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer == null || (scrollViewer.Tag is bool && (bool)scrollViewer.Tag))
return;
if (Keyboard.Modifiers != ModifierKeys.Shift && scrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)
return;
if (e.Delta < 0)
scrollViewer.LineRight();
else
scrollViewer.LineLeft();
e.Handled = true;
}
private void Layout_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
/*if (SimpleIoc.Default.GetInstance<MainViewModel>().WindowSettings.Locked)
{
(sender as ListView).ContextMenu.IsOpen = false;
e.Handled = true;
}*/
}
}
}