Phase 2-3: UI layout, theme switching, CRUD tools, process execution
- Phase 2: MainWindow 3-section layout (sidebar/content/log bar), Dark/Light theme with ThemeHelper, MainViewModel with ObservableProperty/RelayCommand, tool card filtering by search + category - Phase 3: ToolEditWindow for add/edit tools, ProcessExecutionService (Process.Start + error handling), double-click + right-click context menu (run/edit), path browse dialog - Bugfix: ContextMenu commands now use PlacementTarget.Tag binding (ContextMenu in separate visual tree) - Bugfix: StaticResource converters moved to XAML before DataTemplate to fix XamlParseException on tool card render - Bugfix: Pure filenames (no path separators) treated as PATH commands, not marked invalid - Bugfix: RefreshData preserves SelectedCategory; Load() catches all exceptions; Save() wrapped in try-catch; auto-scroll log to newest entry - Tests: xUnit project with 55 tests covering models, services, converters, and view models
This commit is contained in:
126
PersonalToolBox/Views/ToolEditWindow.xaml
Normal file
126
PersonalToolBox/Views/ToolEditWindow.xaml
Normal file
@@ -0,0 +1,126 @@
|
||||
<Window x:Class="PersonalToolBox.Views.ToolEditWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:models="clr-namespace:PersonalToolBox.Models"
|
||||
Title="{Binding WindowTitle}" Height="380" Width="480"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Background="{DynamicResource Theme.Background}">
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- 工具名称 -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Text="名称:" Foreground="{DynamicResource Theme.Foreground}"
|
||||
VerticalAlignment="Center" Margin="0,0,0,12"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="{DynamicResource Theme.InputBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||||
Height="30" Margin="0,0,0,12" Padding="6,0"/>
|
||||
|
||||
<!-- 工具路径 -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Text="路径:" Foreground="{DynamicResource Theme.Foreground}"
|
||||
VerticalAlignment="Center" Margin="0,0,0,12"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1"
|
||||
Text="{Binding ExecutablePath, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="{DynamicResource Theme.InputBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||||
Height="30" Margin="0,0,0,12" Padding="6,0"/>
|
||||
<Button Grid.Row="1" Grid.Column="2"
|
||||
Content="..."
|
||||
Command="{Binding BrowseFileCommand}"
|
||||
Background="{DynamicResource Theme.ButtonBackground}"
|
||||
Foreground="{DynamicResource Theme.ButtonForeground}"
|
||||
BorderThickness="0"
|
||||
Width="24" Height="24" Margin="6,3,0,12"
|
||||
FontWeight="Bold" Cursor="Hand"/>
|
||||
|
||||
<!-- 运行参数 -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
Text="参数:" Foreground="{DynamicResource Theme.Foreground}"
|
||||
VerticalAlignment="Center" Margin="0,0,0,12"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding Arguments, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="{DynamicResource Theme.InputBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||||
Height="30" Margin="0,0,0,12" Padding="6,0"/>
|
||||
|
||||
<!-- 所属分类 -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
Text="分类:" Foreground="{DynamicResource Theme.Foreground}"
|
||||
VerticalAlignment="Center" Margin="0,0,0,12"/>
|
||||
<ComboBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
ItemsSource="{Binding Categories}"
|
||||
SelectedItem="{Binding SelectedCategory}"
|
||||
DisplayMemberPath="Name"
|
||||
Background="{DynamicResource Theme.InputBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||||
Height="30" Margin="0,0,0,12" Padding="4,0"/>
|
||||
|
||||
<!-- 全局快捷键 -->
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
Text="快捷键:" Foreground="{DynamicResource Theme.Foreground}"
|
||||
VerticalAlignment="Center" Margin="0,0,0,12"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding HotKey, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="{DynamicResource Theme.InputBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.InputBorder}"
|
||||
Height="30" Margin="0,0,0,12" Padding="6,0"/>
|
||||
|
||||
<!-- 提示文字 -->
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="快捷键格式示例: Ctrl+Alt+T"
|
||||
Foreground="{DynamicResource Theme.TextSecondary}"
|
||||
FontSize="11" Margin="0,0,0,16"/>
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<Border Grid.Row="6" Grid.ColumnSpan="3"
|
||||
BorderBrush="{DynamicResource Theme.CardBorder}"
|
||||
BorderThickness="0,1,0,0" Margin="0,0,0,14"/>
|
||||
|
||||
<!-- 按钮 -->
|
||||
<StackPanel Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="保存"
|
||||
Command="{Binding SaveCommand}"
|
||||
Background="{DynamicResource Theme.ButtonBackground}"
|
||||
Foreground="{DynamicResource Theme.ButtonForeground}"
|
||||
BorderThickness="0"
|
||||
Width="80" Height="30"
|
||||
FontSize="13"
|
||||
Cursor="Hand"
|
||||
Margin="0,0,10,0"/>
|
||||
<Button Content="取消"
|
||||
Command="{Binding CancelCommand}"
|
||||
Background="{DynamicResource Theme.CardBackground}"
|
||||
Foreground="{DynamicResource Theme.Foreground}"
|
||||
BorderBrush="{DynamicResource Theme.CardBorder}"
|
||||
BorderThickness="1"
|
||||
Width="80" Height="30"
|
||||
FontSize="13"
|
||||
Cursor="Hand"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user