Hi, two years later,
I was looking for differences in the implementation of Ribbon from the 2009 and 2010 and I saw this message.
I have found that many classes have moved Autodesk.AutoCAD.Ribbon namespace (AcRibbon.dll in 2009) to the namespace Autodesk.AutoCAD.Customization (AcCui.dll in 2010).
I do not know if this is a simple reorganization of classes or a deeper refactoring.
What I can tell you is how to implement Ribbon in C++, compiled with option /clr: oldsyntax (this notation is obsolete but i like it more.)
1- Using VS2005 for AutoCAD 2009:
-- In stdafx.h add this lines:
#using <mscorlib.dll>
#using <System.dll>
#using <acdbmgd.dll>
#using <acmgd.dll>
#using <AcRibbon.dll>
#using <AdWindows.dll>
#using <PresentationCore.dll>
#using <PresentationFramework.dll>
#using <WindowsBase.dll>
--- MyRibbonTabProxy.h
#pragma once
#include "StdAfx.h"
using namespace System;
using namespace Autodesk::Windows;
using namespace Autodesk::AutoCAD::Ribbon;
void MakeIt(void);
public __gc class MyRibbonTabProxy
{
private:
RibbonTab* m_RibTab;
public:
MyRibbonTabProxy(String* title, String* id );
protected:
void OnButtonClick(Object* sender, Windows::RoutedEventArgs * ea);
};
--- MyRibbonTabProxy.cpp
#include "StdAfx.h"
#include "MyRibbonTabProxy.h"
void MakeIt()
{
MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
}
MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
{
RibbonControl* ribCtrl = Autodesk::AutoCAD::Ribbon::RibbonServices::RibbonPaletteSet->RibbonControl;
if( ribCtrl == NULL )
return;
m_RibTab = ribCtrl->FindTab( id );
if( m_RibTab != NULL )
return;
m_RibTab = new RibbonTab();
m_RibTab->Title = title;
m_RibTab->Id = id;
ribCtrl->Tabs->Add( m_RibTab );
m_RibTab->IsActive = true;
// Create the panel source
RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
ribSourcePanel->Title = "Bloques";
RibbonPanel* ribPanel = new RibbonPanel;
ribPanel->Source = ribSourcePanel;
m_RibTab->Panels->Add( ribPanel );
// Create a button
RibbonButton* ribButton1 = new RibbonButton();
ribButton1->Text = S"AddTE";
ribButton1->Click += new Windows::RoutedEventHandler(this, &MyRibbonTabProxy:: OnAddTEClick);
ribButton1->ShowText = true;
RibbonRow* row = new RibbonRow();
row->Items->Add(ribButton1);
ribSourcePanel->Rows->Add( row );
}
void MyRibbonTabProxy:: OnAddTEClick(Object* sender, Windows::RoutedEventArgs *ea)
{
Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
->MdiActiveDocument->SendStringToExecute(S"_AddTE ",false, false, false );
}
2 - Using VS2008 for AutoCAD 2011:
-- In stdafx.h add this lines:
#using <mscorlib.dll>
#using <System.dll>
#using <acdbmgd.dll>
#using <acmgd.dll>
#using <AcCui.dll>
#using <AdWindows.dll>
#using <PresentationCore.dll>
#using <PresentationFramework.dll>
#using <WindowsBase.dll>
#pragma once
#include "StdAfx.h"
using namespace System;
using namespace Autodesk::Windows;
void MakeIt(void);
// The new implementation uses ICommand instead RoutedEventHandler
public __gc class AutoCADCommandHandler: public ICommand
{
public:
void remove_CanExecuteChanged(System::EventHandler* eh){};
void add_CanExecuteChanged(System::EventHandler* eh){};
AutoCADCommandHandler(){};
bool CanExecute(Object* parameter);
void Execute(Object* parameter);
};
public __gc class MyRibbonTabProxy
{
private:
RibbonTab* m_RibTab;
public:
MyRibbonTabProxy(String* title, String* id );
};
void MakeIt()
{
MyRibbonTabProxy* rb = new MyRibbonTabProxy( S"CadOfiTec", S"CadOfiTecTab" );
}
bool AutoCADCommandHandler::CanExecute(Object* parameter)
{
return true;
}
void AutoCADCommandHandler::Execute(Object* parameter)
{
RibbonButton* ribBtn =
static_cast<Autodesk::Windows::RibbonButton*> (parameter);
Autodesk::AutoCAD::ApplicationServices::Application:: DocumentManager
->MdiActiveDocument->SendStringToExecute(
static_cast<System::String*>(ribBtn->CommandParameter), false, false, false );
}
MyRibbonTabProxy::MyRibbonTabProxy(String* title, String* id )
{
RibbonControl* ribCtrl = Autodesk::Windows::ComponentManager::Ribbon;
if( ribCtrl == NULL )
return;
m_RibTab = ribCtrl->FindTab( id );
if( m_RibTab != NULL )
return;
m_RibTab = new RibbonTab();
m_RibTab->Title = title;
m_RibTab->Id = id;
ribCtrl->Tabs->Add( m_RibTab );
m_RibTab->IsActive = true;
// Create the panel source
RibbonPanelSource* ribSourcePanel = new RibbonPanelSource();
ribSourcePanel->Title = "Bloques";
RibbonPanel* ribPanel = new RibbonPanel;
ribPanel->Source = ribSourcePanel;
m_RibTab->Panels->Add( ribPanel );
// Create a button
RibbonButton* ribButton1 = new RibbonButton();
ribButton1->Text = S"AddTE";
ribButton1->ShowText = true;
AutoCADCommandHandler* ch = new AutoCADCommandHandler();
ribButton1->CommandHandler = ch;
ribSourcePanel->Items->Add( ribButton1 );
}
Hope It help you.
Regards,
Adolfo
Can't find what you're looking for? Ask the community or share your knowledge.