示例#1
1
文件: SWxAddin.cs 项目: Alex9779/SESE
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp = (ISldWorks)ThisSW;
            addinID = cookie;

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

            iSwApp.AddMenuItem4((int)swDocumentTypes_e.swDocPART, addinID, "Export STLs", -1, "ExportPartSTLs", "", "", "");

            return true;
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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 = (SldWorks)iSwApp;
            _openDocs   = new Hashtable();

            #endregion

            #region Setup Sample Property Manager

            #endregion

            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
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = (ISldWorks)ThisSW;
            addinID = cookie;

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

            iSwApp.AddFileSaveAsItem2(cookie, "ExportToJSON", "Three.JS JSON Format", "json", (int)swDocumentTypes_e.swDocASSEMBLY);
            iSwApp.AddFileSaveAsItem2(cookie, "ExportToJSON", "Three.JS JSON Format", "json", (int)swDocumentTypes_e.swDocPART);

            return(true);
        }
示例#7
0
        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);
        }
示例#8
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp  = (ISldWorks)ThisSW;
            addinID = cookie;

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

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

            return(true);
        }
示例#9
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());
        }
示例#10
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);
        }
示例#11
0
        public void Setup()
        {
            _sldWorks.SetAddinCallbackInfo(0, this, _addinId);

            var knownIds = new[]
            {
                _generateNewIdCmdId,
                _saveWithNewIdCmdId,
                _saveWithNewIdAndUploadCmdId,
                _saveWithNewIdAndUploadCmdId,
                _deleteDocument,
                _downloadFromServerCmdId
            };

            var ignorePrevious = ShouldIgnorePrevious(knownIds, out bool groupExistsInRegistry);

            var commandGroup = CreateCommandGroup(ignorePrevious, out Dictionary <int, int> commandsDictionary);

            CreateCommandTab(commandGroup, groupExistsInRegistry, ignorePrevious, commandsDictionary);
        }
示例#12
0
        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);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
0
        /// <summary>
        /// Connect to SolidWorks
        /// </summary>
        /// <param name="ThisSW"></param>
        /// <param name="cookie"></param>
        /// <returns></returns>
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp = (ISldWorks)ThisSW;
            SwEventPtr = (SldWorks)iSwApp;
            addinID = cookie;

            //detect sw language and set it if present
            string lang = this.iSwApp.GetCurrentLanguage();
            if (lang == "german") Lang.currentLanguage = Lang.Languages.german;
            else if (lang == "english") Lang.currentLanguage = Lang.Languages.english;
            else Lang.currentLanguage = Lang.Languages.none;

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

            //Objects used in initialization of Addin
            openDocs = new Hashtable();
            AddMenus();
            AddToolbar();
            AddPMP();
            AttachEventHandlers();

            //Help
            this.helpPath = Path.Combine(assyDir, Lang.HELP_FILE);

            //Create the additional dialogs (do it here because we need the language information from sw)
            this.aboutDialog = new About(this);
            this.tagDialog = new TagRequestForm(this);

            //Show the about dialog on startup
            this.aboutDialog.ShowDialog();

            return true;
        }
示例#16
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;
        }
示例#17
0
        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;
        }
示例#18
0
        public bool ConnectToSW(object ThisSW, int cookie)
        {
            iSwApp = (ISldWorks)ThisSW;
            addinID = cookie;

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

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

            #region Taskpane setup
            Taskpanesetup();
            #endregion

            return true;
        }
示例#19
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;
        }