mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-21 08:04:26 +08:00
Apply Avalonia 12 migration changes: replace SystemDecorations with WindowDecorations and remove ExtendClientAreaChromeHints/ExtendClientAreaTitleBarHeightHint usages; update BindingPlugins removal logic (no-op); switch clipboard usage to ClipboardExtensions.SetTextAsync; update Bitmap.CopyPixels calls to the new signature. Replace TextBox.Watermark with PlaceholderText, convert NumberBox styles to FANumberBox and adjust templates, change Checked/Unchecked handlers to IsCheckedChanged, and adapt FluentIcons usages (SymbolIconSource -> FASymbol/FAFont/FluentIcon equivalents). Fix MainWindow partial classes to inherit Window and correct missing variables/fields/usings. Add migration docs/specs/tasks under .trae and include a small TestFluentIcons project for icon testing.
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Threading;
|
|
using FluentAvalonia.UI.Controls;
|
|
using LanMountainDesktop.Services;
|
|
|
|
namespace LanMountainDesktop.Views;
|
|
|
|
public partial class MainWindow : Window
|
|
{
|
|
private bool _isSingleInstancePromptVisible;
|
|
|
|
internal void ShowSingleInstanceNotice()
|
|
{
|
|
void ShowPrompt()
|
|
{
|
|
UiExceptionGuard.FireAndForgetGuarded(
|
|
ShowSingleInstanceNoticeCoreAsync,
|
|
"MainWindow.ShowSingleInstanceNotice");
|
|
}
|
|
|
|
if (Dispatcher.UIThread.CheckAccess())
|
|
{
|
|
ShowPrompt();
|
|
return;
|
|
}
|
|
|
|
Dispatcher.UIThread.Post(ShowPrompt, DispatcherPriority.Send);
|
|
}
|
|
|
|
private async Task ShowSingleInstanceNoticeCoreAsync()
|
|
{
|
|
if (_isSingleInstancePromptVisible)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_isSingleInstancePromptVisible = true;
|
|
|
|
try
|
|
{
|
|
var dialog = new FAContentDialog
|
|
{
|
|
Title = L("single_instance.notice.title", "Already running"),
|
|
Content = L(
|
|
"single_instance.notice.description",
|
|
"LanMountainDesktop is already running. The existing window will stay active, so no new instance was started."),
|
|
PrimaryButtonText = L("single_instance.notice.button", "OK"),
|
|
DefaultButton = FAContentDialogButton.Primary
|
|
};
|
|
|
|
await dialog.ShowAsync(this);
|
|
}
|
|
finally
|
|
{
|
|
_isSingleInstancePromptVisible = false;
|
|
}
|
|
}
|
|
}
|