private ServicesManager RegisterServicesManager(ISldWorks app)
        {
            var kit = new ServicesManager(this.GetType().Assembly, new IntPtr(app.IFrameObject().GetHWnd()),
                                          typeof(UpdatesService),
                                          typeof(SystemEventLogService),
                                          typeof(AboutApplicationService));

            kit.HandleError += OnHandleError;

            var syncContext = SynchronizationContext.Current;

            if (syncContext == null)
            {
                syncContext = new System.Windows.Forms.WindowsFormsSynchronizationContext();
            }

            Task.Run(() =>
            {
                SynchronizationContext.SetSynchronizationContext(
                    syncContext);
                kit.StartServicesAsync().Wait();
            });

            return(kit);
        }
Пример #2
0
        internal void Load(ISldWorks app, params Type[] cmdGroupTypes)
        {
            m_Kit = new ServicesManager(this.GetType().Assembly, new IntPtr(app.IFrameObject().GetHWnd()),
                                        typeof(EulaService),
                                        typeof(UpdatesService),
                                        typeof(OpenIdConnectorService),
                                        typeof(UserSettingsService),
                                        typeof(SystemEventLogService),
                                        typeof(AboutApplicationService));

            m_Kit.HandleError += OnHandleError;
            m_Container        = new UnityContainer();

            m_Container.RegisterInstance(app);
            m_Container.RegisterInstance(app.IGetMathUtility() as IMathUtility);
            m_Container.RegisterInstance(app.IGetModeler() as IModeler);
            m_Container.RegisterInstance(m_Kit);

            m_Commands = new Dictionary <Enum, Type>();

            foreach (var cmdGrpType in cmdGroupTypes)
            {
                foreach (var cmd in Enum.GetValues(cmdGrpType).Cast <Enum>())
                {
                    Type from;
                    Type to;
                    GetCommandHandler(cmd, out from, out to);
                    m_Commands.Add(cmd, from);
                    m_Container.RegisterType(from, to,
                                             new ContainerControlledLifetimeManager());
                }
            }

            m_Kit.StartServices();
        }
Пример #3
0
        private ServicesManager RegisterServicesManager(ISldWorks app)
        {
            var srv = new ServicesManager(this.GetType().Assembly, new IntPtr(app.IFrameObject().GetHWnd()),
                                          typeof(UpdatesService),
                                          typeof(UserSettingsService),
                                          typeof(AboutApplicationService));

            srv.HandleError += OnHandleError;

            srv.StartServicesInBackground();

            return(srv);
        }
        private int OnRegeneration()
        {
            const int S_OK     = 0;
            const int S_CANCEL = 1;

            if (IsSuspended)
            {
                m_SuspendedRebuildsCount++;
                m_App.IFrameObject().SetStatusBarText(
                    $"Suspended {m_SuspendedRebuildsCount} rebuild{(m_SuspendedRebuildsCount > 1 ? "s" : "")}");
                return(S_CANCEL);
            }
            else
            {
                m_SuspendedRebuildsCount = 0;
                return(S_OK);
            }
        }
Пример #5
0
        public ServicesContainer(ISldWorks app)
        {
            Instance = this;

            m_Container = new UnityContainer();

            m_Container.RegisterType <RoundStockModel>(
                new ContainerControlledLifetimeManager());

            m_Container.RegisterInstance(app);
            m_Container.RegisterInstance(app.IGetMathUtility() as IMathUtility);

            m_Container.RegisterType <IStockFitExtractor <CylinderParams>, CylindricalStockFitExtractor>(
                new ContainerControlledLifetimeManager());

            m_Container.RegisterType <IVectorMathService, SwVectorMathService>(
                new ContainerControlledLifetimeManager());

            m_Container.RegisterType <RoundStockController>(
                new ContainerControlledLifetimeManager());

            m_Kit = new ServicesManager(this.GetType().Assembly, new IntPtr(app.IFrameObject().GetHWnd()),
                                        typeof(UpdatesService),
                                        typeof(UserSettingsService),
                                        typeof(SystemEventLogService),
                                        typeof(AboutApplicationService));

            m_Kit.HandleError += OnHandleError;

            var syncContext = SynchronizationContext.Current;

            Task.Run(() =>
            {
                SynchronizationContext.SetSynchronizationContext(
                    syncContext);
                m_Kit.StartServicesAsync().Wait();
            });

            m_Container.RegisterInstance(m_Kit.GetService <ILogService>());
            m_Container.RegisterInstance(m_Kit.GetService <IUserSettingsService>());
            m_Container.RegisterInstance(m_Kit.GetService <IAboutApplicationService>());
        }
        public static void ShowBubbleTooltip(this ISldWorks app,
                                             string title, string message, BubbleTooltipPosition_e pos, Image img = null)
        {
            var hwnd = new IntPtr(app.IFrameObject().GetHWnd());

            int x        = 0;
            int y        = 0;
            int xOffset  = 0;
            var arrowPos = swArrowPosition.swArrowNone;

            var doc = app.IActiveDoc2;

            if (doc != null)
            {
                xOffset = doc.GetFeatureManagerWidth();

                var view = doc.IActiveView;

                if (view != null)
                {
                    hwnd = new IntPtr(view.GetViewHWnd());
                }
            }

            RECT rect;

            GetWindowRect(hwnd, out rect);

            switch (pos)
            {
            case BubbleTooltipPosition_e.TopLeft:
                x        = rect.Left;
                y        = rect.Top;
                arrowPos = swArrowPosition.swArrowLeftTop;
                break;

            case BubbleTooltipPosition_e.TopRight:
                x        = rect.Right;
                y        = rect.Top;
                arrowPos = swArrowPosition.swArrowRightTop;
                break;

            case BubbleTooltipPosition_e.BottomRight:
                x        = rect.Right;
                y        = rect.Bottom;
                arrowPos = swArrowPosition.swArrowRightBottom;
                break;

            case BubbleTooltipPosition_e.BottomLeft:
                x        = rect.Left;
                y        = rect.Bottom;
                arrowPos = swArrowPosition.swArrowLeftBottom;
                break;
            }

            x += xOffset;

            var imgPath = "";

            if (img != null)
            {
                imgPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
                img.Save(imgPath);
            }

            app.ShowBubbleTooltipAt2(x, y, (int)arrowPos,
                                     title, message, (int)swBitMaps.swBitMapUserDefined, imgPath, "", 0,
                                     (int)swLinkString.swLinkStringNone, "", "");
        }
 internal SwWindow(ISldWorks app)
 {
     m_Handler = new IntPtr(app.IFrameObject().GetHWnd());
 }