mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 05:10:25 +08:00
31 lines
813 B
C#
31 lines
813 B
C#
using System;
|
|
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Shapes;
|
|
using Avalonia.Media;
|
|
|
|
namespace SourceGit.Views
|
|
{
|
|
public class RepositoryCommandPaletteIcon : Path
|
|
{
|
|
protected override Type StyleKeyOverride => typeof(Path);
|
|
|
|
protected override void OnDataContextChanged(EventArgs e)
|
|
{
|
|
base.OnDataContextChanged(e);
|
|
|
|
if (DataContext is ViewModels.RepositoryCommandPaletteCmd cmd && !string.IsNullOrEmpty(cmd.Icon))
|
|
{
|
|
var geo = this.FindResource($"Icons.{cmd.Icon}") as StreamGeometry;
|
|
if (geo != null)
|
|
{
|
|
Data = geo;
|
|
return;
|
|
}
|
|
}
|
|
|
|
Data = this.FindResource("Icon.Command") as StreamGeometry;
|
|
}
|
|
}
|
|
}
|