Added more themes and serialization of the latest theme
This commit is contained in:

committed by
John Gross

parent
67e663f023
commit
6c6ff18ec3
@@ -11,4 +11,8 @@
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@@ -79,4 +79,8 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
20
Torch.Server/Themes/Light Theme Animated.xaml
Normal file
20
Torch.Server/Themes/Light Theme Animated.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<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">
|
||||
|
||||
|
||||
<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" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
||||
<!-- Accent and AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@@ -1,4 +1,86 @@
|
||||
<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">
|
||||
|
||||
<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" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
|
||||
<!-- Accent and AppTheme setting -->
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style TargetType="TabControl">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TabControl">
|
||||
<Grid ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="ColumnDefinition0"/>
|
||||
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
|
||||
<RowDefinition x:Name="RowDefinition1" Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel x:Name="HeaderPanel" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" Orientation="Horizontal"/>
|
||||
<Border x:Name="ContentPanel" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
|
||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">
|
||||
<TabPanel x:Name="HeaderPanel2"
|
||||
Panel.ZIndex ="1"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Margin="2,2,2,0"
|
||||
IsItemsHost="true"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="TabStripPlacement" Value="Bottom">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,0,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Left">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="1"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="2,2,0,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="TabStripPlacement" Value="Right">
|
||||
<Setter Property="Grid.Row" TargetName="HeaderPanel" Value="0"/>
|
||||
<Setter Property="Grid.Row" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Grid.Column" TargetName="HeaderPanel" Value="1"/>
|
||||
<Setter Property="Grid.Column" TargetName="ContentPanel" Value="0"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
|
||||
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
|
||||
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
|
||||
<Setter Property="Margin" TargetName="HeaderPanel" Value="0,2,2,2"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Hyperlink" x:Name="LegalshtuffLink">
|
||||
<Setter Property="NavigateUri" Value="https://github.com/MahApps/MahApps.Metro/blob/develop/LICENSE" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
@@ -368,6 +368,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Light Theme Animated.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Light Theme.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@@ -65,6 +65,9 @@ namespace Torch.Server
|
||||
|
||||
internal Point WindowSize { get; set; } = new Point(800, 600);
|
||||
internal Point WindowPosition { get; set; } = new Point();
|
||||
|
||||
public string LastUsedTheme { get; set; } = "Torch Theme";
|
||||
|
||||
[XmlIgnore]
|
||||
private string _path;
|
||||
|
||||
|
@@ -16,7 +16,12 @@
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock" x:Name="LegalshtuffBlock">
|
||||
<Setter Property="Visibility" Value="Hidden"/>
|
||||
</Style>
|
||||
|
||||
<converters:ListConverter x:Key="ListConverterString" Type="system:String"/>
|
||||
<converters:ListConverter x:Key="ListConverterUInt64" Type="system:UInt64"/>
|
||||
<converters:BooleanAndConverter x:Key="BooleanAndConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
@@ -21,5 +21,11 @@
|
||||
SelectionChanged="Selector_OnSelectionChanged">
|
||||
</ComboBox>
|
||||
</DockPanel>
|
||||
|
||||
<TextBlock Width="Auto" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Name="LegalshtuffBlock">
|
||||
<Hyperlink Name="LegalshtuffLink" RequestNavigate="Hyperlink_RequestNavigate">
|
||||
Theme License
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ namespace Torch.Server
|
||||
Plugins.BindServer(server);
|
||||
|
||||
Themes.uiSource = this;
|
||||
Themes.SetConfig(_config);
|
||||
|
||||
LoadConfig((TorchConfig)server.Config);
|
||||
}
|
||||
|
Reference in New Issue
Block a user