Skip to content

Commit

Permalink
Merge pull request #545 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
Additonal name change tweak
  • Loading branch information
Psychlist1972 authored Feb 17, 2025
2 parents ad2c7ba + e327470 commit ee80acb
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 37 deletions.
9 changes: 8 additions & 1 deletion src/api/Inc/midi_naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,14 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming

std::wstring name;

name = parentDeviceName;
if (blockName != parentDeviceName)
{
name = parentDeviceName + L" " + blockName;
}
else
{
name = parentDeviceName;
}

return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,9 @@ CMidi2KSMidiEndpointManager::OnDeviceAdded(
else if (MidiPin->NativeDataFormat == KSDATAFORMAT_SUBTYPE_MIDI)
{
// for a native MIDI 1 device, the driver provides a MIDI 1 port name in the GTB
// but it's just the pin (iJack) name, so we still set this to false. Change in behavior.
interfaceDevProperties.push_back({ { PKEY_MIDI_UseGroupTerminalBlocksForExactMidi1PortNames, DEVPROP_STORE_SYSTEM, nullptr },
DEVPROP_TYPE_BOOLEAN, static_cast<ULONG>(sizeof(devPropTrue)), (PVOID) & (devPropTrue) });
DEVPROP_TYPE_BOOLEAN, static_cast<ULONG>(sizeof(devPropFalse)), (PVOID) & (devPropFalse) });
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsAppViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsAppViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsAppViewModel(INavigationService navigationService) : base("APP", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsBle10ViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsBle10ViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsBle10ViewModel(INavigationService navigationService) : base("BLE10MS", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsDiagViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsDiagViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsDiagViewModel(INavigationService navigationService) : base("DIAG", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsKSViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsKSViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsKSViewModel(INavigationService navigationService) : base("KS", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsKsaViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsKsaViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsKsaViewModel(INavigationService navigationService) : base("KSA", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
Click="CreateNewLoopbackPair_Click"/>


<ItemsControl ItemsSource="{x:Bind ViewModel.MidiLoopbackEndpointPairs}" Margin="13">
<ItemsControl ItemsSource="{x:Bind ViewModel.MidiLoopbackEndpointPairs}">
<ItemsControl.ItemTemplate>

<DataTemplate x:DataType="local:MidiLoopbackEndpointPair">
<controls:SettingsCard>
<controls:SettingsCard Margin="3">
<controls:SettingsCard.Header>
<StackPanel Orientation="Vertical">
<TextBlock Text="{x:Bind LoopA.Name}" />
Expand All @@ -68,6 +68,8 @@
</ScrollViewer>




<ContentDialog x:Name="Dialog_CreateLoopbackEndpoints"
PrimaryButtonText="OK"
IsPrimaryButtonEnabled="{x:Bind ViewModel.NewLoopbackSettingsAreValid, Mode=OneWay}"
Expand All @@ -78,7 +80,7 @@
<x:Double x:Key="ContentDialogMaxWidth">800</x:Double>
<x:Double x:Key="ContentDialogMaxHeight">800</x:Double>
</ContentDialog.Resources>

<StackPanel Orientation="Vertical" >
<TextBlock Text="Create MIDI Loopback Endpoints"
Style="{StaticResource DialogHeaderTextBlockStyle}"
Expand All @@ -88,7 +90,7 @@
Text="With MIDI 2.0, all endpoints are bidirectional. Therefore, to have a proper loopback, you need to have two endpoints, A and B, cross-wired to each other. Anything sent out from Loopback A will arrive at Loopback B's input, and vice-versa."
Style="{StaticResource DialogDescriptionTextBlockStyle}"
Margin="13"/>

<Image Source="/Assets/LoopbackDiagram.svg" Height="80" HorizontalAlignment="Center" Margin="0"/>


Expand Down Expand Up @@ -153,6 +155,7 @@
</StackPanel>
</ContentDialog>


</Grid>

</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using Microsoft.Midi.Settings.Contracts.Services;
using Microsoft.Midi.Settings.Controls;
using Microsoft.Midi.Settings.ViewModels;
using Microsoft.Midi.Settings.Contracts.ViewModels;
using Microsoft.UI.Dispatching;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
Expand All @@ -40,29 +42,72 @@ public EndpointsLoopPage()
ViewModel = App.GetService<EndpointsLoopViewModel>();
_loggingService = App.GetService<ILoggingService>();

Loaded += DevicesPage_Loaded;
ViewModel.ShowCreateDialog += ViewModel_ShowCreateDialog;

Loaded += Page_Loaded;
Unloaded += Page_Unloaded;

InitializeComponent();
}

private void DevicesPage_Loaded(object sender, RoutedEventArgs e)
bool m_showCreateDialog = false;

private void ViewModel_ShowCreateDialog(object? sender, EventArgs e)
{
m_showCreateDialog = true;
}


private void Page_Unloaded(object sender, RoutedEventArgs e)
{
ViewModel.ShowCreateDialog -= ViewModel_ShowCreateDialog;
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
ViewModel.DispatcherQueue = this.DispatcherQueue;

ViewModel.RefreshDeviceCollection();
}

if (m_showCreateDialog)
{
// showing the dialog fails if it is attempted before Loaded has completed
// as a result, we set a flag in the event from the VM and then
// show it here, in loaded. Not my favorite code.

DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Normal, async () =>
{
var result = await Dialog_CreateLoopbackEndpoints.ShowAsync();
});

m_showCreateDialog = false;
}

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

private async void CreateNewLoopbackPair_Click(object sender, RoutedEventArgs e)
{
var result = await Dialog_CreateLoopbackEndpoints.ShowAsync();
}



//public void OnNavigatedFrom()
//{
//}

//public void OnNavigatedTo(object parameter)
//{
// if (parameter != null && ((string)parameter).ToLower() == "create")
// {
// DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Normal, async () =>
// {
// var result = await Dialog_CreateLoopbackEndpoints.ShowAsync();
// });
// }
//}



}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Midi.Settings.Services;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using Microsoft.Windows.Devices.Midi2.Endpoints.Loopback;
using System;
using System.Collections.Generic;
Expand All @@ -29,6 +30,11 @@ public partial class EndpointsLoopViewModel : SingleTransportEndpointViewModelBa
{
private IMidiConfigFileService m_midiConfigFileService;

public ICommand ShowCreateLoopbackPairsDialogCommand
{
get; private set;
}

public ICommand CreateLoopbackPairsCommand
{
get; private set;
Expand Down Expand Up @@ -265,6 +271,33 @@ public EndpointsLoopViewModel(INavigationService navigationService, IMidiConfigF
CreateNewLoopbackEndpoints();

});

//ShowCreateLoopbackPairsDialogCommand = new RelayCommand(
// async () =>
// {
// //var dialog = new Dialog_CreateLoopbackEndpoints();

// var dialog = new ContentDialog();
// dialog.Content = XamlReader.Load()

// await dialog.ShowAsync();
// });
}



public void OnNavigatedFrom()
{
}

public event EventHandler ShowCreateDialog;

public void OnNavigatedTo(object parameter)
{
if (parameter != null && ((string)parameter).ToLower() == "create")
{
ShowCreateDialog?.Invoke(this, new EventArgs());
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class EndpointsNet2UdpViewModel : SingleTransportEndpointViewModelBase, INavigationAware
public partial class EndpointsNet2UdpViewModel : SingleTransportEndpointViewModelBase
{
public EndpointsNet2UdpViewModel(INavigationService navigationService) : base("NET2UDP", navigationService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.Midi.Settings.ViewModels
{
public partial class SingleTransportEndpointViewModelBase : ObservableRecipient, INavigationAware
public partial class SingleTransportEndpointViewModelBase : ObservableRecipient
{
private readonly INavigationService _navigationService;

Expand Down Expand Up @@ -86,15 +86,5 @@ public void RefreshDeviceCollection()

}



public void OnNavigatedFrom()
{
}


public void OnNavigatedTo(object parameter)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ public class HomeViewModel : ObservableRecipient, INavigationAware
private readonly INavigationService _navigationService;
private readonly IMidiConfigFileService m_configFileService;

public ICommand LaunchFirstRunExperience
public ICommand LaunchFirstRunExperienceCommand
{
get; private set;
}

public ICommand CommonTaskCreateLoopbackEndpointsCommand
{
get; private set;
}

public ICommand CommonTaskSendSysExCommand
{
get; private set;
}


public string SystemTimerCurrentResolutionFormattedMilliseconds
{
get; set;
Expand Down Expand Up @@ -113,13 +124,24 @@ public HomeViewModel(INavigationService navigationService, IMidiConfigFileServic
_navigationService = navigationService;
m_configFileService = midiConfigFileService;

LaunchFirstRunExperience = new RelayCommand(
LaunchFirstRunExperienceCommand = new RelayCommand(
() =>
{
System.Diagnostics.Debug.WriteLine("View Device Details Command exec");

_navigationService.NavigateTo(typeof(FirstRunExperienceViewModel).FullName!);
});

CommonTaskCreateLoopbackEndpointsCommand = new RelayCommand(
() =>
{
_navigationService.NavigateTo(typeof(EndpointsLoopViewModel).FullName!, "create");
});

CommonTaskSendSysExCommand = new RelayCommand(
() =>
{
_navigationService.NavigateTo(typeof(ToolsSysExViewModel).FullName!, "send");
});

}

public void OnNavigatedFrom()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
>
<InfoBar.ActionButton>
<Button Content="Finish MIDI Setup"
Command="{x:Bind ViewModel.LaunchFirstRunExperience}" />
Command="{x:Bind ViewModel.LaunchFirstRunExperienceCommand}" />
</InfoBar.ActionButton>
</InfoBar>

Expand Down Expand Up @@ -124,7 +124,8 @@
<TextBlock x:Uid="CommonTasksGroup_Endpoints" Style="{StaticResource HomeCardItemSeparatorStyle}" />
</Border>-->

<controls:SettingsCard IsClickEnabled="True" IsEnabled="True">
<controls:SettingsCard IsClickEnabled="True" IsEnabled="True"
Command="{x:Bind ViewModel.CommonTaskCreateLoopbackEndpointsCommand}">
<controls:SettingsCard.Header>
<TextBlock x:Uid="CommonTasks_CreateLoopbackEndpoints" TextWrapping="WrapWholeWords" />
</controls:SettingsCard.Header>
Expand All @@ -142,7 +143,8 @@
</controls:SettingsCard.HeaderIcon>
</controls:SettingsCard>

<controls:SettingsCard IsClickEnabled="True" IsEnabled="True">
<controls:SettingsCard IsClickEnabled="True" IsEnabled="True"
Command="{x:Bind ViewModel.CommonTaskSendSysExCommand}">
<controls:SettingsCard.Header>
<TextBlock x:Uid="CommonTasks_SendSysExFile" TextWrapping="WrapWholeWords" />
</controls:SettingsCard.Header>
Expand Down

0 comments on commit ee80acb

Please sign in to comment.