diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs
index 31ca533..3cd2614 100644
--- a/Correlator/Util/MessengerToken.cs
+++ b/Correlator/Util/MessengerToken.cs
@@ -4,7 +4,6 @@
{
#region AddUserControl
- public const string AddMenu = "2022122401";
public const string AddAudioFile = "2022122403";
public const string AddPictureFile = "2022122405";
public const string AddFilter = "2022122409";
diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs
index 31ca533..3cd2614 100644
--- a/Correlator/Util/MessengerToken.cs
+++ b/Correlator/Util/MessengerToken.cs
@@ -4,7 +4,6 @@
{
#region AddUserControl
- public const string AddMenu = "2022122401";
public const string AddAudioFile = "2022122403";
public const string AddPictureFile = "2022122405";
public const string AddFilter = "2022122409";
diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml
index 10a6019..2f268e4 100644
--- a/Correlator/View/HomePageWindow.xaml
+++ b/Correlator/View/HomePageWindow.xaml
@@ -91,25 +91,37 @@
-
+
-
-
+
+
+
+
-
+
+
+
+
@@ -124,20 +136,6 @@
-
-
@@ -158,11 +156,12 @@
-
+
-
+
-
+
+
@@ -345,6 +344,7 @@
+
@@ -465,6 +465,7 @@
+
@@ -532,6 +533,7 @@
Text="干扰采集" />
+
+ BorderThickness="0">
diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs
index 31ca533..3cd2614 100644
--- a/Correlator/Util/MessengerToken.cs
+++ b/Correlator/Util/MessengerToken.cs
@@ -4,7 +4,6 @@
{
#region AddUserControl
- public const string AddMenu = "2022122401";
public const string AddAudioFile = "2022122403";
public const string AddPictureFile = "2022122405";
public const string AddFilter = "2022122409";
diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml
index 10a6019..2f268e4 100644
--- a/Correlator/View/HomePageWindow.xaml
+++ b/Correlator/View/HomePageWindow.xaml
@@ -91,25 +91,37 @@
-
+
-
-
+
+
+
+
-
+
+
+
+
@@ -124,20 +136,6 @@
-
-
-
-
@@ -158,11 +156,12 @@
-
+
-
+
-
+
+
@@ -345,6 +344,7 @@
+
@@ -465,6 +465,7 @@
+
@@ -532,6 +533,7 @@
Text="干扰采集" />
+
+ BorderBrush="Transparent">
@@ -682,13 +684,13 @@
+ BorderThickness="0">
diff --git a/Correlator/View/HomePageWindow.xaml.cs b/Correlator/View/HomePageWindow.xaml.cs
index f1322ec..0667204 100644
--- a/Correlator/View/HomePageWindow.xaml.cs
+++ b/Correlator/View/HomePageWindow.xaml.cs
@@ -1,11 +1,14 @@
using System;
+using System.Diagnostics;
using System.Drawing;
using System.Windows;
+using Correlator.Pages;
using Correlator.Util;
using GalaSoft.MvvmLight.Messaging;
using MathWorks.MATLAB.NET.Arrays;
using ScottPlot;
using ScottPlot.Plottable;
+using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.View
{
@@ -19,7 +22,7 @@
scottPlot.XLabel("频率(Hz)");
scottPlot.YLabel("相关系数");
ScottplotView.Refresh();
-
+
//渲染数据波形图
Messenger.Default.Register(this, MessengerToken.RenderOscillogram, array =>
{
@@ -148,8 +151,6 @@
});
//菜单
- Messenger.Default.Register(this, MessengerToken.AddMenu,
- s => { HomePageContentGrid.Children.Add(UserControlManager.UserControlMap["menuUserControl"]); });
Messenger.Default.Register(this, MessengerToken.RemoveMenu,
s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["menuUserControl"]); });
@@ -173,6 +174,72 @@
{
HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["pictureFileUserControl"]);
});
+
+ #region 不使用VM
+
+ ShutDownButton.Click += delegate
+ {
+ var result = MessageBox.Show("是否确认关机?\r\n选择是,电脑将关机;\r\n选择否,应用将退出;\r\n选择取消,可继续操作应用",
+ "温馨提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+ switch (result)
+ {
+ case MessageBoxResult.None:
+ break;
+ case MessageBoxResult.OK:
+ break;
+ case MessageBoxResult.Cancel:
+ break;
+ case MessageBoxResult.Yes:
+ var p = new Process();
+ p.StartInfo.FileName = "shutdown.exe";
+ p.StartInfo.Arguments = "-s -f -t 0";
+ p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+ p.Start();
+ break;
+ case MessageBoxResult.No:
+ Close();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ };
+
+ LeftSensorButton.Click += delegate
+ {
+ if (!SerialPortManager.Instance.PortIsReady())
+ {
+ MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ SerialPortManager.Instance.ShowLeftSensorSignal();
+ };
+
+ RightSensorButton.Click += delegate
+ {
+ if (!SerialPortManager.Instance.PortIsReady())
+ {
+ MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ SerialPortManager.Instance.ShowRightSensorSignal();
+ };
+
+ SnapShotButton.Click += delegate
+ {
+ var filePath = Constant.GetPictureDir() + "\\快照_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
+ ImageHelper.SnapShot(filePath);
+ };
+
+ OpenMenuButton.Click += delegate
+ {
+ var menuUserControl = new MenuUserControl();
+ UserControlManager.UserControlMap["menuUserControl"] = menuUserControl;
+ HomePageContentGrid.Children.Add(menuUserControl);
+ };
+
+ #endregion
}
private static double[] GetArray(MWNumericArray inputMw)
diff --git a/Correlator/Util/MessengerToken.cs b/Correlator/Util/MessengerToken.cs
index 31ca533..3cd2614 100644
--- a/Correlator/Util/MessengerToken.cs
+++ b/Correlator/Util/MessengerToken.cs
@@ -4,7 +4,6 @@
{
#region AddUserControl
- public const string AddMenu = "2022122401";
public const string AddAudioFile = "2022122403";
public const string AddPictureFile = "2022122405";
public const string AddFilter = "2022122409";
diff --git a/Correlator/View/HomePageWindow.xaml b/Correlator/View/HomePageWindow.xaml
index 10a6019..2f268e4 100644
--- a/Correlator/View/HomePageWindow.xaml
+++ b/Correlator/View/HomePageWindow.xaml
@@ -91,25 +91,37 @@
-
+
-
-
+
+
+
+
-
+
+
+
+
@@ -124,20 +136,6 @@
-
-
-
-
@@ -158,11 +156,12 @@
-
+
-
+
-
+
+
@@ -345,6 +344,7 @@
+
@@ -465,6 +465,7 @@
+
@@ -532,6 +533,7 @@
Text="干扰采集" />
+
+ BorderBrush="Transparent">
@@ -682,13 +684,13 @@
+ BorderThickness="0">
diff --git a/Correlator/View/HomePageWindow.xaml.cs b/Correlator/View/HomePageWindow.xaml.cs
index f1322ec..0667204 100644
--- a/Correlator/View/HomePageWindow.xaml.cs
+++ b/Correlator/View/HomePageWindow.xaml.cs
@@ -1,11 +1,14 @@
using System;
+using System.Diagnostics;
using System.Drawing;
using System.Windows;
+using Correlator.Pages;
using Correlator.Util;
using GalaSoft.MvvmLight.Messaging;
using MathWorks.MATLAB.NET.Arrays;
using ScottPlot;
using ScottPlot.Plottable;
+using MessageBox = HandyControl.Controls.MessageBox;
namespace Correlator.View
{
@@ -19,7 +22,7 @@
scottPlot.XLabel("频率(Hz)");
scottPlot.YLabel("相关系数");
ScottplotView.Refresh();
-
+
//渲染数据波形图
Messenger.Default.Register(this, MessengerToken.RenderOscillogram, array =>
{
@@ -148,8 +151,6 @@
});
//菜单
- Messenger.Default.Register(this, MessengerToken.AddMenu,
- s => { HomePageContentGrid.Children.Add(UserControlManager.UserControlMap["menuUserControl"]); });
Messenger.Default.Register(this, MessengerToken.RemoveMenu,
s => { HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["menuUserControl"]); });
@@ -173,6 +174,72 @@
{
HomePageContentGrid.Children.Remove(UserControlManager.UserControlMap["pictureFileUserControl"]);
});
+
+ #region 不使用VM
+
+ ShutDownButton.Click += delegate
+ {
+ var result = MessageBox.Show("是否确认关机?\r\n选择是,电脑将关机;\r\n选择否,应用将退出;\r\n选择取消,可继续操作应用",
+ "温馨提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+ switch (result)
+ {
+ case MessageBoxResult.None:
+ break;
+ case MessageBoxResult.OK:
+ break;
+ case MessageBoxResult.Cancel:
+ break;
+ case MessageBoxResult.Yes:
+ var p = new Process();
+ p.StartInfo.FileName = "shutdown.exe";
+ p.StartInfo.Arguments = "-s -f -t 0";
+ p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+ p.Start();
+ break;
+ case MessageBoxResult.No:
+ Close();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ };
+
+ LeftSensorButton.Click += delegate
+ {
+ if (!SerialPortManager.Instance.PortIsReady())
+ {
+ MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ SerialPortManager.Instance.ShowLeftSensorSignal();
+ };
+
+ RightSensorButton.Click += delegate
+ {
+ if (!SerialPortManager.Instance.PortIsReady())
+ {
+ MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
+ return;
+ }
+
+ SerialPortManager.Instance.ShowRightSensorSignal();
+ };
+
+ SnapShotButton.Click += delegate
+ {
+ var filePath = Constant.GetPictureDir() + "\\快照_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
+ ImageHelper.SnapShot(filePath);
+ };
+
+ OpenMenuButton.Click += delegate
+ {
+ var menuUserControl = new MenuUserControl();
+ UserControlManager.UserControlMap["menuUserControl"] = menuUserControl;
+ HomePageContentGrid.Children.Add(menuUserControl);
+ };
+
+ #endregion
}
private static double[] GetArray(MWNumericArray inputMw)
diff --git a/Correlator/ViewModel/HomePageViewModel.cs b/Correlator/ViewModel/HomePageViewModel.cs
index f1ae7f9..07ab41e 100644
--- a/Correlator/ViewModel/HomePageViewModel.cs
+++ b/Correlator/ViewModel/HomePageViewModel.cs
@@ -12,7 +12,6 @@
using Correlator.Pages;
using Correlator.SensorHubTag;
using Correlator.Util;
-using Correlator.View;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
@@ -27,17 +26,12 @@
{
#region RelayCommand
- public RelayCommand ShutDownCommand { get; set; }
- public RelayCommand LeftSensorCommand { get; set; }
- public RelayCommand RightSensorCommand { get; set; }
public RelayCommand FilterCommand { get; set; }
public RelayCommand NoiseCommand { get; set; }
public RelayCommand AudioCommand { get; set; }
- public RelayCommand SnapShotCommand { get; set; }
public RelayCommand ResetParamCommand { get; set; }
public RelayCommand StartCalculateCommand { get; set; }
public RelayCommand SaveAudioCommand { get; set; }
- public RelayCommand OpenMenuCommand { get; set; }
#endregion
@@ -440,33 +434,6 @@
public HomePageViewModel()
{
- ShutDownCommand = new RelayCommand(window =>
- {
- var result = MessageBox.Show("是否确认关机?\r\n选择是,电脑将关机;\r\n选择否,应用将退出;\r\n选择取消,可继续操作应用",
- "温馨提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- switch (result)
- {
- case MessageBoxResult.None:
- break;
- case MessageBoxResult.OK:
- break;
- case MessageBoxResult.Cancel:
- break;
- case MessageBoxResult.Yes:
- var p = new Process();
- p.StartInfo.FileName = "shutdown.exe";
- p.StartInfo.Arguments = "-s -f -t 0";
- p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
- p.Start();
- break;
- case MessageBoxResult.No:
- window.Close();
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- });
-
DisplayCurrentTime();
DisplayBattery();
@@ -505,26 +472,6 @@
RegisterMessage();
- LeftSensorCommand = new RelayCommand(() =>
- {
- if (!SerialPortManager.Instance.PortIsReady())
- {
- MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- SerialPortManager.Instance.ShowLeftSensorSignal();
- });
- RightSensorCommand = new RelayCommand(() =>
- {
- if (!SerialPortManager.Instance.PortIsReady())
- {
- MessageBox.Show("串口状态异常,无法操作", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- SerialPortManager.Instance.ShowRightSensorSignal();
- });
FilterCommand = new RelayCommand(() =>
{
if (!SerialPortManager.Instance.PortIsReady())
@@ -567,11 +514,6 @@
UserControlManager.UserControlMap["auditionUserControl"] = auditionUserControl;
Messenger.Default.Send("", MessengerToken.AddAudition);
});
- SnapShotCommand = new RelayCommand(() =>
- {
- var filePath = Constant.GetPictureDir() + "\\快照_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
- ImageHelper.SnapShot(filePath);
- });
ResetParamCommand = new RelayCommand(ResetParam);
StartCalculateCommand = new RelayCommand(() =>
{
@@ -601,12 +543,6 @@
MessageBox.Show("还未开始采集数据,无法保存音频", "温馨提示", MessageBoxButton.OK, MessageBoxImage.Error);
}
});
- OpenMenuCommand = new RelayCommand(() =>
- {
- var menuUserControl = new MenuUserControl();
- UserControlManager.UserControlMap["menuUserControl"] = menuUserControl;
- Messenger.Default.Send("", MessengerToken.AddMenu);
- });
//计算时间Timer
_runningTimer.Tick += delegate