using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Teigha.DatabaseServices;
using Teigha.Geometry;
using Teigha.Runtime;
using System.Drawing.Design;
using ESRI.ArcGIS.Geometry;
using Teigha.Colors;
using Teigha.GraphicsInterface;
using ESRI.ArcGIS.Display;
using System.Drawing;namespace CADCommonHelper
{public class DatabaseHelper{public DatabaseHelper(){}#region 打开一个已知dwg文件public static Database DbOpen(string dwgpath){// 打开主 CAD 文件if (File.Exists(dwgpath)){Database db = new Database(false, true);db.ReadDwgFile(dwgpath, FileOpenMode.OpenTryForReadShare, true, "");return db;}else{Database db = new Database();db.SaveAs(dwgpath, DwgVersion.vAC18);db.Dispose();Database pdb = new Database(false, true);pdb.ReadDwgFile(dwgpath, FileOpenMode.OpenTryForReadShare, true, "");return pdb;}}public static Database DbOpentempSaveas(string dwgpath){if (File.Exists(dwgpath)){File.Delete(dwgpath);}string temppath = Application.StartupPath + "\\style\\Template.dwt";// 打开主 CAD 文件if (File.Exists(temppath)){Database db = new Database(false, true);db.ReadDwgFile(temppath, FileOpenMode.OpenTryForReadShare, true, "");db.SaveAs(dwgpath, DwgVersion.vAC18);return db;}else{MessageBox.Show("模板文件不存在!");return null;}}#endregion#region 添加一个图层/// /// 添加图层或者查询图层 返回ObjectId/// /// /// /// ObjectIdpublic static Dictionary CreateCADLayer(Database db, HashSet