diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs
new file mode 100644
index 000000000..2dd57809d
--- /dev/null
+++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs
@@ -0,0 +1,62 @@
+using System.Net;
+using System.Windows;
+using CommunityToolkit.Mvvm.Input;
+using Flow.Launcher.Core;
+using Flow.Launcher.Core.Resource;
+using Flow.Launcher.Infrastructure.UserSettings;
+using Flow.Launcher.Plugin;
+
+namespace Flow.Launcher.SettingPages.ViewModels;
+
+public partial class SettingsPaneProxyViewModel : BaseModel
+{
+ private readonly Updater _updater;
+ public Settings Settings { get; }
+
+ public SettingsPaneProxyViewModel(Settings settings, Updater updater)
+ {
+ _updater = updater;
+ Settings = settings;
+ }
+
+ [RelayCommand]
+ private void OnTestProxyClicked()
+ {
+ var message = TestProxy();
+ MessageBox.Show(InternationalizationManager.Instance.GetTranslation(message));
+ }
+
+ private string TestProxy()
+ {
+ if (string.IsNullOrEmpty(Settings.Proxy.Server)) return "serverCantBeEmpty";
+ if (Settings.Proxy.Port <= 0) return "portCantBeEmpty";
+
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_updater.GitHubRepository);
+
+ if (string.IsNullOrEmpty(Settings.Proxy.UserName) || string.IsNullOrEmpty(Settings.Proxy.Password))
+ {
+ request.Proxy = new WebProxy(Settings.Proxy.Server, Settings.Proxy.Port);
+ }
+ else
+ {
+ request.Proxy = new WebProxy(Settings.Proxy.Server, Settings.Proxy.Port)
+ {
+ Credentials = new NetworkCredential(Settings.Proxy.UserName, Settings.Proxy.Password)
+ };
+ }
+
+ try
+ {
+ var response = (HttpWebResponse)request.GetResponse();
+ return response.StatusCode switch
+ {
+ HttpStatusCode.OK => "proxyIsCorrect",
+ _ => "proxyConnectFailed"
+ };
+ }
+ catch
+ {
+ return "proxyConnectFailed";
+ }
+ }
+}
diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml
index a6bd91534..efd4ceb89 100644
--- a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml
+++ b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml
@@ -1,181 +1,77 @@
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs
index 041bd40bc..95c88d627 100644
--- a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs
+++ b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml.cs
@@ -1,28 +1,24 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
using System.Windows.Navigation;
-using System.Windows.Shapes;
+using Flow.Launcher.SettingPages.ViewModels;
-namespace Flow.Launcher.SettingPages.Views
+namespace Flow.Launcher.SettingPages.Views;
+
+public partial class SettingsPaneProxy
{
- ///
- /// Proxy.xaml에 대한 상호 작용 논리
- ///
- public partial class SettingsPaneProxy : Page
+ private SettingsPaneProxyViewModel _viewModel = null!;
+
+ protected override void OnNavigatedTo(NavigationEventArgs e)
{
- public SettingsPaneProxy()
+ if (!IsInitialized)
{
+ if (e.ExtraData is not SettingWindow.PaneData { Settings: { } settings, Updater: { } updater })
+ throw new ArgumentException($"Settings are required for {nameof(SettingsPaneProxy)}.");
+ _viewModel = new SettingsPaneProxyViewModel(settings, updater);
+ DataContext = _viewModel;
InitializeComponent();
}
+
+ base.OnNavigatedTo(e);
}
}