mirror of
https://gitee.com/chinware/atomui.git
synced 2024-11-30 02:47:45 +08:00
重构预设颜色枚举
This commit is contained in:
parent
46aea30ced
commit
b9167a4449
@ -25,8 +25,8 @@
|
||||
<Grid>
|
||||
<Grid.Styles>
|
||||
<Style Selector="atom|Button">
|
||||
<Setter Property="Margin" Value="5"/>
|
||||
<Setter Property="Width" Value="80"/>
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="Width" Value="80" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Grid.RowDefinitions>
|
||||
@ -56,7 +56,7 @@
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>LeftEdgeAlignedBottom</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
|
||||
<atom:Button Grid.Row="0" Grid.Column="1" Text="TL">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>TopEdgeAlignedLeft</atom:ToolTip.Placement>
|
||||
@ -69,7 +69,7 @@
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>TopEdgeAlignedRight</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
|
||||
<atom:Button Grid.Row="1" Grid.Column="4" Text="RT">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>RightEdgeAlignedTop</atom:ToolTip.Placement>
|
||||
@ -82,7 +82,7 @@
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>RightEdgeAlignedBottom</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
|
||||
<atom:Button Grid.Row="4" Grid.Column="1" Text="BL">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>BottomEdgeAlignedLeft</atom:ToolTip.Placement>
|
||||
@ -98,5 +98,109 @@
|
||||
|
||||
</Grid>
|
||||
</showcase:ShowCaseItem>
|
||||
|
||||
<showcase:ShowCaseItem
|
||||
Title="Arrow"
|
||||
Description="Support show, hide or keep arrow in the center.">
|
||||
<StackPanel Orientation="Vertical" Spacing="10">
|
||||
<atom:Segmented>
|
||||
<atom:SegmentedItem>Show</atom:SegmentedItem>
|
||||
<atom:SegmentedItem>Hide</atom:SegmentedItem>
|
||||
<atom:SegmentedItem>Center</atom:SegmentedItem>
|
||||
</atom:Segmented>
|
||||
<Grid>
|
||||
<Grid.Styles>
|
||||
<Style Selector="atom|Button">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="Width" Value="80" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
<RowDefinition Height="Auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<atom:Button Grid.Row="1" Grid.Column="0" Text="LT">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>LeftEdgeAlignedTop</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="2" Grid.Column="0" Text="Left">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>Left</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="3" Grid.Column="0" Text="LB">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>LeftEdgeAlignedBottom</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
<atom:Button Grid.Row="0" Grid.Column="1" Text="TL">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>TopEdgeAlignedLeft</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="0" Grid.Column="2" Text="Top">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>Top</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="0" Grid.Column="3" Text="TR">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>TopEdgeAlignedRight</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
<atom:Button Grid.Row="1" Grid.Column="4" Text="RT">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>RightEdgeAlignedTop</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="2" Grid.Column="4" Text="Right">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>Right</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="3" Grid.Column="4" Text="RB">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>RightEdgeAlignedBottom</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
<atom:Button Grid.Row="4" Grid.Column="1" Text="BL">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>BottomEdgeAlignedLeft</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="4" Grid.Column="2" Text="Bottom">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>Bottom</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
<atom:Button Grid.Row="4" Grid.Column="3" Text="BR">
|
||||
<atom:ToolTip.Tip>prompt text</atom:ToolTip.Tip>
|
||||
<atom:ToolTip.Placement>BottomEdgeAlignedRight</atom:ToolTip.Placement>
|
||||
</atom:Button>
|
||||
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</showcase:ShowCaseItem>
|
||||
|
||||
|
||||
<showcase:ShowCaseItem
|
||||
Title="Colorful Tooltip"
|
||||
Description="We preset a series of colorful Tooltip styles for use in different situations.">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock FontWeight="Bold" FontSize="14" Margin="0, 0, 0, 10">Presets</TextBlock>
|
||||
<WrapPanel HorizontalAlignment="Left">
|
||||
|
||||
</WrapPanel>
|
||||
|
||||
<TextBlock FontWeight="Bold" FontSize="14" Margin="0, 20, 0, 10">Custom</TextBlock>
|
||||
<WrapPanel HorizontalAlignment="Left">
|
||||
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</showcase:ShowCaseItem>
|
||||
</showcase:ShowCasePanel>
|
||||
</UserControl>
|
@ -2,71 +2,73 @@
|
||||
|
||||
namespace AtomUI.ColorSystem;
|
||||
|
||||
public enum PresetColorType
|
||||
{
|
||||
Red,
|
||||
Volcano,
|
||||
Orange,
|
||||
Gold,
|
||||
Yellow,
|
||||
Lime,
|
||||
Green,
|
||||
Cyan,
|
||||
Blue,
|
||||
GeekBlue,
|
||||
Purple,
|
||||
Pink,
|
||||
Magenta,
|
||||
Grey,
|
||||
}
|
||||
|
||||
public class PresetPrimaryColor : IEquatable<PresetPrimaryColor>
|
||||
{
|
||||
public enum ColorType
|
||||
{
|
||||
Red,
|
||||
Volcano,
|
||||
Orange,
|
||||
Gold,
|
||||
Yellow,
|
||||
Lime,
|
||||
Green,
|
||||
Cyan,
|
||||
Blue,
|
||||
GeekBlue,
|
||||
Purple,
|
||||
Pink,
|
||||
Magenta,
|
||||
Grey,
|
||||
}
|
||||
|
||||
public static readonly PresetPrimaryColor Red = new PresetPrimaryColor(ColorType.Red);
|
||||
public static readonly PresetPrimaryColor Volcano = new PresetPrimaryColor(ColorType.Volcano);
|
||||
public static readonly PresetPrimaryColor Orange = new PresetPrimaryColor(ColorType.Orange);
|
||||
public static readonly PresetPrimaryColor Gold = new PresetPrimaryColor(ColorType.Gold);
|
||||
public static readonly PresetPrimaryColor Yellow = new PresetPrimaryColor(ColorType.Yellow);
|
||||
public static readonly PresetPrimaryColor Lime = new PresetPrimaryColor(ColorType.Lime);
|
||||
public static readonly PresetPrimaryColor Green = new PresetPrimaryColor(ColorType.Green);
|
||||
public static readonly PresetPrimaryColor Cyan = new PresetPrimaryColor(ColorType.Cyan);
|
||||
public static readonly PresetPrimaryColor Blue = new PresetPrimaryColor(ColorType.Blue);
|
||||
public static readonly PresetPrimaryColor GeekBlue = new PresetPrimaryColor(ColorType.GeekBlue);
|
||||
public static readonly PresetPrimaryColor Purple = new PresetPrimaryColor(ColorType.Purple);
|
||||
public static readonly PresetPrimaryColor Pink = new PresetPrimaryColor(ColorType.Pink);
|
||||
public static readonly PresetPrimaryColor Magenta = new PresetPrimaryColor(ColorType.Magenta);
|
||||
public static readonly PresetPrimaryColor Grey = new PresetPrimaryColor(ColorType.Grey);
|
||||
|
||||
public static readonly PresetPrimaryColor Red = new PresetPrimaryColor(PresetColorType.Red);
|
||||
public static readonly PresetPrimaryColor Volcano = new PresetPrimaryColor(PresetColorType.Volcano);
|
||||
public static readonly PresetPrimaryColor Orange = new PresetPrimaryColor(PresetColorType.Orange);
|
||||
public static readonly PresetPrimaryColor Gold = new PresetPrimaryColor(PresetColorType.Gold);
|
||||
public static readonly PresetPrimaryColor Yellow = new PresetPrimaryColor(PresetColorType.Yellow);
|
||||
public static readonly PresetPrimaryColor Lime = new PresetPrimaryColor(PresetColorType.Lime);
|
||||
public static readonly PresetPrimaryColor Green = new PresetPrimaryColor(PresetColorType.Green);
|
||||
public static readonly PresetPrimaryColor Cyan = new PresetPrimaryColor(PresetColorType.Cyan);
|
||||
public static readonly PresetPrimaryColor Blue = new PresetPrimaryColor(PresetColorType.Blue);
|
||||
public static readonly PresetPrimaryColor GeekBlue = new PresetPrimaryColor(PresetColorType.GeekBlue);
|
||||
public static readonly PresetPrimaryColor Purple = new PresetPrimaryColor(PresetColorType.Purple);
|
||||
public static readonly PresetPrimaryColor Pink = new PresetPrimaryColor(PresetColorType.Pink);
|
||||
public static readonly PresetPrimaryColor Magenta = new PresetPrimaryColor(PresetColorType.Magenta);
|
||||
public static readonly PresetPrimaryColor Grey = new PresetPrimaryColor(PresetColorType.Grey);
|
||||
|
||||
public ColorType Type { get; }
|
||||
public PresetColorType Type { get; }
|
||||
|
||||
public PresetPrimaryColor(ColorType colorType)
|
||||
public PresetPrimaryColor(PresetColorType colorType)
|
||||
{
|
||||
Type = colorType;
|
||||
}
|
||||
|
||||
public string Name()
|
||||
{
|
||||
return Enum.GetName(typeof(ColorType), Type)!;
|
||||
return Enum.GetName(typeof(PresetColorType), Type)!;
|
||||
}
|
||||
|
||||
public string RgbHex()
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
ColorType.Red => "#F5222D",
|
||||
ColorType.Volcano => "#FA541C",
|
||||
ColorType.Orange => "#FA8C16",
|
||||
ColorType.Gold => "#FAAD14",
|
||||
ColorType.Yellow => "#FADB14",
|
||||
ColorType.Lime => "#A0D911",
|
||||
ColorType.Green => "#52C41A",
|
||||
ColorType.Cyan => "#13C2C2",
|
||||
ColorType.Blue => "#1677FF",
|
||||
ColorType.GeekBlue => "#2F54EB",
|
||||
ColorType.Purple => "#722ED1",
|
||||
ColorType.Magenta => "#EB2F96",
|
||||
ColorType.Pink => "#EB2F96",
|
||||
ColorType.Grey => "#666666",
|
||||
PresetColorType.Red => "#F5222D",
|
||||
PresetColorType.Volcano => "#FA541C",
|
||||
PresetColorType.Orange => "#FA8C16",
|
||||
PresetColorType.Gold => "#FAAD14",
|
||||
PresetColorType.Yellow => "#FADB14",
|
||||
PresetColorType.Lime => "#A0D911",
|
||||
PresetColorType.Green => "#52C41A",
|
||||
PresetColorType.Cyan => "#13C2C2",
|
||||
PresetColorType.Blue => "#1677FF",
|
||||
PresetColorType.GeekBlue => "#2F54EB",
|
||||
PresetColorType.Purple => "#722ED1",
|
||||
PresetColorType.Magenta => "#EB2F96",
|
||||
PresetColorType.Pink => "#EB2F96",
|
||||
PresetColorType.Grey => "#666666",
|
||||
_ => "#666666"
|
||||
};
|
||||
}
|
||||
@ -80,20 +82,20 @@ public class PresetPrimaryColor : IEquatable<PresetPrimaryColor>
|
||||
{
|
||||
return new List<PresetPrimaryColor>
|
||||
{
|
||||
new PresetPrimaryColor(ColorType.Red),
|
||||
new PresetPrimaryColor(ColorType.Volcano),
|
||||
new PresetPrimaryColor(ColorType.Orange),
|
||||
new PresetPrimaryColor(ColorType.Gold),
|
||||
new PresetPrimaryColor(ColorType.Yellow),
|
||||
new PresetPrimaryColor(ColorType.Lime),
|
||||
new PresetPrimaryColor(ColorType.Green),
|
||||
new PresetPrimaryColor(ColorType.Cyan),
|
||||
new PresetPrimaryColor(ColorType.Blue),
|
||||
new PresetPrimaryColor(ColorType.GeekBlue),
|
||||
new PresetPrimaryColor(ColorType.Purple),
|
||||
new PresetPrimaryColor(ColorType.Pink),
|
||||
new PresetPrimaryColor(ColorType.Magenta),
|
||||
new PresetPrimaryColor(ColorType.Grey),
|
||||
new PresetPrimaryColor(PresetColorType.Red),
|
||||
new PresetPrimaryColor(PresetColorType.Volcano),
|
||||
new PresetPrimaryColor(PresetColorType.Orange),
|
||||
new PresetPrimaryColor(PresetColorType.Gold),
|
||||
new PresetPrimaryColor(PresetColorType.Yellow),
|
||||
new PresetPrimaryColor(PresetColorType.Lime),
|
||||
new PresetPrimaryColor(PresetColorType.Green),
|
||||
new PresetPrimaryColor(PresetColorType.Cyan),
|
||||
new PresetPrimaryColor(PresetColorType.Blue),
|
||||
new PresetPrimaryColor(PresetColorType.GeekBlue),
|
||||
new PresetPrimaryColor(PresetColorType.Purple),
|
||||
new PresetPrimaryColor(PresetColorType.Pink),
|
||||
new PresetPrimaryColor(PresetColorType.Magenta),
|
||||
new PresetPrimaryColor(PresetColorType.Grey),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public partial class Tag : Label, ITokenIdProvider
|
||||
{
|
||||
_presetColorMap = new Dictionary<TagPresetColor, TagCalcColor>();
|
||||
_statusColorMap = new Dictionary<TagStatus, TagStatusCalcColor>();
|
||||
_colorCodeMap = new Dictionary<TagPresetColor, PresetPrimaryColor.ColorType>();
|
||||
_colorCodeMap = new Dictionary<TagPresetColor, PresetColorType>();
|
||||
SetupColorCodeMap();
|
||||
AffectsMeasure<Tag>(BorderedProperty,
|
||||
IconProperty,
|
||||
|
@ -36,7 +36,7 @@ public partial class Tag : IControlCustomStyle
|
||||
private bool _hasColorSet = false;
|
||||
private static Dictionary<TagPresetColor, TagCalcColor> _presetColorMap;
|
||||
private static Dictionary<TagStatus, TagStatusCalcColor> _statusColorMap;
|
||||
private static Dictionary<TagPresetColor, PresetPrimaryColor.ColorType> _colorCodeMap;
|
||||
private static Dictionary<TagPresetColor, PresetColorType> _colorCodeMap;
|
||||
private Panel? _layoutPanel;
|
||||
private TextBlock? _textBlock;
|
||||
|
||||
@ -189,19 +189,19 @@ public partial class Tag : IControlCustomStyle
|
||||
|
||||
private static void SetupColorCodeMap()
|
||||
{
|
||||
_colorCodeMap.Add(TagPresetColor.Red, PresetPrimaryColor.ColorType.Red);
|
||||
_colorCodeMap.Add(TagPresetColor.Volcano, PresetPrimaryColor.ColorType.Volcano);
|
||||
_colorCodeMap.Add(TagPresetColor.Orange, PresetPrimaryColor.ColorType.Orange);
|
||||
_colorCodeMap.Add(TagPresetColor.Gold, PresetPrimaryColor.ColorType.Gold);
|
||||
_colorCodeMap.Add(TagPresetColor.Yellow, PresetPrimaryColor.ColorType.Yellow);
|
||||
_colorCodeMap.Add(TagPresetColor.Lime, PresetPrimaryColor.ColorType.Lime);
|
||||
_colorCodeMap.Add(TagPresetColor.Green, PresetPrimaryColor.ColorType.Green);
|
||||
_colorCodeMap.Add(TagPresetColor.Cyan, PresetPrimaryColor.ColorType.Cyan);
|
||||
_colorCodeMap.Add(TagPresetColor.Blue, PresetPrimaryColor.ColorType.Blue);
|
||||
_colorCodeMap.Add(TagPresetColor.GeekBlue, PresetPrimaryColor.ColorType.GeekBlue);
|
||||
_colorCodeMap.Add(TagPresetColor.Purple, PresetPrimaryColor.ColorType.Purple);
|
||||
_colorCodeMap.Add(TagPresetColor.Pink, PresetPrimaryColor.ColorType.Pink);
|
||||
_colorCodeMap.Add(TagPresetColor.Magenta, PresetPrimaryColor.ColorType.Magenta);
|
||||
_colorCodeMap.Add(TagPresetColor.Red, PresetColorType.Red);
|
||||
_colorCodeMap.Add(TagPresetColor.Volcano, PresetColorType.Volcano);
|
||||
_colorCodeMap.Add(TagPresetColor.Orange, PresetColorType.Orange);
|
||||
_colorCodeMap.Add(TagPresetColor.Gold, PresetColorType.Gold);
|
||||
_colorCodeMap.Add(TagPresetColor.Yellow, PresetColorType.Yellow);
|
||||
_colorCodeMap.Add(TagPresetColor.Lime, PresetColorType.Lime);
|
||||
_colorCodeMap.Add(TagPresetColor.Green, PresetColorType.Green);
|
||||
_colorCodeMap.Add(TagPresetColor.Cyan, PresetColorType.Cyan);
|
||||
_colorCodeMap.Add(TagPresetColor.Blue, PresetColorType.Blue);
|
||||
_colorCodeMap.Add(TagPresetColor.GeekBlue, PresetColorType.GeekBlue);
|
||||
_colorCodeMap.Add(TagPresetColor.Purple, PresetColorType.Purple);
|
||||
_colorCodeMap.Add(TagPresetColor.Pink, PresetColorType.Pink);
|
||||
_colorCodeMap.Add(TagPresetColor.Magenta, PresetColorType.Magenta);
|
||||
}
|
||||
|
||||
private Rect IconRect(Size controlSize)
|
||||
|
@ -9,7 +9,6 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Primitives.PopupPositioning;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Styling;
|
||||
using Avalonia.VisualTree;
|
||||
|
@ -92,7 +92,6 @@ public partial class ToolTip : IControlCustomStyle
|
||||
targetHeight += arrowSize;
|
||||
}
|
||||
}
|
||||
|
||||
return new Size(targetWidth, targetHeight);
|
||||
}
|
||||
|
||||
@ -101,7 +100,6 @@ public partial class ToolTip : IControlCustomStyle
|
||||
var visualChildren = VisualChildren;
|
||||
var visualCount = visualChildren.Count;
|
||||
var contentRect = GetContentRect(finalSize);
|
||||
|
||||
for (int i = 0; i < visualCount; ++i) {
|
||||
var child = visualChildren[i];
|
||||
if (child is Layoutable layoutable) {
|
||||
@ -125,13 +123,15 @@ public partial class ToolTip : IControlCustomStyle
|
||||
if (direction == Direction.Left || direction == Direction.Right) {
|
||||
targetWidth -= arrowSize;
|
||||
} else {
|
||||
targetHeight -= arrowSize;
|
||||
targetHeight -= arrowSize + 0.5;
|
||||
}
|
||||
|
||||
if (direction == Direction.Right) {
|
||||
offsetX = arrowSize;
|
||||
} else if (direction == Direction.Bottom) {
|
||||
offsetY = arrowSize;
|
||||
} else if (direction == Direction.Top) {
|
||||
offsetY = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,23 +149,71 @@ public partial class ToolTip : IControlCustomStyle
|
||||
if (IsShowArrow(adornedControl)) {
|
||||
var minValue = Math.Min(size.Width, size.Height);
|
||||
var maxValue = Math.Max(size.Width, size.Height);
|
||||
var direction = GetDirection(GetPlacement(adornedControl));
|
||||
if (direction == Direction.Left) {
|
||||
var placement = GetPlacement(adornedControl);
|
||||
if (placement == PlacementType.Left ||
|
||||
placement == PlacementType.LeftEdgeAlignedTop ||
|
||||
placement == PlacementType.LeftEdgeAlignedBottom) {
|
||||
offsetX = finalSize.Width - minValue;
|
||||
offsetY = (finalSize.Height - maxValue) / 2;
|
||||
if (placement == PlacementType.Left) {
|
||||
offsetY = (finalSize.Height - maxValue) / 2;
|
||||
} else if (placement == PlacementType.LeftEdgeAlignedTop) {
|
||||
if (maxValue * 2 > finalSize.Height / 2) {
|
||||
offsetY = minValue;
|
||||
} else {
|
||||
offsetY = maxValue;
|
||||
}
|
||||
} else {
|
||||
if (maxValue * 2 > finalSize.Height / 2) {
|
||||
offsetY = finalSize.Height - minValue - maxValue;
|
||||
} else {
|
||||
offsetY = finalSize.Height - maxValue * 2;
|
||||
}
|
||||
}
|
||||
|
||||
targetWidth = minValue;
|
||||
targetHeight = maxValue;
|
||||
} else if (direction == Direction.Top) {
|
||||
offsetX = (finalSize.Width - maxValue) / 2;
|
||||
} else if (placement == PlacementType.Top ||
|
||||
placement == PlacementType.TopEdgeAlignedLeft ||
|
||||
placement == PlacementType.TopEdgeAlignedRight) {
|
||||
offsetY = finalSize.Height - minValue;
|
||||
targetWidth = maxValue;
|
||||
targetHeight = minValue;
|
||||
} else if (direction == Direction.Right) {
|
||||
offsetY = (finalSize.Height - maxValue) / 2;
|
||||
if (placement == PlacementType.TopEdgeAlignedLeft) {
|
||||
offsetX = maxValue;
|
||||
} else if (placement == PlacementType.Top) {
|
||||
offsetX = (finalSize.Width - maxValue) / 2;
|
||||
} else {
|
||||
offsetX = finalSize.Width - maxValue * 2;
|
||||
}
|
||||
} else if (placement == PlacementType.Right ||
|
||||
placement == PlacementType.RightEdgeAlignedTop ||
|
||||
placement == PlacementType.RightEdgeAlignedBottom) {
|
||||
targetWidth = minValue;
|
||||
targetHeight = maxValue;
|
||||
if (placement == PlacementType.Right) {
|
||||
offsetY = (finalSize.Height - maxValue) / 2;
|
||||
} else if (placement == PlacementType.RightEdgeAlignedTop) {
|
||||
if (maxValue * 2 > finalSize.Height / 2) {
|
||||
offsetY = minValue;
|
||||
} else {
|
||||
offsetY = maxValue;
|
||||
}
|
||||
} else {
|
||||
if (maxValue * 2 > finalSize.Height / 2) {
|
||||
offsetY = finalSize.Height - minValue - maxValue;
|
||||
} else {
|
||||
offsetY = finalSize.Height - maxValue * 2;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
offsetX = (finalSize.Width - maxValue) / 2;
|
||||
if (placement == PlacementType.BottomEdgeAlignedLeft) {
|
||||
offsetX = maxValue;
|
||||
} else if (placement == PlacementType.Bottom) {
|
||||
offsetX = (finalSize.Width - maxValue) / 2;
|
||||
} else {
|
||||
offsetX = finalSize.Width - maxValue * 2;
|
||||
}
|
||||
targetWidth = maxValue;
|
||||
targetHeight = minValue;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class SeedDesignToken : AbstractDesignToken
|
||||
/// <summary>
|
||||
/// 现在这里的实现是写死的主色,后面是不是可以读取配置
|
||||
/// </summary>
|
||||
private IDictionary<PresetPrimaryColor.ColorType, PresetPrimaryColor> _defaultPresetColors;
|
||||
private IDictionary<PresetColorType, PresetPrimaryColor> _defaultPresetColors;
|
||||
|
||||
public SeedDesignToken()
|
||||
{
|
||||
@ -204,7 +204,7 @@ public class SeedDesignToken : AbstractDesignToken
|
||||
"Courier",
|
||||
"monospace"
|
||||
};
|
||||
_defaultPresetColors = new Dictionary<PresetPrimaryColor.ColorType, PresetPrimaryColor>();
|
||||
_defaultPresetColors = new Dictionary<PresetColorType, PresetPrimaryColor>();
|
||||
IList<PresetPrimaryColor> allColors = PresetPrimaryColor.AllColorTypes();
|
||||
foreach (PresetPrimaryColor color in allColors) {
|
||||
_defaultPresetColors[color.Type] = color;
|
||||
@ -214,7 +214,7 @@ public class SeedDesignToken : AbstractDesignToken
|
||||
ColorTransparent = Colors.Transparent;
|
||||
}
|
||||
|
||||
public PresetPrimaryColor GetPresetPrimaryColor(PresetPrimaryColor.ColorType colorType)
|
||||
public PresetPrimaryColor GetPresetPrimaryColor(PresetColorType colorType)
|
||||
{
|
||||
return _defaultPresetColors[colorType];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user