Only show hollow stars in editing mode
This commit is contained in:
parent
05ac5c63e1
commit
b4838d364e
@ -15,7 +15,7 @@
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
|
||||
<TextBlock IsVisible="false" Grid.Column="0" Grid.Row="0" Name="tblockOverall" Text="Overall:" />
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Name="tblockOverall" Text="Overall:" />
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Name="tblockPerform" Text="Perform:" />
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Name="tblockStory" Text="Story:" />
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ namespace LibationAvalonia.Controls
|
||||
public static readonly StyledProperty<Rating> RatingProperty =
|
||||
AvaloniaProperty.Register<MyRatingCellEditor, Rating>(nameof(Rating));
|
||||
|
||||
public bool AllRatingsVisible { get; set; }
|
||||
public bool IsEditingMode { get; set; }
|
||||
public Rating Rating
|
||||
{
|
||||
get { return GetValue(RatingProperty); }
|
||||
@ -30,19 +30,21 @@ namespace LibationAvalonia.Controls
|
||||
{
|
||||
if (change.Property.Name == nameof(Rating) && Rating is not null)
|
||||
{
|
||||
var blankValue = IsEditingMode ? HOLLOW_STAR : string.Empty;
|
||||
|
||||
int rating = 0;
|
||||
foreach (TextBlock star in panelOverall.Children)
|
||||
star.Tag = star.Text = Rating.OverallRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
|
||||
star.Tag = star.Text = Rating.OverallRating > rating++ ? SOLID_STAR : blankValue;
|
||||
|
||||
rating = 0;
|
||||
foreach (TextBlock star in panelPerform.Children)
|
||||
star.Tag = star.Text = Rating.PerformanceRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
|
||||
star.Tag = star.Text = Rating.PerformanceRating > rating++ ? SOLID_STAR : blankValue;
|
||||
|
||||
rating = 0;
|
||||
foreach (TextBlock star in panelStory.Children)
|
||||
star.Tag = star.Text = Rating.StoryRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
|
||||
star.Tag = star.Text = Rating.StoryRating > rating++ ? SOLID_STAR : blankValue;
|
||||
|
||||
SetVisible(AllRatingsVisible);
|
||||
SetVisible(IsEditingMode);
|
||||
}
|
||||
base.OnPropertyChanged(change);
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ namespace LibationAvalonia.Controls
|
||||
Name = "CellMyRatingDisplay",
|
||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left,
|
||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
||||
AllRatingsVisible = false,
|
||||
IsEditingMode = false,
|
||||
Margin = new Thickness(3),
|
||||
IsEnabled = false
|
||||
};
|
||||
@ -42,7 +42,7 @@ namespace LibationAvalonia.Controls
|
||||
Name = "CellMyRatingCellEditor",
|
||||
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left,
|
||||
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center,
|
||||
AllRatingsVisible = true,
|
||||
IsEditingMode = true,
|
||||
Margin = new Thickness(3)
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user