SystemManager类-
-
- using System;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.GraphicsSystem;
- namespace TlsCad.Runtime
- {
- public static class SystemManager
- {
- #region Goal
- public static Database CurrentDatabase
- {
- get
- {
- return HostApplicationServices.WorkingDatabase;
- }
- }
- public static Document ActiveDocument
- {
- get
- {
- return Application.DocumentManager.MdiActiveDocument;
- }
- }
- public static Editor Editor
- {
- get
- {
- return ActiveDocument.Editor;
- }
- }
- public static Manager GsManager
- {
- get
- {
- return ActiveDocument.GraphicsManager;
- }
- }
- #endregion
- #region Preferences
- public static object GetCurrentProfileProperty(string subSectionName, string propertyName)
- {
- UserConfigurationManager ucm = Application.UserConfigurationManager;
- IConfigurationSection cpf = ucm.OpenCurrentProfile();
- IConfigurationSection ss = cpf.OpenSubsection(subSectionName);
- return ss.ReadProperty(propertyName, "");
- }
- public static IConfigurationSection GetDialogSection(object dialog, string propertyName)
- {
- UserConfigurationManager ucm = Application.UserConfigurationManager;
- IConfigurationSection ds = ucm.OpenDialogSection(dialog);
- return ds;
- }
- public static IConfigurationSection GetGlobalSection(string propertyName)
- {
- UserConfigurationManager ucm = Application.UserConfigurationManager;
- IConfigurationSection gs = ucm.OpenGlobalSection();
- IConfigurationSection ss = gs.OpenSubsection(propertyName);
- return ss;
- }
- #endregion
- #region Enum
- private static T ToEnum(this string value)
- {
- return (T)Enum.Parse(typeof(T), value, true);
- }
- private static string GetName(this T value)
- {
- return Enum.GetName(typeof(T), value);
- }
-
- #region Dimblk
- public enum DimblkType
- {
- Defult,
- Dot,
- DotSmall,
- DotBlank,
- Origin,
- Origin2,
- Open,
- Open90,
- Open30,
- Closed,
- Small,
- None,
- Oblique,
- BoxFilled,
- BoxBlank,
- ClosedBlank,
- DatumFilled,
- DatumBlank,
- Integral,
- ArchTick,
- }
- public static DimblkType Dimblk
- {
- get
- {
- string s = (string)Application.GetSystemVariable("dimblk");
- if (s == "" || s == null)
- {
- return DimblkType.Defult;
- }
- else
- {
- return s.ToEnum();
- }
- }
- set
- {
- string s =
- value == DimblkType.Defult ?
- "." : "_" + value.GetName();
- Application.SetSystemVariable("dimblk", s);
|