.NET

Reply
Member
IvanShchitov
Posts: 5
Registered: ‎05-29-2013
Message 1 of 7 (264 Views)
Accepted Solution

Monitoring If the Text Edit Ribbon Tab Is Open

264 Views, 6 Replies
01-28-2014 05:28 PM

Greetings,

 

How can I make a module that detects wether the text editing tab is open or not?

 

Best regards,

Ivan

You can track whenever the Tab is activated

 

For instance, from inside Initialize event

 

void IExtensionApplication.Initialize()
{
    Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
    foreach(Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs )
    {
        if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
        {
            tab.Activated += tab_Activated;
        }
    }

}

void tab_Activated(object sender, EventArgs e)
{
    // do something here...
}

Actually is a C# code, and you can convert to VB.NET at http://www.developerfusion.com/tools/convert/csharp-to-vb/

ADN Support Specialist
augusto.goncalves
Posts: 358
Registered: ‎04-30-2009
Message 2 of 7 (235 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

01-29-2014 05:35 AM in reply to: IvanShchitov

You can track whenever the Tab is activated

 

For instance, from inside Initialize event

 

void IExtensionApplication.Initialize()
{
    Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
    foreach(Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs )
    {
        if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
        {
            tab.Activated += tab_Activated;
        }
    }

}

void tab_Activated(object sender, EventArgs e)
{
    // do something here...
}
Regards,



Augusto Goncalves
Autodesk Developer Network
Member
IvanShchitov
Posts: 5
Registered: ‎05-29-2013
Message 3 of 7 (213 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

01-30-2014 12:40 AM in reply to: augusto.goncalves

Thank you very much, Augusto!

Member
IvanShchitov
Posts: 5
Registered: ‎05-29-2013
Message 4 of 7 (164 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 01:39 AM in reply to: augusto.goncalves

This code is for C++, isn't it? How to do the same in Visual Basic 2010?

ADN Support Specialist
augusto.goncalves
Posts: 358
Registered: ‎04-30-2009
Message 5 of 7 (156 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 04:23 AM in reply to: IvanShchitov

Actually is a C# code, and you can convert to VB.NET at http://www.developerfusion.com/tools/convert/csharp-to-vb/

Regards,



Augusto Goncalves
Autodesk Developer Network
Member
IvanShchitov
Posts: 5
Registered: ‎05-29-2013
Message 6 of 7 (148 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 01:41 PM in reply to: augusto.goncalves

Thank you, Augusto!

Member
IvanShchitov
Posts: 5
Registered: ‎05-29-2013
Message 7 of 7 (143 Views)

Re: Monitoring If the Text Edit Ribbon Tab Is Open

02-28-2014 04:17 PM in reply to: augusto.goncalves

Greetings, Augusto!

 

I've inserted your code in Microsoft Visual C# 2010 Express and it showed me three errors, particularly: 

 

01. 'CSharp_Plugin.DetectingTab.IExtensionApplication.Initialize()': containing type does not implement interface 'Autodesk.AutoCAD.Runtime.IExtensionApplication'

02. The type or namespace name 'Windows' does not exist in the namespace 'Autodesk' (are you missing an assembly reference?)

03. The type or namespace name 'Ribbon' does not exist in the namespace 'Autodesk.AutoCAD' (are you missing an assembly reference?)

 

How can I fix these errors?

 

Best regards,

Ivan

 

using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

namespace CSharp_Plugin
{
    public class DetectingTab
    {
        void IExtensionApplication.Initialize()
        {
            Autodesk.Windows.RibbonControl ribCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
            foreach (Autodesk.Windows.RibbonTab tab in ribCtrl.Tabs)
            {
                if (!string.IsNullOrWhiteSpace(tab.Id) && tab.Id.Contains("ID_MText_Tab"))
                {
                    tab.Activated += tab_Activated;
                }
            }

        }

        void tab_Activated(object sender, EventArgs e)
        {
            // do something here...
        }
    }
}

 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.