/// <summary> /// 绘制开挖工况的位置线 /// </summary> /// <param name="Cht"></param> /// <param name="WorkingStage"></param> /// <remarks></remarks> private void DrawWorkingStage(Excel.Chart Cht, List <clsData_WorkingStage> WorkingStage) { Excel.Axis AX = Cht.Axes(Excel.XlAxisType.xlCategory) as Excel.Axis; string[] arrLineName = new string[WorkingStage.Count - 1 + 1]; string[] arrTextName = new string[WorkingStage.Count - 1 + 1]; Excel.Chart with_1 = Cht; try { int i = 0; foreach (clsData_WorkingStage WS in WorkingStage) { // ------------------------------------------------------------------------------------------- Excel.Shape shpLine = with_1.Shapes.AddLine(BeginX: 0, BeginY: Cht.PlotArea.InsideTop, EndX: 0, EndY: 75); shpLine.Line.Weight = (float)(1.2F); //.EndArrowheadStyle = Microsoft.Office.Core.MsoArrowheadStyle.msoArrowheadStealth //.EndArrowheadLength = Microsoft.Office.Core.MsoArrowheadLength.msoArrowheadLengthMedium //.EndArrowheadWidth = Microsoft.Office.Core.MsoArrowheadWidth.msoArrowheadWidthMedium shpLine.Line.DashStyle = Microsoft.Office.Core.MsoLineDashStyle.msoLineDashDot; shpLine.Line.ForeColor.RGB = Information.RGB(255, 0, 0); // ExcelFunction.setPositionInChart(shpLine, AX, WS.ConstructionDate.ToOADate()); // ------------------------------------------------------------------------------------------- float TextWidth = 25; float textHeight = 10; Excel.Shape shpText = default(Excel.Shape); shpText = Cht.Shapes.AddTextbox(Orientation: Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, Left: shpLine.Left - TextWidth / 2, Top: shpLine.Top - textHeight, Height: ref textHeight, Width: ref TextWidth); ExcelFunction.FormatTextbox_Tag(TextFrame: shpText.TextFrame2, Text: WS.Description, HorizontalAlignment: Microsoft.Office.Core.MsoParagraphAlignment.msoAlignCenter); // ------------------------------------------------------------------------------------------- arrLineName[i] = shpLine.Name; arrTextName[i] = shpText.Name; i++; } Excel.Shape shp1 = Cht.Shapes.Range[arrLineName].Group(); Excel.Shape shp2 = Cht.Shapes.Range[arrTextName].Group(); Cht.Shapes.Range[new[] { shp1.Name, shp2.Name }].Group(); } catch (Exception ex) { MessageBox.Show("设置开挖工况位置出现异常。" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }