예제 #1
0
        private void OnTaskSetup(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            try
            {
                //Get the property interface used to access the framework
                IEdmTaskProperties props = poCmd.mpoExtra as IEdmTaskProperties;
                //Get the settings for exist task
                try
                {
                    string res = props.GetValEx(AutoCADTaskSettings.Acadtask_Settings) as string;
                    if (!string.IsNullOrEmpty(res))
                    {
                        taskSettings = JsonConvert.DeserializeObject <AutoCADTaskSettings>(res);
                    }
                }
                catch
                {
                }
                if (taskSettings == null)
                {
                    taskSettings                 = new AutoCADTaskSettings();
                    taskSettings.CreateMenu      = true;
                    taskSettings.CreatePDF       = true;
                    taskSettings.MenuDescription = "Convert AutoCAD";
                    taskSettings.MenuName        = "Convert AutoCAD";
                }

                //Set the property flag that says you want a
                //menu item for the user to launch the task
                //and a flag to support scheduling
                props.TaskFlags = (int)EdmTaskFlag.EdmTask_SupportsInitExec + (int)EdmTaskFlag.EdmTask_SupportsDetails + (int)EdmTaskFlag.EdmTask_SupportsChangeState + (int)EdmTaskFlag.EdmTask_SupportsInitForm;



                EdmTaskSetupPage[] setupPages = new EdmTaskSetupPage[2];
                setupPages[0].mbsPageName = "Menus Command";
                setupPages[1].mbsPageName = "TitleBlocks";
                //pages[0].mlPageHwnd = SetupPageObj.Handle.ToInt32();
                //pages[0].mpoPageImpl = SetupPageObj;
                props.SetSetupPages(setupPages);
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                log.Error(ex);
                // MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + ex.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex);
                //MessageBox.Show(ex.Message);
            }
        }
        public AutoCADTaskAddin(EdmCmd poCmd, EdmCmdData[] ppoData, AutoCADTaskSettings taskSettings)
        {
            //Get the task instance interface
            inst     = poCmd.mpoExtra as IEdmTaskInstance;
            data     = ppoData;
            settings = taskSettings;
            if (inst == null)
            {
                throw new Exception("Task values incorrect");
            }

            vault = (IEdmVault20)poCmd.mpoVault;

            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTcwMjQwQDMxMzcyZTMzMmUzMGhycFlDaldXNDVZeWxhdnFwckswQnRhMHVwclp2OWNrUEltNHczb21ENDQ9;MTcwMjQxQDMxMzcyZTMzMmUzMG4xOFQ1dnBDR1oxalUvazM5UmlTRkdUelJRcHkweURnVERXRXRabnpaZVE9");
        }
예제 #3
0
        private void OnTaskSetupButton(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            try
            {
                //Custom setup page, SetupPageObj, is created
                //in method Class1::OnTaskSetup; SetupPage::StoreData
                //saves the contents of the list box to poCmd.mpoExtra
                //in the IEdmTaskProperties interface
                if (poCmd.mbsComment == "OK" && (taskSettings != null))
                {
                    IEdmTaskProperties props = poCmd.mpoExtra as IEdmTaskProperties;
                    //Pull settings from windows


                    //Set up the menu commands to launch this task
                    if (taskSettings.CreateMenu)
                    {
                        EdmTaskMenuCmd[] cmds = new EdmTaskMenuCmd[1];
                        cmds[0].mbsMenuString    = taskSettings.MenuName;
                        cmds[0].mbsStatusBarHelp = taskSettings.MenuDescription;
                        cmds[0].mlCmdID          = 2;
                        cmds[0].mlEdmMenuFlags   = (int)EdmMenuFlags.EdmMenu_MustHaveSelection;
                        props.SetMenuCmds(cmds);
                    }

                    props.SetValEx(AutoCADTaskSettings.Acadtask_Settings, JsonConvert.SerializeObject(taskSettings));
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                taskSettings = null;
            }
        }
예제 #4
0
        private void OnTaskRun(ref EdmCmd poCmd, ref EdmCmdData[] ppoData)
        {
            //Get the task instance interface
            IEdmTaskInstance inst = poCmd.mpoExtra as IEdmTaskInstance;

            if (inst == null)
            {
                return;
            }
            try
            {
                AutoCADTaskSettings taskSettings;
                string settings = inst.GetValEx(AutoCADTaskSettings.Acadtask_Settings) as string;
                if (!string.IsNullOrEmpty(settings))
                {
                    taskSettings = JsonConvert.DeserializeObject <AutoCADTaskSettings>(settings);
                }
                else
                {
                    taskSettings = new AutoCADTaskSettings();
                }

                var tas = new AutoCADTaskAddin(poCmd, ppoData, taskSettings);
                tas.runTask();
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                log.Error(ex);
                inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, ex.ErrorCode, "The test task failed!");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                inst.SetStatus(EdmTaskStatus.EdmTaskStat_DoneFailed, 0, "", "The test task failed!");
            }
        }