From 305dcd1c97841c2844148bc8b6b08f34a666c5ca Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sun, 9 Feb 2025 22:05:15 -0500 Subject: [PATCH 1/3] Minor updates to settings app. Nothing yet complete. --- .../Microsoft.Midi.Settings/App.xaml.cs | 3 + .../MidiEndpointDeviceListItemControl.xaml | 17 +++-- .../Helpers/BooleanToEmojiCheckConverter.cs | 2 +- .../Helpers/BooleanToFluentCheckConverter.cs | 31 +++++++++ .../Endpoints/DIAG/EndpointsDiagPage.xaml | 65 +++++++++++++++++++ .../Endpoints/DIAG/EndpointsDiagPage.xaml.cs | 63 ++++++++++++++++++ .../Endpoints/DIAG/EndpointsDiagViewModel.cs | 25 +++++++ .../Services/PageService.cs | 2 + .../Strings/en-us/Resources.resw | 33 ++++++++++ .../Styles/TextBlock.xaml | 9 +++ .../Views/HomePage.xaml | 57 +++++++++------- .../Views/ShellPage.xaml | 22 +++++-- .../Views/ShellPage.xaml.cs | 4 ++ 13 files changed, 298 insertions(+), 35 deletions(-) create mode 100644 src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToFluentCheckConverter.cs create mode 100644 src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml create mode 100644 src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml.cs create mode 100644 src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagViewModel.cs diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/App.xaml.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/App.xaml.cs index a161d543a..5abdbc997 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/App.xaml.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/App.xaml.cs @@ -109,6 +109,9 @@ public App() services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Controls/MidiEndpointDeviceListItemControl.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Controls/MidiEndpointDeviceListItemControl.xaml index 32f576f9c..864184711 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Controls/MidiEndpointDeviceListItemControl.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Controls/MidiEndpointDeviceListItemControl.xaml @@ -18,7 +18,7 @@ - + @@ -69,31 +69,36 @@ diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToEmojiCheckConverter.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToEmojiCheckConverter.cs index 5a103d2a3..d7c2aab96 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToEmojiCheckConverter.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToEmojiCheckConverter.cs @@ -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) diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToFluentCheckConverter.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToFluentCheckConverter.cs new file mode 100644 index 000000000..9d71e9faf --- /dev/null +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Helpers/BooleanToFluentCheckConverter.cs @@ -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; + } +} \ No newline at end of file diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml new file mode 100644 index 000000000..78e9ffa6f --- /dev/null +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml.cs new file mode 100644 index 000000000..d7b4e1019 --- /dev/null +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagPage.xaml.cs @@ -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 +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class EndpointsDiagPage : Page + { + private ILoggingService _loggingService; + + + public EndpointsDiagViewModel ViewModel + { + get; + } + + + public EndpointsDiagPage() + { + ViewModel = App.GetService(); + _loggingService = App.GetService(); + + 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; + } + } +} + diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagViewModel.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagViewModel.cs new file mode 100644 index 000000000..8133561ef --- /dev/null +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Sections/Endpoints/DIAG/EndpointsDiagViewModel.cs @@ -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) + { + } + + } +} diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/PageService.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/PageService.cs index 6b151a625..f86c08feb 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/PageService.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/PageService.cs @@ -21,6 +21,8 @@ public PageService() Configure(); Configure(); + Configure(); + Configure(); Configure(); diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.resw b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.resw index af5ece9e7..45ef20e6b 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.resw +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.resw @@ -378,4 +378,37 @@ Devices may have more than one MIDI Endpoint. This is the parent device for this endpoint. + + Diagnostic + + + Set MIDI Service to auto-start at boot (requires Administrator account) + + + Set a USB MIDI 1.0 device to use the new fast UMP MIDI 2.0 driver (requires Administrator account) + + + Create a loopback endpoint so two or more applications can communicate using MIDI messages + + + Send a file of System Exclusive data (patches, firmware, etc.) to an endpoint + + + Capture MIDI Diagnostics information to a text file for use with technical support + + + Open Windows MIDI Services Console + + + Set up Network MIDI 2.0 to enable MIDI messages to be sent to other devices on your local network. + + + Endpoints + + + Service and Drivers + + + Other + \ No newline at end of file diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Styles/TextBlock.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Styles/TextBlock.xaml index b04af77a9..ab8811963 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Styles/TextBlock.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Styles/TextBlock.xaml @@ -52,6 +52,15 @@ +