/// <summary> /// 标注对齐方式 /// </summary> /// <param name="alignment"></param> /// <param name="textHorizontalMode"></param> /// <param name="textVerticalMode"></param> private static void GetLabelAlignment(int alignment, ref TextHorizontalMode textHorizontalMode, ref TextVerticalMode textVerticalMode) { if (alignment == 1 || alignment == 5 || alignment == 9) { textHorizontalMode = TextHorizontalMode.TextLeft; } else if (alignment == 0 || alignment == 4 || alignment == 8) { textHorizontalMode = TextHorizontalMode.TextMid; } else if (alignment == 2 || alignment == 6 || alignment == 10) { textHorizontalMode = TextHorizontalMode.TextRight; } if (alignment == 4 || alignment == 5 || alignment == 6) { textVerticalMode = TextVerticalMode.TextTop; } else if (alignment == 0 || alignment == 1 || alignment == 2) { textVerticalMode = TextVerticalMode.TextVerticalMid; } else if (alignment == 8 || alignment == 9 || alignment == 10) { textVerticalMode = TextVerticalMode.TextBottom; } }
public void CreateMenu() { // 获取当前文档和数据库 Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; List <BlockData> lst = new List <BlockData>(); string blocktype = "INSERT"; SelectionFilter selFtrBlock = blocktype.GetSingleTypeFilter(); SelectionSet ss = doc.GetSelectionSet("请选择图框", selFtrBlock); if (ss != null) { foreach (SelectedObject obj in ss) { BlockData data = db.GetBlockData(obj.ObjectId); if (data.ProjectName != null) { lst.Add(data); } } if (lst.Count > 0) { var orderlst = lst.OrderBy(s => s.DrawingNumber).ToList(); Point3d?inp = ed.GetPointOnScreen("\n共找到" + lst.Count.ToString() + "个图框, 请点击图纸目录左上角点: "); if (inp != null) { Point3d p = (Point3d)inp; double h = 3.5, r = 0, f = 0.75; string t = "SMEDI"; TextHorizontalMode thmode = TextHorizontalMode.TextLeft; TextVerticalMode tvmode = TextVerticalMode.TextBottom; db.AddTextToModeSpace("1", p + new Vector3d(29.78, -69.09, 0), h, r, f, t, thmode, tvmode); db.AddTextToModeSpace((orderlst[0].DrawingNumber.Substring(0, orderlst[0].DrawingNumber.Length - 2) + "00"), p + new Vector3d(41.48, -69.09, 0), h, r, f, t, thmode, tvmode); db.AddTextToModeSpace("图纸目录", p + new Vector3d(78.36, -69.09, 0), h, r, f, t, thmode, tvmode); for (int i = 0; i < orderlst.Count(); i++) { db.AddTextToModeSpace((i + 2).ToString(), p + new Vector3d(29.78, -69.09 - 8 * (i + 1), 0), h, r, f, t, thmode, tvmode); db.AddTextToModeSpace(orderlst[i].DrawingNumber, p + new Vector3d(41.48, -69.09 - 8 * (i + 1), 0), h, r, f, t, thmode, tvmode); db.AddTextToModeSpace(orderlst[i].DrawingName, p + new Vector3d(78.36, -69.09 - 8 * (i + 1), 0), h, r, f, t, thmode, tvmode); } ed.WriteMessage("\n生成完成! "); } } } }
private void TextAlign(TextHorizontalMode TypeOfAlign = TextHorizontalMode.TextLeft) //Функция выравнивает однострочные тексты по заданной точке { //Выбрать объекты ed.WriteMessage("Выберите объекты - однострочные тексты"); PromptSelectionResult sr = ed.GetSelection(); if (sr.Status == PromptStatus.OK) { //http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a9193826455f5ff2566ffd511ff6f8c7ca-422c.htm,topicNumber=d0e10522 Point3d pPtRes; PromptPointOptions pPtOpts = new PromptPointOptions(""); // Prompt for the start point pPtOpts.Message = "\nУкажите точку выравнивания текста: "; pPtRes = ed.GetPoint(pPtOpts).Value; if (pPtRes != null) { Transaction tr = acCurDb.TransactionManager.StartTransaction(); try { ObjectId[] objIds = sr.Value.GetObjectIds(); foreach (ObjectId asObjId in objIds) { DBObject dbo = tr.GetObject(asObjId, OpenMode.ForWrite); try { //Преобразуем объекты к тексту DBText txt = (DBText)dbo; txt.HorizontalMode = TypeOfAlign; Point3d pAlign = new Point3d(pPtRes.X, txt.Position.Y, txt.Position.Z); txt.Position = pAlign; txt.AlignmentPoint = pAlign; } catch { /*Преобразовать не получилось*/ } } ; tr.Commit(); } catch (PlatformDb.Runtime.Exception ex) { ed.WriteMessage(ex.Message); tr.Abort(); }; } ; } }
/// <summary> /// Adds the DB text. /// </summary> /// <param name="trans">The trans.</param> /// <param name="insert">The insert.</param> /// <param name="text">The text.</param> /// <param name="layerId">The layer id.</param> /// <param name="textStyleId">The text style id.</param> /// <param name="height">The height.</param> /// <param name="rotation">The rotation.</param> /// <param name="hoizonatlMode">The hoizonatl mode.</param> /// <returns></returns> public static ObjectId AddDBText(Transaction trans, Point3d insert, string text, string layer, string textStyle, double height, double rotation, TextHorizontalMode horizontalMode) { PGA.MessengerManager.MessengerManager.AddLog("Start AddDBText"); try { var db = Application.DocumentManager.MdiActiveDocument.Database; var id = ObjectId.Null; var itemText = new DBText(); itemText.SetDatabaseDefaults(); itemText.Layer = layer; itemText.Height = height; itemText.Rotation = rotation; itemText.TextString = text; itemText.HorizontalMode = TextHorizontalMode.TextCenter; if (horizontalMode == TextHorizontalMode.TextCenter) { itemText.AlignmentPoint = insert; } else { itemText.Position = insert; } using ( var textStyleTable = (TextStyleTable)trans.GetObject(db.TextStyleTableId, OpenMode.ForRead, false)) { if (textStyleTable.Has(textStyle)) { itemText.TextStyleId = textStyleTable[textStyle]; } } id = AddToDatabase(db, itemText, trans); PGA.MessengerManager.MessengerManager.AddLog("End AddDBText"); return(id); } catch (System.Exception ex) { PGA.MessengerManager.MessengerManager.AddLog("Error in AddDBText ", ex); throw; } }
/// <summary> /// 添加文字 /// </summary> /// <param name="db"></param> /// <param name="point0">文字起始点</param> /// <param name="height0">文字高度</param> /// <param name="str0">文字内容</param> /// <returns>图形的ObjectId</returns> public static ObjectId AddTextToModeSpace(this Database db, string content, Point3d position, double height = 3.5, double rotation = 0, double widthfactor = 0.7, string textstylename = "SMEDI", TextHorizontalMode thmode = TextHorizontalMode.TextCenter, TextVerticalMode tvmode = TextVerticalMode.TextVerticalMid) { DBText text = new DBText(); text.TextString = content; text.Position = position; text.Height = height; text.Rotation = rotation; text.WidthFactor = widthfactor; text.TextStyleId = db.GetTextStyleId(textstylename); text.HorizontalMode = thmode; text.VerticalMode = tvmode; text.AlignmentPoint = text.Position; return(db.AddEntityToModeSpace(text)); }
private static DBText addText(BlockTableRecord btr, Transaction t, Point3d pt, string value, double height, TextHorizontalMode horMode = TextHorizontalMode.TextCenter) { // Подпись развертки - номер вида DBText text = new DBText(); text.SetDatabaseDefaults(); text.Height = height; text.TextStyleId = IdTextStylePik; text.TextString = value; if (horMode == TextHorizontalMode.TextLeft) { text.Position = pt; } else { text.HorizontalMode = horMode; text.AlignmentPoint = pt; text.AdjustAlignment(btr.Database); } btr.AppendEntity(text); t.AddNewlyCreatedDBObject(text, true); return(text); }
private static DBText addText(BlockTableRecord btr, Transaction t, Point3d pt, string value, double height, TextHorizontalMode horMode = TextHorizontalMode.TextCenter) { // Подпись развертки - номер вида DBText text = new DBText(); text.SetDatabaseDefaults(); text.Height = height; text.TextStyleId = IdTextStylePik; text.TextString = value; if (horMode == TextHorizontalMode.TextLeft) { text.Position = pt; } else { text.HorizontalMode = horMode; text.AlignmentPoint = pt; text.AdjustAlignment(btr.Database); } btr.AppendEntity(text); t.AddNewlyCreatedDBObject(text, true); return text; }
public void PrintChainage() { if (!CheckLicense.Check()) { return; } Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database; ObjectId textStyleId = ObjectId.Null; using (Transaction tr = db.TransactionManager.StartTransaction()) using (TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead)) { if (tt.Has(TextStyleName)) { textStyleId = tt[TextStyleName]; } tr.Commit(); } Matrix3d ucs2wcs = AcadUtility.AcadGraphics.UcsToWcs; Matrix3d wcs2ucs = AcadUtility.AcadGraphics.WcsToUcs; // Pick polyline bool flag = true; ObjectId centerlineId = ObjectId.Null; while (flag) { PromptEntityOptions entityOpts = new PromptEntityOptions("\nEksen: [Seçenekler]", "Settings"); entityOpts.SetRejectMessage("\nSelect a curve."); entityOpts.AddAllowedClass(typeof(Curve), false); PromptEntityResult entityRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetEntity(entityOpts); if (entityRes.Status == PromptStatus.Keyword && entityRes.StringResult == "Settings") { ShowSettings(); continue; } else if (entityRes.Status == PromptStatus.OK) { centerlineId = entityRes.ObjectId; break; } else { return; } } // Start point Point3d startPoint; PromptPointResult pointRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetPoint("\nBaşlangıç Noktası: "); if (pointRes.Status == PromptStatus.OK) { startPoint = pointRes.Value.TransformBy(ucs2wcs); } else { return; } // Start CH string startCH = ""; PromptResult stringRes = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.GetString("\nBaşlangıç KM: <0+000.00>"); startCH = stringRes.StringResult; if (stringRes.Status == PromptStatus.None) { startCH = "0+000.00"; } else if (stringRes.Status != PromptStatus.OK) { return; } // Print chainages using (Transaction tr = db.TransactionManager.StartTransaction()) using (BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)) using (TextStyleTable tt = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead)) { Autodesk.AutoCAD.DatabaseServices.Curve centerline = tr.GetObject(centerlineId, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Curve; if (centerline != null) { double curveStartCH = AcadText.ChainageFromString(startCH) - centerline.GetDistAtPoint(startPoint); double distToNearestInterval = Math.Ceiling(curveStartCH / Interval) * Interval - curveStartCH; double currentDistance = distToNearestInterval; double curveLength = centerline.GetDistanceAtParameter(centerline.EndParam); while (currentDistance < curveLength) { string currentCH = AcadText.ChainageToString(currentDistance + curveStartCH, Precision); Point3d currentPoint = centerline.GetPointAtDist(currentDistance); Vector3d perp = centerline.GetFirstDerivative(currentPoint).RotateBy(Math.PI / 2.0, Vector3d.ZAxis); perp /= perp.Length; Point3d lineStart = currentPoint + perp * TextHeight / 2.0; Point3d lineEnd = currentPoint - perp * TextHeight / 2.0; Point3d textStart = currentPoint + perp * TextHeight / 2.0 * 1.2; // Tick mark Line line = new Line(); line.StartPoint = lineStart; line.EndPoint = lineEnd; btr.AppendEntity(line); tr.AddNewlyCreatedDBObject(line, true); // CH text double textRotation = Vector3d.XAxis.GetAngleTo(perp, Vector3d.ZAxis); double rot = textRotation * 180 / Math.PI; TextHorizontalMode textHorizontalMode = TextHorizontalMode.TextLeft; if (rot > 90.0 && rot < 270.0) { textRotation = textRotation + Math.PI; textHorizontalMode = TextHorizontalMode.TextRight; } textStyleId = ObjectId.Null; if (tt.Has(TextStyleName)) { textStyleId = tt[TextStyleName]; } DBText text = AcadEntity.CreateText(db, textStart, currentCH, TextHeight, textRotation, 0.8, textHorizontalMode, TextVerticalMode.TextVerticalMid, textStyleId); btr.AppendEntity(text); tr.AddNewlyCreatedDBObject(text, true); currentDistance += Interval; } } tr.Commit(); } }
protected override SamplerStatus Sampler(JigPrompts jp) { // We acquire a point but with keywords JigPromptPointOptions po = new JigPromptPointOptions( "\nPosition of text"); po.UserInputControls = UserInputControls.Accept3dCoordinates | UserInputControls.NullResponseAccepted | UserInputControls.NoNegativeResponseAccepted | UserInputControls.GovernedByOrthoMode; po.SetMessageAndKeywords( "\nSpecify position of text or [Bold/Italic/LArger/Smaller/ROtate90/LEft/Middle/RIght]: ", "Bold Italic LArger Smaller ROtate90 LEft Middle RIght"); PromptPointResult ppr = jp.AcquirePoint(po); if (ppr.Status == PromptStatus.Keyword) { switch (ppr.StringResult) { case "Bold": { _toggleBold = true; break; } case "Italic": { _toggleItalic = true; break; } case "LArger": { // Multiple the text size by two _txtSize *= 2; break; } case "Smaller": { // Divide the text size by two _txtSize /= 2; break; } case "ROtate90": { // To rotate clockwise we subtract 90 degrees and // then normalize the angle between 0 and 360 _angle -= Math.PI / 2; while (_angle < Math.PI * 2) { _angle += Math.PI * 2; } break; } case "LEft": { _align = TextHorizontalMode.TextLeft; break; } case "RIght": { _align = TextHorizontalMode.TextRight; break; } case "Middle": { _align = TextHorizontalMode.TextMid; break; } } return(SamplerStatus.OK); } else if (ppr.Status == PromptStatus.OK) { // Check if it has changed or not (reduces flicker) if (_position.DistanceTo(ppr.Value) < Tolerance.Global.EqualPoint) { return(SamplerStatus.NoChange); } _position = ppr.Value; return(SamplerStatus.OK); } return(SamplerStatus.Cancel); }
/// <summary> 在不改变单行文字定位的情况下,修改其对齐方式。默认为默认的左对齐 </summary> /// <param name="txt"></param> /// <param name="horiMode">水平对齐方式</param> /// <param name="vertMode">竖直对齐方式</param> public static void SetAlignment(this DBText txt, TextVerticalMode vertMode = TextVerticalMode.TextBase, TextHorizontalMode horiMode = TextHorizontalMode.TextLeft) { var originalPosition = txt.Position; // 1. 计算出变形后的 AlignmentPoint。 // 注:除了“布满”与“对齐”这两种对正方式外,其他的对齐方式在互相转换时,AlignmentPoint 是不变的,其计算方式如下面代码; // 而“布满”与“对齐”这两种对正方式,会改变单行文字的宽度,所以在切换时,AlignmentPoint 会略有变化。 Point3d alignPt = txt.IsDefaultAlignment ? originalPosition : txt.AlignmentPoint; // 2. 设置对齐后,其 AlignmentPoint 会被自动设置到 {0,0,0},而且其 Position 属性被屏蔽,设置其值无效。 txt.HorizontalMode = horiMode; txt.VerticalMode = vertMode; // 3. 调整文字定位 if (txt.IsDefaultAlignment) { // AlignmentPoint 始终为 {0,0,0},此时通过设置 Position来控制其定位 txt.Position = originalPosition; } else { // Position 属性无效,此时通过设置 AlignmentPoint 来控制其定位 // 注意设置对齐后的 txt.AlignmentPoint 也可能是无效的{0,0,0},所以要用前面计算得到的 对齐点 txt.AlignmentPoint = originalPosition.Add(txt.Position.GetVectorTo(alignPt)); } }
//-------------------------------------------------------------------------- // // ���ܣ�������Զ�������� // // ���ߣ� // // ���ڣ�200708 // // ��ʷ�� //-------------------------------------------------------------------------- private void SetAttributeDefinition(string tag, Point3d position, double height, Autodesk.AutoCAD.Colors.Color color, TextVerticalMode vertMode, TextHorizontalMode horzMode, string expressionString, Point3d alignmentPoint) { using (Transaction trans = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction()) { //����ע������ ObjectId idTagText; idTagText = m_annotations[m_templateName].CreateAnnotationText(); // AttributeDefinition tagText = null; tagText = trans.GetObject(idTagText, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite) as AttributeDefinition; if (null == tagText) { MessageBox.Show("����ע������ʧ�ܡ�"); return; } // ����Ƿ���ע������ if (!m_annotations.IsAnnotationText(tagText)) { MessageBox.Show(string.Format("�����ж�{0} Ϊע������", tag)); return; } tagText.Position = position; tagText.Tag = tag; tagText.Height = height; tagText.Color = color; tagText.VerticalMode = vertMode; tagText.HorizontalMode = horzMode; tagText.AlignmentPoint = alignmentPoint; m_annotations.SetExpressionString(tagText, AnnotationExpressionFields.AttributeDefinitionAnnotationString, expressionString); // For OD ":Column_Name@Table_Name" // ʹ�� Annotation.TextLayer���ò�. m_annotations.SetExpressionString(tagText, AnnotationExpressionFields.AttributeDefinitionTextLayer, "Layer1"); string newTemplateName = null; newTemplateName = textbTemplateName.Text; // ���ÿ鶨�����ɫ Autodesk.AutoCAD.Colors.Color redClr = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.None, 1); m_annotations[newTemplateName].Color = redClr; //����ע����� trans.Commit(); } }
public static AttributeDefinition CreateAttribute(Database db, Point3d pt, string tag, string prompt, string text, double textHeight, double rotation, double widthFactor, TextHorizontalMode horizontalMode, TextVerticalMode verticalMode, ObjectId textStyleId, ObjectId layerId) { using (CurrentDB curr = new CurrentDB(db)) { AttributeDefinition attdef = new AttributeDefinition(); attdef.SetDatabaseDefaults(db); attdef.Tag = tag; attdef.Prompt = prompt; attdef.TextString = text; attdef.Position = pt; attdef.Height = textHeight; attdef.Rotation = rotation; attdef.WidthFactor = widthFactor; if (horizontalMode == TextHorizontalMode.TextLeft) { if (verticalMode == TextVerticalMode.TextTop) { attdef.Justify = AttachmentPoint.TopLeft; } else if (verticalMode == TextVerticalMode.TextBase) { attdef.Justify = AttachmentPoint.BaseLeft; } else if (verticalMode == TextVerticalMode.TextBottom) { attdef.Justify = AttachmentPoint.BottomLeft; } else { attdef.Justify = AttachmentPoint.MiddleLeft; } } else if (horizontalMode == TextHorizontalMode.TextRight) { if (verticalMode == TextVerticalMode.TextTop) { attdef.Justify = AttachmentPoint.TopRight; } else if (verticalMode == TextVerticalMode.TextBase) { attdef.Justify = AttachmentPoint.BaseRight; } else if (verticalMode == TextVerticalMode.TextBottom) { attdef.Justify = AttachmentPoint.BottomRight; } else { attdef.Justify = AttachmentPoint.MiddleRight; } } else if (horizontalMode == TextHorizontalMode.TextMid || horizontalMode == TextHorizontalMode.TextCenter) { if (verticalMode == TextVerticalMode.TextTop) { attdef.Justify = AttachmentPoint.TopCenter; } else if (verticalMode == TextVerticalMode.TextBase) { attdef.Justify = AttachmentPoint.BaseCenter; } else if (verticalMode == TextVerticalMode.TextBottom) { attdef.Justify = AttachmentPoint.BottomCenter; } else { attdef.Justify = AttachmentPoint.MiddleCenter; } } else if (horizontalMode == TextHorizontalMode.TextAlign) { if (verticalMode == TextVerticalMode.TextTop) { attdef.Justify = AttachmentPoint.TopAlign; } else if (verticalMode == TextVerticalMode.TextBase) { attdef.Justify = AttachmentPoint.BaseAlign; } else if (verticalMode == TextVerticalMode.TextBottom) { attdef.Justify = AttachmentPoint.BottomAlign; } else { attdef.Justify = AttachmentPoint.MiddleAlign; } } else if (horizontalMode == TextHorizontalMode.TextFit) { if (verticalMode == TextVerticalMode.TextTop) { attdef.Justify = AttachmentPoint.TopFit; } else if (verticalMode == TextVerticalMode.TextBase) { attdef.Justify = AttachmentPoint.BaseFit; } else if (verticalMode == TextVerticalMode.TextBottom) { attdef.Justify = AttachmentPoint.BottomFit; } else { attdef.Justify = AttachmentPoint.MiddleFit; } } if (horizontalMode != TextHorizontalMode.TextLeft || verticalMode != TextVerticalMode.TextBase) { attdef.AlignmentPoint = pt; attdef.AdjustAlignment(db); } if (!textStyleId.IsNull) { attdef.TextStyleId = textStyleId; } if (!layerId.IsNull) { attdef.LayerId = layerId; } return(attdef); } }
public static DBText CreateText(Database db, Point3d pt, string text, double textHeight, double rotation, double widthFactor, TextHorizontalMode horizontalMode, TextVerticalMode verticalMode) { return(CreateText(db, pt, text, textHeight, rotation, widthFactor, horizontalMode, verticalMode, ObjectId.Null, ObjectId.Null)); }
public static DBText CreateText(Database db, Point3d pt, string text, double textHeight, double rotation, double widthFactor, TextHorizontalMode horizontalMode, TextVerticalMode verticalMode, ObjectId textStyleId, ObjectId layerId) { using (CurrentDB curr = new CurrentDB(db)) { DBText dbtext = new DBText(); dbtext.SetDatabaseDefaults(db); dbtext.TextString = text; dbtext.Position = pt; dbtext.Height = textHeight; dbtext.Rotation = rotation; dbtext.WidthFactor = widthFactor; if (horizontalMode == TextHorizontalMode.TextLeft) { if (verticalMode == TextVerticalMode.TextTop) { dbtext.Justify = AttachmentPoint.TopLeft; } else if (verticalMode == TextVerticalMode.TextBase) { dbtext.Justify = AttachmentPoint.BaseLeft; } else if (verticalMode == TextVerticalMode.TextBottom) { dbtext.Justify = AttachmentPoint.BottomLeft; } else { dbtext.Justify = AttachmentPoint.MiddleLeft; } } else if (horizontalMode == TextHorizontalMode.TextRight) { if (verticalMode == TextVerticalMode.TextTop) { dbtext.Justify = AttachmentPoint.TopRight; } else if (verticalMode == TextVerticalMode.TextBase) { dbtext.Justify = AttachmentPoint.BaseRight; } else if (verticalMode == TextVerticalMode.TextBottom) { dbtext.Justify = AttachmentPoint.BottomRight; } else { dbtext.Justify = AttachmentPoint.MiddleRight; } } else if (horizontalMode == TextHorizontalMode.TextMid || horizontalMode == TextHorizontalMode.TextCenter) { if (verticalMode == TextVerticalMode.TextTop) { dbtext.Justify = AttachmentPoint.TopCenter; } else if (verticalMode == TextVerticalMode.TextBase) { dbtext.Justify = AttachmentPoint.BaseCenter; } else if (verticalMode == TextVerticalMode.TextBottom) { dbtext.Justify = AttachmentPoint.BottomCenter; } else { dbtext.Justify = AttachmentPoint.MiddleCenter; } } else if (horizontalMode == TextHorizontalMode.TextAlign) { if (verticalMode == TextVerticalMode.TextTop) { dbtext.Justify = AttachmentPoint.TopAlign; } else if (verticalMode == TextVerticalMode.TextBase) { dbtext.Justify = AttachmentPoint.BaseAlign; } else if (verticalMode == TextVerticalMode.TextBottom) { dbtext.Justify = AttachmentPoint.BottomAlign; } else { dbtext.Justify = AttachmentPoint.MiddleAlign; } } else if (horizontalMode == TextHorizontalMode.TextFit) { if (verticalMode == TextVerticalMode.TextTop) { dbtext.Justify = AttachmentPoint.TopFit; } else if (verticalMode == TextVerticalMode.TextBase) { dbtext.Justify = AttachmentPoint.BaseFit; } else if (verticalMode == TextVerticalMode.TextBottom) { dbtext.Justify = AttachmentPoint.BottomFit; } else { dbtext.Justify = AttachmentPoint.MiddleFit; } } if (horizontalMode != TextHorizontalMode.TextLeft || verticalMode != TextVerticalMode.TextBase) { dbtext.AlignmentPoint = pt; dbtext.AdjustAlignment(db); } if (!textStyleId.IsNull) { dbtext.TextStyleId = textStyleId; } if (!layerId.IsNull) { dbtext.LayerId = layerId; } return(dbtext); } }