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> </UserControl.Resources>
<StackPanel> <StackPanel>
<u:Timeline> <u:Timeline>
<u:TimelineItem <u:TimelineItem Content="Start" Time="2022-01-01" />
Content="Start" <u:TimelineItem Content="In between" Time="2022-01-02" />
Description="Get Started!" <u:TimelineItem Content="Finished" Time="2022-01-03" />
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:Timeline> </u:Timeline>
<u:Timeline HorizontalAlignment="Left" ItemsSource="{Binding Items}"> <u:Timeline HorizontalAlignment="Left" ItemsSource="{Binding Items}">
<u:Timeline.ItemTemplate> <u:Timeline.ItemTemplate>

View File

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

View File

@@ -23,15 +23,6 @@ public class TimelineItem: ContentControl
set => SetValue(IconForegroundProperty, value); 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>( public static readonly StyledProperty<DateTime> TimeProperty = AvaloniaProperty.Register<TimelineItem, DateTime>(
nameof(Time)); nameof(Time));
public DateTime Time public DateTime Time
@@ -41,7 +32,7 @@ public class TimelineItem: ContentControl
} }
public static readonly StyledProperty<string?> TimeFormatProperty = AvaloniaProperty.Register<TimelineItem, string?>( 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 public string? TimeFormat
{ {
@@ -64,52 +55,3 @@ public class TimelineItem: ContentControl
PseudoClasses.Set(PC_Last, isLast); 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);
}
}