/// <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); } }
/// <summary> /// 在Chart中绘制每一个选定区域所属的基坑ID的支撑位置 /// </summary> /// <param name="arrExcavID">所有选择的基坑区域所属的基坑ID</param> /// <param name="series_DeepestExca">构件图形的位置的参考</param> /// <remarks></remarks> private void DrawComponents(clsData_ExcavationID[] arrExcavID, Chart DrawingChart, Series series_DeepestExca) { UInt16 RegionsCount = arrExcavID.Length; try { Chart with_1 = DrawingChart; UInt16 Index = 0; string[] arrRegionName = new string[RegionsCount - 1 + 1]; foreach (Point pt in series_DeepestExca.Points()) { Component[] Components = arrExcavID[Index].Components; double dblLeft = pt.Left; double dblWidth = pt.Width; List <string> listComponentName = new List <string>(); foreach (Component Component in Components) { if (Component.Type == ComponentType.Strut) { double dblTop = ExcelFunction.GetPositionInChartByValue(with_1.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue), Component.Elevation); //添加标高线 Microsoft.Office.Interop.Excel.Shape shpLine = with_1.Shapes.AddLine(BeginX: ref dblLeft, BeginY: ref dblTop, EndX: dblLeft + dblWidth, EndY: ref dblTop); shpLine.Line.Weight = (float)(1.5F); shpLine.Line.DashStyle = Microsoft.Office.Core.MsoLineDashStyle.msoLineSolid; shpLine.Line.ForeColor.RGB = Information.RGB(255, 0, 0); //添加文本框 double dblTextHeight = 40; Microsoft.Office.Interop.Excel.Shape shpText = with_1.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, (float) dblLeft, (float)(dblTop - dblTextHeight), (float)dblWidth, (float)dblTextHeight); ExcelFunction.FormatTextbox_Tag(TextFrame: shpText.TextFrame2, TextSize: 8, Text: ref Component.Description, VerticalAnchor: ref MsoVerticalAnchor.msoAnchorBottom); Microsoft.Office.Interop.Excel.Shape shpRg_Components = with_1.Shapes.Range(new[] { shpLine.Name, shpText.Name }).Group(); listComponentName.Add(shpRg_Components.Name); } } //下一组构件 UInt16 ComponentCount = listComponentName.Count; if (ComponentCount > 2) { arrRegionName[Index] = DrawingChart.Shapes.Range(listComponentName.ToArray).Group().Name; } else if (ComponentCount == 1) //只有一组构件,那么不用进行Group { arrRegionName[Index] = System.Convert.ToString(listComponentName.Item(0)); } else //说明此基坑区域中一个构件也没有。 { arrRegionName[Index] = null; } Index++; } //下一个基坑区域 if (arrRegionName.Count() >= 2) { with_1.Shapes.Range(arrRegionName).Group(); } } catch (Exception ex) { MessageBox.Show("绘制基坑构件出错!" + "\r\n" + ex.Message + "\r\n" + "报错位置:" + ex.TargetSite.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }