mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-02 07:06:36 +08:00
Compare commits
13 Commits
v11.2.1.9
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c8f3a4772 | ||
|
|
8ac1e010a3 | ||
|
|
985ad0c637 | ||
|
|
59576d4cfd | ||
|
|
c2a072041d | ||
|
|
a62655d25a | ||
|
|
2d2f2afec1 | ||
|
|
1f02f28f8b | ||
|
|
ec2202e2ef | ||
|
|
68dfaa8a57 | ||
|
|
16a8d6b37d | ||
|
|
6d0f3526a9 | ||
|
|
e5822ff6d1 |
@@ -48,6 +48,7 @@
|
|||||||
IsEnabled="False" />
|
IsEnabled="False" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<TextBox Width="300" Classes="TextArea" Watermark="TextArea TextBox" />
|
<TextBox Width="300" Classes="TextArea" Watermark="TextArea TextBox" />
|
||||||
|
<TextBox Width="300" Classes="TextArea ClearButton" Text="TextArea with ClearButton - text should be clearable" />
|
||||||
<TextBox
|
<TextBox
|
||||||
Width="300"
|
Width="300"
|
||||||
Theme="{StaticResource LooklessTextBox}"
|
Theme="{StaticResource LooklessTextBox}"
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
<Popup
|
<Popup
|
||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
PlacementTarget="{TemplateBinding}">
|
PlacementTarget="{TemplateBinding}">
|
||||||
<Border
|
<Border
|
||||||
@@ -67,6 +68,7 @@
|
|||||||
<Popup
|
<Popup
|
||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
MaxHeight="{TemplateBinding MaxDropDownHeight}"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
PlacementTarget="{TemplateBinding}">
|
PlacementTarget="{TemplateBinding}">
|
||||||
<Border
|
<Border
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
<Popup
|
<Popup
|
||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
Placement="BottomEdgeAlignedLeft"
|
Placement="BottomEdgeAlignedLeft"
|
||||||
PlacementTarget="{TemplateBinding}">
|
PlacementTarget="{TemplateBinding}">
|
||||||
|
|||||||
@@ -226,6 +226,7 @@
|
|||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
Placement="Bottom"
|
Placement="Bottom"
|
||||||
PlacementTarget="{TemplateBinding}"
|
PlacementTarget="{TemplateBinding}"
|
||||||
|
|||||||
@@ -191,6 +191,7 @@
|
|||||||
<Popup
|
<Popup
|
||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
HorizontalOffset="-8"
|
HorizontalOffset="-8"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="False"
|
IsLightDismissEnabled="False"
|
||||||
IsOpen="{TemplateBinding IsSubMenuOpen,
|
IsOpen="{TemplateBinding IsSubMenuOpen,
|
||||||
Mode=TwoWay}"
|
Mode=TwoWay}"
|
||||||
@@ -326,6 +327,7 @@
|
|||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
MinWidth="{Binding $parent[MenuItem].Bounds.Width}"
|
MinWidth="{Binding $parent[MenuItem].Bounds.Width}"
|
||||||
HorizontalOffset="-8"
|
HorizontalOffset="-8"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
IsOpen="{TemplateBinding IsSubMenuOpen,Mode=TwoWay}"
|
IsOpen="{TemplateBinding IsSubMenuOpen,Mode=TwoWay}"
|
||||||
OverlayInputPassThroughElement="{Binding $parent[Menu]}"
|
OverlayInputPassThroughElement="{Binding $parent[Menu]}"
|
||||||
|
|||||||
@@ -163,13 +163,15 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^.clearButton, ^.ClearButton">
|
<Style Selector="^.clearButton, ^.ClearButton">
|
||||||
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:focus:not(:empty) /template/ Button#PART_ClearButton">
|
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:not(:empty)">
|
||||||
<Setter Property="IsVisible" Value="True" />
|
<Style Selector="^:pointerover,^:focus">
|
||||||
</Style>
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:pointerover:not(:empty) /template/ Button#PART_ClearButton">
|
<Setter Property="IsVisible" Value="True" />
|
||||||
<Setter Property="IsVisible" Value="True" />
|
</Style>
|
||||||
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^.revealPasswordButton, ^.RevealPasswordButton">
|
<Style Selector="^.revealPasswordButton, ^.RevealPasswordButton">
|
||||||
<Setter Property="PasswordChar" Value="•" />
|
<Setter Property="PasswordChar" Value="•" />
|
||||||
<Style Selector="^ /template/ ToggleButton#PART_RevealButton">
|
<Style Selector="^ /template/ ToggleButton#PART_RevealButton">
|
||||||
@@ -222,8 +224,27 @@
|
|||||||
<Style Selector="^.TextArea">
|
<Style Selector="^.TextArea">
|
||||||
<Setter Property="AcceptsReturn" Value="True" />
|
<Setter Property="AcceptsReturn" Value="True" />
|
||||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap" />
|
||||||
<Setter Property="Padding" Value="{DynamicResource TextBoxTextAreaContentPadding}" />
|
<Setter Property="Padding" Value="{DynamicResource TextBoxTextAreaContentPadding}" />
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource TextBoxTextAreaHeight}" />
|
<Setter Property="MinHeight" Value="{DynamicResource TextBoxTextAreaHeight}" />
|
||||||
|
<Setter Property="TextInputOptions.ReturnKeyType" Value="Return" />
|
||||||
|
<Style Selector="^.clearButton, ^.ClearButton">
|
||||||
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
|
<Setter Property="VerticalAlignment" Value="Top" />
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
<Setter Property="IsTabStop" Value="False" />
|
||||||
|
<Setter Property="IsEnabled" Value="False" />
|
||||||
|
<Setter Property="Opacity" Value="0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[IsReadOnly=False]:not(:empty)">
|
||||||
|
<Style Selector="^:pointerover,^:focus">
|
||||||
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
|
<Setter Property="IsEnabled" Value="True" />
|
||||||
|
<Setter Property="Opacity" Value="1" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
@@ -370,13 +391,15 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^.clearButton, ^.ClearButton">
|
<Style Selector="^.clearButton, ^.ClearButton">
|
||||||
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:focus:not(:empty) /template/ Button#PART_ClearButton">
|
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:not(:empty)">
|
||||||
<Setter Property="IsVisible" Value="True" />
|
<Style Selector="^:pointerover,^:focus">
|
||||||
</Style>
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
<Style Selector="^[AcceptsReturn=False][IsReadOnly=False]:pointerover:not(:empty) /template/ Button#PART_ClearButton">
|
<Setter Property="IsVisible" Value="True" />
|
||||||
<Setter Property="IsVisible" Value="True" />
|
</Style>
|
||||||
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^.revealPasswordButton, ^.RevealPasswordButton">
|
<Style Selector="^.revealPasswordButton, ^.RevealPasswordButton">
|
||||||
<Setter Property="PasswordChar" Value="•" />
|
<Setter Property="PasswordChar" Value="•" />
|
||||||
<Style Selector="^ /template/ ToggleButton#PART_RevealButton">
|
<Style Selector="^ /template/ ToggleButton#PART_RevealButton">
|
||||||
@@ -429,8 +452,27 @@
|
|||||||
<Style Selector="^.TextArea">
|
<Style Selector="^.TextArea">
|
||||||
<Setter Property="AcceptsReturn" Value="True" />
|
<Setter Property="AcceptsReturn" Value="True" />
|
||||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap" />
|
||||||
<Setter Property="Padding" Value="{DynamicResource TextBoxTextAreaContentPadding}" />
|
<Setter Property="Padding" Value="{DynamicResource TextBoxTextAreaContentPadding}" />
|
||||||
<Setter Property="MinHeight" Value="{DynamicResource TextBoxTextAreaHeight}" />
|
<Setter Property="MinHeight" Value="{DynamicResource TextBoxTextAreaHeight}" />
|
||||||
|
<Setter Property="TextInputOptions.ReturnKeyType" Value="Return" />
|
||||||
|
<Style Selector="^.clearButton, ^.ClearButton">
|
||||||
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
|
<Setter Property="VerticalAlignment" Value="Top" />
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
<Setter Property="IsTabStop" Value="False" />
|
||||||
|
<Setter Property="IsEnabled" Value="False" />
|
||||||
|
<Setter Property="Opacity" Value="0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[IsReadOnly=False]:not(:empty)">
|
||||||
|
<Style Selector="^:pointerover,^:focus">
|
||||||
|
<Style Selector="^ /template/ Button#PART_ClearButton">
|
||||||
|
<Setter Property="IsEnabled" Value="True" />
|
||||||
|
<Setter Property="Opacity" Value="1" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
@@ -546,4 +588,4 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -291,6 +291,7 @@
|
|||||||
Name="PART_Popup"
|
Name="PART_Popup"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
|
InheritsTransform="True"
|
||||||
IsLightDismissEnabled="True"
|
IsLightDismissEnabled="True"
|
||||||
Placement="Bottom"
|
Placement="Bottom"
|
||||||
PlacementTarget="{TemplateBinding}"
|
PlacementTarget="{TemplateBinding}"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class SemiTheme : Styles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (TryGetLocaleResource(value, out var resource) && resource is not null)
|
if (TryGetLocaleResource(value, false, out var resource) && resource is not null)
|
||||||
{
|
{
|
||||||
_locale = value;
|
_locale = value;
|
||||||
foreach (var kv in resource) Resources[kv.Key] = kv.Value;
|
foreach (var kv in resource) Resources[kv.Key] = kv.Value;
|
||||||
@@ -65,6 +65,11 @@ public class SemiTheme : Styles
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryGetLocaleResource(CultureInfo? locale, out ResourceDictionary? resourceDictionary)
|
private static bool TryGetLocaleResource(CultureInfo? locale, out ResourceDictionary? resourceDictionary)
|
||||||
|
{
|
||||||
|
return TryGetLocaleResource(locale, false, out resourceDictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryGetLocaleResource(CultureInfo? locale, bool enableParentCultureFallback, out ResourceDictionary? resourceDictionary)
|
||||||
{
|
{
|
||||||
if (Equals(locale, CultureInfo.InvariantCulture))
|
if (Equals(locale, CultureInfo.InvariantCulture))
|
||||||
{
|
{
|
||||||
@@ -78,20 +83,56 @@ public class SemiTheme : Styles
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try exact match first
|
||||||
if (_localeToResource.TryGetValue(locale, out var resource))
|
if (_localeToResource.TryGetValue(locale, out var resource))
|
||||||
{
|
{
|
||||||
resourceDictionary = resource;
|
resourceDictionary = resource;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If enabled, try to find a culture that has this locale as parent or that shares the same parent
|
||||||
|
if (enableParentCultureFallback)
|
||||||
|
{
|
||||||
|
// Look for any supported culture that has this locale as its parent
|
||||||
|
foreach (var supportedCulture in _localeToResource.Keys)
|
||||||
|
{
|
||||||
|
if (Equals(supportedCulture.Parent, locale))
|
||||||
|
{
|
||||||
|
resourceDictionary = _localeToResource[supportedCulture];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this locale has a parent (and it's not invariant), try to find
|
||||||
|
// a supported culture that shares the same parent
|
||||||
|
var targetParent = locale.Parent;
|
||||||
|
if (!Equals(targetParent, CultureInfo.InvariantCulture))
|
||||||
|
{
|
||||||
|
foreach (var supportedCulture in _localeToResource.Keys)
|
||||||
|
{
|
||||||
|
if (Equals(supportedCulture.Parent, targetParent))
|
||||||
|
{
|
||||||
|
resourceDictionary = _localeToResource[supportedCulture];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resourceDictionary = _defaultResource;
|
resourceDictionary = _defaultResource;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OverrideLocaleResources(Application application, CultureInfo? culture)
|
public static void OverrideLocaleResources(Application application, CultureInfo? culture)
|
||||||
|
{
|
||||||
|
OverrideLocaleResources(application, culture, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OverrideLocaleResources(Application application, CultureInfo? culture, bool enableParentCultureFallback)
|
||||||
{
|
{
|
||||||
if (culture is null) return;
|
if (culture is null) return;
|
||||||
if (!_localeToResource.TryGetValue(culture, out var resources)) return;
|
if (!TryGetLocaleResource(culture, enableParentCultureFallback, out var resources)) return;
|
||||||
|
if (resources is null) return;
|
||||||
foreach (var kv in resources)
|
foreach (var kv in resources)
|
||||||
{
|
{
|
||||||
application.Resources[kv.Key] = kv.Value;
|
application.Resources[kv.Key] = kv.Value;
|
||||||
@@ -99,9 +140,15 @@ public class SemiTheme : Styles
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture)
|
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture)
|
||||||
|
{
|
||||||
|
OverrideLocaleResources(element, culture, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture, bool enableParentCultureFallback)
|
||||||
{
|
{
|
||||||
if (culture is null) return;
|
if (culture is null) return;
|
||||||
if (!_localeToResource.TryGetValue(culture, out var resources)) return;
|
if (!TryGetLocaleResource(culture, enableParentCultureFallback, out var resources)) return;
|
||||||
|
if (resources is null) return;
|
||||||
foreach (var kv in resources)
|
foreach (var kv in resources)
|
||||||
{
|
{
|
||||||
element.Resources[kv.Key] = kv.Value;
|
element.Resources[kv.Key] = kv.Value;
|
||||||
|
|||||||
Reference in New Issue
Block a user