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() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
RefreshListBox();
} }
private void RefreshButton_OnClick(object sender, RoutedEventArgs e) private void RefreshButton_OnClick(object sender, RoutedEventArgs e)

View File

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

View File

@@ -7,8 +7,6 @@ public partial class SetWindow : Window
public SetWindow(PortProxyItem item) public SetWindow(PortProxyItem item)
{ {
Item = item; Item = item;
ListenAddress = item.ListenAddress;
ListenPort = item.ListenPort;
TargetAddress = item.TargetAddress ?? "127.0.0.1"; TargetAddress = item.TargetAddress ?? "127.0.0.1";
TargetPort = item.TargetPort ?? 12345; TargetPort = item.TargetPort ?? 12345;
InitializeComponent(); InitializeComponent();
@@ -16,16 +14,11 @@ public partial class SetWindow : Window
} }
public PortProxyItem Item { get; set; } public PortProxyItem Item { get; set; }
public string ListenAddress { get; set; }
public ushort ListenPort { get; set; }
public string TargetAddress { get; set; } public string TargetAddress { get; set; }
public ushort TargetPort { get; set; } public ushort TargetPort { get; set; }
private void SetButton_OnClick(object sender, RoutedEventArgs e) private void SetButton_OnClick(object sender, RoutedEventArgs e)
{ {
Item.ListenAddress = ListenAddress;
Item.ListenPort = ListenPort;
Item.TargetAddress = TargetAddress; Item.TargetAddress = TargetAddress;
Item.TargetPort = TargetPort; Item.TargetPort = TargetPort;
var result = PortProxy.Set(Item); var result = PortProxy.Set(Item);