mirror of
https://gitee.com/chinware/atomui.git
synced 2024-11-29 18:38:16 +08:00
Refactor IconPkg Generator
This commit is contained in:
parent
f654fa13b4
commit
86491701d0
@ -288,43 +288,43 @@ internal class BaseNavMenuItemTheme : BaseControlTheme
|
||||
|
||||
private void BuildMenuIndicatorStyle()
|
||||
{
|
||||
// {
|
||||
// var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
// menuIndicatorStyle.Add(Visual.IsVisibleProperty, true);
|
||||
// menuIndicatorStyle.Add(Icon.NormalFilledBrushProperty, NavMenuTokenResourceKey.ItemColor);
|
||||
// menuIndicatorStyle.Add(Icon.SelectedFilledBrushProperty, NavMenuTokenResourceKey.ItemSelectedColor);
|
||||
// menuIndicatorStyle.Add(Icon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
// // 设置颜色
|
||||
//
|
||||
// Add(menuIndicatorStyle);
|
||||
// }
|
||||
// {
|
||||
// var darkCommonStyle = new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.IsDarkStyleProperty, true));
|
||||
// {
|
||||
// var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
// menuIndicatorStyle.Add(Icon.NormalFilledBrushProperty, NavMenuTokenResourceKey.DarkItemColor);
|
||||
// menuIndicatorStyle.Add(Icon.SelectedFilledBrushProperty, NavMenuTokenResourceKey.DarkItemSelectedColor);
|
||||
// menuIndicatorStyle.Add(Icon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.DarkItemDisabledColor);
|
||||
// darkCommonStyle.Add(menuIndicatorStyle);
|
||||
// }
|
||||
// Add(darkCommonStyle);
|
||||
// }
|
||||
//
|
||||
// var selectedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Selected));
|
||||
// {
|
||||
// var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
// menuIndicatorStyle.Add(Icon.IconModeProperty, IconMode.Selected);
|
||||
// selectedStyle.Add(menuIndicatorStyle);
|
||||
// }
|
||||
// Add(selectedStyle);
|
||||
//
|
||||
// var hasNoSubMenuStyle = new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.HasSubMenuProperty, false));
|
||||
// {
|
||||
// var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
// menuIndicatorStyle.Add(Visual.IsVisibleProperty, false);
|
||||
// hasNoSubMenuStyle.Add(menuIndicatorStyle);
|
||||
// }
|
||||
// Add(hasNoSubMenuStyle);
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, true);
|
||||
menuIndicatorStyle.Add(Icon.NormalFilledBrushProperty, NavMenuTokenResourceKey.ItemColor);
|
||||
menuIndicatorStyle.Add(Icon.SelectedFilledBrushProperty, NavMenuTokenResourceKey.ItemSelectedColor);
|
||||
menuIndicatorStyle.Add(Icon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.ItemDisabledColor);
|
||||
// 设置颜色
|
||||
|
||||
Add(menuIndicatorStyle);
|
||||
}
|
||||
{
|
||||
var darkCommonStyle = new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.IsDarkStyleProperty, true));
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Icon.NormalFilledBrushProperty, NavMenuTokenResourceKey.DarkItemColor);
|
||||
menuIndicatorStyle.Add(Icon.SelectedFilledBrushProperty, NavMenuTokenResourceKey.DarkItemSelectedColor);
|
||||
menuIndicatorStyle.Add(Icon.DisabledFilledBrushProperty, NavMenuTokenResourceKey.DarkItemDisabledColor);
|
||||
darkCommonStyle.Add(menuIndicatorStyle);
|
||||
}
|
||||
Add(darkCommonStyle);
|
||||
}
|
||||
|
||||
var selectedStyle = new Style(selector => selector.Nesting().Class(StdPseudoClass.Selected));
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Icon.IconModeProperty, IconMode.Selected);
|
||||
selectedStyle.Add(menuIndicatorStyle);
|
||||
}
|
||||
Add(selectedStyle);
|
||||
|
||||
var hasNoSubMenuStyle = new Style(selector => selector.Nesting().PropertyEquals(NavMenuItem.HasSubMenuProperty, false));
|
||||
{
|
||||
var menuIndicatorStyle = new Style(selector => selector.Nesting().Template().Name(MenuIndicatorIconPart));
|
||||
menuIndicatorStyle.Add(Visual.IsVisibleProperty, false);
|
||||
hasNoSubMenuStyle.Add(menuIndicatorStyle);
|
||||
}
|
||||
Add(hasNoSubMenuStyle);
|
||||
}
|
||||
|
||||
private void BuildMenuIconStyle()
|
||||
|
@ -403,7 +403,7 @@ internal class NavMenuToken : AbstractControlDesignToken
|
||||
|
||||
ItemContentMargin = itemContentMargin;
|
||||
ItemContentPadding = new Thickness(_globalToken.Padding, _globalToken.PaddingXXS);
|
||||
ItemMargin = new Thickness(0, 0, _globalToken.MarginXXS, 0);
|
||||
ItemMargin = new Thickness(0, 0, _globalToken.MarginXS, 0);
|
||||
ItemHeight = _globalToken.ControlHeight;
|
||||
GroupTitleLineHeight = _globalToken.ControlHeight;
|
||||
CollapsedWidth = _globalToken.ControlHeight * 2;
|
||||
|
@ -3,6 +3,12 @@
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Common.props"/>
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Nuget.props"/>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/**/*.cs"/>
|
||||
</ItemGroup>
|
||||
|
File diff suppressed because one or more lines are too long
@ -97,23 +97,24 @@ public class IconPackageGenerator : IIncrementalGenerator
|
||||
sourceText.AppendLine("///");
|
||||
sourceText.AppendLine("using Avalonia;");
|
||||
sourceText.AppendLine("using System;");
|
||||
sourceText.AppendLine("using AtomUI.IconPkg;");
|
||||
sourceText.AppendLine($"namespace {ns};");
|
||||
sourceText.AppendLine($"public partial class {packageClassName}");
|
||||
sourceText.AppendLine("{");
|
||||
|
||||
foreach (var info in fileInfos)
|
||||
{
|
||||
sourceText.AppendLine($" public static Icon {info.Name}{info.ThemeType}()");
|
||||
sourceText.AppendLine($" public static AtomUI.IconPkg.Icon {info.Name}{info.ThemeType}()");
|
||||
sourceText.AppendLine(" {");
|
||||
sourceText.AppendLine($" return {packageClassName}.Current.BuildIcon({packageName}IconKind.{info.Name}{info.ThemeType});");
|
||||
sourceText.AppendLine(" }\n");
|
||||
|
||||
sourceText.AppendLine($" public static Icon {info.Name}{info.ThemeType}(ColorInfo colorInfo)");
|
||||
sourceText.AppendLine($" public static AtomUI.IconPkg.Icon {info.Name}{info.ThemeType}(ColorInfo colorInfo)");
|
||||
sourceText.AppendLine(" {");
|
||||
sourceText.AppendLine($" return {packageClassName}.Current.BuildIcon({packageName}IconKind.{info.Name}{info.ThemeType}, colorInfo);");
|
||||
sourceText.AppendLine(" }\n");
|
||||
|
||||
sourceText.AppendLine($" public static Icon {info.Name}{info.ThemeType}(TwoToneColorInfo twoToneColorInfo)");
|
||||
sourceText.AppendLine($" public static AtomUI.IconPkg.Icon {info.Name}{info.ThemeType}(TwoToneColorInfo twoToneColorInfo)");
|
||||
sourceText.AppendLine(" {");
|
||||
sourceText.AppendLine($" return {packageClassName}.Current.BuildIcon({packageName}IconKind.{info.Name}{info.ThemeType}, twoToneColorInfo);");
|
||||
sourceText.AppendLine(" }\n");
|
||||
@ -128,7 +129,7 @@ public class IconPackageGenerator : IIncrementalGenerator
|
||||
|
||||
var viewBox = svgParsedInfo.ViewBox;
|
||||
sourceText.Append(
|
||||
$" _iconInfoPool.Add((int){packageName}IconKind.{info.Name}{info.ThemeType}, ");
|
||||
$" _iconInfoPool.Add((int){packageName}IconKind.{info.Name}{info.ThemeType}, ");
|
||||
|
||||
sourceText.Append("new Lazy<IconInfo>(() => new IconInfo(");
|
||||
sourceText.Append($"\"{info.Name}{info.ThemeType}\", ");
|
||||
|
Loading…
Reference in New Issue
Block a user