diff --git a/PipeGallery/View/HomePageView.xaml b/PipeGallery/View/HomePageView.xaml
index 77cc7be..3589983 100644
--- a/PipeGallery/View/HomePageView.xaml
+++ b/PipeGallery/View/HomePageView.xaml
@@ -1,329 +1,661 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
+
-
+
\ No newline at end of file
diff --git a/PipeGallery/View/HomePageView.xaml b/PipeGallery/View/HomePageView.xaml
index 77cc7be..3589983 100644
--- a/PipeGallery/View/HomePageView.xaml
+++ b/PipeGallery/View/HomePageView.xaml
@@ -1,329 +1,661 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/PipeGallery/View/HomePageView.xaml.cs b/PipeGallery/View/HomePageView.xaml.cs
index 5e6226a..c1a66c1 100644
--- a/PipeGallery/View/HomePageView.xaml.cs
+++ b/PipeGallery/View/HomePageView.xaml.cs
@@ -1,20 +1,23 @@
-using Newtonsoft.Json;
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Threading;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PipeGallery.Chart;
using PipeGallery.Correlator;
using PipeGallery.Manage;
using PipeGallery.Model;
using PipeGallery.ViewModel;
-using System;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Threading;
+using Size = System.Drawing.Size;
+using UserControl = System.Windows.Controls.UserControl;
namespace PipeGallery.View
{
@@ -24,6 +27,7 @@
public partial class HomePageView : UserControl
{
int iSnapshot = 0;
+
public HomePageView()
{
InitializeComponent();
@@ -51,7 +55,6 @@
HomePageViewModel.Instance.TransmitterAFault = true;
HomePageViewModel.Instance.TransmitterBFault = true;
-
}
void btnStart_Click(object sender, RoutedEventArgs e)
@@ -60,7 +63,7 @@
{
DataFactory.SnapshotList.Clear();
//CalculteSatus.isLastCalculate = false;
- CalculteSatus.MaterialDatas.Clear();//清除缓存的管线数据
+ CalculteSatus.MaterialDatas.Clear(); //清除缓存的管线数据
HomePageViewModel.Instance.StartState = false;
CalculteSatus.msp.collectData = false;
@@ -75,64 +78,67 @@
{
DataFactory.ResetHomePageData();
//DataFactory.SnapshotList.Clear();
- CreateView(1);//复位
+ CreateView(1); //复位
CalculteSatus.isCalculateStop = false;
- if (/*CalculteSatus.isLastCalculate &&*/ CalculteSatus.MaterialDatas.Count > 0)//管线条件不为空
+ if ( /*CalculteSatus.isLastCalculate &&*/ CalculteSatus.MaterialDatas.Count > 0) //管线条件不为空
{
String txt = "上次计算条件:\r管道:";
foreach (PipeMaterialData pipeMaterialData in CalculteSatus.MaterialDatas)
{
- txt += pipeMaterialData.Diameter + "mm," + pipeMaterialData.Length + "m" + pipeMaterialData.Material + ";";
+ txt += pipeMaterialData.Diameter + "mm," + pipeMaterialData.Length + "m" +
+ pipeMaterialData.Material + ";";
}
//string txt = "管道:" + CalculteSatus.diameterData + "mm," + CalculteSatus.lengthData + "m" + Correlator.CalculteSatus.MaterialData
txt += "\r干扰频段:"
- + ((CalculteSatus.cutFreLow < 0 || CalculteSatus.cutFreHigh < 0) ? "-" :
- (CalculteSatus.cutFreLow.ToString() + "-" + CalculteSatus.cutFreHigh.ToString()) + "Hz")
- + "\r是否是新管线?";
+ + ((CalculteSatus.cutFreLow < 0 || CalculteSatus.cutFreHigh < 0)
+ ? "-"
+ : (CalculteSatus.cutFreLow.ToString() + "-" + CalculteSatus.cutFreHigh.ToString()) +
+ "Hz")
+ + "\r是否是新管线?";
bool? b = new PopupIsOrNotWindow(txt).ShowDialog();
- if (b == true)//新管线
+ if (b == true) //新管线
{
//CalculteSatus.isLastCalculate = false;
- CalculteSatus.MaterialDatas.Clear();//清除缓存的管线数据
+ CalculteSatus.MaterialDatas.Clear(); //清除缓存的管线数据
isNewPipe();
- startCreateView();//开始监测创建对比视图
+ startCreateView(); //开始监测创建对比视图
SelectPipeMaterialView selectPipeMaterialView = new SelectPipeMaterialView();
Global.GetMainView().bdrPreposition.Child = selectPipeMaterialView;
}
- else//不是新管线
+ else //不是新管线
{
- if (CalculteSatus.isCompleteCalculate)//一轮计算已完成
+ if (CalculteSatus.isCompleteCalculate) //一轮计算已完成
{
- startCreateView();//开始监测创建对比视图
+ startCreateView(); //开始监测创建对比视图
CalculteSatus.isCompleteCalculate = false;
}
- /* 线程优化1
+ // Task不能正常执行第二次三次计算
+ // 线程优化1
Thread calThread = new Thread(new ThreadStart(execute));
calThread.IsBackground = true;
calThread.Start();
- * */
- Task calThread = new Task(() => execute());
- calThread.Start();
+
+ // StartTask calTask = new Task(() => execute());
+ // calTask.Start();
}
}
- else//管线条件为空,默认为新管线
+ else //管线条件为空,默认为新管线
{
isNewPipe();
- startCreateView();//开始监测创建对比视图
+ startCreateView(); //开始监测创建对比视图
CalculteSatus.isCompleteCalculate = false;
SelectPipeMaterialView selectPipeMaterialView = new SelectPipeMaterialView();
Global.GetMainView().bdrPreposition.Child = selectPipeMaterialView;
}
-
}
}
@@ -140,7 +146,8 @@
{
if (DataFactory.SnapshotList.Count < 3 && HomePageViewModel.Instance.BtnFilterIsEnabled)
{
- ColumnGroupInfo snapshot = DataFactory.ChartBaseDictionary[DataFactory.HomePageChartId] as ColumnGroupInfo;
+ ColumnGroupInfo snapshot =
+ DataFactory.ChartBaseDictionary[DataFactory.HomePageChartId] as ColumnGroupInfo;
ColumnGroupInfo snapshot_copy = new ColumnGroupInfo();
snapshot_copy.ColumnListInfo = snapshot.ColumnListInfo;
snapshot_copy.ID = Guid.NewGuid().ToString();
@@ -168,6 +175,7 @@
{
gridRow.Children.RemoveRange(1, gridRow.Children.Count - 1);
}
+
for (int i = 0; i < viewCount; i++)
{
RowDefinition row = new RowDefinition();
@@ -178,7 +186,8 @@
Grid.SetRow(gridPipelinechart, viewCount - 1);
for (int i = viewCount - 2; i >= 0; i--)
{
- BaseControl baseControl = new BaseControl(DataFactory.SnapshotList[i], DataFactory.ChartBaseDictionary[DataFactory.HomePageChartId].Coordinates);
+ BaseControl baseControl = new BaseControl(DataFactory.SnapshotList[i],
+ DataFactory.ChartBaseDictionary[DataFactory.HomePageChartId].Coordinates);
//baseControl.btnClose.Visibility = Visibility.Visible;
//baseControl.gridName.Visibility = Visibility.Visible;
//baseControl.btnClose.Click += delegate
@@ -196,7 +205,7 @@
private void startCreateView()
{
- CalculteSatus.createView = 0;//恢复默认值0
+ CalculteSatus.createView = 0; //恢复默认值0
DataFactory.SnapshotList.Clear();
//启动一个定时器
@@ -209,7 +218,7 @@
{
switch (CalculteSatus.createView)
{
- case 1://取消定时
+ case 1: //取消定时
timer.Stop();
break;
case 2:
@@ -229,25 +238,24 @@
timer.Start();
}
}
-
-
-
+
private void SaveSnapshot()
{
//保存快照
//System.Drawing.Size screen = new System.Drawing.Size((int)gridHomePage.ActualWidth, (int)gridHomePage.ActualHeight);
//Bitmap memoryImage = new Bitmap(screen.Width, screen.Height);
- int width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
- int height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
+ int width = Screen.PrimaryScreen.Bounds.Width;
+ int height = Screen.PrimaryScreen.Bounds.Height;
Bitmap memoryImage = new Bitmap(width, height);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
- memoryGraphics.CopyFromScreen(0, 0, 0, 0, new System.Drawing.Size(width, height), CopyPixelOperation.SourceCopy);
+ memoryGraphics.CopyFromScreen(0, 0, 0, 0, new Size(width, height),
+ CopyPixelOperation.SourceCopy);
MemoryStream data = new MemoryStream();
- memoryImage.Save(data, System.Drawing.Imaging.ImageFormat.Png);
+ memoryImage.Save(data, ImageFormat.Png);
string strAppPath = AppDomain.CurrentDomain.BaseDirectory; //获得可执行文件的路径
string strPath = strAppPath + "File\\snapshot\\快照_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
@@ -277,8 +285,8 @@
void btnAudition_Click(object sender, RoutedEventArgs e)
{
- bool? b = new PopupIsOrNotWindow("是否是新管线?","提示").ShowDialog();
- if(b == true)
+ bool? b = new PopupIsOrNotWindow("是否是新管线?", "提示").ShowDialog();
+ if (b == true)
{
isNewPipe();
}
@@ -286,7 +294,7 @@
//加载听音页
AuditionView auditionView = new AuditionView();
Global.GetMainView().bdrMain.Child = auditionView;
-
+
//HomePageViewModel.Instance.BtnStartIsEnabled = false;
}
@@ -294,7 +302,6 @@
{
DataFactory.InitalHomePageData(canvasCoordinates, gridChartContainer);
DataFactory.SnapshotList.Clear();
-
}
///
@@ -307,7 +314,7 @@
CreateView(1);
//CalculteSatus.isLastCalculate = false;
- CalculteSatus.MaterialDatas.Clear();//清除缓存的管线数据
+ CalculteSatus.MaterialDatas.Clear(); //清除缓存的管线数据
HomePageViewModel.Instance.BtnStartIsEnabled = true;
HomePageViewModel.Instance.BtnAuditionIsEnabled = true;
@@ -315,7 +322,6 @@
HomePageViewModel.Instance.BtnFilterIsEnabled = true;
HomePageViewModel.Instance.BtnSnapshotIsEnabled = true;
-
}
///
@@ -328,16 +334,17 @@
{
SaveWav sw = new SaveWav();
string strPath = AppDomain.CurrentDomain.BaseDirectory +
- "File\\audio\\音频_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".wav";
+ "File\\audio\\音频_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".wav";
FileStream fs = sw.CreateEmpty(strPath);
for (int i = 0; i < CorrelatorDataSaveThread.devDataValueMap[DevCode.Dev2].Count; i++)
{
sw.WriteFilestream(fs, CorrelatorDataSaveThread.devDataValueMap[DevCode.Dev1][i],
- CorrelatorDataSaveThread.devDataValueMap[DevCode.Dev2][i]);
+ CorrelatorDataSaveThread.devDataValueMap[DevCode.Dev2][i]);
}
- sw.WriteHeader(fs, 7500, 2);//重写头文件
+
+ sw.WriteHeader(fs, 7500, 2); //重写头文件
new PopupWindow("音频已保存").ShowDialog();
}
@@ -379,13 +386,13 @@
CalculteThread c = new CalculteThread();
c.exe();
}
-
-
+
//判断是否是新管线
private void isNewPipe()
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- String josnString = File.ReadAllText(System.AppDomain.CurrentDomain.BaseDirectory + "number.json", Encoding.UTF8);
+ String josnString = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "number.json",
+ Encoding.UTF8);
JObject jo = JObject.Parse(josnString);
String date = jo["date"].ToString();
@@ -393,7 +400,7 @@
int locate = Convert.ToInt32(jo["locate"].ToString());
int listen = Convert.ToInt32(jo["listen"].ToString());
- String today = System.DateTime.Now.ToString("yyyyMMdd");
+ String today = DateTime.Now.ToString("yyyyMMdd");
if (date == today)
{
jo["pipe"] = ++pipe;
@@ -416,12 +423,11 @@
jo["locate"] = 1;
CorrelatorDataSaveThread.Locate = 1;
- StreamWriter sw = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory + "number.json");
+ StreamWriter sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "number.json");
sw.Write(JsonConvert.SerializeObject(jo));
sw.Flush();
sw.Close();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
-
}
}
\ No newline at end of file