feat: create new theme for textbox and use in TimePicker.
This commit is contained in:
79
src/Ursa.Themes.Semi/Controls/TextBox.axaml
Normal file
79
src/Ursa.Themes.Semi/Controls/TextBox.axaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="LooklessTextBox" TargetType="TextBox">
|
||||
<Setter Property="TextBox.Foreground" Value="{DynamicResource TextBoxForeground}" />
|
||||
<Setter Property="TextBox.SelectionBrush" Value="{DynamicResource TextBoxSelectionBackground}" />
|
||||
<Setter Property="TextBox.SelectionForegroundBrush" Value="{DynamicResource TextBoxSelectionForeground}" />
|
||||
<Setter Property="TextBox.FontSize" Value="14" />
|
||||
<Setter Property="TextBox.Cursor" Value="Ibeam" />
|
||||
<Setter Property="TextBox.CaretBrush" Value="{DynamicResource TextBoxTextCaretBrush}" />
|
||||
<Setter Property="TextBox.Padding" Value="{DynamicResource TextBoxContentPadding}" />
|
||||
<Setter Property="TextBox.MinHeight" Value="{DynamicResource TextBoxDefaultHeight}" />
|
||||
<Setter Property="TextBox.VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextBox.VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="TextBox.FocusAdorner" Value="{x:Null}" />
|
||||
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
|
||||
<Setter Property="TextBox.Template">
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border Name="PART_ContentPresenterBorder" MinHeight="{TemplateBinding MinHeight}">
|
||||
<Grid Margin="{TemplateBinding Padding}" ColumnDefinitions="Auto, *, Auto">
|
||||
<ContentPresenter
|
||||
Grid.Column="0"
|
||||
Padding="{DynamicResource TextBoxInnerLeftContentPadding}"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding InnerLeftContent}"
|
||||
Foreground="{DynamicResource TextBoxInnerForeground}"
|
||||
IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InnerLeftContent, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ScrollViewer
|
||||
Grid.Column="1"
|
||||
AllowAutoHide="{TemplateBinding (ScrollViewer.AllowAutoHide)}"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
|
||||
IsScrollChainingEnabled="{TemplateBinding (ScrollViewer.IsScrollChainingEnabled)}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
|
||||
<Panel>
|
||||
<TextBlock
|
||||
Name="PART_Watermark"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
IsVisible="{TemplateBinding Text,
|
||||
Converter={x:Static StringConverters.IsNullOrEmpty}}"
|
||||
Opacity="0.5"
|
||||
Text="{TemplateBinding Watermark}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||
<TextPresenter
|
||||
Name="PART_TextPresenter"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
CaretBrush="{TemplateBinding CaretBrush}"
|
||||
CaretIndex="{TemplateBinding CaretIndex}"
|
||||
LineHeight="{TemplateBinding LineHeight}"
|
||||
PasswordChar="{TemplateBinding PasswordChar}"
|
||||
RevealPassword="{TemplateBinding RevealPassword}"
|
||||
SelectionBrush="{TemplateBinding SelectionBrush}"
|
||||
SelectionEnd="{TemplateBinding SelectionEnd}"
|
||||
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
|
||||
SelectionStart="{TemplateBinding SelectionStart}"
|
||||
Text="{TemplateBinding Text,
|
||||
Mode=TwoWay}"
|
||||
TextAlignment="{TemplateBinding TextAlignment}"
|
||||
TextWrapping="{TemplateBinding TextWrapping}" />
|
||||
</Panel>
|
||||
</ScrollViewer>
|
||||
<ContentPresenter
|
||||
Grid.Column="2"
|
||||
Padding="{DynamicResource TextBoxInnerRightContentPadding}"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding InnerRightContent}"
|
||||
Foreground="{DynamicResource TextBoxInnerForeground}"
|
||||
IsVisible="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InnerRightContent, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Style Selector="^:disabled">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextBoxDisabledForeground}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
@@ -129,36 +129,12 @@
|
||||
Grid.Column="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
InnerLeftContent="{TemplateBinding InnerLeftContent}"
|
||||
InnerRightContent="{TemplateBinding InnerRightContent}"
|
||||
IsReadOnly="{TemplateBinding IsReadonly}"
|
||||
Theme="{DynamicResource NoErrorTextBox}"
|
||||
Theme="{DynamicResource LooklessTextBox}"
|
||||
Watermark="{TemplateBinding Watermark}">
|
||||
<TextBox.Styles>
|
||||
<Style Selector="TextBox#PART_TextBox:pointerover /template/ Border#PART_ContentPresenterBorder">
|
||||
<!-- By default the TextBox has its own focused state, override this to disable it here -->
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="TextBox#PART_TextBox:focus /template/ Border#PART_ContentPresenterBorder">
|
||||
<!-- By default the TextBox has its own focused state, override this to disable it here -->
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
</Style>
|
||||
<Style Selector="TextBox#PART_TextBox:disabled">
|
||||
<Style Selector="^ /template/ Border#PART_ContentPresenterBorder">
|
||||
<!-- By default the TextBox has its own disabled state, override this to make the border background show through -->
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
</Style>
|
||||
</TextBox.Styles>
|
||||
</TextBox>
|
||||
<Button
|
||||
Name="ClearButton"
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
<ResourceInclude Source="ScrollToButton.axaml" />
|
||||
<ResourceInclude Source="SelectionList.axaml" />
|
||||
<ResourceInclude Source="TagInput.axaml" />
|
||||
<ResourceInclude Source="TextBox.axaml" />
|
||||
<ResourceInclude Source="ThemeSelector.axaml" />
|
||||
<ResourceInclude Source="TimePicker.axaml" />
|
||||
<ResourceInclude Source="Timeline.axaml" />
|
||||
|
||||
8
src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs
Normal file
8
src/Ursa/Controls/DateTimePicker/TimeRangePicker.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
public class TimeRangePicker: TemplatedControl
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user