<Window x:Class="CrazyCoder.Views.IpConfigWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="IP 设置工具" Height="650" Width="800" WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style x:Key="GroupBorder" TargetType="Border">
<Setter Property="BorderBrush" Value="#D0D0D0"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="0,0,0,6"/>
</Style>
<Style x:Key="SectionTitle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="4,3"/>
<Setter Property="FontSize" Value="13"/>
</Style>
<Style x:Key="ConfigLabel" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="4,2"/>
</Style>
<Style x:Key="ConfigTextBox" TargetType="TextBox">
<Setter Property="Margin" Value="2"/>
<Setter Property="Height" Value="28"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#D0D0D0"/>
</Style>
<Style x:Key="ActionButton" TargetType="Button">
<Setter Property="Height" Value="32"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Padding" Value="16,0"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
<Style x:Key="LogTextBox" TargetType="TextBox">
<Setter Property="FontFamily" Value="Consolas"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="#D0D0D0"/>
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</Window.Resources>
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 适配器选择 -->
<Border Grid.Row="0" Style="{StaticResource GroupBorder}">
<StackPanel>
<TextBlock Text="网络适配器" Style="{StaticResource SectionTitle}"/>
<ComboBox ItemsSource="{Binding Adapters}" SelectedItem="{Binding SelectedAdapter}"
Margin="4,2" Height="30"/>
<TextBlock Text="{Binding AdapterDescription}" Margin="4,2" TextWrapping="Wrap" Foreground="#666"/>
</StackPanel>
</Border>
<!-- IP 配置 -->
<Border Grid.Row="1" Style="{StaticResource GroupBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="IP" Style="{StaticResource ConfigLabel}"/>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding IpAddress, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ConfigTextBox}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="掩码" Style="{StaticResource ConfigLabel}"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding SubnetMask, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ConfigTextBox}"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="网关" Style="{StaticResource ConfigLabel}"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Gateway, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ConfigTextBox}"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="DNS" Style="{StaticResource ConfigLabel}"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Dns, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource ConfigTextBox}"/>
<TextBlock Grid.Row="4" Grid.Column="0" Text="辅助IP" Style="{StaticResource ConfigLabel}"/>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding SecondaryIps, UpdateSourceTrigger=PropertyChanged}"
AcceptsReturn="True" VerticalScrollBarVisibility="Auto" MinHeight="60"
Margin="2" BorderThickness="1" BorderBrush="#D0D0D0"/>
<StackPanel Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="4">
<Button Content="应用设置" Command="{Binding ApplyCommand}" Style="{StaticResource ActionButton}" Background="#4CAF50" Foreground="White"/>
<Button Content="恢复 DHCP" Command="{Binding RestoreCommand}" Style="{StaticResource ActionButton}" Margin="6,2" Background="#F44336" Foreground="White"/>
</StackPanel>
</Grid>
</Border>
<!-- 日志 -->
<Border Grid.Row="2" Style="{StaticResource GroupBorder}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="执行日志" Style="{StaticResource SectionTitle}"/>
<TextBox Grid.Row="1" Text="{Binding Log, Mode=OneWay}" Style="{StaticResource LogTextBox}" Margin="2"/>
</Grid>
</Border>
</Grid>
</Window>
|