MainWindow.xaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <Window x:Class="AutoFocusTool.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="相机自动对焦 · 手动测试台" Height="1180" Width="720"
  5. FontFamily="Microsoft YaHei" FontSize="13" Background="#1E1E1E">
  6. <Window.Resources>
  7. <Style TargetType="Button">
  8. <Setter Property="Margin" Value="2"/>
  9. <Setter Property="Padding" Value="6,4"/>
  10. <Setter Property="Background" Value="#3C3C3C"/>
  11. <Setter Property="Foreground" Value="White"/>
  12. <Setter Property="BorderBrush" Value="#555"/>
  13. </Style>
  14. <Style TargetType="TextBlock">
  15. <Setter Property="Foreground" Value="#DDD"/>
  16. <Setter Property="VerticalAlignment" Value="Center"/>
  17. </Style>
  18. <Style TargetType="GroupBox">
  19. <Setter Property="Foreground" Value="#9CDCFE"/>
  20. <Setter Property="Margin" Value="4"/>
  21. <Setter Property="BorderBrush" Value="#444"/>
  22. </Style>
  23. <Style TargetType="TextBox">
  24. <Setter Property="Background" Value="#2D2D2D"/>
  25. <Setter Property="Foreground" Value="White"/>
  26. <Setter Property="BorderBrush" Value="#555"/>
  27. <Setter Property="VerticalContentAlignment" Value="Center"/>
  28. <Setter Property="Margin" Value="2"/>
  29. </Style>
  30. </Window.Resources>
  31. <Grid Margin="6">
  32. <Grid.RowDefinitions>
  33. <RowDefinition Height="Auto"/> <!-- 0 设备选择 -->
  34. <RowDefinition Height="*"/> <!-- 1 图像预览 -->
  35. <RowDefinition Height="150"/> <!-- 2 清晰度曲线 -->
  36. <RowDefinition Height="Auto"/> <!-- 3 控制面板 -->
  37. <RowDefinition Height="170"/> <!-- 4 日志 -->
  38. </Grid.RowDefinitions>
  39. <!-- ① 设备选择 -->
  40. <GroupBox Grid.Row="0" Header="设备">
  41. <StackPanel Orientation="Horizontal">
  42. <Button x:Name="BtnScan" Content="扫描设备" Click="BtnScan_Click" Width="80"/>
  43. <TextBlock Text="舱室:" Margin="8,0,4,0"/>
  44. <ComboBox x:Name="CmbHouse" Width="200" Margin="2" Height="26"/>
  45. <Button x:Name="BtnConnect" Content="连接" Click="BtnConnect_Click" Width="70"/>
  46. <Button x:Name="BtnDisconnect" Content="断开" Click="BtnDisconnect_Click" Width="70" IsEnabled="False"/>
  47. <TextBlock x:Name="TxtConnState" Text="未连接" Margin="10,0,0,0" Foreground="#F48771"/>
  48. </StackPanel>
  49. </GroupBox>
  50. <!-- ② 图像预览 + 叠加信息 -->
  51. <Border Grid.Row="1" Background="Black" Margin="4" BorderBrush="#444" BorderThickness="1">
  52. <Grid>
  53. <Image x:Name="ImgPreview" Stretch="Uniform"/>
  54. <!-- ROI 框(中心区) -->
  55. <Canvas x:Name="OverlayCanvas"/>
  56. <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8"
  57. Background="#80000000">
  58. <TextBlock x:Name="TxtScore" Text="清晰度: --" FontSize="16" Foreground="#4EC9B0" Margin="4,2"/>
  59. <TextBlock x:Name="TxtZ" Text="Z: -- 水平: --" FontSize="13" Margin="4,2"/>
  60. <TextBlock x:Name="TxtFps" Text="帧: --" FontSize="12" Foreground="#888" Margin="4,2"/>
  61. </StackPanel>
  62. </Grid>
  63. </Border>
  64. <!-- ③ 清晰度曲线 -->
  65. <GroupBox Grid.Row="2" Header="清晰度曲线(Z序列扫描结果)">
  66. <Canvas x:Name="CurveCanvas" Background="#252526" ClipToBounds="True"/>
  67. </GroupBox>
  68. <!-- ④ 控制面板 -->
  69. <GroupBox Grid.Row="3" Header="手动控制">
  70. <StackPanel x:Name="ControlPanel" IsEnabled="False">
  71. <!-- 当前参数值 + 可调范围 实时显示 -->
  72. <Border Background="#2A2D2E" CornerRadius="4" Margin="2" Padding="6">
  73. <StackPanel>
  74. <TextBlock x:Name="TxtCurValues" Foreground="#4EC9B0" FontSize="13" FontWeight="Bold"
  75. Text="当前值:曝光-- 增益-- Z-- 水平--" TextWrapping="Wrap"/>
  76. <TextBlock x:Name="TxtRanges" Foreground="#888" FontSize="11" Margin="0,2,0,0"
  77. Text="可调范围:曝光1~1000(×100µs) | 增益0~255 | Z 0~125000 | 水平 0~210000 (脉冲)"/>
  78. </StackPanel>
  79. </Border>
  80. <!-- well 选择:转到任意 well 再手动调 -->
  81. <StackPanel Orientation="Horizontal" Margin="2">
  82. <TextBlock Text="当前well:" Width="70" Foreground="#DCDCAA"/>
  83. <ComboBox x:Name="CmbWell" Width="70" Height="26" Margin="2"/>
  84. <Button x:Name="BtnGoWell" Content="转到该well" Click="BtnGoWell_Click" Width="90"/>
  85. <TextBlock x:Name="TxtWellInfo" Text="(选well并转到)" Margin="8,0,0,0" Foreground="#888"/>
  86. </StackPanel>
  87. <!-- 光源 + 拍照 -->
  88. <StackPanel Orientation="Horizontal" Margin="2">
  89. <Button x:Name="BtnLedOn" Content="开光源" Click="BtnLedOn_Click" Width="70"/>
  90. <Button x:Name="BtnLedOff" Content="关光源" Click="BtnLedOff_Click" Width="70"/>
  91. <Button x:Name="BtnGrab" Content="抓一帧" Click="BtnGrab_Click" Width="70"/>
  92. <ToggleButton x:Name="TglLive" Content="实时预览" Click="TglLive_Click" Width="80"
  93. Margin="2" Padding="6,4" Background="#3C3C3C" Foreground="White"/>
  94. <Button x:Name="BtnSaveImg" Content="存图" Click="BtnSaveImg_Click" Width="60"/>
  95. </StackPanel>
  96. <!-- 曝光 + 增益 -->
  97. <StackPanel Orientation="Horizontal" Margin="2">
  98. <TextBlock Text="曝光(×100µs):" Width="90"/>
  99. <TextBox x:Name="TxtExposure" Text="400" Width="60"/>
  100. <Button x:Name="BtnSetExp" Content="设置" Click="BtnSetExp_Click" Width="50"/>
  101. <TextBlock Text="增益RGB:" Width="60" Margin="8,0,0,0"/>
  102. <TextBox x:Name="TxtGainR" Text="25" Width="40"/>
  103. <TextBox x:Name="TxtGainG" Text="14" Width="40"/>
  104. <TextBox x:Name="TxtGainB" Text="25" Width="40"/>
  105. <Button x:Name="BtnSetGain" Content="设置" Click="BtnSetGain_Click" Width="50"/>
  106. </StackPanel>
  107. <!-- Z 轴(对焦) -->
  108. <StackPanel Orientation="Horizontal" Margin="2">
  109. <TextBlock Text="Z对焦轴:" Width="70" Foreground="#DCDCAA"/>
  110. <TextBox x:Name="TxtZStep" Text="128" Width="60"/>
  111. <Button x:Name="BtnZUp" Content="Z+ 正转" Click="BtnZUp_Click" Width="70"/>
  112. <Button x:Name="BtnZDown" Content="Z- 反转" Click="BtnZDown_Click" Width="70"/>
  113. <Button x:Name="BtnZReset" Content="Z复位" Click="BtnZReset_Click" Width="60"/>
  114. <TextBlock Text="绝对:" Width="40" Margin="6,0,0,0"/>
  115. <TextBox x:Name="TxtZAbs" Text="0" Width="70"/>
  116. <Button x:Name="BtnZMoveTo" Content="移动" Click="BtnZMoveTo_Click" Width="50"/>
  117. </StackPanel>
  118. <!-- 水平轴 -->
  119. <StackPanel Orientation="Horizontal" Margin="2">
  120. <TextBlock Text="水平轴:" Width="70" Foreground="#DCDCAA"/>
  121. <TextBox x:Name="TxtHStep" Text="100" Width="60"/>
  122. <Button x:Name="BtnHFwd" Content="正转" Click="BtnHFwd_Click" Width="70"/>
  123. <Button x:Name="BtnHBwd" Content="反转" Click="BtnHBwd_Click" Width="70"/>
  124. <Button x:Name="BtnHReset" Content="复位" Click="BtnHReset_Click" Width="60"/>
  125. <TextBlock Text="到位延时ms:" Width="80" Margin="6,0,0,0"/>
  126. <TextBox x:Name="TxtMotorDelay" Text="1500" Width="60"/>
  127. </StackPanel>
  128. <!-- 自动对焦扫描 -->
  129. <StackPanel Orientation="Horizontal" Margin="2">
  130. <TextBlock Text="Z扫描:" Width="70" Foreground="#4EC9B0"/>
  131. <TextBlock Text="起点" Width="34"/>
  132. <TextBox x:Name="TxtScanStart" Text="0" Width="60"/>
  133. <TextBlock Text="层距" Width="34"/>
  134. <TextBox x:Name="TxtScanStep" Text="128" Width="50"/>
  135. <TextBlock Text="层数" Width="34"/>
  136. <TextBox x:Name="TxtScanCount" Text="11" Width="40"/>
  137. <Button x:Name="BtnZScan" Content="扫描选层" Click="BtnZScan_Click" Width="80" Background="#0E639C"/>
  138. <Button x:Name="BtnStop" Content="停止" Click="BtnStop_Click" Width="50" Background="#A1260D"/>
  139. </StackPanel>
  140. <!-- 一键全自动初始化标定 -->
  141. <Border BorderBrush="#4EC9B0" BorderThickness="1" CornerRadius="4" Margin="2" Padding="4">
  142. <StackPanel>
  143. <StackPanel Orientation="Horizontal">
  144. <TextBlock Text="自动标定:" Width="70" Foreground="#4EC9B0" FontWeight="Bold"/>
  145. <Button x:Name="BtnWellAll" Content="全选" Click="BtnWellAll_Click" Width="50"/>
  146. <Button x:Name="BtnWellNone" Content="全不选" Click="BtnWellNone_Click" Width="56"/>
  147. <Button x:Name="BtnAutoInit" Content="一键全自动初始化" Click="BtnAutoInit_Click" Width="130" Background="#1a7f37" FontWeight="Bold"/>
  148. <TextBlock x:Name="TxtCalProgress" Text="就绪" Margin="8,0,0,0" Foreground="#DCDCAA"/>
  149. </StackPanel>
  150. <!-- 16个well勾选(任选) -->
  151. <WrapPanel x:Name="WellCheckPanel" Margin="0,4,0,0"/>
  152. </StackPanel>
  153. </Border>
  154. </StackPanel>
  155. </GroupBox>
  156. <!-- ⑤ 日志 -->
  157. <GroupBox Grid.Row="4" Header="日志">
  158. <TextBox x:Name="TxtLog" IsReadOnly="True" VerticalScrollBarVisibility="Auto"
  159. TextWrapping="NoWrap" HorizontalScrollBarVisibility="Auto"
  160. FontFamily="Consolas" FontSize="11" Background="#1A1A1A"/>
  161. </GroupBox>
  162. </Grid>
  163. </Window>