diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/View/AuditionWindow.xaml.cs b/Correlator/View/AuditionWindow.xaml.cs new file mode 100644 index 0000000..ee7e3e8 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml.cs @@ -0,0 +1,97 @@ +using System.Threading; +using System.Windows; +using Correlator.SensorHubTag; +using Correlator.Util; +using HandyControl.Controls; +using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; + +namespace Correlator.View +{ + public partial class AuditionWindow : Window + { + public AuditionWindow() + { + InitializeComponent(); + + SensorACheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + } + else + { + if (SensorBCheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + SensorBCheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); + } + }; + + SensorBCheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + } + else + { + if (SensorACheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + SensorACheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); + } + }; + } + + private void SendSoundCollectCmd(object devCode) + { + //音频输出 + PlayWav.Instance.InitWaveOut(); + + //停止状态采集指令的发送 + FlowStatus.CanGetSignal = false; + Thread.Sleep(3000); + SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); + Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); + FlowStatus.IsListening = true; + Thread.Sleep(2000); + + new Thread(ListeningTimer) { IsBackground = true }.Start(); + } + + private void ListeningTimer() + { + while (FlowStatus.IsListening) + { + Thread.Sleep(1000); + if (++FlowStatus.ElapseTime >= 15) + { + MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + } + + FlowStatus.ElapseTime = 0; + } + } +} \ No newline at end of file diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/View/AuditionWindow.xaml.cs b/Correlator/View/AuditionWindow.xaml.cs new file mode 100644 index 0000000..ee7e3e8 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml.cs @@ -0,0 +1,97 @@ +using System.Threading; +using System.Windows; +using Correlator.SensorHubTag; +using Correlator.Util; +using HandyControl.Controls; +using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; + +namespace Correlator.View +{ + public partial class AuditionWindow : Window + { + public AuditionWindow() + { + InitializeComponent(); + + SensorACheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + } + else + { + if (SensorBCheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + SensorBCheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); + } + }; + + SensorBCheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + } + else + { + if (SensorACheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + SensorACheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); + } + }; + } + + private void SendSoundCollectCmd(object devCode) + { + //音频输出 + PlayWav.Instance.InitWaveOut(); + + //停止状态采集指令的发送 + FlowStatus.CanGetSignal = false; + Thread.Sleep(3000); + SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); + Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); + FlowStatus.IsListening = true; + Thread.Sleep(2000); + + new Thread(ListeningTimer) { IsBackground = true }.Start(); + } + + private void ListeningTimer() + { + while (FlowStatus.IsListening) + { + Thread.Sleep(1000); + if (++FlowStatus.ElapseTime >= 15) + { + MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + } + + FlowStatus.ElapseTime = 0; + } + } +} \ No newline at end of file diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml index abb4526..feff2cf 100644 --- a/Correlator/View/HomePageWindow.xaml +++ b/Correlator/View/HomePageWindow.xaml @@ -485,7 +485,8 @@ Height="100" HorizontalAlignment="Left" BorderBrush="Transparent" - Command="{Binding AudioCommand}"> + Command="{Binding AudioCommand}" + CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"> diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/View/AuditionWindow.xaml.cs b/Correlator/View/AuditionWindow.xaml.cs new file mode 100644 index 0000000..ee7e3e8 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml.cs @@ -0,0 +1,97 @@ +using System.Threading; +using System.Windows; +using Correlator.SensorHubTag; +using Correlator.Util; +using HandyControl.Controls; +using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; + +namespace Correlator.View +{ + public partial class AuditionWindow : Window + { + public AuditionWindow() + { + InitializeComponent(); + + SensorACheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + } + else + { + if (SensorBCheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + SensorBCheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); + } + }; + + SensorBCheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + } + else + { + if (SensorACheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + SensorACheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); + } + }; + } + + private void SendSoundCollectCmd(object devCode) + { + //音频输出 + PlayWav.Instance.InitWaveOut(); + + //停止状态采集指令的发送 + FlowStatus.CanGetSignal = false; + Thread.Sleep(3000); + SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); + Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); + FlowStatus.IsListening = true; + Thread.Sleep(2000); + + new Thread(ListeningTimer) { IsBackground = true }.Start(); + } + + private void ListeningTimer() + { + while (FlowStatus.IsListening) + { + Thread.Sleep(1000); + if (++FlowStatus.ElapseTime >= 15) + { + MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + } + + FlowStatus.ElapseTime = 0; + } + } +} \ No newline at end of file diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml index abb4526..feff2cf 100644 --- a/Correlator/View/HomePageWindow.xaml +++ b/Correlator/View/HomePageWindow.xaml @@ -485,7 +485,8 @@ Height="100" HorizontalAlignment="Left" BorderBrush="Transparent" - Command="{Binding AudioCommand}"> + Command="{Binding AudioCommand}" + CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"> diff --git a/Correlator/View/HomePageWindow.xaml.cs b/Correlator/View/HomePageWindow.xaml.cs index 25780a1..3992f9e 100644 --- a/Correlator/View/HomePageWindow.xaml.cs +++ b/Correlator/View/HomePageWindow.xaml.cs @@ -63,15 +63,6 @@ Messenger.Default.Register(this, MessengerToken.RemoveNoise, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["noiseUserControl"]); }); - //听音 - Messenger.Default.Register(this, MessengerToken.AddAudition, - s => { HomePageContentGrid.Children.Add(UserControlManager.UserControlMap["auditionUserControl"]); }); - Messenger.Default.Register(this, MessengerToken.RemoveAudition, - s => - { - HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["auditionUserControl"]); - }); - //菜单 Messenger.Default.Register(this, MessengerToken.RemoveMenu, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["menuUserControl"]); }); diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/View/AuditionWindow.xaml.cs b/Correlator/View/AuditionWindow.xaml.cs new file mode 100644 index 0000000..ee7e3e8 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml.cs @@ -0,0 +1,97 @@ +using System.Threading; +using System.Windows; +using Correlator.SensorHubTag; +using Correlator.Util; +using HandyControl.Controls; +using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; + +namespace Correlator.View +{ + public partial class AuditionWindow : Window + { + public AuditionWindow() + { + InitializeComponent(); + + SensorACheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + } + else + { + if (SensorBCheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + SensorBCheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); + } + }; + + SensorBCheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + } + else + { + if (SensorACheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + SensorACheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); + } + }; + } + + private void SendSoundCollectCmd(object devCode) + { + //音频输出 + PlayWav.Instance.InitWaveOut(); + + //停止状态采集指令的发送 + FlowStatus.CanGetSignal = false; + Thread.Sleep(3000); + SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); + Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); + FlowStatus.IsListening = true; + Thread.Sleep(2000); + + new Thread(ListeningTimer) { IsBackground = true }.Start(); + } + + private void ListeningTimer() + { + while (FlowStatus.IsListening) + { + Thread.Sleep(1000); + if (++FlowStatus.ElapseTime >= 15) + { + MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + } + + FlowStatus.ElapseTime = 0; + } + } +} \ No newline at end of file diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml index abb4526..feff2cf 100644 --- a/Correlator/View/HomePageWindow.xaml +++ b/Correlator/View/HomePageWindow.xaml @@ -485,7 +485,8 @@ Height="100" HorizontalAlignment="Left" BorderBrush="Transparent" - Command="{Binding AudioCommand}"> + Command="{Binding AudioCommand}" + CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"> diff --git a/Correlator/View/HomePageWindow.xaml.cs b/Correlator/View/HomePageWindow.xaml.cs index 25780a1..3992f9e 100644 --- a/Correlator/View/HomePageWindow.xaml.cs +++ b/Correlator/View/HomePageWindow.xaml.cs @@ -63,15 +63,6 @@ Messenger.Default.Register(this, MessengerToken.RemoveNoise, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["noiseUserControl"]); }); - //听音 - Messenger.Default.Register(this, MessengerToken.AddAudition, - s => { HomePageContentGrid.Children.Add(UserControlManager.UserControlMap["auditionUserControl"]); }); - Messenger.Default.Register(this, MessengerToken.RemoveAudition, - s => - { - HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["auditionUserControl"]); - }); - //菜单 Messenger.Default.Register(this, MessengerToken.RemoveMenu, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["menuUserControl"]); }); diff --git a/Correlator/ViewModel/AuditionViewModel.cs b/Correlator/ViewModel/AuditionViewModel.cs index 250a696..4144408 100644 --- a/Correlator/ViewModel/AuditionViewModel.cs +++ b/Correlator/ViewModel/AuditionViewModel.cs @@ -6,7 +6,6 @@ using Correlator.Util; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; -using GalaSoft.MvvmLight.Messaging; using LiveCharts; using LiveCharts.Defaults; @@ -14,7 +13,6 @@ { public class AuditionViewModel : ViewModelBase { - public RelayCommand GoBackCommand { get; set; } public RelayCommand MuteCommand { get; set; } public IChartValues ColumnValues { get; set; } = new ChartValues(); @@ -26,7 +24,7 @@ public int SensorASignalIntensity { get => _sensorASignalIntensity; - set + private set { _sensorASignalIntensity = value; RaisePropertyChanged(() => SensorASignalIntensity); @@ -41,7 +39,7 @@ public int SensorBSignalIntensity { get => _sensorBSignalIntensity; - set + private set { _sensorBSignalIntensity = value; RaisePropertyChanged(() => SensorBSignalIntensity); @@ -111,7 +109,6 @@ public AuditionViewModel() { - GoBackCommand = new RelayCommand(() => { Messenger.Default.Send("", MessengerToken.RemoveAudition); }); //静音 MuteCommand = new RelayCommand(() => { diff --git a/Correlator/Correlator.csproj b/Correlator/Correlator.csproj index 94e86c2..a58ea1e 100644 --- a/Correlator/Correlator.csproj +++ b/Correlator/Correlator.csproj @@ -220,9 +220,6 @@ AudioFileUserControl.xaml - - AuditionUserControl.xaml - FilterUserControl.xaml @@ -274,6 +271,9 @@ + + AuditionWindow.xaml + BigPictureWindow.xaml @@ -300,7 +300,6 @@ Designer MSBuild:Compile - Designer @@ -310,6 +309,7 @@ MSBuild:Compile + diff --git a/Correlator/Pages/AuditionUserControl.xaml b/Correlator/Pages/AuditionUserControl.xaml deleted file mode 100644 index 2f59a2b..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Correlator/Pages/AuditionUserControl.xaml.cs b/Correlator/Pages/AuditionUserControl.xaml.cs deleted file mode 100644 index 5669a1e..0000000 --- a/Correlator/Pages/AuditionUserControl.xaml.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Threading; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Shapes; -using Correlator.SensorHubTag; -using Correlator.Util; -using HandyControl.Controls; -using MessageBox = HandyControl.Controls.MessageBox; - -namespace Correlator.Pages -{ - public partial class AuditionUserControl : UserControl - { - public AuditionUserControl() - { - InitializeComponent(); - } - - private void AuditionUserControl_OnLoaded(object sender, RoutedEventArgs e) - { - var colorBrush = new SolidColorBrush(Color.FromArgb(255, 84, 84, 84)); - const double strokeThickness = 1.5; - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = -15, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - TopHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = -5, - X2 = i, - Y2 = 0, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - TopHorizontalLineGrid.Children.Add(shorterScale); - } - - //较高的刻度线 - for (var i = 0; i <= 1100; i += 100) - { - var higherScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 15, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - - BottomHorizontalLineGrid.Children.Add(higherScale); - } - - //较矮的刻度线 - for (var i = 50; i <= 1050; i += 100) - { - var shorterScale = new Line - { - X1 = i, - Y1 = 0, - X2 = i, - Y2 = 5, - Stroke = colorBrush, - StrokeThickness = strokeThickness - }; - BottomHorizontalLineGrid.Children.Add(shorterScale); - } - } - - private void SensorACheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - } - else - { - if (SensorBCheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - SensorBCheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); - } - } - - private void SensorBCheckBox_OnClick(object sender, RoutedEventArgs e) - { - if (!SerialPortManager.Instance.PortIsReady()) - { - MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); - return; - } - - if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); - } - else - { - if (SensorACheckBox.IsChecked == true) - { - SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); - SensorACheckBox.IsChecked = false; - } - - new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); - } - } - - private void SendSoundCollectCmd(object devCode) - { - //音频输出 - PlayWav.Instance.InitWaveOut(); - - //停止状态采集指令的发送 - FlowStatus.CanGetSignal = false; - Thread.Sleep(3000); - SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); - Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); - FlowStatus.IsListening = true; - Thread.Sleep(2000); - - new Thread(ListeningTimer) { IsBackground = true }.Start(); - } - - private void ListeningTimer() - { - while (FlowStatus.IsListening) - { - Thread.Sleep(1000); - if (++FlowStatus.ElapseTime >= 15) - { - MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); - break; - } - } - - FlowStatus.ElapseTime = 0; - } - } -} \ No newline at end of file diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs index b2c98ac..48e16e6 100644 --- a/Correlator/Util/MessengerToken.cs +++ b/Correlator/Util/MessengerToken.cs @@ -8,7 +8,6 @@ public const string AddPictureFile = "2022122405"; public const string AddFilter = "2022122409"; public const string AddNoise = "2022122411"; - public const string AddAudition = "2022122413"; #endregion @@ -19,7 +18,6 @@ public const string RemovePictureFile = "2022122406"; public const string RemoveFilter = "2022122410"; public const string RemoveNoise = "2022122412"; - public const string RemoveAudition = "2022122414"; #endregion diff --git a/Correlator/View/AuditionWindow.xaml b/Correlator/View/AuditionWindow.xaml new file mode 100644 index 0000000..5a22631 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Correlator/View/AuditionWindow.xaml.cs b/Correlator/View/AuditionWindow.xaml.cs new file mode 100644 index 0000000..ee7e3e8 --- /dev/null +++ b/Correlator/View/AuditionWindow.xaml.cs @@ -0,0 +1,97 @@ +using System.Threading; +using System.Windows; +using Correlator.SensorHubTag; +using Correlator.Util; +using HandyControl.Controls; +using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; + +namespace Correlator.View +{ + public partial class AuditionWindow : Window + { + public AuditionWindow() + { + InitializeComponent(); + + SensorACheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorACheckBox.IsChecked == false || SensorACheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + } + else + { + if (SensorBCheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + SensorBCheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev1); + } + }; + + SensorBCheckBox.Click += delegate + { + if (!SerialPortManager.Instance.PortIsReady()) + { + MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); + return; + } + + if (SensorBCheckBox.IsChecked == false || SensorBCheckBox.IsChecked == null) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev2); + } + else + { + if (SensorACheckBox.IsChecked == true) + { + SenderClass.SendSoundStopCmd(SerialPortManager.Instance.SerialPort, DevCode.Dev1); + SensorACheckBox.IsChecked = false; + } + + new Thread(SendSoundCollectCmd) { IsBackground = true }.Start(DevCode.Dev2); + } + }; + } + + private void SendSoundCollectCmd(object devCode) + { + //音频输出 + PlayWav.Instance.InitWaveOut(); + + //停止状态采集指令的发送 + FlowStatus.CanGetSignal = false; + Thread.Sleep(3000); + SenderClass.SendSoundCollectCmd(SerialPortManager.Instance.SerialPort, devCode as string); + Growl.Success(DevCode.Dev1.Equals(devCode as string) ? "设备1发送听音指令" : "设备2发送听音指令"); + FlowStatus.IsListening = true; + Thread.Sleep(2000); + + new Thread(ListeningTimer) { IsBackground = true }.Start(); + } + + private void ListeningTimer() + { + while (FlowStatus.IsListening) + { + Thread.Sleep(1000); + if (++FlowStatus.ElapseTime >= 15) + { + MessageBox.Show("接收不到数据,请重启软件", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Information); + break; + } + } + + FlowStatus.ElapseTime = 0; + } + } +} \ No newline at end of file diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml index abb4526..feff2cf 100644 --- a/Correlator/View/HomePageWindow.xaml +++ b/Correlator/View/HomePageWindow.xaml @@ -485,7 +485,8 @@ Height="100" HorizontalAlignment="Left" BorderBrush="Transparent" - Command="{Binding AudioCommand}"> + Command="{Binding AudioCommand}" + CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}"> diff --git a/Correlator/View/HomePageWindow.xaml.cs b/Correlator/View/HomePageWindow.xaml.cs index 25780a1..3992f9e 100644 --- a/Correlator/View/HomePageWindow.xaml.cs +++ b/Correlator/View/HomePageWindow.xaml.cs @@ -63,15 +63,6 @@ Messenger.Default.Register(this, MessengerToken.RemoveNoise, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["noiseUserControl"]); }); - //听音 - Messenger.Default.Register(this, MessengerToken.AddAudition, - s => { HomePageContentGrid.Children.Add(UserControlManager.UserControlMap["auditionUserControl"]); }); - Messenger.Default.Register(this, MessengerToken.RemoveAudition, - s => - { - HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["auditionUserControl"]); - }); - //菜单 Messenger.Default.Register(this, MessengerToken.RemoveMenu, s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["menuUserControl"]); }); diff --git a/Correlator/ViewModel/AuditionViewModel.cs b/Correlator/ViewModel/AuditionViewModel.cs index 250a696..4144408 100644 --- a/Correlator/ViewModel/AuditionViewModel.cs +++ b/Correlator/ViewModel/AuditionViewModel.cs @@ -6,7 +6,6 @@ using Correlator.Util; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; -using GalaSoft.MvvmLight.Messaging; using LiveCharts; using LiveCharts.Defaults; @@ -14,7 +13,6 @@ { public class AuditionViewModel : ViewModelBase { - public RelayCommand GoBackCommand { get; set; } public RelayCommand MuteCommand { get; set; } public IChartValues ColumnValues { get; set; } = new ChartValues(); @@ -26,7 +24,7 @@ public int SensorASignalIntensity { get => _sensorASignalIntensity; - set + private set { _sensorASignalIntensity = value; RaisePropertyChanged(() => SensorASignalIntensity); @@ -41,7 +39,7 @@ public int SensorBSignalIntensity { get => _sensorBSignalIntensity; - set + private set { _sensorBSignalIntensity = value; RaisePropertyChanged(() => SensorBSignalIntensity); @@ -111,7 +109,6 @@ public AuditionViewModel() { - GoBackCommand = new RelayCommand(() => { Messenger.Default.Send("", MessengerToken.RemoveAudition); }); //静音 MuteCommand = new RelayCommand(() => { diff --git a/Correlator/ViewModel/HomePageViewModel.cs b/Correlator/ViewModel/HomePageViewModel.cs index 3f36675..84f5bc8 100644 --- a/Correlator/ViewModel/HomePageViewModel.cs +++ b/Correlator/ViewModel/HomePageViewModel.cs @@ -10,7 +10,6 @@ using System.Windows.Threading; using Correlator.Dialog; using Correlator.Model; -using Correlator.Pages; using Correlator.SensorHubTag; using Correlator.Util; using Correlator.View; @@ -29,7 +28,7 @@ { #region RelayCommand - public RelayCommand AudioCommand { get; set; } + public RelayCommand AudioCommand { get; set; } public RelayCommand SaveAudioCommand { get; set; } public RelayCommand ResetParamCommand { get; set; } public RelayCommand StartCalculateCommand { get; set; } @@ -43,7 +42,7 @@ public string CurrentTime { get => _currentTime; - set + private set { _currentTime = value; RaisePropertyChanged(() => CurrentTime); @@ -100,7 +99,7 @@ public int TransmitterASignalIntensity { get => _transmitterASignalIntensity; - set + private set { _transmitterASignalIntensity = value; RaisePropertyChanged(() => TransmitterASignalIntensity); @@ -115,7 +114,7 @@ public int TransmitterBSignalIntensity { get => _transmitterBSignalIntensity; - set + private set { _transmitterBSignalIntensity = value; RaisePropertyChanged(() => TransmitterBSignalIntensity); @@ -145,7 +144,7 @@ public bool TransmitterBFault { get => _transmitterBFault; - set + private set { _transmitterBFault = value; RaisePropertyChanged(() => TransmitterBFault); @@ -160,7 +159,7 @@ public bool StartState { get => _startState; - set + private set { _startState = value; RaisePropertyChanged(() => StartState); @@ -175,7 +174,7 @@ public double TransmitterADistance { get => _transmitterADistance; - set + private set { _transmitterADistance = value; RaisePropertyChanged(() => TransmitterADistance); @@ -190,7 +189,7 @@ public double TransmitterBDistance { get => _transmitterBDistance; - set + private set { _transmitterBDistance = value; RaisePropertyChanged(() => TransmitterBDistance); @@ -205,7 +204,7 @@ public string SoundSpeed { get => _soundSpeed; - set + private set { _soundSpeed = value; RaisePropertyChanged(() => SoundSpeed); @@ -220,7 +219,7 @@ public string PassTime { get => _passTime; - set + private set { _passTime = value; RaisePropertyChanged(() => PassTime); @@ -235,7 +234,7 @@ public string NoiseValue { get => _noiseValue; - set + private set { _noiseValue = value; RaisePropertyChanged(() => NoiseValue); @@ -251,7 +250,7 @@ public string FilterValue { get => _filterValue; - set + private set { _filterValue = value; RaisePropertyChanged(() => FilterValue); @@ -266,7 +265,7 @@ public string Snr { get => _snr; - set + private set { _snr = value; RaisePropertyChanged(() => Snr); @@ -282,7 +281,7 @@ public string PipeLine { get => _pipeline; - set + private set { _pipeline = value; RaisePropertyChanged(() => PipeLine); @@ -504,17 +503,19 @@ // Messenger.Default.Send("", MessengerToken.AddNoise); // }); - AudioCommand = new RelayCommand(() => + AudioCommand = new RelayCommand(it => { if (!SerialPortManager.Instance.PortIsReady()) { MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error); return; } - - var auditionUserControl = new AuditionUserControl(); - UserControlManager.UserControlMap["auditionUserControl"] = auditionUserControl; - Messenger.Default.Send("", MessengerToken.AddAudition); + + var auditionWindow = new AuditionWindow + { + Owner = Window.GetWindow(it) + }; + auditionWindow.ShowDialog(); }); SaveAudioCommand = new RelayCommand(() =>