/// <summary> /// 绘制距选定的日期(包括选择的日期)最近的日期的监测数据 /// </summary> /// <param name="dateThisDay">选定的施工日期</param> /// <param name="State">指示选定的日期所处的状态</param> /// <param name="Closestday">距离选定日期最近的日期,如果选定的日期在工作表中有数据,则等效于dateThisDay</param> /// <remarks></remarks> private void CurveRolling(DateTime dateThisDay, TodayState State, DateTime Closestday) { Series series = this.MovingSeries; // Me.Chart.SeriesCollection(1) const string strDateFormat = AMEApplication.DateFormat; F_DicSeries_Tag.Item(1).ConstructionDate = dateThisDay; //刷新滚动的曲线所代表的日期 //绘制曲线图 //.XValues = dicDate_ChosenDatum.Item(dateThisday) 'X轴的数据 // switch (State) { case TodayState.BeforeStartDay: series.Values = new[] { null }; //不能设置为Series.Value=vbEmpty,因为这会将x轴标签中的某一个值设置为0.0。 series.Name = dateThisDay.ToString(strDateFormat) + " :早于" + this.DateSpan.StartedDate.ToString(strDateFormat); break; case TodayState.DateNotFound: series.Values = P_dicDate_ChosenDatum.Item(Closestday); series.Name = Closestday.ToString(strDateFormat) + "(" + dateThisDay.ToString(strDateFormat) + ":No Data" + ")"; break; case TodayState.AfterFinishedDay: series.Values = new[] { null }; series.Name = dateThisDay.ToString(strDateFormat) + " :晚于" + this.DateSpan.FinishedDate.ToString(strDateFormat); break; case TodayState.DateMatched: series.Values = P_dicDate_ChosenDatum.Item(dateThisDay); series.Name = dateThisDay.ToString(strDateFormat); break; } }
/// <summary> /// 图形滚动的Rolling方法 /// </summary> /// <param name="dateThisday">施工当天的日期</param> /// <remarks></remarks> public override void Rolling(DateTime dateThisday) { F_RollingDate = dateThisday; object lockobject = new object(); lock (lockobject) { Excel.Application app = Chart.Application; app.ScreenUpdating = false; // ------------------- 绘制监测曲线图 var Allday = F_dicDateAndColumnNumber.Keys; //考察选定的日期是否有数据 TodayState State = default(TodayState); DateTime closedDay = default(DateTime); // if (DateTime.Compare(dateThisday, DateSpan.StartedDate) < 0) { State = TodayState.BeforeStartDay; } else if (DateTime.Compare(dateThisday, DateSpan.FinishedDate) > 0) { State = TodayState.AfterFinishedDay; } else if (Allday.Contains(dateThisday)) //如果搜索的那一天有数据 { State = TodayState.DateMatched; closedDay = dateThisday; } else //搜索的那一天没有数据,则查找选定的日期附近最近的一天,并绘制其监测曲线 { State = TodayState.DateNotFound; SortedSet <DateTime> sortedlist_AllDays = new SortedSet <DateTime>(Allday); closedDay = GetClosestDay(sortedlist_AllDays, dateThisday); } // CurveRolling(dateThisday, State, closedDay); // -------------------- 移动开挖深度的直线与文本框 if (P_ProcessRegionData != null) { float excavationElevation = 0; try { excavationElevation = Convert.ToSingle(P_ProcessRegionData.Date_Elevation[dateThisday]); //ClsData_DataBase.GetElevation(P_rgExcavationProcess, dateThisday) } catch (Exception) { Debug.Print("上面的Exception已经被Try...Catch语句块捕获,不用担心。出错代码位于ClsDrawing_Mnt_Incline.vb中。"); DateTime ClosestDate = ClsData_DataBase.FindTheClosestDateInSortedList( P_ProcessRegionData.Date_Elevation.Keys, dateThisday); excavationElevation = Convert.ToSingle(P_ProcessRegionData.Date_Elevation[ClosestDate]); } MoveExcavation(_ExcavationDepth_lineAndTextbox, excavationElevation, dateThisday, State); } app.ScreenUpdating = true; } }
/// <summary> /// 图形滚动 /// </summary> /// <param name="dateThisday"></param> /// <remarks></remarks> public override void Rolling(DateTime dateThisday) { base.F_RollingDate = dateThisday; object lockobject = new object(); lock (lockobject) { var app = this.Chart.Application; app.ScreenUpdating = false; // ------------------- 绘制监测曲线图 var Allday = this.P_dicDate_ChosenDatum.Keys; //考察选定的日期是否有数据 TodayState State = default(TodayState); DateTime closedDay = default(DateTime); // if (DateTime.Compare(dateThisday, this.DateSpan.StartedDate) < 0) { State = TodayState.BeforeStartDay; } else if (DateTime.Compare(dateThisday, this.DateSpan.FinishedDate) > 0) { State = TodayState.AfterFinishedDay; } else if (Allday.Contains(dateThisday)) //如果搜索的那一天有数据 { State = TodayState.DateMatched; closedDay = dateThisday; } else //搜索的那一天没有数据,则查找选定的日期附近最近的一天,并绘制其监测曲线 { State = TodayState.DateNotFound; SortedSet <DateTime> sortedlist_AllDays = new SortedSet <DateTime>(Allday); closedDay = base.GetClosestDay(sortedlist_AllDays, dateThisday); } // this.CurveRolling(dateThisday, State, closedDay); app.ScreenUpdating = true; } }
/// <summary> /// 绘制距选定的日期(包括选择的日期)最近的日期的监测数据 /// </summary> /// <param name="dateThisDay">选定的施工日期</param> /// <param name="State">指示选定的日期所处的状态</param> /// <param name="Closestday">距离选定日期最近的日期,如果选定的日期在工作表中有数据,则等效于dateThisDay</param> /// <remarks></remarks> private void CurveRolling(DateTime dateThisDay, TodayState State, DateTime Closestday) { const string strDateFormat = AMEApplication.DateFormat; F_DicSeries_Tag[1].ConstructionDate = dateThisDay; //刷新滚动的曲线所代表的日期 bool blnHasCurve = false; // //进行监测曲线的滚动 MovingSeries.Values = F_YValues; //Y轴的数据 switch (State) { case TodayState.BeforeStartDay: MovingSeries.XValues = new object[] { null }; //不能设置为Series.Value=vbEmpty,因为这会将x轴标签中的某一个值设置为0.0。 MovingSeries.Name = dateThisDay.ToString(strDateFormat) + " :早于" + DateSpan.StartedDate.ToString(strDateFormat); blnHasCurve = false; break; case TodayState.AfterFinishedDay: MovingSeries.XValues = new object[] { null }; // VB语法: MovingSeries.XValues = {Nothing} MovingSeries.Name = dateThisDay.ToString(strDateFormat) + " :晚于" + DateSpan.FinishedDate.ToString(strDateFormat); blnHasCurve = false; break; case TodayState.DateNotFound: MovingSeries.Name = Closestday.ToString(strDateFormat) + "(" + dateThisDay.ToString(strDateFormat) + "无数据" + ")"; blnHasCurve = true; break; case TodayState.DateMatched: MovingSeries.Name = dateThisDay.ToString(strDateFormat); blnHasCurve = true; break; } if (blnHasCurve) { //--------------------------- 设置信息文本框中的信息 double max = 0; double min = 0; string StrdepthForMax = ""; string StrdepthForMin = ""; // var strcolumn = F_dicDateAndColumnNumber[Closestday]; //当天的监测数据的Range对象 var rgDisplacement = P_rgMntData.Columns[strcolumn] as Excel.Range; //只包含对应施工日期的监测数据的那一列Range对象 //当天的监测数据,这里只能定义为Object的数组,因为有可能单元格中会出现没有数据的情况。 object[] MonitorData = ExcelFunction.ConvertRangeDataToVector <object>(rgDisplacement); MovingSeries.XValues = MonitorData; //X轴的数据 // //find the maximun/Minimum displacement max = Sheet_Data.Application.WorksheetFunction.Max(MonitorData); min = Sheet_Data.Application.WorksheetFunction.Min(MonitorData); try { // find the corresponding depth of the maximun displacement //如果 MATCH 函数查找匹配项不成功,在Excel中它会返回错误值 #N/A。 而在VB.NET中,它会直接报错。 int Row_Max = Convert.ToInt32(rgDisplacement.Cells[1, 1].Row - 1 + Sheet_Data.Application.WorksheetFunction.Match(max, MonitorData, 0)); float sngDepthForMax = Convert.ToSingle( Sheet_Data.Cells[Row_Max, Data_Drawing_Format.Mnt_Incline.ColNum_Depth].Value); StrdepthForMax = sngDepthForMax.ToString("0.0"); } catch (Exception) { StrdepthForMax = " Null "; Debug.Print("搜索最大位移所对应的深度失败!"); } try { // find the corresponding depth of the mininum displacement //如果 MATCH 函数查找匹配项不成功,在Excel中它会返回错误值 #N/A。 而在VB.NET中,它会直接报错。 int Row_Min = Convert.ToInt32(rgDisplacement.Cells[1, 1].Row - 1 + Sheet_Data.Application.WorksheetFunction.Match(min, MonitorData, 0)); float sngDepthForMin = Convert.ToSingle( Sheet_Data.Cells[Row_Min, Data_Drawing_Format.Mnt_Incline.ColNum_Depth].Value); StrdepthForMin = sngDepthForMin.ToString("0.0"); } catch (Exception) { StrdepthForMin = " Null "; Debug.Print("搜索最小位移所对应的深度失败!"); } //在信息文本框中输出文本,记录当前曲线的最大与最小位移,以及出现的深度 Information.TextRange.Text = "Max:" + max.ToString("0.00") + "mm" + "\t" + "In depth of " + StrdepthForMax + "m" + "\r\n" + "Min:" + min.ToString("0.00") + "mm" + "\t" + "In depth of " + StrdepthForMin + "m"; } else { Information.TextRange.Text = "Max:" + "\t" + "In depth of " + "\r\n" + "Min:" + "\t" + "In depth of "; } }
/// <summary> /// 根据每天不同的挖深情况,移动挖深线的位置 /// </summary> /// <param name="ExcavationLineAndTextBox">表示挖深深度的直线,文本框中记录有“挖深”二字</param> /// <param name="excavElevation"> 当天开挖标高 </param> /// <param name="dateThisday">施工当天的日期</param> /// <remarks></remarks> private void MoveExcavation(SeriesTag_Incline ExcavationLineAndTextBox, float excavElevation, DateTime dateThisday, TodayState State) { Shape iline = ExcavationLineAndTextBox.DepthLine; Shape itextbox = ExcavationLineAndTextBox.DepthTextbox; // if (State == TodayState.DateMatched | State == TodayState.DateNotFound) { // 将当天的开挖标高转换为相对于测斜管顶部的深度值 float relativedepth = _inclineTopElevaion - excavElevation; //Project_Expo.Elevation_GroundSurface - excavElevation // Excel.Axis axisY = Chart.Axes(Excel.XlAxisType.xlValue) as Excel.Axis; float scalemax = (float)axisY.MaximumScale; float scalemin = (float)axisY.MinimumScale; // float linetop = 0; Excel.PlotArea plotA = Chart.PlotArea; //将相对深度值转换与图表坐标系中的深度坐标值!!!!! linetop = (float)(plotA.InsideTop + plotA.InsideHeight * (relativedepth - scalemin) / (scalemax - scalemin)); // iline.Visible = MsoTriState.msoCTrue; iline.Top = linetop; // if (itextbox != null) { itextbox.Visible = MsoTriState.msoCTrue; itextbox.Top = iline.Top - itextbox.Height; //指示此基坑当前的状态,为向下开挖还是向上建造。 string strStatus = ""; if (P_ProcessRegionData == null || (!P_ProcessRegionData.HasBottomDate)) { strStatus = "挖深/施工深度"; } else { int CompareIndex = DateTime.Compare(dateThisday, P_ProcessRegionData.BottomDate); if (CompareIndex < 0) //说明还未开挖到底 { strStatus = "挖深"; } else if (CompareIndex > 0) //说明已经开挖到底,正在施工上部结构 { strStatus = "施工深度"; } else if (CompareIndex == 0) //说明刚好开挖到基坑底部 { strStatus = "开挖到底"; } } itextbox.TextFrame2.TextRange.Text = strStatus + Convert.ToString(relativedepth); } } else { iline.Visible = MsoTriState.msoFalse; // if (itextbox != null) { itextbox.Visible = MsoTriState.msoFalse; } } }