diff --git a/src/user-tools/README.md b/src/user-tools/README.md index cdfeb2242..2f0000200 100644 --- a/src/user-tools/README.md +++ b/src/user-tools/README.md @@ -1,8 +1,139 @@ -# Tools +# Tools / 工具 These are generally written in .NET (7 or 8) and provide end-user functionality outside of the DAW or other third-party tools. -| Component | Description | -| --------- | ----------- | -| midi-settings | The main MIDI Settings app for Windows | -| midi-settings-extensibility | Extensibility model (client plugin model) for the MIDI Settings app | +这些通常使用 .NET(7 或 8)编写,提供 DAW 或其他第三方工具之外的最终用户功能。 + +| Component | Description / 描述 | +| --------- | ------------------- | +| midi-settings | The main MIDI Settings app for Windows / Windows 的主要 MIDI 设置应用程序 | +| midi-settings-extensibility | Extensibility model (client plugin model) for the MIDI Settings app / MIDI 设置应用程序的扩展性模型(客户端插件模型) | + +--- + +## Build Notes / 构建说明 + +### Requirements / 要求 +- .NET 10 SDK +- Windows App SDK 1.8+ +- Windows SDK 10.0.26100.0 + +### Fixed Issues / 修复的问题 + +#### 1. Missing `CommunityToolkit.WinUI.Controls.TitleBar` Package / 缺少 `CommunityToolkit.WinUI.Controls.TitleBar` 包 +- **Issue / 问题**: The `TitleBar` control from CommunityToolkit was referenced but the package does not exist on NuGet / 引用了 CommunityToolkit 的 `TitleBar` 控件,但该包在 NuGet 上不存在 +- **Solution / 解决方案**: Replaced the `controls:TitleBar` with a standard Grid layout in `ShellPage.xaml` / 在 `ShellPage.xaml` 中将 `controls:TitleBar` 替换为标准 Grid 布局 +- **Files Modified / 修改的文件**: + - `Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml` + - `Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml.cs` + +#### 2. NU1510 Warnings - Redundant Package References / NU1510 警告 - 冗余的包引用 +- **Issue / 问题**: `System.Text.Json` and `System.Text.RegularExpressions` are built-in to .NET 10 and should not be explicitly referenced / `System.Text.Json` 和 `System.Text.RegularExpressions` 是 .NET 10 的内置组件,不应显式引用 +- **Solution / 解决方案**: Removed the explicit package references / 移除显式的包引用 +- **Files Modified / 修改的文件**: + - `Microsoft.Midi.Settings/Microsoft.Midi.Settings.csproj` + +#### 3. WMC1506 Warnings - OneWay Binding Notifications / WMC1506 警告 - OneWay 绑定通知 +- **Issue / 问题**: OneWay bindings require properties to support change notifications, but the MIDI library types do not implement `INotifyPropertyChanged` / OneWay 绑定需要属性支持变更通知,但 MIDI 库类型未实现 `INotifyPropertyChanged` +- **Solution / 解决方案**: Changed binding mode from `OneWay` to `OneTime` for read-only port information / 将只读端口信息的绑定模式从 `OneWay` 改为 `OneTime` +- **Files Modified / 修改的文件**: + - `Microsoft.Midi.Settings/Views/Endpoint Management Pages/EndpointsAllPage.xaml` + +### Build Output / 构建输出 +- **Executable / 可执行文件**: `MidiSettings.exe` +- **Output Directory / 输出目录**: `Microsoft.Midi.Settings/bin/x64/Release/net10.0-windows10.0.26100.0/` +- **Status / 状态**: Build successful with 0 warnings / 构建成功,0 个警告 + +--- + +## Changes / 更改 + +### UI Changes / UI 更改 + +#### Settings Button in NavigationView / 导航视图中的设置按钮 +- **Description / 描述**: Moved the Settings button from `PaneFooter` to `FooterMenuItems` for better navigation support and added bottom margin / 将设置按钮从 `PaneFooter` 移到 `FooterMenuItems` 以获得更好的导航支持,并添加底部边距 +- **Files Modified / 修改的文件**: + - `Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml` + - `Microsoft.Midi.Settings/Strings/en-us/Resources.resw` + +#### Back Button Visibility / 返回按钮可见性 +- **Description / 描述**: Set `NavigationView.IsBackButtonVisible="Collapsed"` and set the custom BackButton `Visibility="Collapsed"` to completely hide the back button / 设置 `NavigationView.IsBackButtonVisible="Collapsed"` 并将自定义 BackButton 的 `Visibility="Collapsed"` 以彻底隐藏返回按钮 +- **Files Modified / 修改的文件**: + - `Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml` + +--- + +## Recent Changes / 最近更改 + +### ShellPage Improvements / ShellPage 改进 + +#### Search Box / 搜索框 +- **Fixed / 修复**: Search box right corner being clipped when window is narrow / 窗口较窄时搜索框右侧圆角被裁切的问题 +- **Changes / 更改**: + - Changed `HorizontalAlignment` from `Left` to `Stretch` / 将 `HorizontalAlignment` 从 `Left` 改为 `Stretch` + - Removed fixed `Width` property, now uses adaptive width (MaxWidth: 700) / 移除固定的 `Width` 属性,现在使用自适应宽度(最大宽度:700) + - Added compact mode: shows search icon button when window width < 1020px / 添加紧凑模式:当窗口宽度 < 1020px 时显示搜索图标按钮 + +#### Title Bar Drag Regions / 标题栏拖拽区域 +- **Fixed / 修复**: Drag regions not working properly / 拖拽区域无法正常工作的问题 +- **Changes / 更改**: + - Now correctly calculates drag areas based on actual search box position / 现在根据搜索框实际位置正确计算拖拽区域 + - Updates drag regions when window size changes (with delay for layout completion) / 窗口大小变化时更新拖拽区域(带延迟以确保布局完成) + +#### Navigation View / 导航视图 +- **Improved / 改进**: Unified content margin between expanded and compact modes / 统一展开模式和紧凑模式下的内容边距 +- **Changes / 更改**: + - Override `NavigationViewContentMargin` and `NavigationViewContentGridMargin` to remove extra top padding / 覆盖 `NavigationViewContentMargin` 和 `NavigationViewContentGridMargin` 以移除额外的顶部边距 + - Set `NavigationFrameContentMargin` to `40,24,40,0` for consistent spacing / 设置 `NavigationFrameContentMargin` 为 `40,24,40,0` 以保持一致间距 + +#### Focus Management / 焦点管理 +- **Improved / 改进**: Set default focus to Home navigation item on startup / 启动时将默认焦点设置到 Home 导航项 +- **Benefit / 好处**: Prevents search box from automatically receiving focus / 防止搜索框自动获得焦点 + +### HomePage Improvements / HomePage 改进 + +#### InfoBar Visibility / InfoBar 可见性 +- **Changed / 更改**: Changed from `IsOpen` to `Visibility` binding / 从 `IsOpen` 绑定改为 `Visibility` 绑定 +- **Benefit / 好处**: Three InfoBars (Service availability, First-run setup, SDK Update) now collapse when hidden, no longer occupy space when not visible / 三个 InfoBar(服务可用性、首次运行设置、SDK 更新)在隐藏时现在会折叠,不可见时不再占用空间 + +### Page Layout Fixes / 页面布局修复 + +#### Commented Out Empty Description Text Blocks / 注释掉空的描述文本块 +- **Pages / 页面**: + - **ManagementSessionsPage**: Commented out empty description text block / 注释掉空的描述文本块 + - **EndpointsAllPage**: Commented out empty description text block (`DevicesPage_Description`) / 注释掉空的描述文本块 (`DevicesPage_Description`) + - **EndpointsBasicLoopPage**: Commented out empty description text block / 注释掉空的描述文本块 + +### Performance Improvements / 性能改进 + +#### Search Data Preloading / 搜索数据预加载 +- **Description / 描述**: Preload search data during app startup to prevent UI blocking / 在应用启动时预加载搜索数据,防止 UI 阻塞 +- **Changes / 更改**: + - Moved `RefreshSearchData()` to `App.OnLaunched()` / 将 `RefreshSearchData()` 移到 `App.OnLaunched()` + - Search data is now loaded in background thread / 搜索数据现在在后台线程加载 + - Search box cursor no longer delayed when entering search field / 进入搜索框时光标不再延迟 + +#### SDK Update Check Optimization / SDK 更新检查优化 +- **Description / 描述**: Moved SDK update check from ViewModel constructor to app startup / 将 SDK 更新检查从 ViewModel 构造函数移到应用启动 +- **Changes / 更改**: + - `CheckForSdkUpdatesAsync()` now called in `App.OnLaunched()` / `CheckForSdkUpdatesAsync()` 现在在 `App.OnLaunched()` 中调用 + - Prevents HOME page navigation lag / 防止 HOME 页面导航卡顿 + - Uses async/await to avoid blocking UI thread / 使用 async/await 避免阻塞 UI 线程 + +#### Search Box Text Deletion / 搜索框文本删除 +- **Fixed / 修复**: Search results list no longer shows when text is deleted / 删除文本时不再显示搜索结果列表 +- **Changes / 更改**: + - Added empty text check in `SettingsSearchBox_TextChanged` / 在 `SettingsSearchBox_TextChanged` 中添加空文本检查 + - Sets `ItemsSource = null` when text is empty / 文本为空时设置 `ItemsSource = null` + +### Page Layout Fixes / 页面布局修复 + +#### SettingsPage Bottom Margin / 设置页面底部边距 +- **Fixed / 修复**: Added bottom margin to prevent content from sticking to window bottom / 添加底部边距防止内容紧贴窗口底部 +- **Changes / 更改**: + - Added `Margin="0,0,0,24"` to StackPanel in SettingsPage.xaml / 在 SettingsPage.xaml 的 StackPanel 添加 `Margin="0,0,0,24"` + +### Technical Details / 技术细节 +- Window threshold for compact mode: 1124px / 紧凑模式窗口阈值:1124px +- Search box collapse threshold: 650px available width / 搜索框折叠阈值:650px 可用宽度 +- Drag region height: 48px (title bar height) / 拖拽区域高度:48px(标题栏高度) 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 72999f7ab..800e9abea 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 @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License // ============================================================================ // This is part of Windows MIDI Services and should be used @@ -286,6 +286,40 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args) App.GetService().LogError("Unable to startup app. Exiting."); Exit(); } + + // 在后台预加载搜索数据,确保用户进入搜索框时光标能立即闪烁 + _ = Task.Run(() => + { + try + { + App.GetService().Refresh(); + App.GetService().LogInfo("Search data preloaded successfully."); + } + catch (Exception ex) + { + App.GetService().LogError("Error preloading search data", ex); + } + }); + + // 在后台异步检查 SDK 更新,避免在 HOME 页面导航时阻塞 UI + _ = Task.Run(async () => + { + try + { + var updateService = App.GetService(); + var homeViewModel = App.GetService(); + + if (updateService.GetAutoCheckForUpdatesEnabled()) + { + await homeViewModel.CheckForSdkUpdatesAsync(); + App.GetService().LogInfo("SDK update check completed."); + } + } + catch (Exception ex) + { + App.GetService().LogError("Error checking for SDK updates during startup", ex); + } + }); } catch (Exception ex) { diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/MainWindow.xaml.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/MainWindow.xaml.cs index e62346f80..127705484 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/MainWindow.xaml.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/MainWindow.xaml.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License // ============================================================================ // This is part of Windows MIDI Services and should be used @@ -10,6 +10,7 @@ using Microsoft.Midi.Settings.Helpers; using Microsoft.Midi.Settings.Services; using Microsoft.UI.Xaml.Media; +using System.Runtime.InteropServices; using System.Threading.Tasks; using WinUIEx; @@ -17,21 +18,76 @@ namespace Microsoft.Midi.Settings; public sealed partial class MainWindow// : WinUIEx.WindowEx { + // Win32 API for setting window min/max size + [DllImport("user32.dll", SetLastError = true)] + private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + [DllImport("user32.dll", SetLastError = true)] + private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect); + + [StructLayout(LayoutKind.Sequential)] + private struct RECT + { + public int Left; + public int Top; + public int Right; + public int Bottom; + } + + private const uint SWP_FRAMECHANGED = 0x0020; + private const uint SWP_NOMOVE = 0x0002; + private const uint SWP_NOSIZE = 0x0001; + private const uint SWP_NOZORDER = 0x0004; + private const uint SWP_NOACTIVATE = 0x0010; + private const uint SWP_SHOWWINDOW = 0x0040; + + private const int WM_GETMINMAXINFO = 0x0024; + + [StructLayout(LayoutKind.Sequential)] + private struct POINT + { + public int x; + public int y; + } + + [StructLayout(LayoutKind.Sequential)] + private struct MINMAXINFO + { + public POINT ptReserved; + public POINT ptMaxSize; + public POINT ptMaxPosition; + public POINT ptMinTrackSize; + public POINT ptMaxTrackSize; + } + + [DllImport("comctl32.dll", SetLastError = true)] + private static extern int SetWindowSubclass(IntPtr hWnd, SubclassProc pfnSubclass, uint uIdSubclass, IntPtr dwRefData); + + [DllImport("comctl32.dll", SetLastError = true)] + private static extern int RemoveWindowSubclass(IntPtr hWnd, SubclassProc pfnSubclass, uint uIdSubclass); + + [DllImport("comctl32.dll", SetLastError = true)] + private static extern IntPtr DefSubclassProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); + + private delegate IntPtr SubclassProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData); + + private IntPtr _hwnd; + private SubclassProc? _subclassProc; + private const int MinWindowWidth = 1000; + private const int MinWindowHeight = 800; + public MainWindow() { InitializeComponent(); AppWindow.SetIcon(@"\Assets\AppIcon.ico"); - AppWindow.TitleBar.ExtendsContentIntoTitleBar = true; AppWindow.TitleBar.ButtonBackgroundColor = Microsoft.UI.Colors.Transparent; - //AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/DIN_Settings.png")); Content = null; Title = "AppDisplayName".GetLocalized(); - - //MinWidth = 640; - //MinHeight = 480; + // 设置窗口最小尺寸 + this.Activated += MainWindow_Activated; //Content = new Microsoft.UI.Xaml.Controls.Grid(); // workaround for WinAppSDK bug http://task.ms/43347736 //this.SystemBackdrop = new MicaBackdrop(); @@ -47,6 +103,32 @@ public MainWindow() this.Closed += MainWindow_Closed; } + private void MainWindow_Activated(object sender, UI.Xaml.WindowActivatedEventArgs args) + { + if (_hwnd == IntPtr.Zero) + { + _hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this); + if (_hwnd != IntPtr.Zero) + { + _subclassProc = new SubclassProc(WindowSubclassProc); + SetWindowSubclass(_hwnd, _subclassProc, 0, IntPtr.Zero); + } + } + } + + private IntPtr WindowSubclassProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, IntPtr uIdSubclass, IntPtr dwRefData) + { + if (uMsg == WM_GETMINMAXINFO) + { + MINMAXINFO mmi = Marshal.PtrToStructure(lParam); + mmi.ptMinTrackSize.x = MinWindowWidth; + mmi.ptMinTrackSize.y = MinWindowHeight; + Marshal.StructureToPtr(mmi, lParam, false); + return IntPtr.Zero; + } + return DefSubclassProc(hWnd, uMsg, wParam, lParam); + } + private async void MainWindow_Closed(object sender, UI.Xaml.WindowEventArgs args) { var settingsService = App.GetService(); diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Microsoft.Midi.Settings.csproj b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Microsoft.Midi.Settings.csproj index 6bbf5047c..0e05d2cf5 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Microsoft.Midi.Settings.csproj +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Microsoft.Midi.Settings.csproj @@ -1,4 +1,4 @@ - + WinExe net10.0-windows10.0.26100.0 @@ -107,7 +107,6 @@ - @@ -115,27 +114,25 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - + + - + diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/NavigationViewService.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/NavigationViewService.cs index 0cf89b54f..083cf7c69 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/NavigationViewService.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Services/NavigationViewService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License // ============================================================================ // This is part of Windows MIDI Services and should be used @@ -24,7 +24,7 @@ public class NavigationViewService : INavigationViewService public IList? MenuItems => _navigationView?.MenuItems; - public object? SettingsItem => _navigationView?.SettingsItem; + public object? SettingsItem => _navigationView?.SettingsItem ?? GetSettingsItemFromFooter(); public NavigationViewService(INavigationService navigationService, IPageService pageService) { @@ -97,6 +97,22 @@ private void OnItemInvoked(NavigationView sender, NavigationViewItemInvokedEvent return null; } + private NavigationViewItem? GetSettingsItemFromFooter() + { + if (_navigationView?.FooterMenuItems != null) + { + foreach (var item in _navigationView.FooterMenuItems.OfType()) + { + if (item.GetValue(NavigationHelper.NavigateToProperty) is string pageKey && + pageKey.Contains("SettingsViewModel")) + { + return item; + } + } + } + return null; + } + private bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType) { if (menuItem.GetValue(NavigationHelper.NavigateToProperty) is string pageKey) diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.Designer.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.Designer.cs index 8f2e23e26..7fb7b3fc5 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.Designer.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Strings/en-us/Resources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 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 35bda9da8..f605d03eb 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 @@ -288,6 +288,9 @@ Home + + Settings + Routing diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/ViewModels/Core View Models/HomeViewModel.cs b/src/user-tools/midi-settings/Microsoft.Midi.Settings/ViewModels/Core View Models/HomeViewModel.cs index a92c02fdc..66b11179a 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/ViewModels/Core View Models/HomeViewModel.cs +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/ViewModels/Core View Models/HomeViewModel.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License // ============================================================================ // This is part of Windows MIDI Services and should be used @@ -192,37 +192,39 @@ public string CurrentConfigurationFileName - public void CheckForSdkUpdates() + public async Task CheckForSdkUpdatesAsync() { try { + await Task.Run(() => + { + IsNewerSdkRuntimeDownloadAvailable = false; + _newRelease = null; - IsNewerSdkRuntimeDownloadAvailable = false; - _newRelease = null; - - // TODO: This needs to check the correct channel - var newRelease = _updateService.CheckForUpdates(); - var installedVersion = _sdkService.InstalledVersion; + // TODO: This needs to check the correct channel + var newRelease = _updateService.CheckForUpdates(); + var installedVersion = _sdkService.InstalledVersion; - if (newRelease == null || installedVersion == null) return; + if (newRelease == null || installedVersion == null) return; - MidiSdkCurrentReleaseVersionString = installedVersion.ToString(); + MidiSdkCurrentReleaseVersionString = installedVersion.ToString(); - if (newRelease.Version.IsGreaterThan(installedVersion)) - { - _newRelease = newRelease; + if (newRelease.Version.IsGreaterThan(installedVersion)) + { + _newRelease = newRelease; - MidiSdkDownloadUri = newRelease.DirectDownloadUriForCurrentRuntimeArchitecture; - MidiSdkReleaseNotesUri = newRelease.ReleaseNotesUri; - MidiSdkNewReleaseDateString = newRelease.BuildDate.ToString("MMMM dd, yyyy"); - MidiSdkNewReleaseVersionString = newRelease.Version.ToString(); + MidiSdkDownloadUri = newRelease.DirectDownloadUriForCurrentRuntimeArchitecture; + MidiSdkReleaseNotesUri = newRelease.ReleaseNotesUri; + MidiSdkNewReleaseDateString = newRelease.BuildDate.ToString("MMMM dd, yyyy"); + MidiSdkNewReleaseVersionString = newRelease.Version.ToString(); - IsNewerSdkRuntimeDownloadAvailable = true; - } - else - { - IsNewerSdkRuntimeDownloadAvailable = false; - } + IsNewerSdkRuntimeDownloadAvailable = true; + } + else + { + IsNewerSdkRuntimeDownloadAvailable = false; + } + }); } catch (Exception ex) { @@ -233,7 +235,6 @@ public void CheckForSdkUpdates() System.Diagnostics.Debug.WriteLine(ex); IsNewerSdkRuntimeDownloadAvailable = false; } - } @@ -371,11 +372,6 @@ IMidiDiagnosticsService diagnosticsService - if (_updateService.GetAutoCheckForUpdatesEnabled()) - { - CheckForSdkUpdates(); - } - IsNetworkMidi2Available = _transportInfoService.IsTransportAvailable("NET2UDP"); //LaunchNewSdkVersionUpdateCommand = new RelayCommand( @@ -393,23 +389,31 @@ public void OnNavigatedFrom() public void OnNavigatedTo(object parameter) { - var timerInfo = MidiClock.GetCurrentSystemTimerInfo(); - - if (timerInfo.CurrentIntervalTicks > 0) + // 系统计时器信息获取是轻量级本地操作,不需要异步处理 + try { - SystemTimerCurrentResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.CurrentIntervalTicks).ToString("N3") + " ms"; - SystemTimerMaxResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.MaximumIntervalTicks).ToString("N3") + " ms"; - SystemTimerMinResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.MinimumIntervalTicks).ToString("N3") + " ms"; + var timerInfo = MidiClock.GetCurrentSystemTimerInfo(); + + if (timerInfo.CurrentIntervalTicks > 0) + { + SystemTimerCurrentResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.CurrentIntervalTicks).ToString("N3") + " ms"; + SystemTimerMaxResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.MaximumIntervalTicks).ToString("N3") + " ms"; + SystemTimerMinResolutionFormattedMilliseconds = MidiClock.ConvertTimestampTicksToMilliseconds(timerInfo.MinimumIntervalTicks).ToString("N3") + " ms"; + } + else + { + SystemTimerCurrentResolutionFormattedMilliseconds = "error"; + SystemTimerMaxResolutionFormattedMilliseconds = "error"; + SystemTimerMinResolutionFormattedMilliseconds = "error"; + } } - else + catch (Exception ex) { - // failed to get timer info - + App.GetService().LogError("Error getting system timer info", ex); SystemTimerCurrentResolutionFormattedMilliseconds = "error"; SystemTimerMaxResolutionFormattedMilliseconds = "error"; SystemTimerMinResolutionFormattedMilliseconds = "error"; } - } diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/HomePage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/HomePage.xaml index 76900f61d..008f86b7c 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/HomePage.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/HomePage.xaml @@ -8,6 +8,7 @@ xmlns:midi2="using:Microsoft.Windows.Devices.Midi2" xmlns:controls="using:CommunityToolkit.WinUI.Controls" xmlns:helpers="using:Microsoft.Midi.Settings.Helpers" + xmlns:converters="using:CommunityToolkit.WinUI.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" @@ -16,6 +17,7 @@ + @@ -44,7 +46,8 @@ diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ManagementSessionsPage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ManagementSessionsPage.xaml index 5e3bac1cd..8bcf78c5a 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ManagementSessionsPage.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ManagementSessionsPage.xaml @@ -22,7 +22,9 @@ + diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/PluginsTransportPage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/PluginsTransportPage.xaml index 93b0f2d15..958926b3d 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/PluginsTransportPage.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/PluginsTransportPage.xaml @@ -41,19 +41,16 @@ - - - - + - - - + + + diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/SettingsPage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/SettingsPage.xaml index 6ee2e4be8..4e14a72be 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/SettingsPage.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/SettingsPage.xaml @@ -24,7 +24,8 @@ + Spacing="4" + Margin="0,0,0,24"> diff --git a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml index e35583dd9..7071111e5 100644 --- a/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml +++ b/src/user-tools/midi-settings/Microsoft.Midi.Settings/Views/Core Pages/ShellPage.xaml @@ -17,14 +17,14 @@ + 26 8,0,0,0 8,0,0,0 12,2,4,2 - 60 - 40,0,40,0 + 40,24,40,0 40,0,40,20