Skip to content

Commit 85e307f

Browse files
committed
Fix theming for plugins
1 parent 03fa0a7 commit 85e307f

13 files changed

Lines changed: 26 additions & 17 deletions

‎Torch.Server/Themes/Dark Theme Animated.xaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:local="clr-namespace:Torch.Server.Themes">
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
43
<ResourceDictionary.MergedDictionaries>
54
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
65
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />

‎Torch.Server/Themes/Dark Theme.xaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:local="clr-namespace:Torch.Server.Themes">
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
43

54
<ResourceDictionary.MergedDictionaries>
65
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->

‎Torch.Server/Themes/Light Theme Animated.xaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:local="clr-namespace:Torch.Server.Themes">
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
43

54

65
<ResourceDictionary.MergedDictionaries>

‎Torch.Server/Themes/Light Theme.xaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:local="clr-namespace:Torch.Server.Themes">
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
43

54
<ResourceDictionary.MergedDictionaries>
65
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->

‎Torch.Server/ViewModels/PluginViewModel.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using System.Linq;
44
using System.Text;
55
using System.Threading.Tasks;
6+
using System.Windows;
67
using System.Windows.Controls;
78
using Torch.API;
89
using Torch.API.Plugins;
10+
using Torch.Server.Views;
911

1012
namespace Torch.Server.ViewModels
1113
{
@@ -23,6 +25,15 @@ public PluginViewModel(ITorchPlugin plugin)
2325
Control = p.GetControl();
2426

2527
Name = $"{plugin.Name} ({plugin.Version})";
28+
29+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
30+
UpdateResourceDict(ThemeControl.currentTheme);
31+
}
32+
33+
public void UpdateResourceDict(ResourceDictionary dictionary)
34+
{
35+
this.Control.Resources.MergedDictionaries.Clear();
36+
this.Control.Resources.MergedDictionaries.Add(dictionary);
2637
}
2738
}
2839
}

‎Torch.Server/Views/Entities/Blocks/BlockView.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public BlockView()
2929
{
3030
InitializeComponent();
3131

32-
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
32+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
3333
UpdateResourceDict(ThemeControl.currentTheme);
3434
}
3535

‎Torch.Server/Views/Entities/Blocks/PropertyView.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public PropertyView()
2727
InitializeComponent();
2828
DataContextChanged += OnDataContextChanged;
2929

30-
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
30+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
3131
UpdateResourceDict(ThemeControl.currentTheme);
3232
}
3333

‎Torch.Server/Views/Entities/CharacterView.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public CharacterView()
2424
{
2525
InitializeComponent();
2626

27-
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
27+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
2828
UpdateResourceDict(ThemeControl.currentTheme);
2929
}
3030

‎Torch.Server/Views/Entities/EntityControlHost.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public EntityControlHost()
1818
InitializeComponent();
1919
DataContextChanged += OnDataContextChanged;
2020

21-
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
21+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
2222
UpdateResourceDict(ThemeControl.currentTheme);
2323
}
2424

‎Torch.Server/Views/Entities/EntityControlsView.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public EntityControlsView()
1212
{
1313
InitializeComponent();
1414

15-
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
15+
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
1616
UpdateResourceDict(ThemeControl.currentTheme);
1717
}
1818

0 commit comments

Comments
 (0)