From b4838d364ed9c282ecd9789554dcd854e3376586 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 31 Dec 2022 10:33:18 -0700 Subject: [PATCH] Only show hollow stars in editing mode --- .../Controls/MyRatingCellEditor.axaml | 2 +- .../Controls/MyRatingCellEditor.axaml.cs | 12 +++++++----- .../Controls/MyRatingGridColumn.axaml.cs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml b/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml index 27b2592d..f15bea8e 100644 --- a/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml +++ b/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml @@ -15,7 +15,7 @@ - + diff --git a/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml.cs b/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml.cs index 89a5ec91..f0c584ab 100644 --- a/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml.cs +++ b/Source/LibationAvalonia/Controls/MyRatingCellEditor.axaml.cs @@ -13,7 +13,7 @@ namespace LibationAvalonia.Controls public static readonly StyledProperty RatingProperty = AvaloniaProperty.Register(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); } diff --git a/Source/LibationAvalonia/Controls/MyRatingGridColumn.axaml.cs b/Source/LibationAvalonia/Controls/MyRatingGridColumn.axaml.cs index c9e67099..736117f4 100644 --- a/Source/LibationAvalonia/Controls/MyRatingGridColumn.axaml.cs +++ b/Source/LibationAvalonia/Controls/MyRatingGridColumn.axaml.cs @@ -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) };