//添加 public override KeyValuePair <int, clsDrawing_Mnt_RollingBase.SeriesTag> CopySeries(int SourceSeriesIndex) { // 调用基类中的方法 KeyValuePair <int, clsDrawing_Mnt_RollingBase.SeriesTag> NewSeriesIndex_Tag = base.CopySeries(SourceSeriesIndex); // // ------------ 为新的数据列创建其对应的Tag // ------------ 这是这个类与其基类所不同的地方,将下面这个函数删除,即与其基类中的这个方法相同了。 ------------ int NewSeriesIndex = NewSeriesIndex_Tag.Key; //新数据列的索引下标,第一条曲线的下标为1; SeriesTag_Incline newTag = default(SeriesTag_Incline); //新数据列的标签Tag newTag = new SeriesTag_Incline(NewSeriesIndex_Tag.Value.series, NewSeriesIndex_Tag.Value.ConstructionDate); try { newTag = this.ConstructNewTag(F_DicSeries_Tag[SourceSeriesIndex], newTag.series); } catch (Exception ex) { Debug.Print(ex.Message); MessageBox.Show("在设置\"表示开挖深度的标志线与文本框\"时出错", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //---------------------- //将基类中的F_DicSeries_Tag.Item(NewSeriesIndex)的值由SeriesTag修改为SeriesTag_Incline F_DicSeries_Tag[NewSeriesIndex] = newTag; return(default(KeyValuePair <int, clsDrawing_Mnt_RollingBase.SeriesTag>)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="DataSheet">图表对应的数据工作表</param> /// <param name="DrawingChart">Excel图形所在的Chart对象</param> /// <param name="ParentApp">此图表所在的Excel类的实例对象</param> /// <param name="DateSpan">此图表的TimeSpan跨度</param> /// <param name="type">此图表的类型,则枚举DrawingType提供</param> /// <param name="CanRoll">是图表是否可以滚动,即是动态图还是静态图</param> /// <param name="date_ColNum">此测斜点的监测数据工作表中的每一天与其在工作表中对应的列号, /// 以监测数据的日期key索引数据所在列号item</param> /// <param name="usedRg">监测曲线的数据范围,此Range对象中, /// 包括此工作表的UsedRange中的第一列,即深度的数据;但是不包括第一行的日期数据</param> /// <param name="Info">记录数据信息的文本框</param> /// <param name="FirstSeriesTag">第一条数据系列对应的Tag信息</param> /// <param name="ProcessRegionData">在施工进度工作表中,每一个基坑区域相关的各种信息,比如区域名称,区域的描述, /// 区域数据的Range对象,区域所属的基坑ID及其ID的数据等</param> /// <remarks></remarks> public ClsDrawing_Mnt_Incline(Excel.Worksheet DataSheet, Excel.Chart DrawingChart, Cls_ExcelForMonitorDrawing ParentApp, DateSpan DateSpan, DrawingType type, bool CanRoll, TextFrame2 Info, MonitorInfo DrawingTag, MntType MonitorType, Dictionary <DateTime, int> date_ColNum, Excel.Range usedRg, SeriesTag_Incline FirstSeriesTag, clsData_ProcessRegionData ProcessRegionData = null) : base(DataSheet, DrawingChart, ParentApp, type, CanRoll, Info, DrawingTag, MonitorType, DateSpan, new clsDrawing_Mnt_RollingBase.SeriesTag(FirstSeriesTag.series, FirstSeriesTag.ConstructionDate)) { // // -------------------------------------------- try { ClsDrawing_Mnt_Incline with_1 = this; with_1.P_rgMntData = usedRg; //'包括第一列,但是不包括第一行的日期。 Excel.Range colRange = usedRg.Columns[1] as Excel.Range; with_1.F_YValues = ExcelFunction.ConvertRangeDataToVector <Single>(colRange); with_1.Information = Info; with_1._ExcavationDepth_lineAndTextbox = FirstSeriesTag; with_1.F_dicDateAndColumnNumber = date_ColNum; with_1.P_ProcessRegionData = ProcessRegionData; with_1._inclineTopElevaion = Project_Expo.InclineTopElevaion; // ----- 集合数据的记录 with_1.F_DicSeries_Tag[(int)LowIndexOfObjectsInExcel.SeriesInSeriesCollection] = FirstSeriesTag; // -----对图例进行更新--------- //Call LegendRefresh(List_HasCurve) } catch (Exception ex) { MessageBox.Show("构造测斜曲线图出错。" + "\r\n" + ex.Message + "\r\n" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//删除 public override void DeleteSeries(int DeletingSeriesIndex) { //删除数据系列以及对应的开挖深度直线与开挖深度文本框 SeriesTag_Incline seriesTag_incline = (SeriesTag_Incline)(F_DicSeries_Tag[DeletingSeriesIndex]); if (seriesTag_incline.DepthLine != null) { seriesTag_incline.DepthLine.Delete(); } if (seriesTag_incline.DepthTextbox != null) { seriesTag_incline.DepthTextbox.Delete(); } // base.DeleteSeries(DeletingSeriesIndex); }
/// <summary> /// 为新的数据列创建其对应的Tag,并且在Excel的绘图中复制出对应的表示开挖深度的深度线与文本框。 /// </summary> /// <param name="SourceTag">用以参考的数据系列的Tag信息</param> /// <param name="newSeries">复制出来的新的数据系列</param> /// <returns></returns> /// <remarks></remarks> private SeriesTag_Incline ConstructNewTag(SeriesTag_Incline SourceTag, Excel.Series newSeries) { SeriesTag_Incline newTag = new SeriesTag_Incline(newSeries, F_RollingDate); // ------------ 为新的数据列创建其对应的Tag //数据系列的颜色 int seriesColor = newSeries.Format.Line.ForeColor.RGB; //复制一个新的开挖深度线 try { if (SourceTag.DepthLine != null) { newTag.DepthLine = SourceTag.DepthLine.Duplicate(); //线条的位置 newTag.DepthLine.Top = SourceTag.DepthLine.Top; //.Left = SourceTag.DepthLine.Left newTag.DepthLine.Left = 0; //线条的颜色 newTag.DepthLine.Line.ForeColor.RGB = seriesColor; //线条的阴影 newTag.DepthLine.Shadow.Type = MsoShadowType.msoShadow21; //线条的缩放 newTag.DepthLine.ScaleWidth(Factor: (float)0.5, RelativeToOriginalSize: MsoTriState.msoFalse, Scale: MsoScaleFrom.msoScaleFromTopLeft); } } catch (Exception ex) { Debug.Print(ex.Message); MessageBox.Show("在设置\"表示开挖深度的标志线\"时出错", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //复制一个新的开挖深度文本框 try { if (SourceTag.DepthTextbox != null) { Shape oldTxtShp = SourceTag.DepthTextbox; newTag.DepthTextbox = oldTxtShp.Duplicate(); //设置文本框的位置 Shape newTxtShp = newTag.DepthTextbox; //设置文本框的位置 newTxtShp.Top = oldTxtShp.Top; //.Left = oldTxtShp.Left newTxtShp.Left = 0; //设置文本框中字体的格式 newTxtShp.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = seriesColor; newTxtShp.TextFrame2.TextRange.Font.Size = 10; newTxtShp.TextFrame2.TextRange.Font.Bold = MsoTriState.msoFalse; } } catch (Exception ex) { Debug.Print(ex.Message); MessageBox.Show("在设置\"表示开挖深度的文本框\"时出错", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(newTag); }
/// <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; } } }