/// <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; } }