按钮逻辑
This commit is contained in:
@@ -243,7 +243,7 @@ Margin="200,0,0,0" Height="194"/>
|
|||||||
PreviewMouseLeftButtonUp="Button_Click_ForUp" />
|
PreviewMouseLeftButtonUp="Button_Click_ForUp" />
|
||||||
|
|
||||||
<!-- 测试 -->
|
<!-- 测试 -->
|
||||||
<Button Grid.Row="0" Grid.Column="4" Grid.RowSpan="2" Content="测试" FontSize="18"
|
<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="#A4ADB3" Foreground="White" Margin="5" Click="Button_Click_Test"/>
|
||||||
|
|
||||||
<!-- 停止 -->
|
<!-- 停止 -->
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ namespace 头罩视野.Views
|
|||||||
}
|
}
|
||||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//反转
|
//反转
|
||||||
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -137,7 +138,7 @@ namespace 头罩视野.Views
|
|||||||
|
|
||||||
{
|
{
|
||||||
ma.BtnClickFunction(Function.ButtonType.复归型, 100);
|
ma.BtnClickFunction(Function.ButtonType.复归型, 100);
|
||||||
|
ButtonTest.Content = "测试中....";
|
||||||
testTimer.Start();
|
testTimer.Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ namespace 头罩视野.Views
|
|||||||
private void Button_Click_Stop(object sender, RoutedEventArgs e)
|
private void Button_Click_Stop(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
||||||
|
ButtonTest.Content = "测试";
|
||||||
testTimer.Stop();
|
testTimer.Stop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ Padding="20" Margin="20,0,0,0" >
|
|||||||
Width="120" Height="40" Background="red" Foreground="White" Margin="5" Click="Button_Click_Reset" />
|
Width="120" Height="40" Background="red" Foreground="White" Margin="5" Click="Button_Click_Reset" />
|
||||||
|
|
||||||
<!-- 左眼开 -->
|
<!-- 左眼开 -->
|
||||||
<Button Grid.Row="0" Grid.Column="1" Content="左眼开" FontSize="18"
|
<Button Grid.Row="0" Name="btnLeft" Grid.Column="1" Content="左眼开" FontSize="18"
|
||||||
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_left"/>
|
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_left"/>
|
||||||
|
|
||||||
<!-- 反转 -->
|
<!-- 反转 -->
|
||||||
@@ -278,7 +278,7 @@ Padding="20" Margin="20,0,0,0" >
|
|||||||
PreviewMouseLeftButtonUp="Button_Click_ResUp" />
|
PreviewMouseLeftButtonUp="Button_Click_ResUp" />
|
||||||
|
|
||||||
<!-- 右眼开 -->
|
<!-- 右眼开 -->
|
||||||
<Button Grid.Column="3" Content="右眼开" FontSize="18"
|
<Button Grid.Column="3" Name="btnRight" Content="右眼开" FontSize="18"
|
||||||
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="6,0,0,0" Click="Button_Click_Right"
|
Width="120" Height="40" Background="#FF87CEFA" Foreground="White" Margin="6,0,0,0" Click="Button_Click_Right"
|
||||||
HorizontalAlignment="Left"/>
|
HorizontalAlignment="Left"/>
|
||||||
|
|
||||||
|
|||||||
@@ -44,74 +44,78 @@ namespace 头罩视野.Views
|
|||||||
//复位btn
|
//复位btn
|
||||||
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
private void Button_Click_Reset(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
btnLeft.Content = "左眼开";
|
||||||
|
btnRight.Content = "右眼开";
|
||||||
ma.BtnClickFunction(Function.ButtonType.复归型, 90);
|
ma.BtnClickFunction(Function.ButtonType.复归型, 90);
|
||||||
}
|
}
|
||||||
//左开眼
|
//左开眼
|
||||||
private void Button_Click_left(object sender, RoutedEventArgs e)
|
private void Button_Click_left(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
// 切换文案:左眼开 ↔ 左眼关
|
||||||
|
if (btnLeft.Content.ToString() == "左眼开")
|
||||||
|
{
|
||||||
|
btnLeft.Content = "左眼关";
|
||||||
|
if (btnRight.Content.ToString() == "右眼关")
|
||||||
|
{
|
||||||
|
btnRight.Content = "右眼开";
|
||||||
|
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnLeft.Content = "左眼开";
|
||||||
|
}
|
||||||
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||||
}
|
}
|
||||||
//右开眼
|
//右开眼
|
||||||
private void Button_Click_Right(object sender, RoutedEventArgs e)
|
private void Button_Click_Right(object sender, RoutedEventArgs e)
|
||||||
{
|
{ // 切换文案:左眼开 ↔ 左眼关
|
||||||
|
if (btnRight.Content.ToString() == "右眼开")
|
||||||
|
{
|
||||||
|
btnRight.Content = "右眼关";
|
||||||
|
if (btnLeft.Content.ToString() == "左眼关")
|
||||||
|
{
|
||||||
|
btnLeft.Content = "左眼开";
|
||||||
|
ma.BtnClickFunction(Function.ButtonType.切换型, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
btnRight.Content = "右眼开";
|
||||||
|
}
|
||||||
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
ma.BtnClickFunction(Function.ButtonType.切换型, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//反转
|
|
||||||
|
|
||||||
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((Button)sender).CaptureMouse();
|
await _modbusMaster.WriteSingleCoilAsync(1, 10, true);
|
||||||
|
System.Diagnostics.Debug.WriteLine("反转开始");
|
||||||
await Task.Run(() => {
|
|
||||||
//重新占位写入
|
|
||||||
_modbusMaster.WriteSingleCoilAsync(1, 10, true);
|
|
||||||
Task.Delay(100);
|
|
||||||
System.Diagnostics.Debug.WriteLine("stard1111");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click_ResUp(object sender, MouseButtonEventArgs e)
|
private async void Button_Click_ResUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((Button)sender).ReleaseMouseCapture();
|
await _modbusMaster.WriteSingleCoilAsync(1, 10, false);
|
||||||
System.Diagnostics.Debug.WriteLine("end1111");
|
System.Diagnostics.Debug.WriteLine("反转结束");
|
||||||
|
|
||||||
}
|
}
|
||||||
//正转
|
//正转
|
||||||
//private bool _isPressing1 = false;
|
|
||||||
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
|
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((Button)sender).CaptureMouse();
|
await _modbusMaster.WriteSingleCoilAsync(1, 11, true);
|
||||||
//_isPressing1 = true;
|
|
||||||
|
|
||||||
await Task.Run(() => {
|
|
||||||
//重新占位写入
|
|
||||||
_modbusMaster.WriteSingleCoilAsync(1, 11, true);
|
|
||||||
System.Diagnostics.Debug.WriteLine("正传start");
|
|
||||||
Task.Delay(100);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click_ForUp(object sender, MouseButtonEventArgs e)
|
private async void Button_Click_ForUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
((Button)sender).ReleaseMouseCapture();
|
|
||||||
|
await _modbusMaster.WriteSingleCoilAsync(1, 11, false);
|
||||||
System.Diagnostics.Debug.WriteLine("正传end");
|
//System.Diagnostics.Debug.WriteLine("正传end");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//测试btn
|
|
||||||
private void Button_Click_Test(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ma.BtnClickFunction(Function.ButtonType.复归型, 101);
|
|
||||||
}
|
|
||||||
//停止btn
|
|
||||||
private void Button_Click_Stop(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ma.BtnClickFunction(Function.ButtonType.复归型, 103);
|
|
||||||
}
|
|
||||||
//读取
|
|
||||||
//读取数据
|
//读取数据
|
||||||
private DispatcherTimer InitDispatcherTimer()
|
private DispatcherTimer InitDispatcherTimer()
|
||||||
{
|
{
|
||||||
|
|||||||
BIN
头罩视野slove/头罩视野/面罩视野测试仪——120°版本打印已改.gxw
Normal file
BIN
头罩视野slove/头罩视野/面罩视野测试仪——120°版本打印已改.gxw
Normal file
Binary file not shown.
Reference in New Issue
Block a user