feat: 完善 PortProxy 图形化管理工具
This commit is contained in:
42
PortProxyTool.Wpf/Views/Windows/SetWindow.xaml.cs
Normal file
42
PortProxyTool.Wpf/Views/Windows/SetWindow.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace PortProxyTool.Wpf.Views.Windows;
|
||||
|
||||
public partial class SetWindow : Window
|
||||
{
|
||||
public SetWindow(PortProxyItem item)
|
||||
{
|
||||
Item = item;
|
||||
ListenAddress = item.ListenAddress;
|
||||
ListenPort = item.ListenPort;
|
||||
TargetAddress = item.TargetAddress ?? "127.0.0.1";
|
||||
TargetPort = item.TargetPort ?? 12345;
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public PortProxyItem Item { get; set; }
|
||||
|
||||
public string ListenAddress { get; set; }
|
||||
public ushort ListenPort { get; set; }
|
||||
public string TargetAddress { get; set; }
|
||||
public ushort TargetPort { get; set; }
|
||||
|
||||
private void SetButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Item.ListenAddress = ListenAddress;
|
||||
Item.ListenPort = ListenPort;
|
||||
Item.TargetAddress = TargetAddress;
|
||||
Item.TargetPort = TargetPort;
|
||||
var result = PortProxy.Set(Item);
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
DialogResult = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult = false;
|
||||
MessageBox.Show(result, "编辑失败", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user