[CommandMethod("0TextToTable")]
public static void CreateTableStyle()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (var tr = db.TransactionManager.StartTransaction())
{
var tst = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
ObjectId romansID;
if (tst.Has("BasicText"))
{
romansID = tst["BasicText"];
}
else
{
romansID = db.Textstyle;
}
var tsd = (DBDictionary)tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead);
if (!tsd.Contains("AuxiliaryDocuments"))
{
var ts = new TableStyle();
ts.SetTextHeight(5, (int)RowType.TitleRow);
ts.SetColor((Color.FromColorIndex(ColorMethod.ByAci, 1)), (int)RowType.TitleRow);
ts.SetAlignment(CellAlignment.MiddleCenter, (int)RowType.TitleRow);
ts.SetTextHeight(4.5, (int)RowType.HeaderRow);
ts.SetAlignment(CellAlignment.MiddleCenter, (int)RowType.HeaderRow);
ts.SetTextHeight(3, (int)RowType.DataRow);
ts.SetAlignment(CellAlignment.MiddleLeft, (int)RowType.DataRow);
ts.SetTextStyle(romansID, (int)(RowType.TitleRow | RowType.HeaderRow | RowType.DataRow));
ts.HorizontalCellMargin = 0.5;
ts.VerticalCellMargin = 0.5;
ts.SetGridLineWeight(LineWeight.LineWeight060, (int)GridLineType.AllGridLines, (int)RowType.HeaderRow);
ts.SetGridLineWeight(LineWeight.LineWeight060, (int)GridLineType.AllGridLines, (int)RowType.TitleRow);
ts.SetGridLineWeight(LineWeight.LineWeight060, (int)GridLineType.OuterGridLines, (int)RowType.DataRow);
ts.FlowDirection = FlowDirection.BottomToTop;
//ts.SetGridColor(
// Color.FromColorIndex(ColorMethod.ByAci, 2),
// (int)GridLineType.AllGridLines, (int)RowType.DataRow);
//ts.SetGridColor(
// Color.FromColorIndex(ColorMethod.ByAci, 3),
// (int)GridLineType.AllGridLines, (int)RowType.HeaderRow);
//ts.SetGridColor(
// Color.FromColorIndex(ColorMethod.ByAci, 4),
// (int)GridLineType.AllGridLines, (int)RowType.TitleRow);
tsd.UpgradeOpen();
tsd.SetAt("AuxiliaryDocuments", ts);
tr.AddNewlyCreatedDBObject(ts, true);
}
tr.Commit();
}
}