public CommandsManager(IXExtension addIn, IXApplication app, IMacroRunner macroRunner, IMessageService msg, ISettingsProvider settsProvider, IToolbarConfigurationProvider toolbarConfProvider, IXLogger logger) { m_AddIn = addIn; m_App = app; m_MacroRunner = macroRunner; m_Msg = msg; m_SettsProvider = settsProvider; m_ToolbarConfProvider = toolbarConfProvider; m_Logger = logger; m_CachedToggleStates = new Dictionary <CommandMacroInfo, bool>(); m_StateResolvers = new ConcurrentDictionary <CommandMacroInfo, IToggleButtonStateResolver>(); try { ToolbarInfo = LoadUserToolbar(); } catch (Exception ex) { m_Msg.ShowError(ex, "Failed to load toolbar specification"); } }
public AddInHost(ICadExtensionApplication app, IInitiator initiator) { m_App = app; m_Initiator = initiator; try { m_Initiator.Init(this); Extension = m_App.Extension; m_RegisteredCommands = new List <Tuple <EnumCommandGroupSpec, Delegate> >(); m_Handlers = new Dictionary <CommandSpec, Tuple <Delegate, Enum> >(); Extension.StartupCompleted += OnStartupCompleted; Extension.Connect += OnExtensionConnect; Extension.Disconnect += OnExtensionDisconnect; if (Extension is IXServiceConsumer) { (Extension as IXServiceConsumer).ConfigureServices += OnConfigureExtensionServices; } m_ModulesLoader = new ModulesLoader(); m_Modules = m_ModulesLoader.Load(this, app.GetType()); } catch (Exception ex) { new GenericMessageService("CAD+").ShowError(ex, "Failed to init add-in"); new AppLogger().Log(ex); throw; } }
public BaseCustomFeatureEditor(IXApplication app, IXExtension ext, Type featDefType, CustomFeatureParametersParser paramsParser, DataConverterDelegate <TPage, TData> pageToDataConv, DataConverterDelegate <TData, TPage> dataToPageConv, CreateGeometryDelegate <TData> geomCreator) { m_App = app; m_FeatDefType = featDefType; if (!typeof(IXCustomFeatureDefinition <TData>).IsAssignableFrom(m_FeatDefType)) { throw new InvalidCastException($"{m_FeatDefType.FullName} must implement {typeof(IXCustomFeatureDefinition<TData>).FullName}"); } m_PageToDataConv = pageToDataConv; m_DataToPageConv = dataToPageConv; m_GeomCreator = geomCreator; m_BodiesComparer = new XObjectEqualityComparer <IXBody>(); m_PmPage = ext.CreatePage <TPage>(); m_ParamsParser = paramsParser; m_PmPage.Closing += OnPageClosing; m_PmPage.DataChanged += OnDataChanged; m_PmPage.Closed += OnPageClosed; }
public AddInController(IXExtension ext) { AppDomain.CurrentDomain.ResolveBindingRedirects(new LocalAppConfigBindingRedirectReferenceResolver()); m_HostModule = new AddInHostModule(ext); m_Ext = ext; var cmdGrp = ext.CommandManager.AddCommandGroup <CadPlusCommands_e>(); cmdGrp.CommandClick += OnCommandClick; var modulesDir = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "Modules"); var catalog = CreateDirectoryCatalog(modulesDir, "*.Module.dll"); var container = new CompositionContainer(catalog); container.SatisfyImportsOnce(this); if (m_Modules?.Any() == true) { foreach (var module in m_Modules) { module.Load(ext); } } }
public static IXCustomFeatureEditor <TData, TData> CreateCustomFeatureEditor <TCustomFeatureDef, TData>( this IXExtension ext, CreateGeometryDelegate <TData> geomCreator) where TCustomFeatureDef : class, IXCustomFeatureDefinition <TData>, new() where TData : class, new() { return(ext.CreateCustomFeatureEditor <TCustomFeatureDef, TData, TData>( d => d, d => d, geomCreator)); }
public static IXCustomFeatureEditor <TData, TPage> CreateCustomFeatureEditor <TCustomFeatureDef, TData, TPage>( this IXExtension ext, DataConverterDelegate <TPage, TData> pageToDataConv, DataConverterDelegate <TData, TPage> dataToPageConv, CreateGeometryDelegate <TData> geomCreator) where TCustomFeatureDef : class, IXCustomFeatureDefinition <TData>, new() where TData : class, new() where TPage : class, new() { return(ext.CreateCustomFeatureEditor <TData, TPage>(typeof(TCustomFeatureDef), pageToDataConv, dataToPageConv, geomCreator)); }
public IssuesManagerController(IXExtension ext) { m_Ext = ext; m_Ext.Application.Documents.RegisterHandler <IssuesDocument>(); m_Ext.Application.Documents.DocumentLoaded += OnDocumentLoaded; m_TaskPane = m_Ext.CreateTaskPane <IssuesControl, IssuesMgrCommands_e>(); m_IssuesControl = m_TaskPane.Control; m_TaskPane.ButtonClick += OnTaskPaneButtonClick; }
public CommandsManager(IXExtension addIn, IXApplication app, IMacroRunner macroRunner, IMessageService msg, IXLogger logger, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver) { m_AddIn = addIn; m_App = app; m_MacroRunner = macroRunner; m_Msg = msg; m_Logger = logger; m_IconsProviders = iconsProviders; m_CachedToggleStates = new Dictionary <CommandMacroInfo, bool>(); m_StateResolvers = new ConcurrentDictionary <CommandMacroInfo, IToggleButtonStateResolver>(); m_PathResolver = pathResolver; }
public InsertQrCodeFeature(IXExtension ext, IMessageService msgSvc, IXLogger logger, IDocumentAdapter docAdapter) { m_App = ext.Application; m_MsgSvc = msgSvc; m_Logger = logger; m_InsertQrCodePage = ext.CreatePage <QrCodeData>(); m_CurInsertQrCodePageData = new QrCodeData(); m_QrDataProvider = new QrDataProvider(m_App, m_Logger, docAdapter); m_QrCodeManager = new QrCodePictureManager(m_App, m_QrDataProvider); m_InsertQrCodePage.DataChanged += OnPageDataChanged; m_InsertQrCodePage.Closed += OnInserQrCodePageClosed; m_InsertQrCodePage.Closing += OnInsertQrCodePageClosing; }
private void OnExtensionConnect(IXExtension ext) { try { var cmdGrp = Extension.CommandManager.AddCommandGroup <CadPlusCommands_e>(); cmdGrp.CommandClick += OnCommandClick; m_ParentGrpSpec = cmdGrp.Spec; Connect?.Invoke(); } catch { new GenericMessageService("CAD+").ShowError("Failed to connect add-in"); throw; } }
public AddInHostApplication(IXExtension ext) { try { Extension = ext; m_NextId = ROOT_GROUP_ID + 1; m_Handlers = new Dictionary <CommandSpec, Tuple <Delegate, Enum> >(); Extension.StartupCompleted += OnStartupCompleted; Extension.Connect += OnExtensionConnect; Extension.Disconnect += OnExtensionDisconnect; if (Extension is IXServiceConsumer) { (Extension as IXServiceConsumer).ConfigureServices += OnConfigureExtensionServices; } var modulesDir = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "Modules"); var catalog = CreateDirectoryCatalog(modulesDir, "*.Module.dll"); var container = new CompositionContainer(catalog); container.SatisfyImportsOnce(this); if (m_Modules?.Any() == true) { foreach (var module in m_Modules) { module.Init(this); } } Initialized?.Invoke(); } catch { new GenericMessageService("CAD+").ShowError("Failed to init add-in"); throw; } }
public CommandsManager(IXExtension addIn, IXApplication app, IMacroRunner macroRunner, IMessageService msg, ISettingsProvider settsProvider, IToolbarConfigurationProvider toolbarConfProvider, IXLogger logger) { m_AddIn = addIn; m_App = app; m_MacroRunner = macroRunner; m_Msg = msg; m_SettsProvider = settsProvider; m_ToolbarConfProvider = toolbarConfProvider; m_Logger = logger; try { ToolbarInfo = LoadUserToolbar(); } catch (Exception ex) { m_Msg.ShowError(ex, "Failed to load toolbar specification"); } }
public PropertyPageCreator(IXExtension ext) { m_Ext = ext; }
public static IXEnumTaskPane <TControl, TEnum> CreateTaskPane <TControl, TEnum>(this IXExtension ext) where TEnum : Enum { var spec = new TaskPaneSpec(); spec.InitFromEnum <TEnum>(); spec.Buttons = Enum.GetValues(typeof(TEnum)).Cast <TEnum>().Select( c => { var btn = new TaskPaneEnumButtonSpec <TEnum>(Convert.ToInt32(c)); btn.InitFromEnum(c); btn.Value = c; c.TryGetAttribute <TaskPaneStandardIconAttribute>(a => btn.StandardIcon = a.StandardIcon); return(btn); }).ToArray(); return(new EnumTaskPane <TControl, TEnum>(ext.CreateTaskPane <TControl>(spec))); }
public EditQrCodeFeature(IXExtension ext, IMessageService msgSvc, IXLogger logger, IDocumentAdapter docAdapter) : base(ext, msgSvc, logger, docAdapter) { }
public void Load(IXExtension ext) { m_Ext = ext; CreateContainer(); LoadCommands(); }
internal SwMacroFeatureEditor(IXApplication app, IXExtension ext, Type defType, CustomFeatureParametersParser paramsParser, DataConverterDelegate <TPage, TData> pageToDataConv, DataConverterDelegate <TData, TPage> dataToPageConv, CreateGeometryDelegate <TData> geomCreator) : base(app, ext, defType, paramsParser, pageToDataConv, dataToPageConv, geomCreator) { }
public SwAddInApplication(IXExtension ext) : base(ext) { }
public CadExtensionApplication(IXExtension ext) { Extension = ext; }
private void OnStartupCompleted(IXExtension ext) { Started?.Invoke(); }
internal AddInHostModule(IXExtension ext) { m_Ext = ext; m_Ext.Application.Loaded += OnApplicationLoaded; }
private void OnExtensionConnect(IXExtension ext) { try { var cmdGrp = Extension.CommandManager.AddCommandGroup <CadPlusCommands_e>(); cmdGrp.CommandClick += OnCommandClick; var mainGrpSpec = cmdGrp.Spec; Connect?.Invoke(); var groups = m_RegisteredCommands.GroupBy(x => x.Item1.Id) .Select(g => { var baseGroupSpecs = g.Where(x => !x.Item1.CmdGrpEnumType.TryGetAttribute <PartialCommandGroupAttribute>(out _)) .Select(x => x).ToArray(); if (baseGroupSpecs.Any()) { if (baseGroupSpecs.Length == 1) { var baseGroupSpec = baseGroupSpecs.First().Item1; return(new Tuple <EnumCommandGroupSpec, IEnumerable <Tuple <EnumCommandGroupSpec, Delegate> > >(baseGroupSpec, g)); } else { throw new Exception("More than one base group defined"); } } else { throw new Exception("No base groups defined"); } }).OrderBy(g => { if (g.Item1.CmdGrpEnumType.TryGetAttribute(out CommandOrderAttribute att)) { return(att.Order); } else { return(0); } }).ToArray(); foreach (var group in groups) { var baseGroupSpec = group.Item1; //TODO: add support for nested groups baseGroupSpec.Parent = mainGrpSpec; baseGroupSpec.Commands = group.Item2.SelectMany(g => { var cmds = g.Item1.Commands; foreach (var cmd in cmds) { m_Handlers.Add(cmd, new Tuple <Delegate, Enum>(g.Item2, cmd.Value)); } return(cmds); }).OrderBy(c => { int order = -1; if (!c.Value.TryGetAttribute <CommandOrderAttribute>(x => order = x.Order)) { order = 0; } ; return(order); }).ToArray(); var grp = Extension.CommandManager.AddCommandGroup(baseGroupSpec); grp.CommandClick += OnCommandClick; } } catch (Exception ex) { new AppLogger().Log(ex); new GenericMessageService("CAD+").ShowError("Failed to connect add-in"); throw; } }
private void OnStartupCompleted(IXExtension ext) { Started?.Invoke(ext.Application.WindowHandle); }
private void OnExtensionDisconnect(IXExtension ext) => Dispose();