-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStreams.xaml.cs
77 lines (67 loc) · 2.16 KB
/
Streams.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
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
// ReSharper disable RedundantExtendsListEntry
namespace NutzCode.MPVPlayer.WPF.Wrapper
{
/// <summary>
/// Interaction logic for Streams.xaml
/// </summary>
public partial class Streams : Window
{
public delegate void StreamChangedHandler(Stream s);
private readonly bool _canbeunselected;
public Streams(string title, bool canbeunselected)
{
_canbeunselected = canbeunselected;
InitializeComponent();
Title = title;
MouseDown += Streams_MouseDown;
}
public event StreamChangedHandler StreamChanged;
private void Streams_MouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void ToggleButton_OnChecked(object sender, RoutedEventArgs e)
{
CheckBox chk = (CheckBox) sender;
Stream str = (Stream) chk.DataContext;
ObservableCollection<Stream> s = (ObservableCollection<Stream>) DataContext;
if (!str.Selected)
{
if (_canbeunselected)
{
StreamChanged?.Invoke(null);
return;
}
str.Selected = true;
e.Handled = true;
}
else
{
Stream n = s.FirstOrDefault(a => a.Selected && a != str);
if (n != null)
n.Selected = false;
StreamChanged?.Invoke(str);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
Visibility = Visibility.Hidden;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Window w = Owner;
Left = w.Left + w.Width - ActualWidth;
Top = w.Top + w.Height - ActualHeight - 48;
}
}
}