본문 바로가기
Revit/Revit API

[레빗 API 시작하기] Revit Ui Lab1 - Ribbon

by Crony 2013. 12. 6.

Revit Ui Lab1 - Ribbon


Revit Ui Lab1 - Ribbon_번역.docx








using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Media.Imaging;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Util;

namespace UiCs
{
/// Ribbon UI. 
/// 우리는 Revit Intro에서 정의된 명령이나 직접 코딩한 명령을 사용할수 있습니다.
/// 모든 명령은 리본패널을 만드는 연습에 사용이 될 것입니다.
/// cf. Developer Guide, Section 3.8: Ribbon Panels and Controls. (pp 46). 
[Transaction(TransactionMode.Automatic)]
public class UIRibbon : IExternalApplication
{
/// 이것은 어셈블리명과 외부명령 제공된 namespace입니다
const string _introLabName = "IntroCs";
const string _uiLabName = "UiCs";
const string _dllExtension = ".dll";
/// 이미지가 있는 폴더명
const string _imageFolderName = "Images";
/// 정의된 명령어가 있는 dll파일의 경로
string _introLabPath;
/// 아이콘 이미지가 있는 폴더명
string _imageFolder;
/// 주어진 디렉토리에서 시작, 상위 디렉토리의 위치에 주어진 대상의 이름의 하위 디렉토리 위단계를 검색 
/// <param name="path">Starting directory, e.g. GetDirectoryName( GetExecutingAssembly().Location ).</param>
/// <param name="target">Target subdirectory name, e.g. "Images".</param>
/// <returns>The full path of the target directory if found, else null.</returns>
string FindFolderInParents(string path, string target)
{
Debug.Assert(Directory.Exists(path), "expected an existing directory to start search in");
string s;
do
{
s = Path.Combine(path, target);
if (Directory.Exists(s))
{
return s;
}
path = Path.GetDirectoryName(path);
} while (null != path);
return null;
}
/// 이미지 폴더로 부터 새 아이콘이미지를 로딩하기
BitmapImage NewBitmapImage(string imageName)
{
return new BitmapImage(new Uri(
Path.Combine(_imageFolder, imageName)));
}
/// OnShutdown() - Revit 종료될때 호출 
public Result OnShutdown(UIControlledApplication app)
{
return Result.Succeeded;
}
/// OnStartup() - Revit 시작될때 호출 
public Result OnStartup(UIControlledApplication app)
{
// 외부 응용프로그램 디렉토리:
string dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
// 외부 명령어 경로:
_introLabPath = Path.Combine(dir, _introLabName + _dllExtension);
if (!File.Exists(_introLabPath))
{
TaskDialog.Show("UIRibbon", "External command assembly not found: " + _introLabPath);
return Result.Failed;
}
// 이미지 경로
_imageFolder = FindFolderInParents(dir, _imageFolderName);
if (null == _imageFolder || !Directory.Exists(_imageFolder))
{
TaskDialog.Show("UIRibbon",
string.Format("No image folder named '{0}' found in the parent directories of '{1}.",
_imageFolderName, dir));
return Result.Failed;
}
// 사용자 버턴 및 컨트롤의 종류를  보이게 Add-Ins탭에 추가하기
AddRibbonSampler(app);
// UI Labs 리본메뉴 추가하기
AddUILabsButtons(app);
return Result.Succeeded;
}
/// 연습을 위해서 Verious 버튼을 가진 리본 패널을 작성하기. Revit Intro Labs에서 여기에 정의 된 명령을 다시 사용.
/// Cf. Section 3.8 (pp 46) of the Developers Guide. 
public void AddRibbonSampler(UIControlledApplication app)
{
// 1. 리본탭과 리본패널 만들기 
app.CreateRibbonTab("Ribbon Sampler");
RibbonPanel panel = app.CreateRibbonPanel("Ribbon Sampler", "Ribbon Sampler");
// 아래 구문은 리본항목 샘플입니다. 이처럼 보이는 방법을 볼 수있는 관심의 주석 기능 // 무슨 말인지...그냥 읽지 마세요^^
// 2.1 Hello World를 위한 간단한 버턴 추가하기
AddPushButton(panel);
// 2.2 "Command Data", "DB Element" 그리고 "Element Filtering"를 위한 분할버턴 추가하기
AddSplitButton(panel);
// 2.3 "Command Data", "DB Element" 그리고 "Element Filtering"를 위한 풀다운 버턴 추가하기
AddPulldownButton(panel);
// 2.4 "Command Data", "DB Element" 그리고 "Element Filtering"를 위한 라디오/토글 버턴 추가하기
// we put it on the slide-out below.
//AddRadioButton(panel);
//panel.AddSeparator();
//2.5 글자박스 추가하기 - TBD: 이것은 이벤트와 함께 사용됩니다 이벤트트에 대한 설명은 다음에 다루겠습니다
// we put it on the slide-out below. 
//AddTextBox(panel);
//panel.AddSeparator();
//2.6 콤보박스 - TBD: 이것은 이벤트와 함께 사용됩니다 이벤트트에 대한 설명은 다음에 다루겠습니다
// 2개의 그룹 보이기 : Element Bascis (3개버턴) and Modification/Creation (2개 버턴)  
AddComboBox(panel);
// 2.7 각가의 항목들
//hello world 버턴, pulldown element basics(command data, DB element, element filtering), pulldown modification/creation(element modification, model creation)
AddStackedButtons_Complex(panel);
//2.8 slide out - 적을 공간이 없으면, 당신은 패널 아래에 공간에 추가 할 수 있습니다.이 후에 오는 것은 슬라이드 아웃에있을 것입니다. 
panel.AddSlideOut();
//2.4 라디오 버턴 - 윗글 참조
AddRadioButton(panel);
//2.5 글자박스 - 윗글 참조
AddTextBox(panel);
}
/// UI Labs을 위한 자신의 버턴을 만들기
/// cf. Section 3.8 (pp 46) of Developer Guide. 
public void AddUILabsButtons(UIControlledApplication app)
{
// 리본 패널 만들기
RibbonPanel panel = app.CreateRibbonPanel("UI Labs");
// (3) adding buttons for the current labs itself. 
// You may modify this AFTER each command are defined in each lab. 
//AddUILabsCommandButtons_Template(panel) ' dummy 
AddUILabsCommandButtons(panel);
// Lab4 이벤트화 동적업데이트입니다. 
AddUILabsCommandButtons2(panel);
}
/// Simple push button for "Hello World"
public void AddPushButton(RibbonPanel panel)
{
// Set the information about the command we will be assigning to the button 
PushButtonData pushButtonDataHello = new PushButtonData(
"PushButtonHello", 
"Hello World", 
_introLabPath,
_introLabName + ".HelloWorld" ); // could also use typeof(HelloWorld).FullName here
// Add a button to the panel
PushButton pushButtonHello = panel.AddItem(pushButtonDataHello) as PushButton;
// Add an icon
// Make sure you reference WindowsBase and PresentationCore, and import System.Windows.Media.Imaging namespace. 
pushButtonHello.LargeImage = NewBitmapImage("ImgHelloWorld.png");
// Add a tooltip 
pushButtonHello.ToolTip = "simple push button";
}
/// Split button for "Command Data", "DB Element" and "Element Filtering" 
public void AddSplitButton(RibbonPanel panel)
{
// Create three push buttons for split button drop down
// #1 
PushButtonData pushButtonData1 = new PushButtonData("SplitCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
pushButtonData1.LargeImage = NewBitmapImage("ImgHelloWorld.png");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("SplitDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");
pushButtonData2.LargeImage = NewBitmapImage("ImgHelloWorld.png");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("SplitElementFiltering", "ElementFiltering", _introLabPath, _introLabName + ".ElementFiltering");
pushButtonData3.LargeImage = NewBitmapImage("ImgHelloWorld.png");
// Make a split button now 
SplitButtonData splitBtnData = new SplitButtonData("SplitButton", "Split Button");
SplitButton splitBtn = panel.AddItem(splitBtnData) as SplitButton;
splitBtn.AddPushButton(pushButtonData1);
splitBtn.AddPushButton(pushButtonData2);
splitBtn.AddPushButton(pushButtonData3);
}
/// Pulldown button for "Command Data", "DB Element" and "Element Filtering"
public void AddPulldownButton(RibbonPanel panel)
{
// Create three push buttons for pulldown button drop down 
// #1 
PushButtonData pushButtonData1 = new PushButtonData("PulldownCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
pushButtonData1.LargeImage = NewBitmapImage("Basics.ico");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("PulldownDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");
pushButtonData2.LargeImage = NewBitmapImage("Basics.ico");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("PulldownElementFiltering", "Filtering", _introLabPath, _introLabName + ".ElementFiltering");
pushButtonData3.LargeImage = NewBitmapImage("Basics.ico");
// Make a pulldown button now 
PulldownButtonData pulldownBtnData = new PulldownButtonData("PulldownButton", "Pulldown");
PulldownButton pulldownBtn = panel.AddItem(pulldownBtnData) as PulldownButton;
pulldownBtn.AddPushButton(pushButtonData1);
pulldownBtn.AddPushButton(pushButtonData2);
pulldownBtn.AddPushButton(pushButtonData3);
}
/// Radio/toggle button for "Command Data", "DB Element" and "Element Filtering"
public void AddRadioButton(RibbonPanel panel)
{
// Create three toggle buttons for radio button group 
// #1 
ToggleButtonData toggleButtonData1 = new ToggleButtonData("RadioCommandData", "Command" + "\n Data", _introLabPath, _introLabName + ".CommandData");
toggleButtonData1.LargeImage = NewBitmapImage("Basics.ico");
// #2 
ToggleButtonData toggleButtonData2 = new ToggleButtonData("RadioDbElement", "DB" + "\n Element", _introLabPath, _introLabName + ".DBElement");
toggleButtonData2.LargeImage = NewBitmapImage("Basics.ico");
// #3 
ToggleButtonData toggleButtonData3 = new ToggleButtonData("RadioElementFiltering", "Filtering", _introLabPath, _introLabName + ".ElementFiltering");
toggleButtonData3.LargeImage = NewBitmapImage("Basics.ico");
// Make a radio button group now 
RadioButtonGroupData radioBtnGroupData = new RadioButtonGroupData("RadioButton");
RadioButtonGroup radioBtnGroup = panel.AddItem(radioBtnGroupData) as RadioButtonGroup;
radioBtnGroup.AddItem(toggleButtonData1);
radioBtnGroup.AddItem(toggleButtonData2);
radioBtnGroup.AddItem(toggleButtonData3);
}
/// Text box 
/// Text box used in conjunction with event. We'll come to this later. 
/// For now, just shows how to make a text box. 
public void AddTextBox(RibbonPanel panel)
{
// Fill the text box information 
TextBoxData txtBoxData = new TextBoxData("TextBox");
txtBoxData.Image = NewBitmapImage("Basics.ico");
txtBoxData.Name = "Text Box";
txtBoxData.ToolTip = "Enter text here";
txtBoxData.LongDescription = "<p>This is Revit UI Labs.</p><p>Ribbon Lab</p>";
txtBoxData.ToolTipImage = NewBitmapImage("ImgHelloWorld.png");
// Create the text box item on the panel 
TextBox txtBox = panel.AddItem(txtBoxData) as TextBox;
txtBox.PromptText = "Enter a comment";
txtBox.ShowImageAsButton = true;
txtBox.EnterPressed += new EventHandler<Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs>(txtBox_EnterPressed);
txtBox.Width = 180;
}
/// Event handler for the above text box 
void txtBox_EnterPressed(object sender, Autodesk.Revit.UI.Events.TextBoxEnterPressedEventArgs e)
{
// Cast sender to TextBox to retrieve text value
TextBox textBox = sender as TextBox;
TaskDialog.Show("TextBox Input", "This is what you typed in: " + textBox.Value.ToString());
}
/// Combo box - 5 items in 2 groups. 
/// Combo box is used in conjunction with event. We'll come back later. 
/// For now, just demonstrates how to make a combo box. 
public void AddComboBox(RibbonPanel panel)
{
// Create five combo box members with two groups 
// #1 
ComboBoxMemberData comboBoxMemberData1 = new ComboBoxMemberData("ComboCommandData", "Command Data");
comboBoxMemberData1.Image = NewBitmapImage("Basics.ico");
comboBoxMemberData1.GroupName = "DB Basics";
// #2 
ComboBoxMemberData comboBoxMemberData2 = new ComboBoxMemberData("ComboDbElement", "DB Element");
comboBoxMemberData2.Image = NewBitmapImage("Basics.ico");
comboBoxMemberData2.GroupName = "DB Basics";
// #3 
ComboBoxMemberData comboBoxMemberData3 = new ComboBoxMemberData("ComboElementFiltering", "Filtering");
comboBoxMemberData3.Image = NewBitmapImage("Basics.ico");
comboBoxMemberData3.GroupName = "DB Basics";
// #4 
ComboBoxMemberData comboBoxMemberData4 = new ComboBoxMemberData("ComboElementModification", "Modify");
comboBoxMemberData4.Image = NewBitmapImage("Basics.ico");
comboBoxMemberData4.GroupName = "Modeling";
// #5 
ComboBoxMemberData comboBoxMemberData5 = new ComboBoxMemberData("ComboModelCreation", "Create");
comboBoxMemberData5.Image = NewBitmapImage("Basics.ico");
comboBoxMemberData5.GroupName = "Modeling";
// Make a combo box now 
ComboBoxData comboBxData = new ComboBoxData("ComboBox");
ComboBox comboBx = panel.AddItem(comboBxData) as ComboBox;
comboBx.ToolTip = "Select an Option";
comboBx.LongDescription = "select a command you want to run";
comboBx.AddItem(comboBoxMemberData1);
comboBx.AddItem(comboBoxMemberData2);
comboBx.AddItem(comboBoxMemberData3);
comboBx.AddItem(comboBoxMemberData4);
comboBx.AddItem(comboBoxMemberData5);
comboBx.CurrentChanged += new EventHandler<Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs>(comboBx_CurrentChanged);
}
/// Event handler for the above combo box   
void comboBx_CurrentChanged(object sender, Autodesk.Revit.UI.Events.ComboBoxCurrentChangedEventArgs e)
{
// Cast sender as TextBox to retrieve text value
ComboBox combodata = sender as ComboBox;
ComboBoxMember member = combodata.Current;
TaskDialog.Show("Combobox Selection", "Your new selection: " + member.ItemText);
}
/// Stacked Buttons - combination of: push button, dropdown button, combo box and text box. 
/// (no radio button group, split buttons). 
/// Here we stack three push buttons for "Command Data", "DB Element" and "Element Filtering". 
public void AddStackedButtons_Simple(RibbonPanel panel)
{
// Create three push buttons to stack up
// #1 
PushButtonData pushButtonData1 = new PushButtonData("StackSimpleCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
pushButtonData1.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("StackSimpleDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");
pushButtonData2.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("StackSimpleElementFiltering", "Element Filtering", _introLabPath, _introLabName + ".ElementFiltering");
pushButtonData3.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// Put them on stack 
IList<RibbonItem> stackedButtons = panel.AddStackedItems(pushButtonData1, pushButtonData2, pushButtonData3);
}
/// Stacked Buttons - combination of: push button, dropdown button, combo box and text box. 
/// (no radio button group, split buttons). 
/// Here we define 6 buttons, make grouping of 1, 3, 2 items, and stack them in three layer: 
/// (1) simple push button with "Hello World" 
/// (2) pull down with 3 items: "Command Data", "DB Element" and "Element Filtering". 
/// (3) pull down with 2 items: "Element Modification" and "Model Creation" 
public void AddStackedButtons_Complex(RibbonPanel panel)
{
// Create six push buttons to group for pull down and stack up 
// #0 
PushButtonData pushButtonData0 = new PushButtonData("StackComplexHelloWorld", "Hello World", _introLabPath, _introLabName + ".HelloWorld");
pushButtonData0.Image = NewBitmapImage("Basics.ico");
// #1 
PushButtonData pushButtonData1 = new PushButtonData("StackComplexCommandData", "Command Data", _introLabPath, _introLabName + ".CommandData");
pushButtonData1.Image = NewBitmapImage("Basics.ico");

// #2 
PushButtonData pushButtonData2 = new PushButtonData("StackComplexDbElement", "DB Element", _introLabPath, _introLabName + ".DBElement");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("StackComplexElementFiltering", "Filtering", _introLabPath, _introLabName + ".ElementFiltering");
// #4 
PushButtonData pushButtonData4 = new PushButtonData("StackComplexElementModification", "Modify", _introLabPath, _introLabName + ".ElementModification");
// #5 
PushButtonData pushButtonData5 = new PushButtonData("StackComplexModelCreation", "Create", _introLabPath, _introLabName + ".ModelCreation");
// Make two sets of pull down 
PulldownButtonData pulldownBtnData1 = new PulldownButtonData("StackComplePulldownButton1", "DB Basics");
PulldownButtonData pulldownBtnData2 = new PulldownButtonData("StackComplePulldownButton2", "Modeling");
// Create three item stack. 
IList<RibbonItem> stackedItems = panel.AddStackedItems(pushButtonData0, pulldownBtnData1, pulldownBtnData2);
PulldownButton pulldownBtn2 = stackedItems[1] as PulldownButton;
PulldownButton pulldownBtn3 = stackedItems[2] as PulldownButton;
pulldownBtn2.Image = NewBitmapImage("Basics.ico");
pulldownBtn3.Image = NewBitmapImage("House.ico");
// Add each sub items 
PushButton button1 = pulldownBtn2.AddPushButton(pushButtonData1);
PushButton button2 = pulldownBtn2.AddPushButton(pushButtonData2);
PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
PushButton button4 = pulldownBtn3.AddPushButton(pushButtonData4);
PushButton button5 = pulldownBtn3.AddPushButton(pushButtonData5);
// Note: we need to set the image later. if we do in button data, it won't show in the Ribbon. 
button1.Image = NewBitmapImage("Basics.ico");
button2.Image = NewBitmapImage("Basics.ico");
button3.Image = NewBitmapImage("Basics.ico");
button4.Image = NewBitmapImage("Basics.ico");
button5.Image = NewBitmapImage("Basics.ico");
}
/// 이과정에서는 정의하는 명령에 대한 단추를 추가합니다.
/// 여기에서 3개의 버턴을 쌓아서 더 많은 것을 실행할수 있도록 반복합니다.
/// 다음  Ribbon lab과정을 할수 있는 템플릿입니다.
public void AddUILabsCommandButtons_Template(RibbonPanel panel)
{
// Get the location of this dll. 
string assembly = GetType().Assembly.Location;
// Create three push buttons to stack up 
// #1 
PushButtonData pushButtonData1 = new PushButtonData("UILabsCommand1", "Command1", assembly, _uiLabName + ".Command1");
pushButtonData1.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("UILabsCommand2", "Command2", assembly, _uiLabName + ".Command2");
pushButtonData2.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("UILabsCommand3", "Command3", assembly, _uiLabName + ".Command3");
pushButtonData3.Image = NewBitmapImage("ImgHelloWorldSmall.png");
// Put them on stack 
IList<RibbonItem> stackedButtons = panel.AddStackedItems(pushButtonData1, pushButtonData2, pushButtonData3);
}
/// 이과정에서는 정의하는 명령에 대한 단추를 추가합니다.
/// 여기에서 3개의 버턴을 쌓아서 더 많은 것을 실행할수 있도록 반복합니다. 
public void AddUILabsCommandButtons(RibbonPanel panel)
{
// Get the location of this dll. 
string assembly = GetType().Assembly.Location;
// Create three push buttons to stack up 
// #1 
PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");
pushButtonData1.Image = NewBitmapImage("basics.ico");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouse", "Create House Pick", assembly, _uiLabName + ".UICreateHouse");
pushButtonData2.Image = NewBitmapImage("House.ico");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");
pushButtonData3.Image = NewBitmapImage("basics.ico");
// #4 
PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".UICreateHouseDialog");
pushButtonData4.Image = NewBitmapImage("House.ico");
// #5 
// Make three sets of pull down 
PulldownButtonData pulldownBtnData1 = new PulldownButtonData("UILabsPulldownButton1", "Selection");
PulldownButtonData pulldownBtnData2 = new PulldownButtonData("UILabsPulldownButton2", "Task Dialog");
// Create three item stack. 
IList<RibbonItem> stackedItems = panel.AddStackedItems(pulldownBtnData1, pulldownBtnData2);
PulldownButton pulldownBtn1 = stackedItems[0] as PulldownButton;
PulldownButton pulldownBtn2 = stackedItems[1] as PulldownButton;
pulldownBtn1.Image = NewBitmapImage("Basics.ico");
pulldownBtn2.Image = NewBitmapImage("Basics.ico");
// Add each sub items 
PushButton button1 = pulldownBtn1.AddPushButton(pushButtonData1);
PushButton button2 = pulldownBtn1.AddPushButton(pushButtonData2);
PushButton button3 = pulldownBtn2.AddPushButton(pushButtonData3);
PushButton button4 = pulldownBtn2.AddPushButton(pushButtonData4);
// Note: we need to set the image later. if we do in button data, it won't show in the Ribbon. 
button1.Image = NewBitmapImage("Basics.ico");
button2.Image = NewBitmapImage("Basics.ico");
button3.Image = NewBitmapImage("Basics.ico");
button4.Image = NewBitmapImage("Basics.ico");
}
/// 이번과정에서 정의하는 명령어 버턴를 추가합니다.
/// 여기에서 2 x 2 버턴을 쌓아서 더 많은 것을 실행할수 있도록 반복합니다. 
/// TBD: 좋은 버젼이 될수 있도록 생각 하시길 ... 
public void AddUILabsCommandButtons_v2(RibbonPanel panel)
{
// Get the location of this dll. 
string assembly = GetType().Assembly.Location;
// Create push buttons to stack up 
// #1 
PushButtonData pushButtonData1 = new PushButtonData("UILabsSelection", "Pick Sampler", assembly, _uiLabName + ".UISelection");
pushButtonData1.Image = NewBitmapImage("basics.ico");
// #2 
PushButtonData pushButtonData2 = new PushButtonData("UILabsCreateHouseUI", "Create House Pick", assembly, _uiLabName + ".CreateHouseUI");
pushButtonData2.Image = NewBitmapImage("basics.ico");
// #3 
PushButtonData pushButtonData3 = new PushButtonData("UILabsTaskDialog", "Dialog Sampler", assembly, _uiLabName + ".UITaskDialog");
pushButtonData3.Image = NewBitmapImage("basics.ico");
// #4 
PushButtonData pushButtonData4 = new PushButtonData("UILabsCreateHouseDialog", "Create House Dialog", assembly, _uiLabName + ".CreateHouseDialog");
pushButtonData4.Image = NewBitmapImage("basics.ico");
// Create 2 x 2-item stack. 
IList<RibbonItem> stackedItems1 = panel.AddStackedItems(pushButtonData1, pushButtonData2);
IList<RibbonItem> stackedItems2 = panel.AddStackedItems(pushButtonData3, pushButtonData4);
}
/// 이벤트 및 동적 모델 업데이트에 대한 제어 버튼
public void AddUILabsCommandButtons2(RibbonPanel panel)
{
// Get the location of this dll. 
string assembly = GetType().Assembly.Location;
// Create three toggle buttons for radio button group 
// #1 
ToggleButtonData toggleButtonData1 = new ToggleButtonData("UILabsEventOn", "Event" + "\n Off", assembly, _uiLabName + ".UIEventOff");
toggleButtonData1.LargeImage = NewBitmapImage("Basics.ico");
// #2 
ToggleButtonData toggleButtonData2 = new ToggleButtonData("UILabsEventOff", "Event" + "\n On", assembly, _uiLabName + ".UIEventOn");
toggleButtonData2.LargeImage = NewBitmapImage("Basics.ico");
// Create three toggle buttons for radio button group 
// #3 
ToggleButtonData toggleButtonData3 = new ToggleButtonData("UILabsDynUpdateOn", "Center" + "\n Off", assembly, _uiLabName + ".UIDynamicModelUpdateOff");
toggleButtonData3.LargeImage = NewBitmapImage("Families.ico");
// #4 
ToggleButtonData toggleButtonData4 = new ToggleButtonData("UILabsDynUpdateOff", "Center" + "\n On", assembly, _uiLabName + ".UIDynamicModelUpdateOn");
toggleButtonData4.LargeImage = NewBitmapImage("Families.ico");
// Make event pn/off radio button group 
RadioButtonGroupData radioBtnGroupData1 = new RadioButtonGroupData("EventNotification");
RadioButtonGroup radioBtnGroup1 = panel.AddItem(radioBtnGroupData1) as RadioButtonGroup;
radioBtnGroup1.AddItem(toggleButtonData1);
radioBtnGroup1.AddItem(toggleButtonData2);
// Make dyn update on/off radio button group 
RadioButtonGroupData radioBtnGroupData2 = new RadioButtonGroupData("WindowDoorCenter");
RadioButtonGroup radioBtnGroup2 = panel.AddItem(radioBtnGroupData2) as RadioButtonGroup;
radioBtnGroup2.AddItem(toggleButtonData3);
radioBtnGroup2.AddItem(toggleButtonData4);
}
}
/// Helper Classes
/// 이번 Lab은 Revit Intro Labs에서 작성된 명령어를 사용합니다.
/// 더미 명령어를 대신 사용하는 것을 선호한다면 그렇게 사용하셔도 됩니다. 
/// 여기에 명령 템플릿을 제공합합니다. 
[Transaction(TransactionMode.Automatic)]
public class DummyCommand1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message,ElementSet elements)
{
// 여기에 완성된 명령어를 작성하세요 
TaskDialog.Show("Dummy command", "You have called Command1");
return Result.Succeeded;
}
}
}