页面逻辑调整
This commit is contained in:
@@ -125,31 +125,62 @@
|
||||
<TextBox Name="zdangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="zdangle_GotFocus"/>
|
||||
<TextBlock Text="°/S" Style="{StaticResource UnitStyle}"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
<Button Grid.Column="2" Content="打印" Margin="270,6,0,0" VerticalAlignment="Top" Height="42" Width="75" Click="Button_Click_Print" FontSize="18" RenderTransformOrigin="0.360,-0.63" HorizontalAlignment="Left"/>
|
||||
|
||||
<Button Grid.Column="2" Content="打印" Margin="356,11,0,0" VerticalAlignment="Top" Height="42" Width="75" Click="Button_Click_Print" FontSize="18" RenderTransformOrigin="0.330,-0.63" HorizontalAlignment="Left"/>
|
||||
<ToggleButton x:Name="tbTest"
|
||||
FontSize="18"
|
||||
Width="111" Height="40"
|
||||
Background="LightBlue"
|
||||
Background="LightGray"
|
||||
Checked="TbTest_Checked"
|
||||
Unchecked="TbTest_Unchecked" Grid.Column="1" HorizontalAlignment="Left" Margin="131,8,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2">
|
||||
<!-- 取消时(空白测试) -->
|
||||
<!-- 关键:用Style去掉边框 -->
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton">
|
||||
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
<ToggleButton.Template>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<!-- 自定义外观,去掉所有默认hover效果 -->
|
||||
<Border x:Name="border"
|
||||
CornerRadius="3"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="0">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<!-- 去掉默认的hover/点击效果触发器 -->
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="LightGray"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</ToggleButton.Template>
|
||||
|
||||
试样测试
|
||||
</ToggleButton>
|
||||
<TextBlock x:Name="当前模式" Grid.Column="1" HorizontalAlignment="Left" Margin="39,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-6.776,-2.381" Width="116"><Run Text="当前模式"/><Run Language="zh-cn" Text=":"/></TextBlock>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,48,0,53" Width="126">
|
||||
<!-- 左灯:BL_0 (M-104) -->
|
||||
<Ellipse x:Name="led0"
|
||||
Width="40" Height="40"
|
||||
Margin="10"
|
||||
Fill="LightGray"
|
||||
Stroke="LightGray" StrokeThickness="1" >
|
||||
<Ellipse.Effect>
|
||||
<DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
|
||||
<!-- 右灯:BL_1 (M-105) -->
|
||||
<Ellipse x:Name="led1"
|
||||
Width="40" Height="40"
|
||||
Margin="10"
|
||||
Fill="LightGray"
|
||||
Stroke="LightGray" StrokeThickness="1">
|
||||
<Ellipse.Effect>
|
||||
<DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
|
||||
</Ellipse.Effect>
|
||||
</Ellipse>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 第三行:视野数据区 -->
|
||||
@@ -248,10 +279,9 @@
|
||||
<Button Grid.Row="1" Grid.Column="2" Content="正转" FontSize="18"
|
||||
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" PreviewMouseLeftButtonDown="Button_Click_ForDown"
|
||||
PreviewMouseLeftButtonUp="Button_Click_ForUp" />
|
||||
|
||||
<!-- 测试 -->
|
||||
<Button Grid.Row="0" Grid.Column="4" Name="ButtonTest" Grid.RowSpan="2" Content="测试" FontSize="18"
|
||||
Width="120" Height="50" Background="#A4ADB3" Foreground="White" Margin="5" Click="Button_Click_Test"/>
|
||||
Width="120" Height="50" Background="LightGray" Foreground="White" Margin="5" Click="Button_Click_Test"/>
|
||||
|
||||
<!-- 停止 -->
|
||||
<Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Content="停止" FontSize="18"
|
||||
|
||||
@@ -4,6 +4,7 @@ using Sunny.UI;
|
||||
//using RecordDateView;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@@ -57,23 +58,43 @@ namespace 头罩视野.Views
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 蓝色亮(蓝色)
|
||||
private void LedOn(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightSkyBlue;
|
||||
}
|
||||
|
||||
// 灯灭(灰色)
|
||||
private void LedOff(Ellipse led)
|
||||
{
|
||||
led.Fill = Brushes.LightGray;
|
||||
}
|
||||
|
||||
//复位btn
|
||||
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 90);
|
||||
}
|
||||
//左开眼
|
||||
private void Button_Click_left(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 切换文案:左眼开 ↔ 左眼关
|
||||
// 切换文案:开是关,关是开
|
||||
if (btnLeft.Content.ToString() == "左眼开")
|
||||
{
|
||||
|
||||
|
||||
btnLeft.Content = "左眼关";
|
||||
LedOn(led0);
|
||||
if (btnRight.Content.ToString() == "右眼关")
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
|
||||
}
|
||||
@@ -81,8 +102,10 @@ namespace 头罩视野.Views
|
||||
else
|
||||
{
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
//LedOn(led0);
|
||||
}
|
||||
//右开眼
|
||||
private void Button_Click_Right(object sender, RoutedEventArgs e)
|
||||
@@ -92,9 +115,12 @@ namespace 头罩视野.Views
|
||||
if (btnRight.Content.ToString() == "右眼开")
|
||||
{
|
||||
btnRight.Content = "右眼关";
|
||||
LedOn(led1);
|
||||
if (btnLeft.Content.ToString() == "左眼关")
|
||||
{
|
||||
|
||||
btnLeft.Content = "左眼开";
|
||||
LedOff(led0);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||
|
||||
}
|
||||
@@ -102,8 +128,11 @@ namespace 头罩视野.Views
|
||||
else
|
||||
{
|
||||
btnRight.Content = "右眼开";
|
||||
LedOff(led1);
|
||||
|
||||
}
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||
//LedOn(led1);
|
||||
}
|
||||
|
||||
//反转
|
||||
@@ -141,7 +170,7 @@ namespace 头罩视野.Views
|
||||
ma.BtnClickFunction(Function.ButtonType.复归型, 100);
|
||||
ButtonTest.Content = "测试中....";
|
||||
testTimer.Start();
|
||||
|
||||
|
||||
}
|
||||
//停止btn
|
||||
private void Button_Click_Stop(object sender, RoutedEventArgs e)
|
||||
@@ -203,18 +232,21 @@ namespace 头罩视野.Views
|
||||
private void TbTest_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 选中 → 试样测试
|
||||
var btn = sender as ToggleButton;
|
||||
btn.Content = "试样测试";
|
||||
btn.Background = System.Windows.Media.Brushes.LightBlue;
|
||||
|
||||
|
||||
tbTest.Content = "空白测试";
|
||||
|
||||
tbTest.Background = System.Windows.Media.Brushes.LightSkyBlue;
|
||||
System.Diagnostics.Debug.WriteLine($"1232312312");
|
||||
_modbusMaster.WriteSingleCoilAsync(1, 41, true);
|
||||
}
|
||||
|
||||
private void TbTest_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 取消 → 空白测试
|
||||
var btn = sender as ToggleButton;
|
||||
btn.Content = "空白测试";
|
||||
btn.Background = System.Windows.Media.Brushes.LightGray;
|
||||
|
||||
tbTest.Content = "试样测试";
|
||||
tbTest.Background = System.Windows.Media.Brushes.LightGray;
|
||||
_modbusMaster.WriteSingleCoilAsync(1, 41, false);
|
||||
}
|
||||
private void Button_Click_home(object sender, RoutedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user