修改逻辑

This commit is contained in:
2026-04-21 11:15:37 +08:00
parent e9c7ebe0a7
commit d5ce8b4748
3 changed files with 44 additions and 13 deletions

View File

@@ -230,7 +230,8 @@ Margin="200,0,0,0" Height="194"/>
<!-- 反转 -->
<Button Grid.Row="0" Grid.Column="2" Content="反转" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Res" />
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" PreviewMouseLeftButtonDown="Button_Click_ResDown"
PreviewMouseLeftButtonUp="Button_Click_ResUp" />
<!-- 右眼开 -->
<Button Grid.Row="1" Grid.Column="1" Content="右眼开" FontSize="18"
@@ -238,7 +239,8 @@ Margin="200,0,0,0" Height="194"/>
<!-- 正转 -->
<Button Grid.Row="1" Grid.Column="2" Content="正转" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_For" />
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" Grid.RowSpan="2" Content="测试" FontSize="18"

View File

@@ -51,7 +51,6 @@ namespace 头罩视野.Views
private void Button_Click_Reset(object sender, RoutedEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 90);
MessageBox.Show("数据已复位", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
}
//左开眼
private void Button_Click_left(object sender, RoutedEventArgs e)
@@ -64,17 +63,50 @@ namespace 头罩视野.Views
ma.BtnClickFunction(Function.ButtonType., 1);
}
//反转
private void Button_Click_Res(object sender, RoutedEventArgs e)
private bool _isPressing = false;
private async void Button_Click_ResDown(object sender, MouseButtonEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 10);
((Button)sender).CaptureMouse();
_isPressing = true;
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)
{
((Button)sender).ReleaseMouseCapture();
_isPressing = false;
System.Diagnostics.Debug.WriteLine("end1111");
}
//正转
private void Button_Click_For(object sender, RoutedEventArgs e)
private bool _isPressing1 = false;
private async void Button_Click_ForDown(object sender, MouseButtonEventArgs e)
{
ma.BtnClickFunction(Function.ButtonType., 11);
((Button)sender).CaptureMouse();
_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)
{
((Button)sender).ReleaseMouseCapture();
_isPressing1 = false;
System.Diagnostics.Debug.WriteLine("正传end");
}
//测试btn 测试按钮:读取数据,存入共享列表
private void Button_Click_Test(object sender, RoutedEventArgs e)
@@ -312,6 +344,8 @@ namespace 头罩视野.Views
private void Page_Loaded(object sender, RoutedEventArgs e)
{
_timer.Start();
ma = new Function(_modbusMaster);
c = new DataChange();
}
}
}

View File

@@ -19,11 +19,6 @@ using 头罩视野.Services.Data;
namespace .Views
{
/// <summary>
/// VisiData.xaml 的交互逻辑
/// </summary>
public partial class VisiData : Page
{