Added more themes and serialization of the latest theme

This commit is contained in:
sirhamsteralot
2018-03-15 23:26:47 +01:00
committed by John Gross
parent 67e663f023
commit 6c6ff18ec3
10 changed files with 156 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Windows.Navigation;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -21,6 +23,7 @@ namespace Torch.Server.Views
public partial class ThemeControl : UserControl, INotifyPropertyChanged
{
public TorchUI uiSource;
private TorchConfig _torchConfig;
public List<string> Themes
{
@@ -37,8 +40,13 @@ namespace Torch.Server.Views
this.DataContext = this;
_themes["Dark theme"] = new ResourceDictionary() { Source = new Uri(@"/Themes/Dark Theme.xaml", UriKind.Relative) };
_themes["Light theme"] = new ResourceDictionary() { Source = new Uri(@"/Themes/Light Theme.xaml", UriKind.Relative) };
_themes["Animated Dark theme"] = new ResourceDictionary() { Source = new Uri(@"/Themes/Dark Theme Animated.xaml", UriKind.Relative) };
_themes["Light theme"] = new ResourceDictionary() { Source = new Uri(@"/Themes/Light Theme.xaml", UriKind.Relative) };
_themes["Light theme animated"] = new ResourceDictionary() { Source = new Uri(@"/Themes/Light Theme Animated.xaml", UriKind.Relative) };
_themes["Torch Theme"] = new ResourceDictionary() { Source = new Uri(@"/Views/Resources.xaml", UriKind.Relative) };
if (null == System.Windows.Application.Current)
{
new System.Windows.Application();
@@ -51,6 +59,9 @@ namespace Torch.Server.Views
var boxText = box.SelectedItem.ToString();
ChangeTheme(_themes[boxText].Source);
if (_torchConfig != null)
_torchConfig.LastUsedTheme = boxText;
}
public void ChangeTheme(Uri uri)
@@ -58,5 +69,19 @@ namespace Torch.Server.Views
uiSource.Resources.MergedDictionaries.Clear();
uiSource.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = uri });
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
e.Handled = true;
}
public void SetConfig(TorchConfig config)
{
_torchConfig = config;
if (_themes.ContainsKey(config.LastUsedTheme))
ChangeTheme(_themes[config.LastUsedTheme].Source);
}
}
}