misc: update timelineitem style

This commit is contained in:
rabbitism
2023-03-23 23:25:29 +08:00
parent 2b183027b1
commit 2a38bb09a2
3 changed files with 10 additions and 77 deletions

View File

@@ -16,18 +16,9 @@
</UserControl.Resources>
<StackPanel>
<u:Timeline>
<u:TimelineItem
Content="Start"
Description="Get Started!"
Time="2022-01-01" />
<u:TimelineItem
Content="In between"
Description="In Process!"
Time="2022-01-02" />
<u:TimelineItem
Content="Finished"
Description="Done!"
Time="2022-01-03" />
<u:TimelineItem Content="Start" Time="2022-01-01" />
<u:TimelineItem Content="In between" Time="2022-01-02" />
<u:TimelineItem Content="Finished" Time="2022-01-03" />
</u:Timeline>
<u:Timeline HorizontalAlignment="Left" ItemsSource="{Binding Items}">
<u:Timeline.ItemTemplate>

View File

@@ -33,7 +33,7 @@
Width="1"
VerticalAlignment="Stretch"
Classes="end"
Fill="Gray" />
Fill="LightGray" />
<Grid
Grid.Row="0"
Grid.RowSpan="2"
@@ -47,29 +47,29 @@
Height="8"
VerticalAlignment="Top"
Classes="start"
Fill="Red" />
Fill="LightGray" />
<Ellipse
Grid.Row="1"
Width="8"
Height="8"
Margin="4"
Margin="2"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="Gray" />
Fill="LightGray" />
<Rectangle
Grid.Row="2"
Grid.Column="0"
Width="1"
VerticalAlignment="Stretch"
Classes="end"
Fill="Gray" />
Fill="LightGray" />
</Grid>
<ContentPresenter
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Foreground="DarkGray">
Foreground="Gray">
<ContentPresenter.Content>
<MultiBinding Converter="{StaticResource FormatConverter}">
<Binding Path="Time" RelativeSource="{RelativeSource TemplatedParent}" />

View File

@@ -23,15 +23,6 @@ public class TimelineItem: ContentControl
set => SetValue(IconForegroundProperty, value);
}
public static readonly StyledProperty<object?> DescriptionProperty =
AvaloniaProperty.Register<TimelineItem, object?>(nameof(Description));
public object? Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
public static readonly StyledProperty<DateTime> TimeProperty = AvaloniaProperty.Register<TimelineItem, DateTime>(
nameof(Time));
public DateTime Time
@@ -41,7 +32,7 @@ public class TimelineItem: ContentControl
}
public static readonly StyledProperty<string?> TimeFormatProperty = AvaloniaProperty.Register<TimelineItem, string?>(
nameof(TimeFormat), defaultValue:CultureInfo.CurrentUICulture.DateTimeFormat.SortableDateTimePattern);
nameof(TimeFormat), defaultValue:CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern);
public string? TimeFormat
{
@@ -63,53 +54,4 @@ public class TimelineItem: ContentControl
PseudoClasses.Set(PC_First, isFirst);
PseudoClasses.Set(PC_Last, isLast);
}
}
public class TimelineItemLayoutProperties: AvaloniaObject
{
private double _dimensionDelta = 0.01;
public static readonly StyledProperty<double> TimeSlotWidthProperty = AvaloniaProperty.Register<TimelineItemLayoutProperties, double>(
nameof(TimeSlotWidth));
public double TimeSlotWidth
{
get => GetValue(TimeSlotWidthProperty);
set
{
if (Math.Abs(GetValue(TimeSlotWidthProperty) - value) < _dimensionDelta) return;
SetValue(TimeSlotWidthProperty, value);
}
}
public static readonly StyledProperty<double> TimeSlotHeightProperty = AvaloniaProperty.Register<TimelineItemLayoutProperties, double>(
nameof(TimeSlotHeight));
public double TimeSlotHeight
{
get => GetValue(TimeSlotHeightProperty);
set
{
if (Math.Abs(GetValue(TimeSlotHeightProperty) - value) < _dimensionDelta) return;
SetValue(TimeSlotHeightProperty, value);
}
}
public static readonly StyledProperty<double> ContentSlotWidthProperty = AvaloniaProperty.Register<TimelineItemLayoutProperties, double>(
nameof(ContentSlotWidth));
public double ContentSlotWidth
{
get => GetValue(ContentSlotWidthProperty);
set => SetValue(ContentSlotWidthProperty, value);
}
public static readonly StyledProperty<double> ContentSlotHeightProperty = AvaloniaProperty.Register<TimelineItemLayoutProperties, double>(
nameof(ContentSlotHeight));
public double ContentSlotHeight
{
get => GetValue(ContentSlotHeightProperty);
set => SetValue(ContentSlotHeightProperty, value);
}
}