Example #1
0
        public SwMacroFeatureDefinition()
        {
            string provider = "";

            this.GetType().TryGetAttribute <MissingDefinitionErrorMessage>(a =>
            {
                provider = a.Message;
            });

            m_Provider = provider;

            var svcColl = new ServiceCollection();

            svcColl.AddOrReplace <IXLogger>(() => new TraceLogger($"xCad.MacroFeature.{this.GetType().FullName}"));

            ConfigureServices(svcColl);

            m_SvcProvider = svcColl.CreateProvider();

            m_Logger = m_SvcProvider.GetService <IXLogger>();

            CustomFeatureDefinitionInstanceCache.RegisterInstance(this);

            TryCreateIcons();
        }
Example #2
0
        internal SwPart(IPartDoc part, SwApplication app, IXLogger logger, bool isCreated)
            : base((IModelDoc2)part, app, logger, isCreated)
        {
            m_CutListRebuild = new CutListRebuildEventsHandler(this);

            Bodies = new SwPartBodyCollection(this);
        }
        internal SwModelViewTab(ModelViewTabCreator <TControl> ctrlCreator,
                                ModelViewManager modelViewManager, SwDocument doc, IXLogger logger) : base(doc, logger)
        {
            m_CtrlCreator = ctrlCreator;

            m_ModelViewMgr = modelViewManager;
        }
Example #4
0
        private void OnConnect()
        {
            m_Msg    = m_SvcProvider.GetService <IMessageService>();
            m_Logger = m_SvcProvider.GetService <IXLogger>();

            m_Host.RegisterCommands <Commands_e>(OnCommandClick);
        }
Example #5
0
 public TriggersManager(IXApplication app,
                        IMacroRunner macroRunner, IXLogger logger)
 {
     m_App         = app;
     m_MacroRunner = macroRunner;
     m_Logger      = logger;
 }
Example #6
0
        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");
            }
        }
Example #7
0
        private void OnHostInitialized(IApplication app, IServiceContainer svcProvider, IModule[] modules)
        {
            m_SvcProvider = svcProvider;

            m_Logger = m_SvcProvider.GetService <IXLogger>();
            m_MsgSvc = m_SvcProvider.GetService <IMessageService>();
        }
Example #8
0
        private void OnConnect()
        {
            CreateContainer();

            m_Msg    = Resolve <IMessageService>();
            m_Logger = Resolve <IXLogger>();

            m_ToolbarProxy = Resolve <IToolbarModuleProxy>();
            m_ToolbarProxy.RequestMacroRunning += OnRequestMacroRunning;

            m_ToolbarConfMgr = Resolve <IToolbarConfigurationManager>();

            m_Host.RegisterCommands <Commands_e>(OnCommandClick);

            try
            {
                m_ToolbarConfMgr.Load();
                var workDir = Path.GetDirectoryName(m_ToolbarConfMgr.FilePath);
                LoadCommands(m_ToolbarConfMgr.Toolbar, workDir);
            }
            catch (Exception ex)
            {
                m_Logger.Log(ex);
                m_Msg.ShowError(ex, "Failed to load Toolbar+ commands");
            }
        }
        public SwMacroFeatureDefinition()
        {
            string provider = "";

            this.GetType().TryGetAttribute <MissingDefinitionErrorMessage>(a =>
            {
                provider = a.Message;
            });

            m_Provider = provider;

            var svcColl = new ServiceCollection();

            svcColl.AddOrReplace <IXLogger>(() => new TraceLogger($"xCad.MacroFeature.{this.GetType().FullName}"));
            svcColl.AddOrReplace <IIconsCreator>(() => new BaseIconsCreator());

            ConfigureServices?.Invoke(this, svcColl);
            OnConfigureServices(svcColl);

            m_SvcProvider = svcColl.CreateProvider();

            m_Logger = m_SvcProvider.GetService <IXLogger>();

            CustomFeatureDefinitionInstanceCache.RegisterInstance(this);

            var iconsConv = m_SvcProvider.GetService <IIconsCreator>();

            iconsConv.KeepIcons   = true;
            iconsConv.IconsFolder = MacroFeatureIconInfo.GetLocation(this.GetType());
            TryCreateIcons(iconsConv);
        }
Example #10
0
        internal MacroFeatureParametersParser(ISldWorks app)
        {
            MathUtils = app.IGetMathUtility();

            //TODO: pass logger as parameter
            m_Logger = new TraceLogger("xCAD.MacroFeature");
        }
Example #11
0
        public RecentFilesManager(IXLogger logger)
        {
            m_Logger = logger;

            m_RecentFiles = new List <string>(TryLoadRecentFiles());
            TruncateList();
        }
Example #12
0
        internal void Init(IXServiceCollection customServices)
        {
            if (!m_IsInitialized)
            {
                m_CustomServices = customServices;

                m_IsInitialized = true;

                var services = new ServiceCollection();
                ConfigureServices(services);

                if (customServices != null)
                {
                    services.Merge(customServices);
                }

                m_Provider = services.CreateProvider();
                m_Logger   = m_Provider.GetService <IXLogger>();

                Documents = new SwDocumentCollection(this, m_Logger);

                var geomBuilderDocsProvider = m_Provider.GetService <IMemoryGeometryBuilderDocumentProvider>();

                MemoryGeometryBuilder = new SwMemoryGeometryBuilder(this, geomBuilderDocsProvider);
            }
            else
            {
                Debug.Assert(false, "App has been already initialized. Must be only once");
            }
        }
Example #13
0
        public DocumentsHandler(IXApplication app, IXLogger logger)
        {
            m_App    = app;
            m_Logger = logger;

            m_Handlers = new List <Type>();
            m_DocsMap  = new Dictionary <IXDocument, List <IDocumentHandler> >();
        }
Example #14
0
 public BatchDocumentMockVM(string name, BatchJob job, ICadApplicationInstanceProvider[] appProviders,
                            IJournalExporter[] journalExporters, IResultsSummaryExcelExporter[] resultsExporters,
                            IMessageService msgSvc, IXLogger logger, Func <BatchJob, IBatchRunJobExecutor> execFact,
                            IBatchApplicationProxy batchAppProxy, MainWindow parentWnd, IRibbonButtonCommand[] backstageCmds)
     : base(name, job, appProviders, journalExporters, resultsExporters,
            msgSvc, logger, execFact, batchAppProxy, parentWnd, backstageCmds)
 {
 }
        internal MacroFeatureParametersParser(ISwApplication app)
        {
            m_App     = app;
            MathUtils = m_App.Sw.IGetMathUtility();

            //TODO: pass logger as parameter
            m_Logger = new TraceLogger("xCAD.MacroFeature");
        }
Example #16
0
        public MacroExecutor(IXCadMacroProvider xCadMacroProvider, IXLogger logger)
        {
            m_Logger = logger;

            m_Runner            = TryCreateMacroRunner();
            m_XCadMacroProvider = xCadMacroProvider;
            m_XCadMacrosCache   = new Dictionary <string, IXCadMacro>(StringComparer.CurrentCultureIgnoreCase);
        }
Example #17
0
        /// <summary>
        /// Logs error
        /// </summary>
        /// <param name="ex">Exception</param>
        public static void Log(this IXLogger logger, Exception ex, bool stackTrace = true)
        {
            var msg = new StringBuilder();

            ParseExceptionLog(ex, msg, stackTrace);

            logger.Log(msg.ToString());
        }
Example #18
0
        /// <summary>
        /// Prints the message to trace
        /// </summary>
        /// <param name="logger">Logger</param>
        /// <param name="msg">Message to trace</param>
        /// <param name="category">Trace category</param>
        /// <param name="severity"></param>
        /// <param name="singleLine">True to merge multiline into a single line</param>
        public static void Trace(this IXLogger logger, string msg, string category, LoggerMessageSeverity_e severity, bool singleLine = false)
        {
            if (singleLine)
            {
                msg = Regex.Replace(msg, @"\r\n?|\n", " :: ");
            }

            System.Diagnostics.Trace.WriteLine($"[{severity}]{msg}", category);
        }
Example #19
0
 public MacroRunner(IXApplication app, IMacroExecutor runner, IMessageService msgSvc, IXLogger logger,
                    IToolbarModuleProxy toolbarModuleProxy, IFilePathResolver filePathResolver)
 {
     m_App                = app;
     m_Runner             = runner;
     m_ToolbarModuleProxy = toolbarModuleProxy;
     m_MsgSvc             = msgSvc;
     m_Logger             = logger;
     m_FilePathResolver   = filePathResolver;
 }
Example #20
0
        internal SwDocumentDispatcher(SwApplication app, IXLogger logger)
        {
            m_App    = app;
            m_Logger = logger;

            m_DocsDispatchQueue   = new List <SwDocument>();
            m_ModelsDispatchQueue = new List <ModelInfo>();

            m_Lock = new object();
        }
Example #21
0
        public DungeonGenerator()
        {
            _logger = new NullLogger();

            _corridorWidthMin = 3;
            _corridorWidthMax = 3;
            _mapMargin        = 0;
            _mapCropEnabled   = false;
            clearBoard();
        }
Example #22
0
 public CaveGenerator()
 {
     //_dunGen = new DungeonGenerator();
     _dunGen                = new ForcedDungeonGenerator(10);
     _seed                  = 0;
     _logger                = new NullLogger();
     _cellularFillChance    = 50;
     _cellularSmoothingStep = 5;
     setMapMargin(1);
 }
Example #23
0
        private void OnHostInitialized(IApplication app, IServiceContainer svcProvider, IModule[] modules)
        {
            m_MacroRunnerSvc = svcProvider.GetService <IMacroExecutor>();
            m_Msg            = svcProvider.GetService <IMessageService>();
            m_Logger         = svcProvider.GetService <IXLogger>();

            m_CadDesc = svcProvider.GetService <ICadDescriptor>();

            m_Data = new AssemblyBatchData(m_CadDesc);
        }
Example #24
0
        public SwApplicationProvider(IXLogger logger, IMacroExecutor svc, ICadDescriptor entDesc)
        {
            m_Logger = logger;

            MacroRunnerService = svc;
            Descriptor         = entDesc;
            m_CustomServices   = new ServiceCollection();
            m_CustomServices.AddOrReplace <IXLogger>(() => m_Logger);

            m_ForceDisabledAddIns = new Dictionary <Process, List <string> >();
        }
Example #25
0
        internal SwCommandManager(ISwApplication app, int addinCookie, IXLogger logger, Guid addInGuid)
        {
            m_App       = app;
            m_AddInGuid = addInGuid;

            CmdMgr = m_App.Sw.GetCommandManager(addinCookie);

            m_Logger      = logger;
            m_Commands    = new Dictionary <string, CommandInfo>();
            m_CommandBars = new List <SwCommandGroup>();
        }
Example #26
0
        internal SwDocumentDispatcher(ISwApplication app, IXLogger logger)
        {
            m_App    = app;
            m_Logger = logger;

            m_Comparer = new SwPointerEqualityComparer <IModelDoc2>(app.Sw);

            m_DocsDispatchQueue   = new List <SwDocument>();
            m_ModelsDispatchQueue = new List <IModelDoc2>();

            m_Lock = new object();
        }
Example #27
0
        private void OnConnect()
        {
            m_MacroRunnerSvc = m_Host.Services.GetService <IMacroRunnerExService>();
            m_Msg            = m_Host.Services.GetService <IMessageService>();
            m_Logger         = m_Host.Services.GetService <IXLogger>();

            m_Host.RegisterCommands <Commands_e>(OnCommandClick);
            m_Page          = m_Host.CreatePage <AssemblyBatchData>();
            m_Data          = new AssemblyBatchData(m_Host.Services.GetService <IMacroFileFilterProvider>());
            m_Page.Closing += OnPageClosing;
            m_Page.Closed  += OnPageClosed;
        }
Example #28
0
 protected BaseCustomFeatureEditor(IXApplication app,
                                   Type featDefType,
                                   CustomFeatureParametersParser paramsParser,
                                   IServiceProvider svcProvider)
 {
     m_App            = app;
     m_SvcProvider    = svcProvider;
     m_Logger         = svcProvider.GetService <IXLogger>();
     m_DefType        = featDefType;
     m_BodiesComparer = new XObjectEqualityComparer <IXBody>();
     m_ParamsParser   = paramsParser;
 }
Example #29
0
        internal SwCommandManager(ISwApplication app, int addinCookie, IServiceProvider svcProvider)
        {
            m_App = app;

            CmdMgr = m_App.Sw.GetCommandManager(addinCookie);

            m_SvcProvider = svcProvider;

            m_Logger        = svcProvider.GetService <IXLogger>();
            m_TabConfigurer = svcProvider.GetService <ICommandGroupTabConfigurer>();
            m_Commands      = new Dictionary <string, CommandInfo>();
            m_CommandBars   = new List <SwCommandGroup>();
        }
        private void OnInitialized(IApplication app, IServiceContainer svcProvider, IModule[] modules)
        {
            m_BatchInAppModule = modules.OfType <IBatchInAppModule>().FirstOrDefault();

            m_Logger = svcProvider.GetService <IXLogger>();
            m_MsgSvc = svcProvider.GetService <IMessageService>();

            if (m_BatchInAppModule != null)
            {
                m_EntDesc = svcProvider.GetService <ICadDescriptor>();
                m_BatchInAppModule.ProcessInput += OnProcessInput;
            }
        }