当前位置: 首页>>代码示例>>C#>>正文


C# Viewport.SetDatabaseDefaults方法代码示例

本文整理汇总了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;
        }
开发者ID:bargool,项目名称:LayoutsFromModel,代码行数:44,代码来源:LayoutCreator.cs

示例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;
            }
        }
开发者ID:vildar82,项目名称:AcadLib,代码行数:38,代码来源:ColorBookHelper.cs


注:本文中的Viewport.SetDatabaseDefaults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。