From 2bb5f6afc437da5ba250e7a6e70b515d17d9940b Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Thu, 3 Oct 2024 17:22:07 +0800
Subject: [PATCH] Add DialogHost fro Desktop
---
v2rayN/v2rayN.Desktop/App.axaml | 1 +
v2rayN/v2rayN.Desktop/Views/MainWindow.axaml | 500 +++++++++---------
.../Views/ProfilesView.axaml.cs | 6 +-
v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml | 20 +-
.../v2rayN.Desktop/Views/QrcodeView.axaml.cs | 4 +-
.../Views/SubSettingWindow.axaml | 113 ++--
.../Views/SubSettingWindow.axaml.cs | 3 +-
v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj | 1 +
8 files changed, 325 insertions(+), 323 deletions(-)
diff --git a/v2rayN/v2rayN.Desktop/App.axaml b/v2rayN/v2rayN.Desktop/App.axaml
index 12b0fc39..81f369d2 100644
--- a/v2rayN/v2rayN.Desktop/App.axaml
+++ b/v2rayN/v2rayN.Desktop/App.axaml
@@ -9,6 +9,7 @@
+
diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml
index c1d0770e..9262a677 100644
--- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml
@@ -3,6 +3,7 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
@@ -15,270 +16,273 @@
ShowInTaskbar="True"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
index 4df3854f..ed9a34d7 100644
--- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
@@ -3,6 +3,7 @@ using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
+using DialogHostAvalonia;
using MsBox.Avalonia.Enums;
using ReactiveUI;
using Splat;
@@ -88,7 +89,7 @@ namespace v2rayN.Desktop.Views
RestoreUI();
ViewModel?.RefreshServers();
- }
+ }
//#region Event
@@ -170,8 +171,9 @@ namespace v2rayN.Desktop.Views
{
return;
}
+
var dialog = new QrcodeView(url);
- await dialog.ShowDialog(_window);
+ await DialogHost.Show(dialog);
}
private void lstProfiles_SelectionChanged(object? sender, SelectionChangedEventArgs e)
diff --git a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml
index 2f92209a..aefd7619 100644
--- a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml
@@ -1,25 +1,17 @@
-
-
-
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs
index e9f18f90..15ba0357 100644
--- a/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/QrcodeView.axaml.cs
@@ -3,7 +3,7 @@ using Avalonia.Media.Imaging;
namespace v2rayN.Desktop.Views
{
- public partial class QrcodeView : Window
+ public partial class QrcodeView : UserControl
{
public QrcodeView(string? url)
{
@@ -12,7 +12,7 @@ namespace v2rayN.Desktop.Views
txtContent.Text = url;
imgQrcode.Source = GetQRCode(url);
- btnCancel.Click += (s, e) => this.Close();
+ // btnCancel.Click += (s, e) => this.Close();
}
private Bitmap? GetQRCode(string? url)
diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml
index 929ca75c..23974c14 100644
--- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml
@@ -3,6 +3,7 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
@@ -15,58 +16,64 @@
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs
index 9cd62245..7a9aad66 100644
--- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.ReactiveUI;
+using DialogHostAvalonia;
using DynamicData;
using MsBox.Avalonia.Enums;
using ReactiveUI;
@@ -71,7 +72,7 @@ namespace v2rayN.Desktop.Views
return;
}
var dialog = new QrcodeView(url);
- await dialog.ShowDialog(this);
+ await DialogHost.Show(dialog, "dialogHostSub");
}
private void LstSubscription_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
diff --git a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj
index 1eda6990..02497df6 100644
--- a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj
+++ b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj
@@ -24,6 +24,7 @@
+