コード例 #1
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = (ISldWorks)ThisSW;
            addinID = cookie;

            //Setup callbacks
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs   = new Hashtable();
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return(true);
        }
コード例 #2
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            solidworks  = (ISldWorks)ThisSW;
            addinCookie = cookie;

            //Setup callbacks
            solidworks.SetAddinCallbackInfo(0, this, addinCookie);

            #region Setup the Command Manager
            _commandManager = solidworks.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            addin = (SolidWorks.Interop.sldworks.SldWorks)solidworks;
            documentsEventsRepo = new Hashtable();
            //this will be called only the first time the addin is loaded
            //this method will attached events to all documents that open after the addin is loaded.
            AttachSwEvents();
            //Listen for events on all currently open docs
            //we need to call this method here because sometimes user fires the addin while he has some documents open already
            //there are events that will attach event handlers to all documents but until those events are fired this call to the method will suffice
            AttachEventsToAllDocuments();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return(true);
        }
コード例 #3
0
ファイル: SwGUID.cs プロジェクト: GitHubVents/SwSpecification
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp   = (ISldWorks)ThisSW;
            _addinId = cookie;

            //Setup callbacks
            iSwApp.SetAddinCallbackInfo(0, this, _addinId);

            #region Setup the Command Manager
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            _swEventPtr = (SldWorks)iSwApp;
            _openDocs   = new Hashtable();

            #endregion

            #region Setup Sample Property Manager

            #endregion

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Called when addin is loaded into SolidWorks
        /// </summary>
        /// <param name="ThisSW"></param>
        /// <param name="Cookie"></param>
        /// <returns></returns>
        public bool ConnectToSW(object ThisSW, int Cookie)
        {
            _swApp  = (ISldWorks)ThisSW;
            _cookie = Cookie;
            _swApp.SetAddinCallbackInfo2(0, this, Cookie);
            _cmdMgr = _swApp.GetCommandManager(_cookie);

            SetupUI();

            return(true);
        }
コード例 #5
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            m_App     = (ISldWorks)ThisSW;
            m_AddinID = cookie;
            m_Bmp     = new BitmapHandler();

            m_App.SetAddinCallbackInfo(0, this, m_AddinID);

            m_CmdMgr = m_App.GetCommandManager(cookie);
            AddCommandMgr();

            return(true);
        }
コード例 #6
0
ファイル: SwAddin.cs プロジェクト: Nikollay/SWAddin
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = ThisSW as ISldWorks;
            addinID = cookie;

            //Setup callbacks
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            return(true);
        }
コード例 #7
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            m_App         = ThisSW as ISldWorks;
            m_AddInCookie = cookie;

            m_App.SetAddinCallbackInfo(0, this, m_AddInCookie);

            m_CmdMgr = m_App.GetCommandManager(cookie);

            m_CachedCmdsEnable = new Dictionary <string, swWorkspaceTypes_e>();
            m_CallbacksParams  = new Dictionary <string, Tuple <Delegate, Enum> >();
            m_EnableParams     = new Dictionary <string, Tuple <Delegate, Enum> >();
            m_CommandGroupIds  = new List <int>();

            return(OnConnect());
        }
コード例 #8
0
ファイル: SwAddin.cs プロジェクト: gaodansoft/sw
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            try
            {
                iSwApp  = (ISldWorks)ThisSW;
                addinID = cookie;

                //docMgr = new CAD3dSW.Controler.Model(iSwApp, "", string.Empty);
                //Setup callbacks
                iSwApp.SetAddinCallbackInfo(0, this, addinID);

                #region Setup the Command Manager
                iCmdMgr = iSwApp.GetCommandManager(cookie);
                AddCommandMgr();
                #endregion

                #region Setup the Event Handlers
                SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
                openDocs   = new Hashtable();
                //AttachEventHandlers();
                #endregion

                #region Setup Sample Property Manager
                AddPMP();
                #endregion

                //System.Text.StringBuilder temp = new System.Text.StringBuilder(5);
                //GetPrivateProfileString("Control", "AutoLoad", "0", temp, 5, System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                //if (temp.ToString() == "1")
                //{
                //    RunCADworkstation();
                //}
                RunCADworkstation();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
                throw;
            }


            return(true);
        }
コード例 #9
0
ファイル: SwAddin.cs プロジェクト: weianweigan/swex-pmpage
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            m_App     = (ISldWorks)ThisSW;
            m_AddinID = cookie;

            m_App.SetAddinCallbackInfo(0, this, m_AddinID);

            m_Bmp = new BitmapHandler();

            m_CmdMgr = m_App.GetCommandManager(cookie);
            AddCommandMgr();

            m_ActivePage    = new PropertyManagerPageEx <PropertyPageEventsHandler, DataModel>(m_App);
            m_ActiveTabPage = new PropertyManagerPageEx <PropertyPageEventsHandler, TabDataModel>(m_App);

            m_ActivePage.Handler.DataChanged += OnDataChanged;
            m_ActivePage.Handler.Closing     += OnPageClosing;
            m_ActivePage.Handler.Closed      += OnClosed;

            return(true);
        }
コード例 #10
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = (ISldWorks)ThisSW;
            addinID = cookie;


            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers

            openDocs = new Hashtable();

            #endregion

            return(true);
        }
コード例 #11
0
        // This method is called by SolidWorks when bhe add-in is loaded.
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            // The add-in stores the SolidWorks application pointer in a global variable.
            iSwApp = (ISldWorks)ThisSW;
            // The add-in stores the cookie in a global variable.
            addinID = cookie;

            // Setup callbacks
            // The add-in uses this method to send SolidWorks a pointer to itself.
            // It also sends the cookie back to create custom menus and custom toolbars.
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            // Setup the Command Manager
            // The Command Manager is used to create custom menus and custom toolbars in the SolidWorks user interface.
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            // 自定义函数
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            // Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs   = new Hashtable();
            // The Event handlers are added.
            // 自定义函数
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            // Setup Sample Property Manager
            // A custom PropertyManagerPage is created.
            // 自定义函数
            AddPMP();
            #endregion

            // The add-in inform SolidWorks that this method was successful.
            return(true);
        }
コード例 #12
0
ファイル: SwAddin.cs プロジェクト: virall/EpicorIntegration
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp = (ISldWorks)ThisSW;
            addinID = cookie;

            //Setup callbacks
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs = new Hashtable();
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            AddPMP();
            #endregion

            return true;
        }
コード例 #13
0
ファイル: SwAddin.cs プロジェクト: digger1985/MyCode
        public bool ConnectToSW(object thisSw, int cookie)
        {
            // �������� ��� ��������� � xml config
            Furniture.Helpers.SaveLoadSettings.SaveAllProperties();

            bool ret;
            _iSwApp = (ISldWorks)thisSw;
            if (!Properties.Settings.Default.CashModeAvailable)
            {
                Properties.Settings.Default.CashModeOn = false;
                Properties.Settings.Default.Save();
            }
            if (!Properties.Settings.Default.KitchenModeAvailable)
            {
                Properties.Settings.Default.KitchenModeOn = false;
                Properties.Settings.Default.Save();
            }
            _addinId = cookie;
            _iSwApp.SetAddinCallbackInfo(0, this, _addinId);

            if (!CheckSolid())
            {
                string strReg = Interaction.InputBox("������� ��������������� ���:", MyTitle, "", 0, 0);
                if (strReg != "")
                {

                    try
                    {
                        // ������ �����
                        // SaveInRegEdit(strReg);
                        Furniture.Helpers.SaveLoadSettings.AddOrUpdateAppSettings("SerialKey", strReg);

                        Properties.Settings.Default.AppRegCode = strReg;  // ������ �������
                        Properties.Settings.Default.Save();

                    }

                    catch (SecurityException ex)
                    {
                        Logging.Log.Instance.Fatal(ex, ex.Message.ToString() + "ConnectToSW");
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        Logging.Log.Instance.Fatal(ex, ex.Message.ToString() + "ConnectToSW");
                    }
                    finally
                    {
                        Properties.Settings.Default.AppRegCode = strReg;  // ������ �������
                        Properties.Settings.Default.Save();
                    }
                }
            }
            if (CheckSolid())
            {
                var dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

                #region �������� ������ ����������� �����
                List<string> filesToDownload = new List<string>();
                filesToDownload.Add("Oracle.ManagedDataAccess.dll");
                filesToDownload.Add("log4net.dll");
                foreach (string file in filesToDownload)
                {
                    if (!File.Exists(Path.Combine(dirName, file)))
                    {
                        //�������..
                        UpdaterFromFtp.DownloadFromFtp(file);
                    }
                }

                #endregion

                #region ���������� ������ ����� ��� ����������
                string newFileLocation;

                string lastFileLocation = dirName + "\\Furniture.dll";
                string updFullName = dirName + "\\update_furniture.exe";
                var ss = new SecureString();
                foreach (var ch in Properties.Settings.Default.AdmUsrPsw)
                {
                    ss.AppendChar(ch);
                }
                var psi = new ProcessStartInfo
                              {
                                  UseShellExecute = false,
                                  Domain = Environment.UserDomainName
                              };
                if (CheckIsSolidUserInAdmin())
                {
                    psi.UserName = Properties.Settings.Default.AdmUsrName;
                    psi.Password = ss;
                }
                if (!File.Exists(updFullName))
                {
                    string updTmpPath;
                    if (DownloadUpdFrn(out updTmpPath))
                    {
                        psi.FileName = updTmpPath;
                        psi.Arguments = Path.GetDirectoryName(updTmpPath) + "\\update_furniture.exe" + "@" +
                                        updFullName;
                        Process.Start(psi);
                    }
                }

                #endregion

                #region ����������

                if (CheckUpdate(out newFileLocation))
                {
                    string arguments = newFileLocation + "@" + lastFileLocation;

                    if (File.Exists(updFullName))
                    {
                        if (!CheckIsSolidUserInAdmin())
                        {
                            psi = new ProcessStartInfo(updFullName, arguments);
                            psi.UseShellExecute = false;
                            psi.Domain = Environment.UserDomainName;
                        }
                        else
                        {
                            psi.FileName = updFullName;
                            psi.Arguments = arguments;
                        }
                        Process.Start(psi);
                        return false;
                    }
                }

                if (Properties.Settings.Default.CheckUpdateLib)
                    UpdatePatch();

                #endregion

                _iCmdMgr = _iSwApp.GetCommandManager(cookie);
                ChangeActiveDoc(false);

                _swEventPtr = (SldWorks)_iSwApp;
                _openDocs = new Hashtable();
                AttachEventHandlers();

                AddPmp();
                _swHandle = (IntPtr)((Frame)_iSwApp.Frame()).GetHWnd();
                WriteLogInfoOnServer();

                ret = true;

                hook = new KeyboardHook();
                hook.AddFilter(Keys.F, true, true, true);
                hook.AddFilter(Keys.Enter, false, false, false);
                hook.KeyPressed += new KeyboardHookEventHandler(hook_KeyPressed);
                hook.Install();
            }
            else
            {
                throw new Exception();
            }
            return ret;
        }
コード例 #14
0
ファイル: SwAddin.cs プロジェクト: wyvictor/ReducerDesign
        // This method is called by SolidWorks when bhe add-in is loaded.
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            // The add-in stores the SolidWorks application pointer in a global variable.
            iSwApp = (ISldWorks)ThisSW;
            // The add-in stores the cookie in a global variable.
            addinID = cookie;

            // Setup callbacks
            // The add-in uses this method to send SolidWorks a pointer to itself.
            // It also sends the cookie back to create custom menus and custom toolbars.
            iSwApp.SetAddinCallbackInfo(0, this, addinID);

            #region Setup the Command Manager
            // Setup the Command Manager
            // The Command Manager is used to create custom menus and custom toolbars in the SolidWorks user interface.
            iCmdMgr = iSwApp.GetCommandManager(cookie);
            // �Զ��庯��
            AddCommandMgr();
            #endregion

            #region Setup the Event Handlers
            // Setup the Event Handlers
            SwEventPtr = (SolidWorks.Interop.sldworks.SldWorks)iSwApp;
            openDocs = new Hashtable();
            // The Event handlers are added.
            // �Զ��庯��
            AttachEventHandlers();
            #endregion

            #region Setup Sample Property Manager
            // Setup Sample Property Manager
            // A custom PropertyManagerPage is created.
            // �Զ��庯��
            AddPMP();
            #endregion

            // The add-in inform SolidWorks that this method was successful.
            return true;
        }