theme improvements

This commit is contained in:
2021-04-14 15:28:30 +03:00
parent 4faf7fecc1
commit 55e354b980
12 changed files with 221 additions and 318 deletions

View File

@@ -0,0 +1,26 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Markup;
[assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: XmlnsPrefix("http://schemas.brightsharp.com/developer", "bs")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Extensions")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Behaviors")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/developer", "BrightSharp.Converters")]
[assembly: XmlnsPrefix("http://schemas.brightsharp.com/diagrams", "bsDiag")]
[assembly: XmlnsDefinition("http://schemas.brightsharp.com/diagrams", "BrightSharp.Diagrams")]

View File

@@ -1,29 +1,31 @@
using System;
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;
using System.Windows.Threading;
namespace BrightSharp.Behaviors
{
public class FilterDefaultViewTextBoxBehavior : Behavior<TextBox>
{
DispatcherTimer timer = new DispatcherTimer();
readonly DispatcherTimer _timer = new DispatcherTimer();
public FilterDefaultViewTextBoxBehavior()
{
timer.Tick += Timer_Tick;
_timer.Tick += Timer_Tick;
FilterDelay = TimeSpan.FromSeconds(1);
IgnoreCase = null; //Case sensitive if any char upper case
FilterStringPropertyName = "FilterString";
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
_timer.Stop();
if (ItemsSource != null)
{
var view = CollectionViewSource.GetDefaultView(ItemsSource);
@@ -90,7 +92,7 @@ namespace BrightSharp.Behaviors
public Predicate<object> CustomFilter { get; set; }
public TimeSpan FilterDelay { get { return timer.Interval; } set { timer.Interval = value; } }
public TimeSpan FilterDelay { get { return _timer.Interval; } set { _timer.Interval = value; } }
protected override void OnAttached()
{
@@ -101,14 +103,14 @@ namespace BrightSharp.Behaviors
private void AssociatedObject_TextChanged(object sender, TextChangedEventArgs e)
{
timer.Stop(); timer.Start();
_timer.Stop(); _timer.Start();
HasFilterText = !string.IsNullOrEmpty(AssociatedObject.Text);
}
protected override void OnDetaching()
{
AssociatedObject.TextChanged -= AssociatedObject_TextChanged;
timer.Tick -= Timer_Tick;
_timer.Tick -= Timer_Tick;
base.OnDetaching();
}
}

View File

@@ -2,6 +2,7 @@
using BrightSharp.Interop.Constants;
using BrightSharp.Interop.Structures;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
@@ -38,6 +39,7 @@ namespace BrightSharp.Behaviors
}
}
[DebuggerStepThrough]
private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)

View File

@@ -1,6 +1,6 @@
using System.Windows.Controls.Primitives;
using Microsoft.Xaml.Behaviors;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace BrightSharp.Behaviors
{

View File

@@ -1,23 +1,22 @@
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Interop;
using Microsoft.Xaml.Behaviors;
using System.Windows;
namespace BrightSharp.Behaviors
{
public class WindowMinMaxSizeBehavior : Behavior<Window>
{
private MinMaxSize_Logic logic;
private MinMaxSize_Logic _logic;
protected override void OnAttached()
{
base.OnAttached();
logic = new MinMaxSize_Logic(AssociatedObject);
logic.OnAttached();
_logic = new MinMaxSize_Logic(AssociatedObject);
_logic.OnAttached();
}
protected override void OnDetaching()
{
logic.OnDetaching();
_logic.OnDetaching();
base.OnDetaching();
}
}

View File

@@ -1,218 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ACC3C556-F8E4-4F2A-A23D-8E8749679A1B}</ProjectGuid>
<OutputType>library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BrightSharp</RootNamespace>
<AssemblyName>BrightSharp</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>G:\repositories\Tps.Next\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<None Remove="Themes\icons\app.png" />
<None Remove="Themes\icons\copy.png" />
<None Remove="Themes\icons\cut.png" />
<None Remove="Themes\icons\paste.png" />
<None Remove="Themes\icons\undo.png" />
</ItemGroup>
<ItemGroup>
<Compile Include="Behaviors\FilterDefaultViewTextBoxBehavior.cs" />
<Compile Include="Behaviors\SelectAllTextOnFocusBehavior.cs" />
<Compile Include="Behaviors\MinMaxSize_Logic.cs" />
<Compile Include="Behaviors\WindowMinMaxSizeBehavior.cs" />
<Compile Include="Commands\AsyncCommand.cs" />
<Compile Include="Commands\RelayCommand.cs" />
<Compile Include="Converters\IntToValueConverter.cs" />
<Compile Include="Converters\InverseBooleanToVisibilityConverter.cs" />
<Compile Include="Diagrams\Adorners\ResizeRotateAdorner.cs" />
<Compile Include="Diagrams\Adorners\ResizeRotateChrome.cs" />
<Compile Include="Diagrams\Adorners\SizeAdorner.cs" />
<Compile Include="Diagrams\Adorners\SizeChrome.cs" />
<Compile Include="Diagrams\DesignerItemDecorator.cs" />
<Compile Include="Diagrams\VisualExtensions.cs" />
<Compile Include="Diagrams\SelectionBehavior.cs" />
<Compile Include="Diagrams\Thumbs\MoveThumb.cs" />
<Compile Include="Diagrams\Thumbs\ResizeThumb.cs" />
<Compile Include="Diagrams\Thumbs\RotateThumb.cs" />
<Compile Include="Extensions\WpfExtensions.cs" />
<Compile Include="Interop\Constants.cs" />
<Compile Include="Interop\NativeMethods.cs" />
<Compile Include="Interop\Structures.cs" />
<Compile Include="Themes\Theme.cs">
<DependentUpon>Theme.xaml</DependentUpon>
</Compile>
<Compile Include="Themes\ThemeManager.cs" />
<Compile Include="Diagrams\ZoomControl.cs">
<SubType>Code</SubType>
</Compile>
<Page Include="Themes\Controls\ZoomControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="Converters\ThicknessConverter.cs" />
<Compile Include="Extensions\MarkupExtensionProperties.cs" />
<None Include="packages.config" />
<None Include="Themes\Theme.Static.cs">
<DependentUpon>Theme.Static.xaml</DependentUpon>
</None>
<Page Include="Themes\Diagrams\DesignerItem.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Diagrams\ResizeRotateChrome.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Diagrams\SizeChrome.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Style.Blue.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Style.Classic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Style.DarkBlue.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Style.Silver.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Style.DevLab.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Theme.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<None Include="Themes\Theme.Static.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</None>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
</ItemGroup>
<ItemGroup>
<Resource Include="Themes\icons\app.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Themes\icons\copy.png" />
<Resource Include="Themes\icons\cut.png" />
<Resource Include="Themes\icons\paste.png" />
<Resource Include="Themes\icons\undo.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
<ItemGroup>
<Compile Update="Diagrams\ZoomControl.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Themes\Theme.cs">
<DependentUpon>Theme.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="Themes\Controls\ZoomControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Diagrams\DesignerItem.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Diagrams\ResizeRotateChrome.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Diagrams\SizeChrome.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Generic.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Style.Blue.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Style.Classic.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Style.DarkBlue.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Style.DevLab.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Style.Silver.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Theme.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

View File

@@ -21,6 +21,11 @@ namespace BrightSharp.Commands
_canExecuteEvaluator = canExecuteEvaluator;
}
public RelayCommand(Action methodToExecute)
{
_methodToExecute = methodToExecute;
}
public bool CanExecute(object parameter)
{
if (_canExecuteEvaluator == null)
@@ -35,7 +40,7 @@ namespace BrightSharp.Commands
}
}
public class RelayCommand<T> : ICommand
public class RelayCommand<T> : ICommand where T : class
{
private readonly Action<T> _methodToExecuteWithParam;
private readonly Func<T, bool> _canExecuteEvaluator;
@@ -56,11 +61,11 @@ namespace BrightSharp.Commands
{
if (_canExecuteEvaluator == null)
return true;
return _canExecuteEvaluator.Invoke((T)parameter);
return _canExecuteEvaluator.Invoke(parameter as T);
}
public void Execute(object parameter)
{
_methodToExecuteWithParam?.Invoke((T)parameter);
_methodToExecuteWithParam?.Invoke(parameter as T);
}
}
}

View File

@@ -212,11 +212,10 @@
<LinearGradientBrush x:Key="WindowBackgroundBrush">
<GradientStop Color="#EEE" />
</LinearGradientBrush>
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#FFDFE1E8" />
<SolidColorBrush x:Key="SelectedBackgroundBrush" Color="#FAE0A0" />
<SolidColorBrush x:Key="GlyphBrush" Color="#444" />
<SolidColorBrush x:Key="LightColorBrush" Color="#DDD" />
<Color x:Key="OnWindowForegroundColor">Black</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="{DynamicResource OnWindowForegroundColor}" />
<SolidColorBrush x:Key="DisabledForegroundBrush" Color="#FF4D4D4D" />
<SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
<LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
@@ -229,10 +228,9 @@
</LinearGradientBrush>
<SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#F0F0F0" />
<SolidColorBrush x:Key="HighLightForegroundBrush" Color="#FF2E2020" />
<Color x:Key="SelectedUnfocusedColor">#E0E0EA</Color>
<Color x:Key="UiForegroundColor">Black</Color>
<SolidColorBrush x:Key="UiForegroundBrush" Color="{DynamicResource UiForegroundColor}" />
<Color x:Key="SelectedBackgroundColor">#DEE4FF</Color>
<Color x:Key="SelectedUnfocusedColor">#FFB6B6B6</Color>
<Color x:Key="SelectedBackgroundColor">#FAE0A0</Color>
<Color x:Key="ControlLightColor">#FFFFFFFF</Color>
<Color x:Key="ControlMediumColor">#FFC5C5C5</Color>
<Color x:Key="ControlDarkColor">#FF6B6B6B</Color>
@@ -240,6 +238,9 @@
<Color x:Key="ControlPressedColor">#FF47909B</Color>
<Color x:Key="BorderLightColor">#D6D6D6</Color>
<Color x:Key="BorderMediumColor">#E6E6E6</Color>
<SolidColorBrush x:Key="OnWindowForegroundBrush" Color="Black" />
<SolidColorBrush x:Key="SelectedUnfocusedBrush" Color="#FFB0B0EA" />
<SolidColorBrush x:Key="UiForegroundBrush" Color="Black" />
<!--Window Brushes-->
@@ -247,15 +248,16 @@
<SolidColorBrush x:Key="WindowHeaderInactiveBackgroundBrush" Color="#8888" />
<LinearGradientBrush x:Key="GradientWindowBackgroundBrush" EndPoint="1,1" StartPoint="0,0">
<GradientStop Color="#FFAFBAD6" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
<GradientStop Color="#FFD1E3FF" Offset="0.766"/>
<GradientStop Color="#FFE9F2FF" Offset="0.766"/>
<GradientStop Color="#FFE2E8F8" Offset="0.238"/>
<GradientStop Color="#FFD0D8EC" Offset="0"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="WindowHeaderBrush" EndPoint="0,1">
<GradientStop Color="#FFEEEEEE" />
<GradientStop Color="#FFCCCCCC" Offset="1" />
<GradientStop Color="#F4F4FF" />
<GradientStop Color="#FFD4EAFF" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="WindowHeaderInactiveBrush" EndPoint="0,1">

View File

@@ -224,7 +224,7 @@
<Color x:Key="SelectedBackgroundColor">#E3E3E3</Color>
<Color x:Key="SelectedUnfocusedColor">#FFB6B6B6</Color>
<Color x:Key="SelectedUnfocusedColor">#FFD6E6E6</Color>
<Color x:Key="ControlLightColor">#FFFFFFFF</Color>
<Color x:Key="ControlMediumColor">#FFC5C5C5</Color>
<Color x:Key="ControlDarkColor">#FF6B6B6B</Color>

View File

@@ -36,7 +36,5 @@ namespace BrightSharp.Themes
var window = Window.GetWindow((DependencyObject)sender);
window.WindowState = WindowState.Minimized;
}
}
}

View File

@@ -17,10 +17,10 @@
<BorderGapMaskConverter x:Key="BorderGapMaskConverter" />
<BooleanToVisibilityConverter x:Key="btvc" />
<conv:InverseBooleanToVisibilityConverter x:Key="ibtvc" />
<conv:IntToValueConverter x:Key="btvhc" FalseValue="Hidden" TrueValue="Visible" />
<!--STYLES-->
<ContextMenu x:Key="DecoTextBoxContextMenu">
<MenuItem Command="ApplicationCommands.Copy">
<MenuItem.Icon>
@@ -2440,7 +2440,7 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type GroupBox}">
<Style x:Key="GroupBoxSimpleBorderStyle" TargetType="{x:Type GroupBox}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="BorderBrush" Value="{DynamicResource UiForegroundBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
@@ -2485,7 +2485,7 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpandrStyleGroupBox" TargetType="{x:Type GroupBox}">
<Style TargetType="{x:Type GroupBox}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush}" />
@@ -2565,28 +2565,6 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type Label}" TargetType="{x:Type Label}">
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Foreground" Value="{DynamicResource OnWindowForegroundBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<Border Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type ListBox}" TargetType="{x:Type ListBox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
@@ -2674,6 +2652,9 @@
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource SelectedUnfocusedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
@@ -2957,7 +2938,7 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ContextMenu}">
<Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Grid.IsSharedSizeScope" Value="true"/>
@@ -3016,15 +2997,14 @@
<DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="MenuBackground" Storyboard.TargetProperty="Opacity" />
</Storyboard>
</ControlTemplate.Resources>
<Border x:Name="Border">
<Border x:Name="Border" Background="{TemplateBinding Background}">
<Grid>
<Border x:Name="MenuBackground" IsHitTestVisible="False" Background="{DynamicResource TopLevelMenuBackgroundHover}" Opacity="0" />
<Popup
x:Name="Popup"
Placement="Relative"
VerticalOffset="{Binding ElementName=Border, Path=ActualHeight}"
HorizontalOffset="{Binding ElementName=SubmenuBorder, Path=ActualWidth}"
IsOpen="{TemplateBinding IsSubmenuOpen}"
IsOpen="{TemplateBinding IsSubmenuOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Slide">
@@ -3076,7 +3056,7 @@
<ControlTemplate
x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}"
TargetType="{x:Type MenuItem}">
<Border x:Name="Border" >
<Border x:Name="Border" Background="{TemplateBinding Background}">
<Grid>
<ContentPresenter
Margin="6,3,6,3"
@@ -3315,9 +3295,9 @@
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
<Style TargetType="{x:Type MenuItem}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="Background" Value="{DynamicResource WindowBackgroundBrush}" />
<Style.Triggers>
<Trigger Property="Role" Value="TopLevelHeader">
<Setter Property="BorderThickness" Value="1"/>
@@ -3431,7 +3411,7 @@
</Trigger>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}"/>
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, FallbackValue={x:Null}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -4711,10 +4691,6 @@
</Setter>
</Style>
<Style BasedOn="{StaticResource RoundedTabItemStyle}" TargetType="{x:Type TabItem}"></Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="TextTrimming" Value="None"/>
</Style>
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderThickness" Value="1" />
@@ -4757,7 +4733,7 @@
</BeginStoryboard>
</EventTrigger>
</Label.Triggers>
<TextBlock TextWrapping="Wrap" Text="{Binding ElementName=MyAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"></TextBlock>
<TextBlock TextWrapping="Wrap" Text="{Binding ElementName=MyAdorner, FallbackValue={x:Null}, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"></TextBlock>
</Label>
</Grid>
</ControlTemplate>
@@ -4814,8 +4790,8 @@
</Grid.ColumnDefinitions>
<ContentControl Margin="2,0,0,0" Content="{TemplateBinding bs:MarkupExtensionProperties.LeadingElement}" VerticalAlignment="Center" />
<ContentControl Margin="0,0,2,0" Grid.Column="2" Content="{TemplateBinding bs:MarkupExtensionProperties.TrailingElement}" VerticalAlignment="Center" />
<Border Visibility="{Binding (Validation.HasError), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource btvc}}" Grid.Column="3" VerticalAlignment="Center" Width="15" Height="14" HorizontalAlignment="Right" BorderBrush="White" BorderThickness="1" CornerRadius="7" Margin="0,0,4,0"
Opacity=".8" ToolTip="{Binding Path=(Validation.Errors)[0].ErrorContent, RelativeSource={RelativeSource TemplatedParent}}">
<Border x:Name="ErrorInfoBorder" Grid.Column="3" Visibility="Collapsed" VerticalAlignment="Center" Width="15" Height="14" HorizontalAlignment="Right" BorderBrush="White" BorderThickness="1" CornerRadius="7" Margin="0,0,4,0"
Opacity=".8">
<Border.Background>
<SolidColorBrush Color="{DynamicResource ValidationErrorColor}" />
</Border.Background>
@@ -4875,7 +4851,8 @@
<SolidColorBrush Color="{DynamicResource ValidationErrorColor}" />
</Setter.Value>
</Setter>
<!--<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}"/>-->
<Setter TargetName="ErrorInfoBorder" Property="Visibility" Value="Visible"/>
<Setter TargetName="ErrorInfoBorder" Property="ToolTip" Value="{Binding Path=(Validation.Errors)[0].ErrorContent, FallbackValue={x:Null}, RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -5478,7 +5455,7 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type TreeView}" TargetType="{x:Type TreeView}">
<Style TargetType="{x:Type TreeView}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="UseLayoutRounding" Value="True" />
@@ -5490,28 +5467,39 @@
<Setter Property="Padding" Value="2" />
<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<!--<EventSetter Event="Drop" Handler="treeView_Drop"/>-->
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeView}">
<Border
x:Name="Border"
CornerRadius="{TemplateBinding bs:MarkupExtensionProperties.CornerRadius}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}" Focusable="False">
<ItemsPresenter />
<Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">
<ScrollViewer x:Name="_tv_scrollviewer_" Background="{TemplateBinding Background}" CanContentScroll="false" Focusable="false" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ScrollViewer" Property="Opacity" Value="0.7" />
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource SolidBorderBrush}"/>
</Trigger>
<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
<Setter Property="CanContentScroll" TargetName="_tv_scrollviewer_" Value="true"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable" Value="False"/>
@@ -5583,6 +5571,9 @@
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Padding" Value="0,3,0,3" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="{DynamicResource SolidBorderBrush}" />
<Setter Property="bs:MarkupExtensionProperties.SpecialWidth" Value="16" />
<Setter Property="Template">
<Setter.Value>
@@ -5597,7 +5588,7 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle x:Name="OffsetRect" Width="{TemplateBinding bs:MarkupExtensionProperties.SpecialWidth}" />
<Border x:Name="Border" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" />
<Border x:Name="Border" Margin="13,0,0,0" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
<Rectangle Name="FocusRect" Grid.Column="1" Stroke="#60000000" StrokeDashArray="1 2" Visibility="Hidden" Grid.ColumnSpan="2"/>
<ToggleButton Grid.ColumnSpan="2"
x:Name="Expander"
@@ -5607,7 +5598,7 @@
<Grid Background="Transparent" x:Name="PART_Header" Grid.ColumnSpan="2" Margin="16,0,0,0">
<ContentPresenter ContentSource="Header" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
<ItemsPresenter Grid.Column="1" Grid.Row="1" x:Name="ItemsHost" />
<VirtualizingStackPanel Grid.Column="1" Grid.Row="1" x:Name="ItemsHost" IsItemsHost="true" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="false">
@@ -5616,10 +5607,11 @@
<Trigger Property="HasItems" Value="false">
<Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
<Setter TargetName="OffsetRect" Property="Width" Value="8" />
<Setter TargetName="PART_Header" Property="Margin" Value="3,0,0,0" />
<!--<Setter TargetName="PART_Header" Property="Margin" Value="3,0,0,0" />-->
</Trigger>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="{DynamicResource SelectedBackgroundBrush}"/>
<Setter TargetName="Border" Property="BorderThickness" Value="1"/>
<Setter Property="TextBlock.Foreground" Value="{DynamicResource HighLightForegroundBrush}" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
@@ -5651,11 +5643,10 @@
<Setter Property="BorderBrush" Value="{DynamicResource WindowBorderBrush}" />
<Setter Property="bs:MarkupExtensionProperties.UseMinMaxSizeBehavior" Value="True" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Icon" Value="icons/app.png" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="4" CornerRadius="0" GlassFrameThickness="0" UseAeroCaptionButtons="False" />
<WindowChrome CaptionHeight="30" ResizeBorderThickness="4" CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="{DynamicResource OnWindowForegroundBrush}"/>
@@ -5683,9 +5674,31 @@
<GradientStop Color="WhiteSmoke" Offset="0.0"/>
</LinearGradientBrush>
</StackPanel.Resources>
<Button Padding="10,6" VerticalAlignment="Top" Name="PART_MinimizeButton" Click="minimizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="0" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings" />
<Button Padding="10,6" VerticalAlignment="Top" Name="PART_MaximizeButton" Click="maximizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="1" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings" />
<Button Padding="10,6" Name="PART_CloseButton" Click="closeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="r" bs:MarkupExtensionProperties.CornerRadius="0" BorderBrush="Transparent" FontFamily="Webdings">
<Button Padding="10,6" VerticalAlignment="Top" Name="PART_MinimizeButton" Click="minimizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="0" bs:MarkupExtensionProperties.CornerRadius="0" BorderThickness="0" FontFamily="Webdings">
<Button.Background>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="Transparent" Offset="0.0"/>
</LinearGradientBrush>
</Button.Background>
<Button.Resources>
<LinearGradientBrush x:Key="DarkBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FF8A8A8A" Offset="0"/>
</LinearGradientBrush>
</Button.Resources>
</Button>
<Button Padding="10,6" VerticalAlignment="Top" Name="PART_MaximizeButton" Click="maximizeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="1" bs:MarkupExtensionProperties.CornerRadius="0" BorderThickness="0" FontFamily="Webdings">
<Button.Background>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="Transparent" Offset="0.0"/>
</LinearGradientBrush>
</Button.Background>
<Button.Resources>
<LinearGradientBrush x:Key="DarkBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FF8A8A8A" Offset="0"/>
</LinearGradientBrush>
</Button.Resources>
</Button>
<Button Padding="10,6" Name="PART_CloseButton" Click="closeButton_Click" Focusable="False" WindowChrome.IsHitTestVisibleInChrome="True" Content="r" bs:MarkupExtensionProperties.CornerRadius="0" BorderThickness="0" FontFamily="Webdings">
<Button.Background>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="Transparent" Offset="0.0"/>
@@ -5694,15 +5707,14 @@
<Button.Resources>
<LinearGradientBrush x:Key="DarkBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFF8A8A" Offset="0"/>
<GradientStop Color="#FFD14D4D" Offset="1"/>
</LinearGradientBrush>
</Button.Resources>
</Button>
</StackPanel>
<Label Padding="0,5" Foreground="White" HorizontalContentAlignment="{TemplateBinding bs:MarkupExtensionProperties.HeaderHorizontalAlignment}" Content="{TemplateBinding bs:MarkupExtensionProperties.Header}" FontSize="14">
<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="1" Color="Black" />
</Label.Effect>
<Label Padding="0,5" Foreground="{DynamicResource OnWindowForegroundBrush}" HorizontalContentAlignment="{TemplateBinding bs:MarkupExtensionProperties.HeaderHorizontalAlignment}" Content="{TemplateBinding bs:MarkupExtensionProperties.Header}" FontSize="14">
<!--<Label.Effect>
<DropShadowEffect BlurRadius="2" ShadowDepth="1" Color="White" />
</Label.Effect>-->
</Label>
</DockPanel>
</Border>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
@@ -19,49 +20,49 @@ namespace BrightSharp.Themes
public static class ThemeManager
{
private const string StyleDictionaryPattern = @"(?<=.+style\.)(.*?)(?=\.xaml)";
private const string StaticThemeDictionaryUri = "/brightsharp;component/themes/theme.static.xaml";
private const string ThemeDictionaryUri = "/brightsharp;component/themes/theme.xaml";
static ColorThemes? _theme;
private static ColorThemes? ThemeField;
public static ColorThemes? Theme
{
get {
if (_theme.HasValue) return _theme.Value;
if (ThemeField.HasValue) return ThemeField.Value;
var curStyleRes = Resources.Where(r => r.Source != null &&
Regex.IsMatch(r.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase)).FirstOrDefault();
if (curStyleRes == null) return null;
var match = Regex.Match(curStyleRes.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase);
_theme = (ColorThemes)Enum.Parse(typeof(ColorThemes), match.Value, true);
return _theme.Value;
ThemeField = (ColorThemes)Enum.Parse(typeof(ColorThemes), match.Value, true);
return ThemeField.Value;
}
set {
SetTheme(value);
_ = SetTheme(value);
}
}
public static DispatcherOperation SetTheme(ColorThemes? value, DispatcherPriority priority = DispatcherPriority.Background) {
if (_theme == value) return Application.Current.Dispatcher.BeginInvoke(new Action(() => { }), priority);
_theme = value;
return Application.Current.Dispatcher.BeginInvoke(new Action(() =>
public static async Task SetTheme(ColorThemes? value, DispatcherPriority priority = DispatcherPriority.Background)
{
if (ThemeField == value) { return; }
ThemeField = value;
await Application.Current.Dispatcher.InvokeAsync(() =>
{
if (_theme != value) return;
if (ThemeField != value) return;
Application.Current.Resources.BeginInit();
var curStyleRes = Resources.Where(r => r.Source != null &&
Regex.IsMatch(r.Source.OriginalString, StyleDictionaryPattern, RegexOptions.IgnoreCase)).FirstOrDefault();
var curThemeRes = Resources.Where(r => r.Source != null && r.Source.OriginalString.Equals(StaticThemeDictionaryUri, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
var curThemeRes = Resources.Where(r => r.Source != null && r.Source.OriginalString.Equals(ThemeDictionaryUri, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (curThemeRes != null)
Resources.Remove(curThemeRes);
if (curStyleRes != null)
Resources.Remove(curStyleRes);
if (value == null) return;
Resources.Add(new ResourceDictionary() { Source = new Uri($"/brightsharp;component/themes/style.{value}.xaml", UriKind.RelativeOrAbsolute) });
if (curThemeRes != null)
Resources.Add(new ResourceDictionary() { Source = new Uri(StaticThemeDictionaryUri, UriKind.RelativeOrAbsolute) });
Resources.Add(new ResourceDictionary() { Source = new Uri(ThemeDictionaryUri, UriKind.RelativeOrAbsolute) });
Application.Current.Resources.EndInit();
ThemeChanged?.Invoke(null, EventArgs.Empty);
}), priority);
}, priority);
}
public static event EventHandler ThemeChanged;