Skip to content

Commit

Permalink
Minor updates to settings app. Nothing yet complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychlist1972 committed Feb 10, 2025
1 parent c7ddc7e commit 305dcd1
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public App()
services.AddTransient<EndpointsLoopPage>();
services.AddTransient<EndpointsLoopViewModel>();

services.AddTransient<EndpointsDiagPage>();
services.AddTransient<EndpointsDiagViewModel>();


services.AddTransient<DeviceDetailPage>();
services.AddTransient<DeviceDetailViewModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<helpers:HasUniqueIdToInverseVisibilityConverter x:Key="HasUniqueIdToInverseVisibilityConverter" />
<helpers:MidiEndpointNativeDataFormatConverter x:Key="MidiEndpointNativeDataFormatConverter" />
<helpers:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<helpers:BooleanToEmojiCheckConverter x:Key="BooleanToEmojiCheckConverter" />
<helpers:BooleanToFluentCheckConverter x:Key="BooleanToFluentCheckConverter" />
</ResourceDictionary>
</UserControl.Resources>

Expand Down Expand Up @@ -69,31 +69,36 @@
<TextBlock Grid.Row="0" Grid.Column="2"
Text="MIDI 1.0" Style="{StaticResource SmallPropertyLabel}" Margin="21,3,3,3"/>
<TextBlock Grid.Row="0" Grid.Column="3"
Text="{x:Bind EndpointItem.SupportsMidi10Protocol, Mode=OneTime, Converter={StaticResource BooleanToEmojiCheckConverter}}"
Text="{x:Bind EndpointItem.SupportsMidi10Protocol, Mode=OneTime, Converter={StaticResource BooleanToFluentCheckConverter}}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Style="{StaticResource SmallEmphasizedPropertyValue}"/>

<TextBlock Grid.Row="1" Grid.Column="2"
Text="MIDI 2.0" Style="{StaticResource SmallPropertyLabel}" Margin="21,3,3,3"/>
<TextBlock Grid.Row="1" Grid.Column="3"
Text="{x:Bind EndpointItem.SupportsMidi20Protocol, Mode=OneTime, Converter={StaticResource BooleanToEmojiCheckConverter}}"
Text="{x:Bind EndpointItem.SupportsMidi20Protocol, Mode=OneTime, Converter={StaticResource BooleanToFluentCheckConverter}}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Style="{StaticResource SmallEmphasizedPropertyValue}"/>


<TextBlock Grid.Row="0" Grid.Column="4"
Text="Unique Id?" Style="{StaticResource SmallPropertyLabel}" Margin="21,3,3,3"/>
<TextBlock Grid.Row="0" Grid.Column="5"
Text="☑️"
Text="&#xf16c;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Visibility="{x:Bind EndpointItem.TransportSuppliedSerialNumber, Mode=OneTime, Converter={StaticResource HasUniqueIdToVisibilityConverter}}"
Style="{StaticResource SmallEmphasizedPropertyValue}"/>
<TextBlock Grid.Row="0" Grid.Column="5"
Text=""
Text="&#xf16b;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Visibility="{x:Bind EndpointItem.TransportSuppliedSerialNumber, Mode=OneTime, Converter={StaticResource HasUniqueIdToInverseVisibilityConverter}}"
Style="{StaticResource SmallEmphasizedPropertyValue}"/>

<TextBlock Grid.Row="1" Grid.Column="4"
Text="Multi-client" Style="{StaticResource SmallPropertyLabel}" Margin="21,3,3,3"/>
<TextBlock Grid.Row="1" Grid.Column="5"
Text="{x:Bind EndpointItem.SupportsMultiClient, Mode=OneTime, Converter={StaticResource BooleanToEmojiCheckConverter}}"
Text="{x:Bind EndpointItem.SupportsMultiClient, Mode=OneTime, Converter={StaticResource BooleanToFluentCheckConverter}}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Style="{StaticResource SmallEmphasizedPropertyValue}"/>

</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public object Convert(object value, Type targetType, object parameter, string la
return "❌";
}

throw new ArgumentException("BooleanToVisibilityConverter object must be a bool");
throw new ArgumentException("BooleanToEmojiCheckConverter object must be a bool");
}

public object? ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace Microsoft.Midi.Settings.Helpers;

public partial class BooleanToFluentCheckConverter : IValueConverter
{
public BooleanToFluentCheckConverter()
{
}

public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is bool val)
{
if (val)
{
return "\uf16c";
}

return "\uf16b";
}

throw new ArgumentException("BooleanToFluentCheckConverter object must be a bool");
}

public object? ConvertBack(object value, Type targetType, object parameter, string language)
{
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<Page
x:Class="Microsoft.Midi.Settings.Views.EndpointsDiagPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="using:Microsoft.Midi.Settings.Views"
xmlns:local="using:Microsoft.Midi.Settings.ViewModels"
xmlns:midi2="using:Microsoft.Windows.Devices.Midi2"
xmlns:helpers="using:Microsoft.Midi.Settings.Helpers"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:midicontrols="using:Microsoft.Midi.Settings.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>

<Page.Resources>
<ResourceDictionary>
<helpers:HasUniqueIdToVisibilityConverter x:Key="HasUniqueIdToVisibilityConverter" />
<helpers:HasUniqueIdToInverseVisibilityConverter x:Key="HasUniqueIdToInverseVisibilityConverter" />
<helpers:MidiEndpointNativeDataFormatConverter x:Key="MidiEndpointNativeDataFormatConverter" />
<helpers:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<helpers:BooleanToEmojiCheckConverter x:Key="BooleanToEmojiCheckConverter" />
</ResourceDictionary>
</Page.Resources>

<Grid x:Name="ContentArea">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0" x:Uid="DevicesPage_Description" Margin="0,0,0,8" />

<ScrollViewer Grid.Row="1">
<StackPanel Margin="0,0,8,0" HorizontalAlignment="Stretch">

<!-- Transport -->


<!-- If this transport supports runtime creation, have create button at this level -->


<TextBlock Text="{x:Bind ViewModel.Transport.Name, Mode=OneWay}" Style="{StaticResource SmallEmphasizedPropertyValue}"/>
<TextBlock Text="{x:Bind ViewModel.Transport.Description, Mode=OneWay}" Style="{StaticResource SmallPlainPropertyValue}"/>


<ItemsControl ItemsSource="{x:Bind ViewModel.MidiEndpointDevices}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="local:MidiEndpointDeviceListItem">
<midicontrols:MidiEndpointDeviceListItemControl EndpointItem="{x:Bind}"
Loaded="MidiEndpointDeviceListItemControl_Loaded"
Margin="3"/>
</DataTemplate>

</ItemsControl.ItemTemplate>

</ItemsControl>

</StackPanel>

</ScrollViewer>

</Grid>

</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Microsoft.Midi.Settings.Contracts.Services;
using Microsoft.Midi.Settings.Controls;
using Microsoft.Midi.Settings.ViewModels;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace Microsoft.Midi.Settings.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class EndpointsDiagPage : Page
{
private ILoggingService _loggingService;


public EndpointsDiagViewModel ViewModel
{
get;
}


public EndpointsDiagPage()
{
ViewModel = App.GetService<EndpointsDiagViewModel>();
_loggingService = App.GetService<ILoggingService>();

Loaded += DevicesPage_Loaded;

InitializeComponent();
}

private void DevicesPage_Loaded(object sender, RoutedEventArgs e)
{
ViewModel.DispatcherQueue = this.DispatcherQueue;

ViewModel.RefreshDeviceCollection();
}


// work around WinUI binding bug
private void MidiEndpointDeviceListItemControl_Loaded(object sender, RoutedEventArgs e)
{
((MidiEndpointDeviceListItemControl)sender).ViewDeviceDetailsCommand = ViewModel.ViewDeviceDetailsCommand;
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Midi.Settings.Contracts.Services;
using Microsoft.Midi.Settings.Contracts.ViewModels;
using Microsoft.Midi.Settings.Models;
using Microsoft.Midi.Settings.Services;
using Microsoft.UI.Dispatching;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsDiagViewModel : SingleTransportEndpointViewModelBase, INavigationAware
{
public EndpointsDiagViewModel(INavigationService navigationService) : base("DIAG", navigationService)
{
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public PageService()
Configure<EndpointsLoopViewModel, EndpointsLoopPage>();
Configure<EndpointsNet2UdpViewModel, EndpointsNet2UdpPage>();

Configure<EndpointsDiagViewModel, EndpointsDiagPage>();


Configure<DeviceDetailViewModel, DeviceDetailPage>();
Configure<RoutesViewModel, RoutesPage>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,37 @@
<data name="DeviceDetailPage_ParentDeviceExpander.Description" xml:space="preserve">
<value>Devices may have more than one MIDI Endpoint. This is the parent device for this endpoint.</value>
</data>
<data name="Shell_EndpointsDiagnostic.Content" xml:space="preserve">
<value>Diagnostic</value>
</data>
<data name="CommonTasks_SetServiceAutoStart.Text" xml:space="preserve">
<value>Set MIDI Service to auto-start at boot (requires Administrator account)</value>
</data>
<data name="CommonTasks_AssignMidi1DeviceToNewDriver.Text" xml:space="preserve">
<value>Set a USB MIDI 1.0 device to use the new fast UMP MIDI 2.0 driver (requires Administrator account)</value>
</data>
<data name="CommonTasks_CreateLoopbackEndpoints.Text" xml:space="preserve">
<value>Create a loopback endpoint so two or more applications can communicate using MIDI messages</value>
</data>
<data name="CommonTasks_SendSysExFile.Text" xml:space="preserve">
<value>Send a file of System Exclusive data (patches, firmware, etc.) to an endpoint</value>
</data>
<data name="CommonTasks_CaptureMidiDiag.Text" xml:space="preserve">
<value>Capture MIDI Diagnostics information to a text file for use with technical support</value>
</data>
<data name="CommonTasks_OpenConsole.Text" xml:space="preserve">
<value>Open Windows MIDI Services Console</value>
</data>
<data name="CommonTasks_SetUpNetworkMidi2.Text" xml:space="preserve">
<value>Set up Network MIDI 2.0 to enable MIDI messages to be sent to other devices on your local network.</value>
</data>
<data name="CommonTasksGroup_Endpoints.Text" xml:space="preserve">
<value>Endpoints</value>
</data>
<data name="CommonTasksGroup_ServiceAndDrivers.Text" xml:space="preserve">
<value>Service and Drivers</value>
</data>
<data name="CommonTasksGroup_Other.Text" xml:space="preserve">
<value>Other</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
<Setter Property="TextWrapping" Value="WrapWholeWords" />
</Style>

<Style x:Key="HomeCardItemSeparatorStyle" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{StaticResource MediumFontSize}" />
<Setter Property="Margin" Value="16,6,0,6" />
<Setter Property="TextTrimming" Value="None" />
<Setter Property="TextWrapping" Value="NoWrap" />
<Setter Property="Foreground" Value="CornflowerBlue" />
</Style>


<Style x:Key="SmallPropertyLabel" TargetType="TextBlock">
Expand Down
Loading

0 comments on commit 305dcd1

Please sign in to comment.