Esempio n. 1
0
        public void Init(FeatureCAM.Application app)
        {
            const int WHATEVER_VERSION_I_COMPILED_AGAINST = 5;

            _app = app;

            string warning1, warning2;

            try
            {
                warning1 = String.Format("Warning: This dll add-in was compiled against v{0} of FeatureCAM tlb.", WHATEVER_VERSION_I_COMPILED_AGAINST);
                // the featurecam tlb version is a property on the app now adays...
                // if the app doesn't have that propety, the next line will throw a com exception
                if (app.MajorTLBVersionNum != WHATEVER_VERSION_I_COMPILED_AGAINST)
                {
                    MessageBox.Show(warning1);
                }
            }
            catch
            {
                warning2 = String.Format("Warning: This dll add-in was compiled against v{0} of FeatureCAM tlb, and should not be run with older versions of FeatureCAM.", WHATEVER_VERSION_I_COMPILED_AGAINST);
                // must be tlb version 1?
                MessageBox.Show(warning2);
            }


            AddToolbarButton(app);
            Variables.app = app;
            InitializeVariables();
        }
        public void Init(FeatureCAM.Application app)
        {
            const int WHATEVER_VERSION_I_COMPILED_AGAINST = 2;
            string    vrsionStr = "2 ";

            _app = app;

            string warning = "Warning: This dll add-in was compiled against v";
            string more    = "of FeatureCAM tlb";

            try
            {
                // the featurecam tlb version is a property on the app now adays...
                // if the app doesn't have that propety, the next line will throw a com exception
                if (app.MajorTLBVersionNum != WHATEVER_VERSION_I_COMPILED_AGAINST)
                {
                    MessageBox.Show(warning + vrsionStr + more);
                }
            }
            catch
            {
                // must be tlb version 1?
                MessageBox.Show(warning + vrsionStr + more + " and should not be run with older versions of FeatureCAM.");
            }


            AddToolbarButton(app);
            Variables.app = app;
            InitializeVariables();
        }
Esempio n. 3
0
 public void Disconnect()
 {
     RemoveToolbarButton(_app);
     _app = null;
     Marshal.FinalReleaseComObject(Variables.app);
     GC.Collect();
     System.Threading.Thread.Sleep(1000);
 }
        public void Disconnect()
        {
            RemoveToolbarButton(_app);

            _app = null;
            GC.Collect();
            System.Threading.Thread.Sleep(1000);
        }
Esempio n. 5
0
        private void RemoveToolbarButton(FeatureCAM.Application app)
        {
            FeatureCAM.FMCmdBars    bars;
            FeatureCAM.FMCmdBar     bar;
            FeatureCAM.FMCmdBarCtrl ctrl;

            try
            {
                if (app == null)
                {
                    return;
                }

                bars = app.CommandBars;
                bar  = (FeatureCAM.FMCmdBar)bars.Item(tb_name);
                if (bar == null)
                {
                    return;
                }

                ctrl = (FeatureCAM.FMCmdBarCtrl)bar.Controls.Item(tb_icon_name);
                if (ctrl != null)
                {
                    ctrl.Delete();
                }
            }
            catch
            {
                MessageBox.Show("Failed to remove FeatureCAM to CAMplete macro toolbar button");
            }
            finally
            {
                ctrl = null;
                bar  = null;
                bars = null;
                app  = null;
                GC.Collect();
            }
        }
Esempio n. 6
0
        private void AddToolbarButton(FeatureCAM.Application app)
        {
            FeatureCAM.FMCmdBars    bars;
            FeatureCAM.FMCmdBar     bar;
            FeatureCAM.FMCmdBarCtrl ctrl;

            try
            {
                if (app == null)
                {
                    return;
                }

                bars = app.CommandBars;
                bar  = (FeatureCAM.FMCmdBar)bars.Item(tb_name);
                if (bar == null)
                {
                    bar = bars.Add(tb_name, Type.Missing, Type.Missing);
                }

                ctrl = (FeatureCAM.FMCmdBarCtrl)bar.Controls.Item(tb_icon_name);
                if (ctrl == null)
                {
                    ctrl = (FeatureCAM.FMCmdBarCtrl)bar.Controls.Add(Type.Missing, Type.Missing, tb_icon_name, Type.Missing);
                }
                bar.Visible = true;
            }
            catch
            {
                MessageBox.Show("Failed to add toolbar button for FeatureCAM to CAMplete macro");
            }
            finally
            {
                ctrl = null;
                bar  = null;
                bars = null;
                app  = null;
            }
        }