//加入对比 private void btnAddCompare_Click(object sender, RoutedEventArgs e) { if (cmbWindFanNumber.SelectedItem == null) { //标志已经关闭对比功能 compareFlag = false; MessageBox.Show("请先选择要加入对比的风机再执行此操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //获取当前风机的时间集合 compareDateTimeCollection = FanPointDAL.GetDateTimeCollectionOfSingleFan(windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime); if (compareDateTimeCollection == null) { //标志已经关闭对比功能 compareFlag = false; MessageBox.Show("没有检索到该风机的任何风速风向数据!", "啥也没找到", MessageBoxButton.OK, MessageBoxImage.Warning); return; } //另开线程绘制对比曲线 Task <int> drawTask = new Task <int>(() => { return(DrawCompareTask()); }); drawTask.Start();//开始工作 }
private void DrawWave() { //标志已经关闭对比功能 compareFlag = false; //获取起始时间 startTime = dpStart.SelectedDate; //获取终止时间 endTime = dpEnd.SelectedDate; if (startTime == null || endTime == null) { //重置日期标志为false selectDateFlag = false; MessageBox.Show("要查询的起止时间不能为空,请选择时间!"); return; } if (startTime >= endTime) { //重置日期标志为false selectDateFlag = false; MessageBox.Show("您选择的时间不对,请重新输入"); return; } //获取当前风机的时间集合 dateTimeCollection = FanPointDAL.GetDateTimeCollectionOfSingleFan(windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime); if (dateTimeCollection == null) { MessageBox.Show("没有检索到该风机的任何风速风向数据!", "啥也没找到", MessageBoxButton.OK, MessageBoxImage.Warning); Draw.DrawGrid(cvsWindSpeed, "#FF95310C"); //此方法有清空canvas的操作 Draw.DrawGrid(cvsWindDirection, "#FF4D056E"); //此方法有清空canvas的操作 //重置日期标志为false selectDateFlag = false; return; } //重置日期标志为true selectDateFlag = true; //使能对比按钮 btnAddCompare.IsEnabled = true; //获取当前风机的风速集合 windSpeedList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风速, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime); //获取当前风机的风向集合 windDirectionList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风向, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime); //获取风速最大值和最小值 windSpeedMaxAndMin = new double[2]; windSpeedMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风速, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime); //获取风向最大值和最小值 windDirectionMaxAndMin = new double[2]; windDirectionMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风向, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime); //绘制风速数据 Draw.DrawGrid(cvsWindSpeed, "#FF95310C");//此方法有清空canvas的操作 Draw.DrawWord(cvsWindSpeed, this.CompanyName, this.WindFieldName, this.FanNumber, windSpeedMaxAndMin[0], windSpeedMaxAndMin[1], "#FF95310C", "(米/秒)", dateTimeCollection, null); Draw.DrawCurve(cvsWindSpeed, windSpeedList, windSpeedMaxAndMin[0], windSpeedMaxAndMin[1], "#FF95310C"); //绘制风向数据 Draw.DrawGrid(cvsWindDirection, "#FF4D056E");//此方法有清空canvas的操作 Draw.DrawWord(cvsWindDirection, this.CompanyName, this.WindFieldName, this.FanNumber, windDirectionMaxAndMin[0], windDirectionMaxAndMin[1], "#FF4D056E", "(度)", dateTimeCollection, null); Draw.DrawCurve(cvsWindDirection, windDirectionList, windDirectionMaxAndMin[0], windDirectionMaxAndMin[1], "#FF4D056E"); return; }