本文整理汇总了C#中Viewport.SetDatabaseDefaults方法的典型用法代码示例。如果您正苦于以下问题:C# Viewport.SetDatabaseDefaults方法的具体用法?C# Viewport.SetDatabaseDefaults怎么用?C# Viewport.SetDatabaseDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport.SetDatabaseDefaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateViewport
/// <summary>
/// Метод создаёт Viewport на заданном Layout, в размер листа
/// </summary>
/// <param name="layout">Layout, на котором создаётся viewport</param>
/// <param name="borders">Границы выделенной области в модели</param>
void CreateViewport(Layout layout, DrawingBorders borders, Transaction tr)
{
int vpCount = layout.GetViewports().Count;
if (vpCount == 0)
{
throw new System.Exception(String.Format("Layout {0} не инициализирован", layout.LayoutName));
}
Viewport vp;
if (vpCount == 1)
{
BlockTableRecord lbtr =
(BlockTableRecord)tr.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite);
vp = new Viewport();
vp.SetDatabaseDefaults();
lbtr.AppendEntity(vp);
tr.AddNewlyCreatedDBObject(vp, true);
vp.On = true;
}
else
{
ObjectId vpId = layout.GetViewports()[vpCount-1];
if (vpId.IsNull)
throw new System.Exception("Не удалось получить вьюпорт!");
vp = (Viewport)tr.GetObject(vpId, OpenMode.ForWrite);
if (vp == null)
throw new System.Exception("Не удалось получить вьюпорт!");
}
// Высоту и ширину вьюпорта выставляем в размер выделенной области
vp.Height = borders.Height / borders.ScaleFactor;
vp.Width = borders.Width / borders.ScaleFactor;
vp.CenterPoint = new Point3d(vp.Width/2 + layout.PlotOrigin.X,
vp.Height/2 + layout.PlotOrigin.Y,
0);
vp.ViewTarget = new Point3d(0,0,0);
vp.ViewHeight = borders.Height;
vp.ViewCenter = new Point2d(borders.Center.X, borders.Center.Y);
vp.Locked = LayoutsFromModel.Configuration.AppConfig.Instance.LockViewPorts;
}
示例2: createLayout
private static void createLayout(Polyline pl, int layout, double widthLay, double heightLay, Transaction t)
{
LayoutManager lm = LayoutManager.Current;
var idLay = lm.CreateLayout(layout.ToString());
var extPl = pl.GeometricExtents;
using (var lay = idLay.GetObject( OpenMode.ForWrite)as Layout)
{
var btrLay = lay.BlockTableRecordId.GetObject( OpenMode.ForWrite)as BlockTableRecord;
Viewport view = new Viewport();
view.SetDatabaseDefaults();
btrLay.AppendEntity(view);
t.AddNewlyCreatedDBObject(view, true);
view.Width = widthLay;
view.Height = heightLay;
view.CenterPoint = new Point3d(widthLay*0.5, heightLay*0.5, 0);
view.On = true;
view.ViewCenter = extPl.Center().Convert2d();
var hvp = extPl.MaxPoint.Y - extPl.MinPoint.Y;
var wvp = extPl.MaxPoint.X - extPl.MinPoint.X;
var aspect = view.Width / view.Height;
if (wvp/hvp>aspect)
{
hvp = wvp / aspect;
}
view.ViewHeight = hvp;
view.CustomScale = 1;
}
}