mlaumcherb/Mlaumcherb.Client.Avalonia/зримое/VersionItemView.axaml.cs
2024-12-27 21:11:19 +05:00

34 lines
983 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Threading;
using Mlaumcherb.Client.Avalonia.классы;
namespace Mlaumcherb.Client.Avalonia.зримое;
public partial class VersionItemView : ListBoxItem
{
public GameVersionProps Props { get; }
private SolidColorBrush _avaliableColor = new(Color.FromRgb(30, 130, 40));
private SolidColorBrush _unavaliableColor = new(Color.FromRgb(170, 70, 70));
public VersionItemView()
{
throw new Exception();
}
public VersionItemView(GameVersionProps props)
{
Props = props;
InitializeComponent();
text.Text = props.Name;
props.StatusChanged += UpdateBackground;
UpdateBackground(props.IsDownloaded);
}
private void UpdateBackground(bool isDownloaded)
{
Dispatcher.UIThread.Invoke(() =>
Background = isDownloaded ? _avaliableColor : _unavaliableColor
);
}
}