wenxiangchao
4 天以前 559890c482f5973f06aafdfec9550fee5ba3c7f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<UserControl x:Class="Plugin.DeviceDebug.Panels.PowerSupplyDebugPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
             mc:Ignorable="d" 
             d:DesignHeight="500" d:DesignWidth="600">
 
    <Grid dp:GridHelper.Space="12" Margin="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
 
        <!-- 标题 -->
        <Border Grid.Row="0" Background="#2196F3" CornerRadius="4" Padding="12,8">
            <TextBlock Text="电源控制面板" FontSize="16" FontWeight="Bold" Foreground="White"/>
        </Border>
 
        <!-- 设置区 -->
        <Border Grid.Row="1" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4" Padding="12">
            <Grid dp:GridHelper.Space="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="50"/>
                </Grid.ColumnDefinitions>
 
                <!-- 电压设定 -->
                <TextBlock Grid.Row="0" Grid.Column="0" Text="电压设定:" VerticalAlignment="Center" FontWeight="Bold"/>
                <TextBox Grid.Row="0" Grid.Column="1" x:Name="voltageInput" 
                         IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
                         VerticalContentAlignment="Center" Padding="6,4" Text="0.00"/>
                <TextBlock Grid.Row="0" Grid.Column="2" Text="V" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#666"/>
 
                <!-- 限流设定 -->
                <TextBlock Grid.Row="1" Grid.Column="0" Text="限流设定:" VerticalAlignment="Center" FontWeight="Bold"/>
                <TextBox Grid.Row="1" Grid.Column="1" x:Name="currentInput"
                         IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
                         VerticalContentAlignment="Center" Padding="6,4" Text="0.000"/>
                <TextBlock Grid.Row="1" Grid.Column="2" Text="A" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#666"/>
 
                <!-- 输出控制 -->
                <TextBlock Grid.Row="2" Grid.Column="0" Text="输出控制:" VerticalAlignment="Center" FontWeight="Bold"/>
                <ToggleButton Grid.Row="2" Grid.Column="1" x:Name="outputToggle"
                              IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
                              Checked="OutputToggle_Changed" Unchecked="OutputToggle_Changed"
                              Height="30" Cursor="Hand">
                    <ToggleButton.Style>
                        <Style TargetType="ToggleButton">
                            <Setter Property="Content" Value="OFF"/>
                            <Setter Property="Background" Value="#F44336"/>
                            <Setter Property="Foreground" Value="White"/>
                            <Setter Property="FontWeight" Value="Bold"/>
                            <Style.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter Property="Content" Value="ON"/>
                                    <Setter Property="Background" Value="#4CAF50"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ToggleButton.Style>
                </ToggleButton>
 
                <!-- 操作按钮 -->
                <StackPanel Grid.Row="3" Grid.ColumnSpan="3" Orientation="Horizontal" 
                            dp:StackPanelHelper.ChildSpace="10" HorizontalAlignment="Left" Margin="0,6,0,0">
                    <Button x:Name="applyBtn" Content="设置" Padding="16,6"
                            IsEnabled="{Binding IsMaintenanceMode, RelativeSource={RelativeSource AncestorType=UserControl}}"
                            Click="ApplyBtn_Click"
                            Background="#2196F3" Foreground="White" BorderThickness="0" Cursor="Hand"/>
                    <Button x:Name="measureBtn" Content="测量" Padding="16,6"
                            Click="MeasureBtn_Click"
                            Background="#4CAF50" Foreground="White" BorderThickness="0" Cursor="Hand"/>
                </StackPanel>
            </Grid>
        </Border>
 
        <!-- 实测值显示区 -->
        <Border Grid.Row="2" BorderBrush="#DDD" BorderThickness="1" CornerRadius="4" Padding="12">
            <Grid dp:GridHelper.Space="8">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
 
                <TextBlock Grid.Row="0" Grid.Column="0" Text="实测电压:" FontWeight="Bold" VerticalAlignment="Center"/>
                <TextBlock Grid.Row="0" Grid.Column="1" x:Name="measuredVoltage" 
                           Text="-- V" FontSize="18" Foreground="#2196F3" VerticalAlignment="Center"/>
 
                <TextBlock Grid.Row="1" Grid.Column="0" Text="实测电流:" FontWeight="Bold" VerticalAlignment="Center"/>
                <TextBlock Grid.Row="1" Grid.Column="1" x:Name="measuredCurrent" 
                           Text="-- A" FontSize="18" Foreground="#FF9800" VerticalAlignment="Center"/>
 
                <TextBlock Grid.Row="2" Grid.Column="0" Text="更新时间:" FontWeight="Bold" VerticalAlignment="Center"/>
                <TextBlock Grid.Row="2" Grid.Column="1" x:Name="lastUpdateTime" 
                           Text="--" Foreground="#999" VerticalAlignment="Center"/>
            </Grid>
        </Border>
 
        
    </Grid>
</UserControl>