// update UI when the selection changes void UpdateUI() { // start updating _updatingUI = true; // update selected tab C1TextEditorRibbonTab tab = this.SelectedTab as C1TextEditorRibbonTab; if (tab != null) { tab.UpdateUI(); } // done updating _updatingUI = false; _dirtyUI = false; }
static RibbonSplitButton CreateSplitButton(string id, params object[] items) { return(C1TextEditorRibbonTab.CreateSplitButton(id, items)); }
static RibbonButton CreateButton(string id, string imageId) { return(C1TextEditorRibbonTab.CreateButton(id, imageId)); }
static RibbonAppMenuTab CreateTab(string id) { return(C1TextEditorRibbonTab.CreateTab(id)); }
static RibbonListItem CreateHeader(string id) { return(C1TextEditorRibbonTab.CreateHeader(id)); }
// delegate element creation to C1XHtmlRibbonTab static RibbonLabel CreateHeaderLabel(string id) { return(C1TextEditorRibbonTab.CreateHeaderLabel(id)); }
//------------------------------------------------------------ #region ** command dispatcher // forward ribbon events to the appropriate C1XHtmlRibbonTab. protected override void OnRibbonEvent(RibbonEventArgs e) { RibbonItem item = e.Item as RibbonItem; if (item != null) { // handle clicks on non-tab items if (e.EventType == RibbonEventType.Click) { // handle application menu and Qat items if (item.Tab == null) { switch (item.ID) { case "New": NewDocument(); return; case "Open": case "OpenQat": OpenDocument(); return; case "Save": case "SaveQat": SaveDocument(); return; case "SaveAs": SaveDocumentAs(); break; case "Print": PrintDocument(true, false); break; case "PrintPreview": PrintDocument(false, true); break; case "QuickPrint": PrintDocument(false, false); break; case "ExportPdf": ExportDocument(); break; case "Exit": Exit(); break; case "Undo": Undo(); break; case "Redo": Redo(); break; default: break; } } } else if (e.EventType == RibbonEventType.DropDown) { switch (item.ID) { case "Undo": case "Redo": bool isUndo = string.Compare(item.ID, "Undo", true) == 0; string[] actionList = isUndo ? _editor.Editor.History.UndoList : _editor.Editor.History.RedoList; RibbonSplitButton sb = item as RibbonSplitButton; sb.Items.Clear(); int actionIndex = 0; foreach (string action in actionList) { RibbonButton rb = new RibbonButton(action); rb.Tag = actionIndex; rb.Click += (isUndo ? new EventHandler(UndoClick) : new EventHandler(RedoClick)); sb.Items.Add(rb); actionIndex += 1; } break; default: break; } } // delegate to tab elements if (!_updatingUI) { C1TextEditorRibbonTab tab = item.Tab as C1TextEditorRibbonTab; if (tab != null) { tab.HandleItemEvent(e); } } // exit when double-clicking the app menu if (item.Equals(this.ApplicationMenu) && e.EventType == RibbonEventType.DoubleClick) { Exit(); } } // fire event as usual base.OnRibbonEvent(e); }