- show icon of mapped controllable

master
Simon G 5 years ago
parent daf84fa5f4
commit e7ecc6903f
  1. 1
      Mystify/Mystify.csproj
  2. 2
      Mystify/Resources/ChannelTemplate.axaml
  3. 6
      Mystify/ViewModels/ControllableViewModel.cs
  4. 2
      Mystify/Views/ControllableSelectionWindow.axaml

@ -23,6 +23,7 @@
<ProjectReference Include="..\Lib.Midi\Lib.Midi.csproj" /> <ProjectReference Include="..\Lib.Midi\Lib.Midi.csproj" />
<ProjectReference Include="..\Lib.NotifyIcon\Lib.NotifyIcon.csproj" /> <ProjectReference Include="..\Lib.NotifyIcon\Lib.NotifyIcon.csproj" />
<ProjectReference Include="..\Lib.ProcessManaging\Lib.ProcessManaging.csproj" /> <ProjectReference Include="..\Lib.ProcessManaging\Lib.ProcessManaging.csproj" />
<ProjectReference Include="..\Lib.Tools.Avalonia\Lib.Tools.Avalonia.csproj" />
<ProjectReference Include="..\Lib.Tools\Lib.Tools.csproj" /> <ProjectReference Include="..\Lib.Tools\Lib.Tools.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -12,7 +12,7 @@
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="ControllableTemplate" DataType="{x:Type viewModels:ControllableViewModel}"> <DataTemplate x:Key="ControllableTemplate" DataType="{x:Type viewModels:ControllableViewModel}">
<TextBlock Text="{Binding Name}"/> <Image Source="{Binding Icon}"/>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="ChannelTemplate" DataType="{x:Type viewModels:ChannelViewModel}"> <DataTemplate x:Key="ChannelTemplate" DataType="{x:Type viewModels:ChannelViewModel}">

@ -4,7 +4,9 @@
using System; using System;
using System.Windows.Input; using System.Windows.Input;
using Avalonia.Media.Imaging;
using Lib.Audio.Interfaces; using Lib.Audio.Interfaces;
using Lib.Tools.Avalonia;
using ReactiveUI; using ReactiveUI;
namespace Mystify.ViewModels namespace Mystify.ViewModels
@ -12,12 +14,14 @@ namespace Mystify.ViewModels
public class ControllableViewModel : ViewModelBase public class ControllableViewModel : ViewModelBase
{ {
private bool _isSelected; private bool _isSelected;
private Bitmap? _icon;
public ControllableViewModel(IControllable controllable) => Controllable = controllable; public ControllableViewModel(IControllable controllable) => Controllable = controllable;
public IControllable Controllable { get; } public IControllable Controllable { get; }
public string Name => Controllable.Name; public string Name => Controllable.Name;
public string? IconPath => Controllable.IconPath; public Bitmap? Icon => string.IsNullOrEmpty(Controllable.ExecutablePath) ? null
: _icon ??= Icons.ExtractAssociatedIcon(Controllable.ExecutablePath);
public bool IsSelected public bool IsSelected
{ {

@ -23,7 +23,7 @@
<DataTemplate DataType="viewModels:ControllableViewModel"> <DataTemplate DataType="viewModels:ControllableViewModel">
<Button Command="{Binding SelectCommand}" HorizontalAlignment="Stretch"> <Button Command="{Binding SelectCommand}" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="{Binding IconPath}" Margin="10,5"/> <Image Source="{Binding Icon}" Margin="10,5"/>
<TextBlock Text="{Binding Name}" Margin="10,5"/> <TextBlock Text="{Binding Name}" Margin="10,5"/>
</StackPanel> </StackPanel>
</Button> </Button>

Loading…
Cancel
Save