forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelect.xaml.cs
73 lines (64 loc) · 1.53 KB
/
Select.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
/**
* Copyright (C) 2014 Patrick Mours. All rights reserved.
* License: https://github.com/crosire/reshade#license
*/
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace ReShade.Setup
{
public partial class SelectWindow : Window
{
public class EffectItem : INotifyPropertyChanged
{
public string Name { get; set; }
public string Path { get; set; }
public bool IsChecked
{
get
{
return _isChecked;
}
set
{
_isChecked = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsChecked"));
}
}
private bool _isChecked = true;
public event PropertyChangedEventHandler PropertyChanged;
}
public SelectWindow(IEnumerable<string> effectFiles)
{
InitializeComponent();
EffectList.ItemsSource =
effectFiles
.Where(it => Path.GetExtension(it) == ".fx")
.Select(it => new EffectItem {
Name = Path.GetFileName(it),
Path = it
});
}
public IEnumerable<EffectItem> GetSelection()
{
return EffectList.Items.Cast<EffectItem>();
}
private void ChangeChecked(object sender, RoutedEventArgs e)
{
var button = (Button)sender;
bool check = (string)button.Content == "Check All";
button.Content = check ? "Uncheck All" : "Check All";
foreach (EffectItem item in EffectList.Items)
{
item.IsChecked = check;
}
}
private void ConfirmSelection(object sender, RoutedEventArgs e)
{
Close();
}
}
}