optimized demo start-up speed
This commit is contained in:
1 parent
b57e6e8961
commit
aa745e32b1
14 files changed
+116
-69
No files matched your search
@@ -20,12 +20,12 @@ namespace HandyControl.Controls
|
||||
EnableBlur(this);
|
||||
}
|
||||
|
||||
public static SystemVersionInfo SystemVersionInfo { get; set; }
|
||||
|
||||
internal static void EnableBlur(Window window)
|
||||
{
|
||||
if (SystemVersionInfo < SystemVersionInfo.Windows10 ||
|
||||
SystemVersionInfo >= SystemVersionInfo.Windows10_1903)
|
||||
var versionInfo = ConfigHelper.Instance.SystemVersionInfo;
|
||||
|
||||
if (versionInfo < SystemVersionInfo.Windows10 ||
|
||||
versionInfo >= SystemVersionInfo.Windows10_1903)
|
||||
{
|
||||
var colorValue = ResourceHelper.GetResource<uint>(ResourceToken.BlurGradientValue);
|
||||
var color = ColorHelper.ToColor(colorValue);
|
||||
@@ -37,7 +37,7 @@ namespace HandyControl.Controls
|
||||
var accentPolicy = new InteropValues.ACCENTPOLICY();
|
||||
var accentPolicySize = Marshal.SizeOf(accentPolicy);
|
||||
|
||||
accentPolicy.AccentState = SystemVersionInfo < SystemVersionInfo.Windows10_1809
|
||||
accentPolicy.AccentState = versionInfo < SystemVersionInfo.Windows10_1809
|
||||
? InteropValues.ACCENTSTATE.ACCENT_ENABLE_BLURBEHIND
|
||||
: InteropValues.ACCENTSTATE.ACCENT_ENABLE_ACRYLICBLURBEHIND;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
@@ -8,7 +7,32 @@ namespace HandyControl.Themes
|
||||
{
|
||||
public class Theme : ResourceDictionary
|
||||
{
|
||||
public Theme() => UpdateResource();
|
||||
public Theme()
|
||||
{
|
||||
if (DesignerHelper.IsInDesignMode)
|
||||
{
|
||||
MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml")
|
||||
});
|
||||
MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateResource();
|
||||
}
|
||||
}
|
||||
|
||||
private Uri _source;
|
||||
|
||||
public new Uri Source
|
||||
{
|
||||
get => DesignerHelper.IsInDesignMode ? null : _source;
|
||||
set => _source = value;
|
||||
}
|
||||
|
||||
private SkinType _skin;
|
||||
|
||||
@@ -26,20 +50,19 @@ namespace HandyControl.Themes
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual Uri ThemeUri => new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml");
|
||||
|
||||
public virtual ResourceDictionary GetSkin(SkinType skinType) => ResourceHelper.GetSkin(skinType);
|
||||
|
||||
public virtual ResourceDictionary GetTheme() => new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
|
||||
};
|
||||
|
||||
private void UpdateResource()
|
||||
{
|
||||
base.MergedDictionaries.Clear();
|
||||
base.MergedDictionaries.Add(GetSkin(Skin));
|
||||
base.MergedDictionaries.Add(new ResourceDictionary
|
||||
{
|
||||
Source = ThemeUri
|
||||
});
|
||||
if (DesignerHelper.IsInDesignMode) return;
|
||||
MergedDictionaries.Clear();
|
||||
MergedDictionaries.Add(GetSkin(Skin));
|
||||
MergedDictionaries.Add(GetTheme());
|
||||
}
|
||||
|
||||
public new Collection<ResourceDictionary> MergedDictionaries => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Navigation;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Properties.Langs;
|
||||
|
||||
@@ -38,7 +37,7 @@ namespace HandyControl.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSystemVersionInfo(SystemVersionInfo info) => BlurWindow.SystemVersionInfo = info;
|
||||
public SystemVersionInfo SystemVersionInfo { get; set; }
|
||||
|
||||
public void SetLang(string lang)
|
||||
{
|
||||
@@ -49,7 +48,7 @@ namespace HandyControl.Tools
|
||||
|
||||
public void SetConfig(HandyControlConfig config)
|
||||
{
|
||||
SetSystemVersionInfo(config.SystemVersionInfo);
|
||||
SystemVersionInfo = config.SystemVersionInfo;
|
||||
SetLang(config.Lang);
|
||||
SetTimelineFrameRate(config.TimelineFrameRate);
|
||||
}
|
||||
@@ -60,10 +59,10 @@ namespace HandyControl.Tools
|
||||
public void SetWindowDefaultStyle(object resourceKey = null)
|
||||
{
|
||||
var metadata = resourceKey == null
|
||||
? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(System.Windows.Window)))
|
||||
? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(Window)))
|
||||
: new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
|
||||
|
||||
FrameworkElement.StyleProperty.OverrideMetadata(typeof(System.Windows.Window), metadata);
|
||||
FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), metadata);
|
||||
}
|
||||
|
||||
public void SetNavigationWindowDefaultStyle(object resourceKey = null)
|
||||
|
||||
Reference in new issue
Block a user