blob: dfc6fefca6b61c874390703e828ca6d715d730e4 (
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
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PresetManagerView.xaml.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// Interaction logic for PresetManagerView.xaml
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Views
{
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using HandBrakeWPF.Services.Presets.Model;
using HandBrakeWPF.ViewModels;
public partial class PresetManagerView : Window
{
public PresetManagerView()
{
this.InitializeComponent();
this.Closing += this.PresetManagerView_Closing;
}
private void PresetManagerView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.Closing -= this.PresetManagerView_Closing;
((PresetManagerViewModel)this.DataContext).Close();
}
private void PresetTreeviewItemCollasped(object sender, RoutedEventArgs e)
{
if (e.Source.GetType() == typeof(TreeViewItem))
{
TreeViewItem item = e.Source as TreeViewItem;
if (item != null && item.DataContext?.GetType() == typeof(PresetDisplayCategory))
{
item.IsSelected = false;
}
}
}
private void PresetListTree_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (e.Source.GetType() == typeof(TreeView))
{
if (e.NewValue != null && e.NewValue.GetType() == typeof(Preset))
{
((PresetManagerViewModel)this.DataContext).SelectedPreset = (Preset)e.NewValue;
}
else if (e.NewValue != null && e.NewValue.GetType() == typeof(PresetDisplayCategory))
{
((PresetManagerViewModel)this.DataContext).SelectedPresetCategory = (PresetDisplayCategory)e.NewValue;
}
}
}
private void PresetListTree_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject);
if (treeViewItem != null)
{
treeViewItem.Focus();
e.Handled = true;
}
}
private static TreeViewItem VisualUpwardSearch(DependencyObject source)
{
while (source != null && !(source is TreeViewItem))
source = VisualTreeHelper.GetParent(source);
return source as TreeViewItem;
}
private void ToolBarLoaded(object sender, RoutedEventArgs e)
{
ToolBar toolBar = sender as ToolBar;
if (toolBar != null)
{
var overflowGrid = toolBar.Template.FindName("OverflowGrid", toolBar) as FrameworkElement;
if (overflowGrid != null)
{
overflowGrid.Visibility = Visibility.Collapsed;
}
}
}
}
}
|