<Window x:Class="Ink_Canvas.Windows.PluginSettingsWindow"
        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"
        xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
        xmlns:local="clr-namespace:Ink_Canvas.Windows"
        mc:Ignorable="d"
        Title="插件管理" Height="550" Width="800"
        WindowStartupLocation="CenterScreen"
        ResizeMode="CanResize"
        Background="#F9F9F9">
    
    <Window.Resources>
        <!-- 定义必要的资源 -->
        <SolidColorBrush x:Key="BorderBrush" Color="#DDDDDD"/>
        <SolidColorBrush x:Key="SystemAccentColorLight1" Color="#3B82F6"/>
        <SolidColorBrush x:Key="SystemAccentColor" Color="#2563EB"/>
        <SolidColorBrush x:Key="SystemControlBackgroundChromeMediumBrush" Color="#F0F0F0"/>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <!-- 标题栏 -->
        <Border Grid.Row="0" Background="{DynamicResource SystemAccentColorLight1}" Height="60">
            <Grid>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="20,0,0,0">
                    <TextBlock Text="插件管理" FontSize="22" FontWeight="SemiBold" Foreground="White" VerticalAlignment="Center"/>
                </StackPanel>
                <Button x:Name="BtnClose" Content="&#xE8BB;" FontFamily="Segoe MDL2 Assets" 
                        HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0"
                        Background="Transparent" BorderThickness="0" FontSize="16" Foreground="White"
                        Click="BtnClose_Click"/>
            </Grid>
        </Border>
        
        <!-- 主内容区 -->
        <Grid Grid.Row="1" Margin="20">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <!-- 左侧插件列表 -->
            <Border Grid.Column="0" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,0,10,0" CornerRadius="5">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    
                    <TextBlock Grid.Row="0" Text="插件列表" Margin="10,10,0,5" FontSize="16" FontWeight="SemiBold" Foreground="Black"/>
                    
                    <ListView Grid.Row="1" x:Name="PluginListView" BorderThickness="0" Margin="0,5,0,0" 
                              SelectionChanged="PluginListView_SelectionChanged">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="0,5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Name}" Grid.Column="0" VerticalAlignment="Center" 
                                              Foreground="Black" FontWeight="Normal" FontSize="14"/>
                                    <ui:ToggleSwitch Grid.Column="1" IsOn="{Binding IsEnabled}" 
                                                    Toggled="PluginToggleSwitch_Toggled" 
                                                    Tag="{Binding}" MinWidth="40"/>
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </Border>
            
            <!-- 右侧插件详情和设置 -->
            <ScrollViewer Grid.Column="1" Margin="10,0,0,0" VerticalScrollBarVisibility="Auto">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    
                    <!-- 插件详情 -->
                    <Border Grid.Row="0" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Padding="15" CornerRadius="5">
                        <Grid x:Name="PluginDetailGrid">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            
                            <TextBlock Grid.Row="0" Grid.Column="0" Text="名称：" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
                            <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Name}" Margin="0,0,0,5" Foreground="Black"/>

                            <TextBlock Grid.Row="1" Grid.Column="0" Text="版本：" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
                            <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Version}" Margin="0,0,0,5" Foreground="Black"/>

                            <TextBlock Grid.Row="2" Grid.Column="0" Text="作者：" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
                            <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Author}" Margin="0,0,0,5" Foreground="Black"/>

                            <TextBlock Grid.Row="3" Grid.Column="0" Text="描述：" FontWeight="SemiBold" Margin="0,0,0,5" Foreground="Black"/>
                            <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Description}" TextWrapping="Wrap" Margin="0,0,0,5" Foreground="Black"/>
                            
                            <Button Grid.Row="3" Grid.Column="2" x:Name="BtnDeletePlugin" Content="删除插件" 
                                    Visibility="Collapsed" Click="BtnDeletePlugin_Click"
                                    Margin="10,0,0,0" Padding="8,3" HorizontalAlignment="Right"
                                    Background="#FFEE5555" Foreground="White"/>
                        </Grid>
                    </Border>
                    
                    <!-- 插件设置区域 -->
                    <Border Grid.Row="1" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,10,0,0" Padding="15" CornerRadius="5">
                        <StackPanel>
                            <TextBlock Text="插件设置" FontSize="16" FontWeight="SemiBold" Margin="0,0,0,10" Foreground="Black"/>
                            <ContentControl x:Name="PluginSettingsContainer" MinHeight="50"/>
                        </StackPanel>
                    </Border>
                    
                    <!-- 插件配置内容区 -->
                    <Border Grid.Row="2" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" Margin="0,10,0,0" Padding="0" CornerRadius="5">
                        <ContentControl x:Name="PluginContentContainer" Margin="0"/>
                    </Border>
                </Grid>
            </ScrollViewer>
        </Grid>
        
        <!-- 底部操作栏 -->
        <Border Grid.Row="2" Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}" Height="60">
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="20,0,0,0">
                    <Button x:Name="BtnLoadPlugin" Content="加载本地插件" Click="BtnLoadPlugin_Click"
                            Padding="15,5" Background="{DynamicResource SystemAccentColor}" Foreground="White"/>
                    <Button x:Name="BtnSaveConfig" Content="保存状态" Click="BtnSaveConfig_Click"
                            Padding="15,5" Margin="10,0,0,0" Background="{DynamicResource SystemAccentColor}" Foreground="White"
                            ToolTip="手动保存当前所有插件的启用/禁用状态到配置文件"/>
                    <Button x:Name="BtnExportPlugin" Content="导出插件" Click="BtnExportPlugin_Click"
                            Padding="15,5" Margin="10,0,0,0" Background="{DynamicResource SystemAccentColor}" Foreground="White"/>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Window> 