private void AddTagsToRibbonMenu(List<MenuInfo> tags) { foreach (var tag in tags) { RibbonTab tab = new RibbonTab() { Text = tag.TagName }; ribbon1.Tabs.Add(tab); foreach (var button in tag.Downloaders) { var pnl = new RibbonPanel() { Text = (button.Tag as Downloader).Name, }; pnl.Items.Add(button); tab.Panels.Add(pnl); } } this.ResumeLayout(false); this.PerformLayout(); }
internal RibbonPanelPopup(RibbonPanel panel) { DoubleBuffered = true; _sensor = new RibbonMouseSensor(this, panel.Owner, panel.Items); _sensor.PanelLimit = panel; _panel = panel; _panel.PopUp = this; panel.Owner.SuspendSensor(); using (Graphics g = CreateGraphics()) { panel.overflowBoundsBuffer = panel.Bounds; Size s = panel.SwitchToSize(this, g, GetSizeMode(panel)); s.Width += 100; s.Height += 100; Size = s; } foreach (RibbonItem item in panel.Items) { item.SetCanvas(this); } }
public RibbonElementSizeMode GetSizeMode(RibbonPanel pnl) { if (pnl.FlowsTo == RibbonPanelFlowDirection.Right) { return RibbonElementSizeMode.Medium; } else { return RibbonElementSizeMode.Large; } }
internal RibbonPanelPopup(RibbonPanel panel) { DoubleBuffered = true; _sensor = new RibbonSensor(this, panel.Owner, panel.OwnerTab); _sensor.PanelLimit = panel; _panel = panel; _panel.PopUp = this; using (Graphics g = CreateGraphics()) { Size s = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, GetSizeMode(panel))); //s.Width+=3; s.Height+=3; Size = s; panel.SetBounds(new Rectangle(0, 0, Size.Width, Size.Height)); panel.UpdateItemsRegions(g, GetSizeMode(panel)); } foreach (RibbonItem item in panel.Items) { item.SetCanvas(this); } }
/// <summary> /// Raises the paint event and draws the /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public virtual void OnPaint(object sender, RibbonElementPaintEventArgs e) { if (Paint != null) { Paint(this, new PaintEventArgs(e.Graphics, e.Clip)); } if (PopupShowed && e.Control == Owner) { //Draw a fake collapsed and pressed panel #region Create fake panel RibbonPanel fakePanel = new RibbonPanel(this.Text); fakePanel.Image = this.Image; fakePanel.SetSizeMode(RibbonElementSizeMode.Overflow); fakePanel.SetBounds(overflowBoundsBuffer); fakePanel.SetPressed(true); fakePanel.SetOwner(Owner); #endregion Owner.Renderer.OnRenderRibbonPanelBackground(new RibbonPanelRenderEventArgs(Owner, e.Graphics, e.Clip, fakePanel, e.Control)); Owner.Renderer.OnRenderRibbonPanelText(new RibbonPanelRenderEventArgs(Owner, e.Graphics, e.Clip, fakePanel, e.Control)); } else { //Draw normal Owner.Renderer.OnRenderRibbonPanelBackground(new RibbonPanelRenderEventArgs(Owner, e.Graphics, e.Clip, this, e.Control)); Owner.Renderer.OnRenderRibbonPanelText(new RibbonPanelRenderEventArgs(Owner, e.Graphics, e.Clip, this, e.Control)); } if (e.Mode != RibbonElementSizeMode.Overflow || (e.Control != null && e.Control == PopUp)) { foreach (RibbonItem item in Items) { if (item.Visible || Owner.IsDesignMode()) item.OnPaint(this, new RibbonElementPaintEventArgs(item.Bounds, e.Graphics, item.SizeMode)); } } }
private void UserInterfaceEvents_OnResetRibbonInterface(NameValueMap context) { //TODO: Fix this try { //get the ribbon associated with part document Inventor.Ribbons ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon assemblyRibbon = ribbons["Assembly"]; //get the tabls associated with part ribbon RibbonTabs ribbonTabs = assemblyRibbon.RibbonTabs; RibbonTab assemblyRibbonTab = ribbonTabs["id_Assembly"]; //create a new panel with the tab RibbonPanels ribbonPanels = assemblyRibbonTab.RibbonPanels; assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls; CommandControl copyUtilCmdBtnCmdCtrl = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void UserInterfaceEvents_OnResetRibbonInterface(NameValueMap context) { try { UserInterfaceManager userInterfaceManager; userInterfaceManager = m_inventorApplication.UserInterfaceManager; //get the ribbon associated with part document Inventor.Ribbons ribbons; ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon partRibbon; partRibbon = ribbons["Part"]; //get the tabls associated with part ribbon RibbonTabs ribbonTabs; ribbonTabs = partRibbon.RibbonTabs; RibbonTab partSketchRibbonTab; partSketchRibbonTab = ribbonTabs["id_TabSketch"]; //create a new panel with the tab RibbonPanels ribbonPanels; ribbonPanels = partSketchRibbonTab.RibbonPanels; m_partSketchSlotRibbonPanel = ribbonPanels.Add("Slot", "Autodesk:SimpleAddIn:SlotRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); //add controls to the slot panel CommandControls partSketchSlotRibbonPanelCtrls; partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls; //add the combo boxes to the ribbon panel CommandControl slotWidthCmdCboBoxCmdCtrl; slotWidthCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotWidthComboBoxDefinition, "", false); CommandControl slotHeightCmdCboBoxCmdCtrl; slotHeightCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotHeightComboBoxDefinition, "", false); //add the buttons to the ribbon panel CommandControl drawSlotCmdBtnCmdCtrl; drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_drawSlotButton.ButtonDefinition, false, true, "", false); CommandControl slotOptionCmdBtnCmdCtrl; slotOptionCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false); CommandControl toggleSlotStateCmdBtnCmdCtrl; toggleSlotStateCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_toggleSlotStateButton.ButtonDefinition, false, true, "", false); } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void InitViewTab() { chkBackground = new RibbonCheckBox("Background"); chkBackground.Checked = true; chkBackground.CheckedChanged += new EventHandler(showBackgroundRibbonButton_Click); chkInterface = new RibbonCheckBox("Interface"); chkInterface.Checked = true; chkInterface.CheckedChanged += new EventHandler(showInterfaceRibbonButton_Click); chkObjects = new RibbonCheckBox("Objects"); chkObjects.Checked = true; chkObjects.CheckedChanged += new EventHandler(showPegsRibbonButton_Click); chkCollision = new RibbonCheckBox("Collision"); chkCollision.CheckedChanged += new EventHandler(showCollisionRibbonButton_Click); chkPreview = new RibbonCheckBox("Preview"); chkPreview.CheckedChanged += new EventHandler(showPreviewRibbonButton_Click); RibbonPanel panelShowHide = new RibbonPanel("Show / Hide"); panelShowHide.Items.Add(chkBackground); panelShowHide.Items.Add(chkInterface); panelShowHide.Items.Add(chkObjects); panelShowHide.Items.Add(chkCollision); panelShowHide.Items.Add(chkPreview); RibbonButton btnPackExplorer = new RibbonButton("Pack Explorer"); btnPackExplorer.Image = Resources.pack_explorer_32; btnPackExplorer.Click += new EventHandler(packExplorerRibbonButton_Click); RibbonButton btnProperties = new RibbonButton("Properties"); btnProperties.Image = Resources.properties_32; btnProperties.Click += new EventHandler(propertiesRibbonButton_Click); RibbonButton btnEntryList = new RibbonButton("Entry List"); btnEntryList.Image = Resources.properties_32; btnEntryList.Click += new EventHandler(entryListRibbonButton_Click); RibbonPanel panelWindow = new RibbonPanel("Window"); panelWindow.Items.Add(btnPackExplorer); panelWindow.Items.Add(btnProperties); panelWindow.Items.Add(btnEntryList); RibbonTab tabView = new RibbonTab(mRibbon, "View"); tabView.Panels.Add(panelShowHide); tabView.Panels.Add(panelWindow); mRibbon.Tabs.Add(tabView); }
public RibbonPanelRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonPanel panel, Control canvas) : base(owner, g, clip) { Panel = panel; Canvas = canvas; }
/// <summary> /// Sets the currently selected panel /// </summary> /// <param name="panel"></param> private void SetSelectedPanel(RibbonPanel panel, int mouseX, int mouseY) { if (panel == _lastSelectedPanel) return; if (_lastSelectedPanel != null) { _lastSelectedPanel.SetSelected(false, mouseX, mouseY ); RedrawPanel(_lastSelectedPanel); } if (panel != null) { panel.SetSelected(true, mouseX, mouseY); RedrawPanel(panel); } _lastSelectedPanel = panel; }
private void InitToolTab() { //Tool panel btnSelectTool = new RibbonButton("Select"); btnSelectTool.Image = Resources.pointer_32; btnSelectTool.Click += new EventHandler(selectRibbonButton_Click); btnPegTool = new RibbonButton("Peg"); btnPegTool.Image = Resources.peg_32; btnPegTool.Click += new EventHandler(pegRibbonButton_Click); btnBrickTool = new RibbonButton("Brick"); btnBrickTool.Image = Resources.brick_32; btnBrickTool.Click += new EventHandler(brickRibbonButton_Click); btnCircle = new RibbonButton("Circle"); btnCircle.Image = Resources.material_32; btnCircle.Click += new EventHandler(circleRibbonButton_Click); btnPolygon = new RibbonButton("Polygon"); btnPolygon.Image = Resources.polygon_32; btnPolygon.Click += new EventHandler(polygonRibbonButton_Click); btnRod = new RibbonButton("Rod"); btnRod.Image = Resources.rod_32; btnRod.Click += new EventHandler(rodRibbonButton_Click); btnTeleport = new RibbonButton("Teleport"); btnTeleport.Image = Resources.teleport_32; btnTeleport.Click += new EventHandler(teleportRibbonButton_Click); btnEmitter = new RibbonButton("Emitter"); btnEmitter.Image = Resources.emitter_32; btnEmitter.Click += new EventHandler(emitterRibbonButton_Click); RibbonButton btnGenerator = new RibbonButton("Generator"); btnGenerator.Style = RibbonButtonStyle.DropDown; btnGenerator.Image = Resources.peg_circle_32; btnPegGenerator = new RibbonButton("Peg Generator"); btnPegGenerator.SmallImage = Resources.peg_16; btnPegGenerator.Click += new EventHandler(pegGeneratorRibbonButton_Click); btnBrickGenerator = new RibbonButton("Brick Generator"); btnBrickGenerator.SmallImage = Resources.brick_16; btnBrickGenerator.Click += new EventHandler(brickGeneratorRibbonButton_Click); btnGenerator.DropDownItems.Add(btnPegGenerator); btnGenerator.DropDownItems.Add(btnBrickGenerator); panelInsert = new RibbonPanel("Tools"); panelInsert.Items.Add(btnSelectTool); panelInsert.Items.Add(btnPegTool); panelInsert.Items.Add(btnBrickTool); panelInsert.Items.Add(btnCircle); panelInsert.Items.Add(btnPolygon); panelInsert.Items.Add(btnRod); panelInsert.Items.Add(btnTeleport); panelInsert.Items.Add(btnEmitter); panelInsert.Items.Add(btnGenerator); RibbonPanel panelFunctions = new RibbonPanel("Functions"); RibbonButton btnApplyFunction = new RibbonButton("Apply"); btnApplyFunction.Image = Resources.execute_32; btnApplyFunction.Click += new EventHandler(applyFunctionRibbonButton_Click); btnScript = new RibbonButton("Script"); btnScript.Image = Resources.script_32; btnScript.Click += new EventHandler(scriptRibbonButton_Click); panelFunctions.Items.Add(btnApplyFunction); panelFunctions.Items.Add(btnScript); RibbonButton btnRemove = new RibbonButton("Remove"); btnRemove.Image = Resources.remove_peg_32; btnRemove.Style = RibbonButtonStyle.DropDown; RibbonButton btnDuplicatePegs = new RibbonButton("Duplicate Pegs"); btnDuplicatePegs.Click += new EventHandler(removeDuplicatePegsRibbonButton_Click); RibbonButton btnOffscreenPegs = new RibbonButton("Offscreen Pegs"); btnOffscreenPegs.Click += new EventHandler(removeOffscreenPegsRibbonButton_Click); btnRemove.DropDownItems.Add(btnDuplicatePegs); btnRemove.DropDownItems.Add(btnOffscreenPegs); panelRemove = new RibbonPanel("Remove"); panelRemove.Items.Add(btnRemove); RibbonTab tabTools = new RibbonTab(mRibbon, "Tools"); tabTools.Panels.Add(panelInsert); tabTools.Panels.Add(panelFunctions); tabTools.Panels.Add(panelRemove); mRibbon.Tabs.Add(tabTools); }
/// <summary> /// Senses the mouse button up /// </summary> /// <param name="e"></param> public void SenseMouseUp(MouseEventArgs e) { if (Disposed) throw new ObjectDisposedException(GetType().Name); RibbonPanel mouseUpPanel = null; RibbonItem mouseUpItem = null; RibbonPanel hittedPanel = null; RibbonItem hittedItem = null; if (!SenseOnlyItems) { if (MouseUpTabScroll(e.X, e.Y)) return; ///Check for the selected panel if (Tab.TabContentBounds.Contains(e.X, e.Y) || PanelLimit != null) { foreach (RibbonPanel panel in GetPanelsToSense()) { if (panel.Bounds.Contains(e.X, e.Y)) { hittedPanel = panel; if (PanelLimit == null || PanelLimit == hittedPanel) { mouseUpPanel = panel; panel.OnMouseUp(e); } break; } } } if (mouseUpPanel != null && mouseUpPanel == _mouseDownPanel) { _mouseDownPanel = null; mouseUpPanel.OnClick(EventArgs.Empty); } if (hittedPanel != null) { hittedPanel.OnMouseUp(e); } } ///Check for the selected item if (hittedPanel != null || SenseOnlyItems) { IEnumerable<RibbonItem> items = SenseOnlyItems ? ItemsToSense : hittedPanel.Items; foreach (RibbonItem item in items) { if (item.Bounds.Contains(e.X, e.Y)) { item.OnMouseUp(e); hittedItem = item; mouseUpItem = item; RedrawItem(item); break; } } } ///Check for sub-items on the item ///(This should be recursive, but it's not necessary so far) if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems) { foreach (RibbonItem item in (hittedItem as IContainsSelectableRibbonItems).GetItems()) { if (item.Bounds.Contains(e.X, e.Y)) { item.OnMouseUp(e); mouseUpItem = item; RedrawItem(item, GetContentBounds(hittedItem)); break; } } } if (mouseUpItem == _mouseDownItem && mouseUpItem != null) { _mouseDownItem = null; mouseUpItem.OnClick(EventArgs.Empty); } }
/// <summary> /// Redraws the specified panel /// </summary> /// <param name="panel"></param> private void RedrawPanel(RibbonPanel panel) { //RibbonElementSizeMode size = panel.SizeMode; //if (panel.PopUp != null) //{ // size = RibbonElementSizeMode.Large; //} //using (Graphics g = Control.CreateGraphics()) //{ // g.SetClip(panel.Bounds); // panel.OnPaint(this, new RibbonElementPaintEventArgs(panel.Bounds, g, size, Control)); //} Control.Invalidate(panel.Bounds); }
/// <summary> /// Sets the value of the OwnerPanel property /// </summary> /// <param name="ownerPanel">RibbonPanel where this item is located</param> internal virtual void SetOwnerPanel(RibbonPanel ownerPanel) { _ownerPanel = ownerPanel; }
/// <summary> /// Updates the regions of the panels and its contents /// </summary> internal void UpdatePanelsRegions() { if (Panels.Count == 0) { return; } if (!Owner.IsDesignMode()) { _offset = 0; } int curRight = TabContentBounds.Left + Owner.PanelPadding.Left + _offset; int curLeft = TabContentBounds.Right - Owner.PanelPadding.Right; int panelsTop = TabContentBounds.Top + Owner.PanelPadding.Top; using (Graphics g = Owner.CreateGraphics()) { //Check all at full size foreach (RibbonPanel panel in Panels) { if (panel.Visible && Owner.RightToLeft == RightToLeft.No) { RibbonElementSizeMode sMode = panel.FlowsTo == RibbonPanelFlowDirection.Right ? RibbonElementSizeMode.Medium : RibbonElementSizeMode.Large; //Set the bounds of the panel to let it know it's height panel.SetBounds(new Rectangle(0, 0, 1, TabContentBounds.Height - Owner.PanelPadding.Vertical)); ///Size of the panel Size size = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, sMode)); ///Creates the bounds of the panel Rectangle bounds = new Rectangle( curRight, panelsTop, size.Width, size.Height); ///Set the bounds of the panel panel.SetBounds(bounds); ///Let the panel know what size we have decided for it panel.SetSizeMode(sMode); ///Update curLeft curRight = bounds.Right + 1 + Owner.PanelSpacing; } else if (panel.Visible && Owner.RightToLeft == RightToLeft.Yes) { RibbonElementSizeMode sMode = panel.FlowsTo == RibbonPanelFlowDirection.Right ? RibbonElementSizeMode.Medium : RibbonElementSizeMode.Large; //Set the bounds of the panel to let it know it's height panel.SetBounds(new Rectangle(0, 0, 1, TabContentBounds.Height - Owner.PanelPadding.Vertical)); ///Size of the panel Size size = panel.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, sMode)); curLeft -= size.Width + Owner.PanelSpacing; ///Creates the bounds of the panel Rectangle bounds = new Rectangle( curLeft, panelsTop, size.Width, size.Height); ///Set the bounds of the panel panel.SetBounds(bounds); ///Let the panel know what size we have decided for it panel.SetSizeMode(sMode); ///Update curLeft curLeft = bounds.Left - 1 - Owner.PanelSpacing; } else { panel.SetBounds(Rectangle.Empty); } } if (!Owner.IsDesignMode()) { while (curRight > TabContentBounds.Right && !AllPanelsOverflow()) { #region Down grade the larger panel one position RibbonPanel larger = GetLargerPanel(); if (larger.SizeMode == RibbonElementSizeMode.Large) { larger.SetSizeMode(RibbonElementSizeMode.Medium); } else if (larger.SizeMode == RibbonElementSizeMode.Medium) { larger.SetSizeMode(RibbonElementSizeMode.Compact); } else if (larger.SizeMode == RibbonElementSizeMode.Compact) { larger.SetSizeMode(RibbonElementSizeMode.Overflow); } Size size = larger.MeasureSize(this, new RibbonElementMeasureSizeEventArgs(g, larger.SizeMode)); larger.SetBounds(new Rectangle(larger.Bounds.Location, new Size(size.Width + Owner.PanelMargin.Horizontal, size.Height))); #endregion ///Reset x-axis reminder curRight = TabContentBounds.Left + Owner.PanelPadding.Left; ///Re-arrange location because of the new bounds foreach (RibbonPanel panel in Panels) { Size s = panel.Bounds.Size; panel.SetBounds(new Rectangle(new Point(curRight, panelsTop), s)); curRight += panel.Bounds.Width + 1 + Owner.PanelSpacing; } } } ///Update regions of all panels foreach (RibbonPanel panel in Panels) { panel.UpdateItemsRegions(g, panel.SizeMode); } } UpdateScrollBounds(); }
private void HitOn(int x, int y) { if (Ribbon.Tabs.Count == 0 || Ribbon.ActiveTab == null) { SelectRibbon(); return; } if (Ribbon != null) { if (Ribbon.TabHitTest(x, y)) { SelectedElement = Ribbon.ActiveTab; } else { #region Tab ScrollTest if (Ribbon.ActiveTab.TabContentBounds.Contains(x, y)) { if (Ribbon.ActiveTab.ScrollLeftBounds.Contains(x, y) && Ribbon.ActiveTab.ScrollLeftVisible) { Ribbon.ActiveTab.ScrollLeft(); SelectedElement = Ribbon.ActiveTab; return; } if (Ribbon.ActiveTab.ScrollRightBounds.Contains(x, y) && Ribbon.ActiveTab.ScrollRightVisible) { Ribbon.ActiveTab.ScrollRight(); SelectedElement = Ribbon.ActiveTab; return; } } #endregion //Check Panel if (Ribbon.ActiveTab.TabContentBounds.Contains(x, y)) { RibbonPanel hittedPanel = null; foreach (RibbonPanel panel in Ribbon.ActiveTab.Panels) { if (panel.Bounds.Contains(x, y)) { hittedPanel = panel; break; } } if (hittedPanel != null) { //Check item RibbonItem hittedItem = null; foreach (RibbonItem item in hittedPanel.Items) { if (item.Bounds.Contains(x, y)) { hittedItem = item; break; } } if (hittedItem != null && hittedItem is IContainsSelectableRibbonItems) { //Check subitem RibbonItem hittedSubItem = null; foreach (RibbonItem subItem in (hittedItem as IContainsSelectableRibbonItems).GetItems()) { if (subItem.Bounds.Contains(x, y)) { hittedSubItem = subItem; break; } } if (hittedSubItem != null) { SelectedElement = hittedSubItem; } else { SelectedElement = hittedItem; } } else if (hittedItem != null) { SelectedElement = hittedItem; } else { SelectedElement = hittedPanel; } } else { SelectedElement = Ribbon.ActiveTab; } } else if (Ribbon.QuickAcessToolbar.SuperBounds.Contains(x, y)) { bool itemHitted = false; foreach (RibbonItem item in Ribbon.QuickAcessToolbar.Items) { if (item.Bounds.Contains(x, y)) { itemHitted = true; SelectedElement = item; break; } } if (!itemHitted) { SelectedElement = Ribbon.QuickAcessToolbar; } } else if (Ribbon.OrbBounds.Contains(x, y)) { Ribbon.OrbMouseDown(); } else { SelectRibbon(); Ribbon.ForceOrbMenu = false; if (Ribbon.OrbDropDown.Visible) { Ribbon.OrbDropDown.Close(); } } } } }
internal override void SetOwnerPanel(RibbonPanel ownerPanel) { base.SetOwnerPanel(ownerPanel); _dropDownItems.SetOwnerPanel(ownerPanel); }
public RibbonPanelRenderEventArgs(Ribbon owner, Graphics g, Rectangle clip, RibbonPanel panel, Control canvas) : base(owner, g, clip) { Panel = panel; Canvas = canvas; }
private void InitHomeTab() { //Clipboard panel RibbonButton btnPaste = new RibbonButton("Paste"); btnPaste.Image = Resources.paste_32; btnPaste.Click += new EventHandler(pasteRibbonButton_Click); RibbonButton btnCut = new RibbonButton("Cut"); btnCut.MaxSizeMode = RibbonElementSizeMode.Medium; btnCut.SmallImage = Resources.cut_16; btnCut.Click += new EventHandler(cutRibbonButton_Click); RibbonButton btnCopy = new RibbonButton("Copy"); btnCopy.MaxSizeMode = RibbonElementSizeMode.Medium; btnCopy.SmallImage = Resources.copy_16; btnCopy.Click += new EventHandler(copyRibbonButton_Click); RibbonButton btnDelete = new RibbonButton("Delete"); btnDelete.MaxSizeMode = RibbonElementSizeMode.Medium; btnDelete.SmallImage = Resources.delete_16; btnDelete.Click += new EventHandler(deleteRibbonButton_Click); panelClipboard = new RibbonPanel("Clipboard"); panelClipboard.Items.Add(btnPaste); panelClipboard.Items.Add(btnCut); panelClipboard.Items.Add(btnCopy); panelClipboard.Items.Add(btnDelete); //Arrange RibbonButton btnAlignHorizontally = new RibbonButton(); btnAlignHorizontally.SmallImage = Resources.align_horizontally_16; btnAlignHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact; btnAlignHorizontally.Click += new EventHandler(alignHorizontallyRibbonButton_Click); RibbonButton btnAlignVertically = new RibbonButton(); btnAlignVertically.SmallImage = Resources.align_vertically_16; btnAlignVertically.MaxSizeMode = RibbonElementSizeMode.Compact; btnAlignVertically.Click += new EventHandler(alignVerticallyRibbonButton_Click); RibbonButton btnSpaceHorizontally = new RibbonButton(); btnSpaceHorizontally.SmallImage = Resources.space_horizontally_16; btnSpaceHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact; btnSpaceHorizontally.Click += new EventHandler(spaceHorizontallyRibbonButton_Click); RibbonButton btnSpaceVertically = new RibbonButton(); btnSpaceVertically.SmallImage = Resources.space_vertically_16; btnSpaceVertically.MaxSizeMode = RibbonElementSizeMode.Compact; btnSpaceVertically.Click += new EventHandler(spaceVerticallyRibbonButton_Click); RibbonItemGroup itemgroupAlignment = new RibbonItemGroup(); itemgroupAlignment.Items.Add(btnAlignHorizontally); itemgroupAlignment.Items.Add(btnAlignVertically); itemgroupAlignment.Items.Add(btnSpaceHorizontally); itemgroupAlignment.Items.Add(btnSpaceVertically); RibbonButton btnFlipHorizontally = new RibbonButton(); btnFlipHorizontally.SmallImage = Resources.flip_horizontally_16; btnFlipHorizontally.MaxSizeMode = RibbonElementSizeMode.Compact; btnFlipHorizontally.Click += new EventHandler(flipHorizontallyRibbonButton_Click); RibbonButton btnFlipVertically = new RibbonButton(); btnFlipVertically.SmallImage = Resources.flip_vertically_16; btnFlipVertically.MaxSizeMode = RibbonElementSizeMode.Compact; btnFlipVertically.Click += new EventHandler(flipVerticallyRibbonButton_Click); RibbonItemGroup itemgroupTransform = new RibbonItemGroup(); itemgroupTransform.Items.Add(btnFlipHorizontally); itemgroupTransform.Items.Add(btnFlipVertically); RibbonButton btnRotateAntiClockwise = new RibbonButton(); btnRotateAntiClockwise.SmallImage = Resources.rotate_acw_16; btnRotateAntiClockwise.MaxSizeMode = RibbonElementSizeMode.Compact; btnRotateAntiClockwise.Click += new EventHandler(rotateACwRibbonButton_Click); RibbonButton btnRotateClockwise = new RibbonButton(); btnRotateClockwise.SmallImage = Resources.rotate_cw_16; btnRotateClockwise.MaxSizeMode = RibbonElementSizeMode.Compact; btnRotateClockwise.Click += new EventHandler(rotateCwRibbonButton_Click); RibbonItemGroup itemgroupRotatation = new RibbonItemGroup(); itemgroupRotatation.Items.Add(btnRotateAntiClockwise); itemgroupRotatation.Items.Add(btnRotateClockwise); panelAlignment = new RibbonPanel("Alignment"); panelAlignment.FlowsTo = RibbonPanelFlowDirection.Right; panelAlignment.Items.Add(itemgroupAlignment); panelAlignment.Items.Add(itemgroupTransform); panelAlignment.Items.Add(itemgroupRotatation); RibbonButton btnBringForward = new RibbonButton("Bring Forwards"); btnBringForward.Image = Resources.bring_forward_32; btnBringForward.Click += new EventHandler(bringForwardRibbonButton_Click); RibbonButton btnSendBackward = new RibbonButton("Send Backwards"); btnSendBackward.Image = Resources.send_backward_32; btnSendBackward.Click += new EventHandler(sendBackwardRibbonButton_Click); RibbonButton btnBringToFront = new RibbonButton("Bring to Front"); btnBringToFront.Image = Resources.bring_to_front_32; btnBringToFront.Click += new EventHandler(bringToFrontRibbonButton_Click); RibbonButton btnSendToBack = new RibbonButton("Send to Back"); btnSendToBack.Image = Resources.send_to_back_32; btnSendToBack.Click += new EventHandler(sendToBackRibbonButton_Click); panelZOrder = new RibbonPanel("Z Order"); panelZOrder.Items.Add(btnBringForward); panelZOrder.Items.Add(btnSendBackward); panelZOrder.Items.Add(btnBringToFront); panelZOrder.Items.Add(btnSendToBack); RibbonButton btnLaunchPeggleNights = new RibbonButton("Nights"); btnLaunchPeggleNights.Image = Resources.PeggleNights_32; btnLaunchPeggleNights.Click += new EventHandler(peggleNightsRibbonButton_Click); RibbonPanel panelPeggle = new RibbonPanel("Launch Peggle"); panelPeggle.Items.Add(btnLaunchPeggleNights); RibbonTab tabHome = new RibbonTab(mRibbon, "Home"); tabHome.Panels.Add(panelClipboard); tabHome.Panels.Add(panelAlignment); tabHome.Panels.Add(panelZOrder); tabHome.Panels.Add(panelPeggle); mRibbon.Tabs.Add(tabHome); }
private void AddAMEEConnectButton(RibbonPanel panel) { var pushButton = panel.AddItem(new PushButtonData("launchAMEEConnect", "AMEE Connect", AddInPath, "AMEE_in_Revit.Addin.Commands.LaunchAMEEConnectCommand")) as PushButton; pushButton.ToolTip = "Say Hello World"; pushButton.Image = pushButton.LargeImage = new BitmapImage(new Uri(ButtonIconsFolder + @"\search_amee.png")); }
private void InitObjectTab() { RibbonButton btnSameLocation = new RibbonButton("Relocate"); btnSameLocation.Image = Resources.properties_32; btnSameLocation.Click += new EventHandler(sameLocationRibbonButton_Click); RibbonPanel panelProperties = new RibbonPanel("Properties"); panelProperties.Items.Add(btnSameLocation); RibbonButton btnMovementType = new RibbonButton("Type"); btnMovementType.Image = Resources.peg_move_type_32; btnMovementType.Style = RibbonButtonStyle.DropDown; for (int i = 0; i <= (int)MovementType.WeirdShape; i++) { RibbonButton ritem = new RibbonButton(); ritem.Text = ((MovementType)i).ToString(); ritem.Tag = i; ritem.Click += new EventHandler(movementTypeRibbonButton_Click); btnMovementType.DropDownItems.Add(ritem); } RibbonButton btnSpreadPhase = new RibbonButton("Phase"); btnSpreadPhase.Image = Resources.spread_phase_32; btnSpreadPhase.Click += new EventHandler(spreadPhaseRibbonButton_Click); RibbonButton btnDuplicateAndPhase = new RibbonButton("Duplicate & Phase"); btnDuplicateAndPhase.Image = Resources.duplicate_and_phase_32; btnDuplicateAndPhase.Click += new EventHandler(duplicateAndPhaseRibbonButton_Click); RibbonButton btnLinkSubMovements = new RibbonButton("Link Sub-movements"); btnLinkSubMovements.Image = Resources.link_sub_movements_32; btnLinkSubMovements.Click += new EventHandler(linkSubMovementsRibbonButton_Click); RibbonPanel panelMovement = new RibbonPanel("Movement"); panelMovement.Items.Add(btnMovementType); panelMovement.Items.Add(btnSpreadPhase); panelMovement.Items.Add(btnDuplicateAndPhase); panelMovement.Items.Add(btnLinkSubMovements); RibbonTab tabObject = new RibbonTab(mRibbon, "Object"); tabObject.Panels.Add(panelProperties); tabObject.Panels.Add(panelMovement); mRibbon.Tabs.Add(tabObject); }
private void AddTellAMEEButton(RibbonPanel panel) { var pushButton = panel.AddItem(new PushButtonData("launchTellAMEE", "Tell AMEE", AddInPath, "AMEE_in_Revit.Addin.Commands.LaunchTellAMEECommand")) as PushButton; pushButton.Image = pushButton.LargeImage = new BitmapImage(new Uri(ButtonIconsFolder + @"\send.png")); }
private void InitHelpTab() { RibbonButton btnReadme = new RibbonButton("Readme.txt"); btnReadme.Image = Resources.readme_32; btnReadme.Click += new EventHandler(readmeRibbonButton_Click); RibbonButton btnAbout = new RibbonButton("About"); btnAbout.Image = Resources.orca_32; btnAbout.Click += new EventHandler(aboutRibbonButton_Click); RibbonPanel panelHelp = new RibbonPanel(); panelHelp.Items.Add(btnReadme); panelHelp.Items.Add(btnAbout); RibbonTab tabHelp = new RibbonTab(mRibbon, "Help"); tabHelp.Panels.Add(panelHelp); mRibbon.Tabs.Add(tabHelp); }
protected virtual void PopulateRibbonMenuButtons() { IDictionary<NavigationNodeItem, IEnumerable<RibbonModulePluginItem>> modulePluginsByNavList = this.pluginProvider.GetPlugins<RibbonModulePluginItem>(); this.ribbonMenu.Tabs.Clear(); this.ribbonMenu.QuickAcessToolbar.Items.Clear(); foreach (KeyValuePair<NavigationNodeItem, IEnumerable<RibbonModulePluginItem>> pluginItemsByNav in modulePluginsByNavList) { string tabName = pluginItemsByNav.Key.Name; string tabText = pluginItemsByNav.Key.Text; RibbonPanel mainModulePanel = new RibbonPanel(); RibbonPanel subModulePanel = new RibbonPanel(); IEnumerable<RibbonModulePluginItem> modulePlugins = pluginItemsByNav.Value; foreach (RibbonModulePluginItem modulePluginItem in modulePlugins) { RibbonButton ribbonButton = new RibbonButton(); ribbonButton.Name = modulePluginItem.Name; ribbonButton.Text = modulePluginItem.Text; ribbonButton.Image = (Image)this.resourceManager.GetImage(modulePluginItem.IconResourceName); ribbonButton.Enabled = modulePluginItem.Enabled; ribbonButton.Checked = modulePluginItem.Checked; ribbonButton.Tag = modulePluginItem; if (modulePluginItem.Alignment == RibbonButtonAlignment.Left) { mainModulePanel.Items.Add(ribbonButton); } else { subModulePanel.Items.Add(ribbonButton); } } RibbonTab ribbonTab = new RibbonTab(); ribbonTab.Name = tabName; ribbonTab.Text = tabText; ribbonTab.Panels.AddRange(new RibbonPanel[] { mainModulePanel, subModulePanel }); this.ribbonMenu.Tabs.Add(ribbonTab); } }
private void AddRecalculateCO2eButton(RibbonPanel panel) { var pushButton = panel.AddItem(new PushButtonData("recalculateCO2e", "Recalculate CO2e\nfor all elements", AddInPath, "AMEE_in_Revit.Addin.Commands.RecalculateCO2eCommand")) as PushButton; pushButton.Image = pushButton.LargeImage = new BitmapImage(new Uri(ButtonIconsFolder + @"\calculate.png")); }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { // This method is called by Inventor when it loads the addin. // The AddInSiteObject provides access to the Inventor Application object. // The FirstTime flag indicates if the addin is loaded for the first time. try { // Initialize AddIn members. m_inventorApplication = addInSiteObject.Application; //m_inventorApplication.Caption = "Addin Loaded!!!"; //MessageBox.Show("Addin First time"); Button.InventorApplication = m_inventorApplication; //load image icons for UI items Icon addShaftIcon = new Icon(this.GetType(), "AddShaft.ico"); //retrieve the GUID for this class GuidAttribute addInCLSID; addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(StandardAddInServer), typeof(GuidAttribute)); string addInCLSIDString; addInCLSIDString = "{" + addInCLSID.Value + "}"; //create buttons m_addShaftButton = new AddShaftButton( "Shaft", "Autodesk:Shaft:AddShaftCmdBtn", CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Build shaft", "Helps to calculate and build shaft", addShaftIcon, addShaftIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); //create the command category CommandCategory ShaftCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Shaft", "Autodesk:Shaft:ShaftCmdCat", addInCLSIDString); ShaftCmdCategory.Add(m_addShaftButton.ButtonDefinition); if (firstTime == true) { //access user interface manager UserInterfaceManager userInterfaceManager; userInterfaceManager = m_inventorApplication.UserInterfaceManager; InterfaceStyleEnum interfaceStyle; interfaceStyle = userInterfaceManager.InterfaceStyle; //create the UI for ribbon interface //get the ribbon associated with part document Inventor.Ribbons ribbons; ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon partRibbon; partRibbon = ribbons["Part"]; //get the tabls associated with part ribbon RibbonTabs ribbonTabs; ribbonTabs = partRibbon.RibbonTabs; RibbonTab partSketchRibbonTab; partSketchRibbonTab = ribbonTabs["id_TabSketch"]; //create a new panel with the tab RibbonPanels ribbonPanels; ribbonPanels = partSketchRibbonTab.RibbonPanels; m_partSketchShaftRibbonPanel = ribbonPanels.Add("Shaft", "Autodesk:Shaft:ShaftRibbonPanel", "{187856c3-b22f-43dc-8068-5d6adbe4adc5}", "", false); //add controls to the Shaft panel CommandControls partSketchShaftRibbonPanelCtrls; partSketchShaftRibbonPanelCtrls = m_partSketchShaftRibbonPanel.CommandControls; //add the buttons to the ribbon panel CommandControl ShaftCmdBtnCmdCtrl; ShaftCmdBtnCmdCtrl = partSketchShaftRibbonPanelCtrls.AddButton(m_addShaftButton.ButtonDefinition, false, true, "", false); } // TODO: Add ApplicationAddInServer.Activate implementation. // e.g. event initialization, command creation etc. } catch (Exception e) { MessageBox.Show(e.ToString()); } }
private void AddUpdateCO2eVisualization(RibbonPanel panel) { var pushButton = panel.AddItem(new PushButtonData("updateCO2eVisualization", "Update CO2e\nvisualization", AddInPath, "AMEE_in_Revit.Addin.Commands.UpdateCO2eVisualizationCommand")) as PushButton; pushButton.Image = pushButton.LargeImage = new BitmapImage(new Uri(ButtonIconsFolder + @"\visualize.png")); }
/// <summary> /// Removes the rectangle tools from Inventor. /// </summary> public void Deactivate() { DeactivateButtons(); partRectControlsPanel = null; drawingRectControlsPanel = null; assemblyRectControlPanel = null; }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { try { SetupDynamoPaths(); inventorApplication = addInSiteObject.Application; PersistenceManager.InventorApplication = inventorApplication; userInterfaceManager = inventorApplication.UserInterfaceManager; //initialize event delegates userInterfaceEvents = inventorApplication.UserInterfaceManager.UserInterfaceEvents; UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars); userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate; UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments); userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate; UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface); userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate; appEvents = inventorApplication.ApplicationEvents; appEvents.OnActivateDocument += appEvents_OnActivateDocument; appEvents.OnDeactivateDocument += appEvents_OnDeactivateDocument; Icon dynamoIcon = Resources.logo_square_32x32; //retrieve the GUID for this class GuidAttribute addInCLSID; addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(this.GetType(), typeof(GuidAttribute)); string addInCLSIDString; addInCLSIDString = "{" + addInCLSID.Value + "}"; dynamoAddinButton = new DynamoInventorAddinButton( buttonDisplayName, buttonInternalName, CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Initialize Dynamo.", "Dynamo is a visual programming environment for Inventor.", dynamoIcon, dynamoIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); CommandCategory assemblyUtilitiesCategory = inventorApplication.CommandManager.CommandCategories.Add(commandCategoryDisplayName, commandCategoryInternalName, addInCLSID); assemblyUtilitiesCategory.Add(dynamoAddinButton.ButtonDefinition); if (firstTime == true) { InterfaceStyleEnum interfaceStyle; interfaceStyle = userInterfaceManager.InterfaceStyle; if (interfaceStyle == InterfaceStyleEnum.kClassicInterface) { CommandBar assemblyUtilityCommandBar; assemblyUtilityCommandBar = userInterfaceManager.CommandBars.Add(commandBarDisplayName, commandBarInternalName, CommandBarTypeEnum.kRegularCommandBar, addInCLSID); } else { Inventor.Ribbons ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon assemblyRibbon = ribbons["Assembly"]; RibbonTabs ribbonTabs = assemblyRibbon.RibbonTabs; RibbonTab assemblyRibbonTab = ribbonTabs["id_AddInsTab"]; RibbonPanels ribbonPanels = assemblyRibbonTab.RibbonPanels; assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls; CommandControl assemblyCmdBtnCmdCtrl = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); Inventor.Ribbon partRibbon = ribbons["Part"]; RibbonTabs partRibbonTabs = partRibbon.RibbonTabs; RibbonTab modelRibbonTab = partRibbonTabs["id_AddInsTab"]; RibbonPanels partRibbonPanels = modelRibbonTab.RibbonPanels; partRibbonPanel = partRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls partRibbonPanelCtrls = partRibbonPanel.CommandControls; CommandControl partCmdBtnCmdCtrl = partRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); Inventor.Ribbon drawingRibbon = ribbons["Drawing"]; RibbonTabs drawingRibbonTabs = drawingRibbon.RibbonTabs; RibbonTab drawingRibbonTab = drawingRibbonTabs["id_AddInsTab"]; RibbonPanels drawingRibbonPanels = drawingRibbonTab.RibbonPanels; drawingRibbonPanel = drawingRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); CommandControls drawingRibbonPanelCtrls = drawingRibbonPanel.CommandControls; CommandControl drawingCmdBtnCmdCtrl = drawingRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false); } } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
/// <summary> /// This method gets called to add a new panel to the ribbon to be the container for /// the rectangle buttons /// </summary> private void CreateRectangleRibbonPanel() { //create a reference to the ribbon Ribbon partRibbon = StandardAddInServer.InventorApplication.UserInterfaceManager.Ribbons["Part"]; Ribbon drawingRibbon = StandardAddInServer.InventorApplication.UserInterfaceManager.Ribbons["Drawing"]; Ribbon assemblyRibbon = StandardAddInServer.InventorApplication.UserInterfaceManager.Ribbons["Assembly"]; //create a reference to the tab you want to add a control to RibbonTab partSketchTab = partRibbon.RibbonTabs["id_TabSketch"]; RibbonTab drawingSketchTab = drawingRibbon.RibbonTabs["id_TabSketch"]; RibbonTab assemblySketchTab = assemblyRibbon.RibbonTabs["id_TabSketch"]; //reference the panels collection in a variable so that you can call the add method in a clean fashion RibbonPanels partSketchTabPanels = partSketchTab.RibbonPanels; RibbonPanels drawingSketchTabPanels = drawingSketchTab.RibbonPanels; RibbonPanels assemblySketchTabPanels = assemblySketchTab.RibbonPanels; //Add your panel to the panels collection partRectControlsPanel = partSketchTabPanels.Add("Rectangles", RectangleControlsPanelInternalName, StandardAddInServer.AddInServerId,"id_PanelP_2DSketchConstrain", true); drawingRectControlsPanel = drawingSketchTabPanels.Add("Rectangles", RectangleControlsPanelInternalName, StandardAddInServer.AddInServerId, "id_PanelD_2DSketchConstrain", true); assemblyRectControlPanel = assemblySketchTabPanels.Add("Rectangles", RectangleControlsPanelInternalName, StandardAddInServer.AddInServerId, "id_PanelA_2DSketchConstrain", true); //Create an Inventor Object collection that will hold the buttons for the split control that gets added to //the rectangles panel. To add a split button control you have to pass in a collection. ObjectCollection objectCollection = StandardAddInServer.InventorApplication.TransientObjects.CreateObjectCollection(); //Add the rectangle buttons to the collection objectCollection.Add(centerPointRectangleBtn.ButtonDefinition); objectCollection.Add(diagonalCenterPointRectangleButton.ButtonDefinition); objectCollection.Add(hzMidPointRectangleBtn.ButtonDefinition); objectCollection.Add(vertMidPointRectangleBtn.ButtonDefinition); //Add the split button control to the rectangles panel partRectangleSplitButton = partRectControlsPanel.CommandControls.AddSplitButton (DisplayedControl: DefaultDisplayControl, ButtonDefinitions: objectCollection, UseLargeIcon: true); drawingRectangleSplitButton = drawingRectControlsPanel.CommandControls.AddSplitButton (DisplayedControl: DefaultDisplayControl, ButtonDefinitions: objectCollection, UseLargeIcon: true); assemblyRectangleSplitButton = assemblyRectControlPanel.CommandControls.AddSplitButton (DisplayedControl: DefaultDisplayControl, ButtonDefinitions: objectCollection, UseLargeIcon: true); }
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime) { try { //the Activate method is called by Inventor when it loads the addin //the AddInSiteObject provides access to the Inventor Application object //the FirstTime flag indicates if the addin is loaded for the first time //initialize AddIn members m_inventorApplication = addInSiteObject.Application; Button.InventorApplication = m_inventorApplication; //initialize event delegates m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents; UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars); m_userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate; UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments); m_userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate; UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface); m_userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate; //load image icons for UI items Icon addSlotOptionIcon = new Icon(this.GetType(), "AddSlotOption.ico"); Icon drawSlotIcon = new Icon(this.GetType(), "DrawSlot.ico"); Icon toggleSlotStateIcon = new Icon(this.GetType(), "ToggleSlotState.ico"); //retrieve the GUID for this class GuidAttribute addInCLSID; addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(AddInServer), typeof(GuidAttribute)); string addInCLSIDString; addInCLSIDString = "{" + addInCLSID.Value + "}"; //create the comboboxes m_slotWidthComboBoxDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Slot Width", "Autodesk:SimpleAddIn:SlotWidthCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Slot width", "Slot width", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode); m_slotHeightComboBoxDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Slot Height", "Autodesk:SimpleAddIn:SlotHeightCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Slot height", "Slot height", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode); //add some initial items to the comboboxes m_slotWidthComboBoxDefinition.AddItem("1 cm", 0); m_slotWidthComboBoxDefinition.AddItem("2 cm", 0); m_slotWidthComboBoxDefinition.AddItem("3 cm", 0); m_slotWidthComboBoxDefinition.AddItem("4 cm", 0); m_slotWidthComboBoxDefinition.AddItem("5 cm", 0); m_slotWidthComboBoxDefinition.ListIndex = 1; m_slotWidthComboBoxDefinition.ToolTipText = m_slotWidthComboBoxDefinition.Text; m_slotWidthComboBoxDefinition.DescriptionText = "Slot width: " + m_slotWidthComboBoxDefinition.Text; SlotWidthComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotWidthComboBox_OnSelect); m_slotWidthComboBoxDefinition.OnSelect += SlotWidthComboBox_OnSelectEventDelegate; m_slotHeightComboBoxDefinition.AddItem("1 cm", 0); m_slotHeightComboBoxDefinition.AddItem("2 cm", 0); m_slotHeightComboBoxDefinition.AddItem("3 cm", 0); m_slotHeightComboBoxDefinition.AddItem("4 cm", 0); m_slotHeightComboBoxDefinition.AddItem("5 cm", 0); m_slotHeightComboBoxDefinition.ListIndex = 1; m_slotHeightComboBoxDefinition.ToolTipText = m_slotHeightComboBoxDefinition.Text; m_slotHeightComboBoxDefinition.DescriptionText = "Slot height: " + m_slotHeightComboBoxDefinition.Text; SlotHeightComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotHeightComboBox_OnSelect); m_slotHeightComboBoxDefinition.OnSelect += SlotHeightComboBox_OnSelectEventDelegate; //create buttons m_addSlotOptionButton = new AddSlotOptionButton( "Add Slot width/height", "Autodesk:SimpleAddIn:AddSlotOptionCmdBtn", CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Adds option for slot width/height", "Add slot option", addSlotOptionIcon, addSlotOptionIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); m_drawSlotButton = new DrawSlotButton( "Draw Slot", "Autodesk:SimpleAddIn:DrawSlotCmdBtn", CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Create slot sketch graphics", "Draw Slot", drawSlotIcon, drawSlotIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); m_toggleSlotStateButton = new ToggleSlotStateButton( "Toggle Slot State", "Autodesk:SimpleAddIn:ToggleSlotStateCmdBtn", CommandTypesEnum.kShapeEditCmdType, addInCLSIDString, "Enables/Disables state of slot command", "Toggle Slot State", toggleSlotStateIcon, toggleSlotStateIcon, ButtonDisplayEnum.kDisplayTextInLearningMode); //create the command category CommandCategory slotCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Slot", "Autodesk:SimpleAddIn:SlotCmdCat", addInCLSIDString); slotCmdCategory.Add(m_slotWidthComboBoxDefinition); slotCmdCategory.Add(m_slotHeightComboBoxDefinition); slotCmdCategory.Add(m_addSlotOptionButton.ButtonDefinition); slotCmdCategory.Add(m_drawSlotButton.ButtonDefinition); slotCmdCategory.Add(m_toggleSlotStateButton.ButtonDefinition); if (firstTime == true) { //access user interface manager UserInterfaceManager userInterfaceManager; userInterfaceManager = m_inventorApplication.UserInterfaceManager; InterfaceStyleEnum interfaceStyle; interfaceStyle = userInterfaceManager.InterfaceStyle; //create the UI for classic interface if (interfaceStyle == InterfaceStyleEnum.kClassicInterface) { //create toolbar CommandBar slotCommandBar; slotCommandBar = userInterfaceManager.CommandBars.Add("Slot", "Autodesk:SimpleAddIn:SlotToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString); //add comboboxes to toolbar slotCommandBar.Controls.AddComboBox(m_slotWidthComboBoxDefinition, 0); slotCommandBar.Controls.AddComboBox(m_slotHeightComboBoxDefinition, 0); //add buttons to toolbar slotCommandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0); slotCommandBar.Controls.AddButton(m_drawSlotButton.ButtonDefinition, 0); slotCommandBar.Controls.AddButton(m_toggleSlotStateButton.ButtonDefinition, 0); //Get the 2d sketch environment base object Inventor.Environment partSketchEnvironment; partSketchEnvironment = userInterfaceManager.Environments["PMxPartSketchEnvironment"]; //make this command bar accessible in the panel menu for the 2d sketch environment. partSketchEnvironment.PanelBar.CommandBarList.Add(slotCommandBar); } //create the UI for ribbon interface else { //get the ribbon associated with part document Inventor.Ribbons ribbons; ribbons = userInterfaceManager.Ribbons; Inventor.Ribbon partRibbon; partRibbon = ribbons["Part"]; //get the tabls associated with part ribbon RibbonTabs ribbonTabs; ribbonTabs = partRibbon.RibbonTabs; RibbonTab partSketchRibbonTab; partSketchRibbonTab = ribbonTabs["id_TabSketch"]; //create a new panel with the tab RibbonPanels ribbonPanels; ribbonPanels = partSketchRibbonTab.RibbonPanels; m_partSketchSlotRibbonPanel = ribbonPanels.Add("Slot", "Autodesk:SimpleAddIn:SlotRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false); //add controls to the slot panel CommandControls partSketchSlotRibbonPanelCtrls; partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls; //add the combo boxes to the ribbon panel CommandControl slotWidthCmdCboBoxCmdCtrl; slotWidthCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotWidthComboBoxDefinition, "", false); CommandControl slotHeightCmdCboBoxCmdCtrl; slotHeightCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotHeightComboBoxDefinition, "", false); //add the buttons to the ribbon panel CommandControl drawSlotCmdBtnCmdCtrl; drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_drawSlotButton.ButtonDefinition, false, true, "", false); CommandControl slotOptionCmdBtnCmdCtrl; slotOptionCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false); CommandControl toggleSlotStateCmdBtnCmdCtrl; toggleSlotStateCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_toggleSlotStateButton.ButtonDefinition, false,true, "", false); } } MessageBox.Show ("To access the commands of the sample addin, activate a 2d sketch of a part \n document and select the \"AddInSlot\" toolbar within the panel menu"); } catch(Exception e) { MessageBox.Show(e.ToString()); } }
/// <summary> /// When an item is removed from the RibbonItemCollection remove all its references. /// </summary> internal virtual void ClearOwner() { _ownerItem = null; _ownerPanel = null; _ownerTab = null; _owner = null; OnOwnerChanged(EventArgs.Empty); }
internal override void SetOwnerPanel(RibbonPanel ownerPanel) { base.SetOwnerPanel(ownerPanel); if (_dropDownItems != null) _dropDownItems.SetOwnerPanel(ownerPanel); }
/// <summary> /// Sets the value of the OwnerPanel property /// </summary> /// <param name="ownerPanel">RibbonPanel where this item is located</param> internal virtual void SetOwnerPanel(RibbonPanel ownerPanel) { _ownerPanel = ownerPanel; }
internal override void SetOwnerPanel(RibbonPanel ownerPanel) { base.SetOwnerPanel(ownerPanel); _buttons.SetOwnerPanel(ownerPanel); _dropDownItems.SetOwnerPanel(ownerPanel); }
protected override void OnPaintAdornments(PaintEventArgs pe) { base.OnPaintAdornments(pe); using (Pen p = new Pen(Color.Black)) { p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; ISelectionService host = GetService(typeof(ISelectionService)) as ISelectionService; if (host != null) { foreach (IComponent comp in host.GetSelectedComponents()) { if (comp is RibbonContext) { RibbonContext item = comp as RibbonContext; if (item != null) { Rectangle selection = (item.ContextualTabsCount > 0) ? item.HeaderBounds : item.Bounds; selection.Inflate(-1, -1); pe.Graphics.DrawRectangle(p, selection); } } else if (comp is RibbonTab) { RibbonTab item = comp as RibbonTab; if (item != null) { Rectangle selection = item.Bounds; selection.Inflate(-1, -1); pe.Graphics.DrawRectangle(p, selection); } } else if (comp is RibbonPanel) { RibbonPanel item = comp as RibbonPanel; if (item != null) { Rectangle selection = item.Bounds; selection.Inflate(-1, -1); pe.Graphics.DrawRectangle(p, selection); } } else if (comp is RibbonItem) { RibbonItem item = comp as RibbonItem; if (item != null && !Ribbon.OrbDropDown.AllItems.Contains(item)) { Rectangle selection = item.Bounds; selection.Inflate(1, 1); pe.Graphics.DrawRectangle(p, selection); } } } } } }