改写自Kean的BlockView.Net
加入显示实体的功能
并集成输出图像文件的功能
BlockPreviewManager.cs
-
- using System;
- using System.IO;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Collections;
- using System.Collections.Generic;
- using Autodesk..GraphicsSystem;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.GraphicsInterface;
- using Autodesk.AutoCAD.ApplicationServices;
- using TlsCad.Utils;
- using TlsCad.ExtendMethods;
- namespace TlsCad.Trans
- {
- public class BlockPreviewManager : IEnumerable,IDisposable
- {
- List[B] m_Previews = new List[B]();
- Color m_BackColor = Color.Empty;
- Database m_Database = null;
- private Autodesk.AutoCAD.GraphicsSystem.RenderMode m_RenderMode = Autodesk.AutoCAD.GraphicsSystem.RenderMode.Wireframe;
- private VisualStyleType m_VisualStyleType = VisualStyleType.Basic;
- bool m_AllowMouseEvents = false;
- bool m_DisplayByBlock = true;
- #region Properties
- public Autodesk.AutoCAD.GraphicsSystem.RenderMode RenderMode
- {
- set { m_RenderMode = value; }
- get { return m_RenderMode; }
- }
- public VisualStyleType ViewStyle
- {
- set { m_VisualStyleType = value; }
- get { return m_VisualStyleType; }
- }
- public Database Database
- {
- get { return m_Database; }
- }
- public Color BackColor
- {
- set { m_BackColor = value; }
- get { return m_BackColor; }
- }
- public bool AllowMouseEvents
- {
- set { m_AllowMouseEvents = true; }
- get { return m_AllowMouseEvents; }
- }
- public bool DisplayByBlock
- {
- get { return m_DisplayByBlock; }
- set { m_DisplayByBlock = value; }
- }
- public BlockPreview this[int index]
- {
- get
- {
- if (index >= 0 && index ents = new List();
- foreach (ObjectId id in btr)
- {
- ents.Add((Entity)tr.GetObject(id, OpenMode.ForRead).Clone());
- }
- return Add(panel, ents, ext3d);
- }
- }
- }
- return null;
- }
- public BlockPreview Add(Panel panel, BlockTableRecord btr, Extents3d ext3d)
- {
- BlockPreview bp =
- new BlockPreview(
- this,
- panel,
- btr,
- ext3d);
- m_Previews.Add(bp);
- return bp;
- }
- public BlockPreview Add(Panel panel, List ents, Extents3d ext3d)
- {
- BlockPreview bp =
- new BlockPreview(
- this,
- panel,
- ents,
- ext3d);
- m_Previews.Add(bp);
- return bp;
- }
- public BlockPreview Add(IEnumerable ents, Extents3d ext3d)
- {
- BlockPreview bp =
- new BlockPreview(
- this,
- ents,
- ext3d);
- m_Previews.Add(bp);
- return bp;
- }
- public BlockPreview Add(IEnumerable ents)
- {
- BlockPreview bp =
- new BlockPreview(
- this,
- ents,
- DbUtility.GetExtents(ents));
- m_Previews.Add(bp);
- return bp;
- }
- public void RemoveAt(int index)
- {
- if (index >= 0 && index = 0 && index ents = new List();
-
- foreach (ObjectId id in btr)
- {
|