Fix theming for plugins
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Torch.Server.Themes">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Torch.Server.Themes">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Torch.Server.Themes">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Torch.Server.Themes">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
|
||||
|
@@ -3,9 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Torch.API;
|
||||
using Torch.API.Plugins;
|
||||
using Torch.Server.Views;
|
||||
|
||||
namespace Torch.Server.ViewModels
|
||||
{
|
||||
@@ -23,6 +25,15 @@ namespace Torch.Server.ViewModels
|
||||
Control = p.GetControl();
|
||||
|
||||
Name = $"{plugin.Name} ({plugin.Version})";
|
||||
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
public void UpdateResourceDict(ResourceDictionary dictionary)
|
||||
{
|
||||
this.Control.Resources.MergedDictionaries.Clear();
|
||||
this.Control.Resources.MergedDictionaries.Add(dictionary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ namespace Torch.Server.Views.Blocks
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ namespace Torch.Server.Views.Blocks
|
||||
InitializeComponent();
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ namespace Torch.Server.Views.Entities
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ namespace Torch.Server.Views.Entities
|
||||
InitializeComponent();
|
||||
DataContextChanged += OnDataContextChanged;
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@ namespace Torch.Server.Views.Entities
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,7 @@ namespace Torch.Server.Views.Entities
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ namespace Torch.Server.Views.Entities
|
||||
InitializeComponent();
|
||||
DataContextChanged += VoxelMapView_DataContextChanged;
|
||||
|
||||
ThemeControl.UpdateWeirdViews += UpdateResourceDict;
|
||||
ThemeControl.UpdateDynamicControls += UpdateResourceDict;
|
||||
UpdateResourceDict(ThemeControl.currentTheme);
|
||||
}
|
||||
|
||||
|
@@ -11,6 +11,7 @@ using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Torch.API.Managers;
|
||||
using Torch.API.Plugins;
|
||||
using Torch.Server.Annotations;
|
||||
using Torch.Server.Managers;
|
||||
using Torch.Server.ViewModels;
|
||||
@@ -25,7 +26,7 @@ namespace Torch.Server.Views
|
||||
/// <summary>
|
||||
/// Action other views can subscribe to to update their views if they dont inherit the style from the window for some reason.
|
||||
/// </summary>
|
||||
public static Action<ResourceDictionary> UpdateWeirdViews;
|
||||
public static Action<ResourceDictionary> UpdateDynamicControls;
|
||||
|
||||
/// <summary>
|
||||
/// Current theme other views can set their theme to when they first spawn
|
||||
@@ -47,6 +48,7 @@ namespace Torch.Server.Views
|
||||
}
|
||||
|
||||
private Dictionary<string, ResourceDictionary> _themes = new Dictionary<string, ResourceDictionary>();
|
||||
private HashSet<ITorchPlugin> plugins;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
@@ -84,7 +86,7 @@ namespace Torch.Server.Views
|
||||
uiSource.Resources.MergedDictionaries.Clear();
|
||||
var resource = new ResourceDictionary() { Source = uri };
|
||||
uiSource.Resources.MergedDictionaries.Add(resource);
|
||||
UpdateWeirdViews?.Invoke(resource);
|
||||
UpdateDynamicControls?.Invoke(resource);
|
||||
currentTheme = resource;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user