-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathElementSorterItem.xaml.cs
More file actions
113 lines (105 loc) · 2.78 KB
/
Copy pathElementSorterItem.xaml.cs
File metadata and controls
113 lines (105 loc) · 2.78 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#region
using System;
using System.Windows;
using Hearthstone_Deck_Tracker.Enums;
using Hearthstone_Deck_Tracker.Utility.Animations;
using static Hearthstone_Deck_Tracker.Enums.SortDirection;
#endregion
namespace Hearthstone_Deck_Tracker
{
/// <summary>
/// Interaction logic for ElementSorterItem.xaml
/// </summary>
public partial class ElementSorterItem
{
private readonly bool _initialized;
private readonly bool _isPlayerList;
private readonly Action<ElementSorterItem, SortDirection> _moveItem;
private readonly Action<bool> _setConfigValue;
public DeckPanel Panel { get; }
public ElementSorterItem(DeckPanel panel, bool isChecked, Action<bool> setConfigValue, bool isPlayerList, Action<ElementSorterItem, SortDirection> moveItem)
{
InitializeComponent();
Panel = panel;
CheckBox.IsChecked = isChecked;
_setConfigValue = setConfigValue;
_isPlayerList = isPlayerList;
_moveItem = moveItem;
_initialized = true;
}
private void ButtonUp_OnClick(object sender, RoutedEventArgs e)
{
if(_isPlayerList)
{
_moveItem(this, Up);
Core.Overlay.UpdatePlayerLayout();
Core.Windows.PlayerWindow.UpdatePlayerLayout();
}
else
{
_moveItem(this, Up);
Core.Overlay.UpdateOpponentLayout();
Core.Windows.OpponentWindow.UpdateOpponentLayout();
}
}
private void ButtonDown_OnClick(object sender, RoutedEventArgs e)
{
if(_isPlayerList)
{
_moveItem(this, Down);
Core.Overlay.UpdatePlayerLayout();
Core.Windows.PlayerWindow.UpdatePlayerLayout();
}
else
{
_moveItem(this, Down);
Core.Overlay.UpdateOpponentLayout();
Core.Windows.OpponentWindow.UpdateOpponentLayout();
}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
_setConfigValue(true);
Config.Save();
if(_isPlayerList)
{
Core.Overlay.UpdatePlayerLayout();
Core.Windows.PlayerWindow.Update();
Core.Windows.PlayerWindow.UpdatePlayerLayout();
Core.UpdatePlayerCards(true);
}
else
{
Core.Overlay.UpdateOpponentLayout();
Core.Windows.OpponentWindow.Update();
Core.Windows.OpponentWindow.UpdateOpponentLayout();
Core.UpdateOpponentCards(true);
}
Core.Overlay.Update(false);
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
if(!_initialized)
return;
_setConfigValue(false);
Config.Save();
if(_isPlayerList)
{
Core.Overlay.UpdatePlayerLayout();
Core.Windows.PlayerWindow.Update();
Core.Windows.PlayerWindow.UpdatePlayerLayout();
Core.UpdatePlayerCards(true);
}
else
{
Core.Overlay.UpdateOpponentLayout();
Core.Windows.OpponentWindow.Update();
Core.Windows.OpponentWindow.UpdateOpponentLayout();
Core.UpdateOpponentCards(true);
}
Core.Overlay.Update(false);
}
}
}