forked from mkaring/ConfuserEx
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathProjectTabAdvancedView.xaml.cs
More file actions
71 lines (60 loc) · 2.23 KB
/
Copy pathProjectTabAdvancedView.xaml.cs
File metadata and controls
71 lines (60 loc) · 2.23 KB
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
using System;
using System.Diagnostics;
using System.Windows;
using CommunityToolkit.Mvvm.Input;
using ConfuserEx.ViewModel;
using Ookii.Dialogs.Wpf;
namespace ConfuserEx.Views {
public partial class ProjectTabAdvancedView : Window {
readonly ProjectVM project;
public ProjectTabAdvancedView(ProjectVM project) {
InitializeComponent();
this.project = project;
DataContext = project;
}
public override void OnApplyTemplate() {
base.OnApplyTemplate();
ChooseSymbolMap.Command = new RelayCommand(() => {
var ofd = new VistaOpenFileDialog();
ofd.Filter = "Symbol map (*.map)|*.map|All Files (*.*)|*.*";
if (ofd.ShowDialog() ?? false)
project.InputSymbolMap = ofd.FileName;
});
AddPlugin.Command = new RelayCommand(() => {
var ofd = new VistaOpenFileDialog();
ofd.Filter = ".NET assemblies (*.exe, *.dll)|*.exe;*.dll|All Files (*.*)|*.*";
ofd.Multiselect = true;
if (ofd.ShowDialog() ?? false) {
foreach (string plugin in ofd.FileNames) {
try {
ComponentDiscovery.LoadComponents(project.Protections, project.Packers, plugin);
project.Plugins.Add(new StringItem(plugin));
}
catch {
MessageBox.Show("Failed to load plugin '" + plugin + "'.");
}
}
}
});
RemovePlugin.Command = new RelayCommand(() => {
int selIndex = PluginPaths.SelectedIndex;
Debug.Assert(selIndex != -1);
string plugin = project.Plugins[selIndex].Item;
ComponentDiscovery.RemoveComponents(project.Protections, project.Packers, plugin);
project.Plugins.RemoveAt(selIndex);
PluginPaths.SelectedIndex = selIndex >= project.Plugins.Count ? project.Plugins.Count - 1 : selIndex;
}, () => PluginPaths.SelectedIndex != -1);
AddProbe.Command = new RelayCommand(() => {
var fbd = new VistaFolderBrowserDialog();
if (fbd.ShowDialog() ?? false)
project.ProbePaths.Add(new StringItem(fbd.SelectedPath));
});
RemoveProbe.Command = new RelayCommand(() => {
int selIndex = ProbePaths.SelectedIndex;
Debug.Assert(selIndex != -1);
project.ProbePaths.RemoveAt(selIndex);
ProbePaths.SelectedIndex = selIndex >= project.ProbePaths.Count ? project.ProbePaths.Count - 1 : selIndex;
}, () => ProbePaths.SelectedIndex != -1);
}
}
}