Compare commits

...

2 Commits

Author SHA1 Message Date
eb09a42dc6 feat: 在进入时自动刷新一次 2025-01-29 02:44:40 +08:00
1a4ad9a18f refactor: 重构设置窗口逻辑 2025-01-29 02:43:45 +08:00
3 changed files with 6 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
RefreshListBox();
}
private void RefreshButton_OnClick(object sender, RoutedEventArgs e)

View File

@@ -16,7 +16,8 @@
</Grid.ColumnDefinitions>
<Label Grid.Column="0">监听地址</Label>
<TextBox Grid.Column="1"
Text="{Binding ListenAddress}" />
Text="{Binding Item.ListenAddress}"
IsEnabled="False" />
</Grid>
<Grid Margin="4">
<Grid.ColumnDefinitions>
@@ -24,9 +25,10 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0">监听端口</Label>
<TextBox Grid.Column="1">
<TextBox Grid.Column="1"
IsEnabled="False">
<TextBox.Text>
<Binding Path="ListenPort" UpdateSourceTrigger="PropertyChanged">
<Binding Path="Item.ListenPort" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<rules:PortValidationRule />
</Binding.ValidationRules>

View File

@@ -7,8 +7,6 @@ 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();
@@ -16,16 +14,11 @@ public partial class SetWindow : Window
}
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);