//获取轴号信息 public CalcGridInfoResult GetGridNumberShowInfo(bool bIdling, Rect formRec, ref System.Drawing.Point formLeftTopPt, ref Size formSize) { if (m_uiDoc == null) { return(CalcGridInfoResult._Error); } if (m_uiView == null) { IList <UIView> openUIViews = m_uiDoc.GetOpenUIViews(); foreach (UIView uiview in openUIViews) { if (uiview.ViewId == m_uiDoc.ActiveView.Id) { m_uiView = uiview; break; } } } if (m_uiView == null) { return(CalcGridInfoResult._Error); } GetLinkInstances(); m_OutViewInfos.Clear(); m_DrawElems.Clear(); m_GridNumShowInfos.Clear(); CalcGridInfoResult result = GetCurrentViewOutLine(bIdling, formRec, ref formSize, ref formLeftTopPt); if (result != CalcGridInfoResult._Succeded) { return(result); } GetAllGridInfo(); GetAllMultiSegmentGridInfo(); GetAllLevelInfo(); GetAllLevelInfoInLinkDoc(); if (m_DrawElems.Count <= 0) { return(CalcGridInfoResult._Error); } GetIntersectPtAndDirection(); if (m_GridNumShowInfos.Count <= 0) { return(CalcGridInfoResult._Error); } return(CalcGridInfoResult._Succeded); }
//获取轴号信息 public CalcGridInfoResult GetGridNumberShowInfo(bool bIdling, DllImportManeger.Rect rcMDIClientWin, ref System.Drawing.Point ptForm, ref Size sizeForm) { if (this.m_uiDoc == null) { return(CalcGridInfoResult.eError); } if (this.m_uiView == null) { IList <UIView> openUIViews = this.m_uiDoc.GetOpenUIViews(); foreach (UIView uiview in openUIViews) { if (uiview.ViewId == this.m_uiDoc.ActiveView.Id) { this.m_uiView = uiview; break; } } } if (this.m_uiView == null) { return(CalcGridInfoResult.eError); } this.GetAllRevitLinkInstancesInDoc(); this.m_lstViewOutLineInfo.Clear(); this.m_lstDrawElems.Clear(); this.m_lstGridNumShowInfo.Clear(); CalcGridInfoResult currentViewOutLine = this.GetCurrentViewOutLine(bIdling, rcMDIClientWin, ref sizeForm, ref ptForm); if (currentViewOutLine != CalcGridInfoResult.eSucceded) { return(currentViewOutLine); } this.GetAllGridInfo(); this.GetAllMultiSegmentGridInfo(); this.GetAllLevelInfo(); this.GetAllLevelInfoInLinkDoc(); if (this.m_lstDrawElems.Count <= 0) { return(CalcGridInfoResult.eError); } this.GetIntersectPtAndDirection(); if (this.m_lstGridNumShowInfo.Count <= 0) { return(CalcGridInfoResult.eError); } return(CalcGridInfoResult.eSucceded); }
// 绘制轴圈/文字 public void DrawGridNumText(bool bIdling = false) { Graphics graphics = base.CreateGraphics(); if (m_uiDoc == null || m_uiDoc.ActiveView == null) { graphics.Clear(System.Drawing.Color.White); graphics.Dispose(); return; } if (!m_appShowGrid.DrawGridNumber || m_uiDoc.ActiveView.ViewType == Autodesk.Revit.DB.ViewType.ThreeD) { graphics.Clear(System.Drawing.Color.White); graphics.Dispose(); return; } Size dlgSzie = default(Size); Point locationPt = Point.Empty; Rect rcMDIClientWin; GetWindowRect(m_hMDIChildHandle, out rcMDIClientWin); CalcGridInfoResult gridNumberShowInfo = m_GridNumShowMag.GetGridNumberShowInfo(bIdling, rcMDIClientWin, ref locationPt, ref dlgSzie); if (gridNumberShowInfo == CalcGridInfoResult._Idling) { return; } base.Location = locationPt; base.Size = dlgSzie; m_GridNumShowMag.TranformIntersectPt(base.Handle); graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.Clear(System.Drawing.Color.White); Brush brush = new SolidBrush(fontColor); Pen pen = new Pen(fontColor, 2f); Font m_font = new Font("微软雅黑", m_FontSize, GraphicsUnit.Pixel); int circleSize = Convert.ToInt32(m_FontSize) + 5; StringFormat bottomStr = new StringFormat(); bottomStr.Alignment = StringAlignment.Center; bottomStr.LineAlignment = StringAlignment.Center; StringFormat leftStr = new StringFormat(); leftStr.Alignment = StringAlignment.Near; leftStr.LineAlignment = StringAlignment.Center; StringFormat rightStr = new StringFormat(); rightStr.Alignment = StringAlignment.Far; rightStr.LineAlignment = StringAlignment.Center; for (int i = 0; i < m_GridNumShowMag.m_GridNumShowInfos.Count; i++) { Point cirlLocation = m_GridNumShowMag.m_GridNumShowInfos[i].CirlLocation; Point textLocation = m_GridNumShowMag.m_GridNumShowInfos[i].TextLocation; string elemText = m_GridNumShowMag.m_GridNumShowInfos[i].ElemText; if (m_GridNumShowMag.m_GridNumShowInfos[i].ElemClass == ElemType._Grid) { //轴号圈大小位置颜色 graphics.DrawArc(pen, cirlLocation.X, cirlLocation.Y, circleSize, circleSize, 0, 360); } switch (m_GridNumShowMag.m_GridNumShowInfos[i].OutlineSide) { case OutViewSide._Up: case OutViewSide._Bottom: graphics.DrawString(elemText, m_font, brush, textLocation, bottomStr); break; case OutViewSide._Left: graphics.DrawString(elemText, m_font, brush, textLocation, leftStr); break; case OutViewSide._Right: graphics.DrawString(elemText, m_font, brush, textLocation, rightStr); break; } } bottomStr.Dispose(); leftStr.Dispose(); rightStr.Dispose(); graphics.Dispose(); }