/// <summary> /// Renders the menu. /// </summary> private void RefreshMenu() { RibbonApplicationMenu MainMenu = ShellWindow.RibbonMainMenu as RibbonApplicationMenu; if (MainMenu != null) { MainMenu.Items.Clear(); bool firstGroup = true; foreach (string group in menuGroups.Keys) { IList <RibbonApplicationMenuItem> items = menuGroups[group]; if (!firstGroup) { MainMenu.Items.Add(new RibbonSeparator()); } foreach (RibbonApplicationMenuItem item in items) { MainMenu.Items.Add(item); } firstGroup = false; } } }
/// <summary> /// Creates peers for AuxiliaryPaneContent and FooterPanecontent and add them to the /// collection of children peers. /// </summary> /// <returns></returns> protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = base.GetChildrenCore(); RibbonApplicationMenu menu = Owner as RibbonApplicationMenu; UIElement element = menu.FooterPaneHost; if (element != null) { if (children == null) { children = new List <AutomationPeer>(); } children.Add(RibbonHelper.CreatePeer(element)); } element = menu.AuxiliaryPaneHost; if (element != null) { if (children == null) { children = new List <AutomationPeer>(); } children.Add(RibbonHelper.CreatePeer(element)); } return(children); }
private void BackstageController_Loaded(object sender, RoutedEventArgs e) { RibbonApplicationMenu menu = TemplatedParent as RibbonApplicationMenu; menu.DropDownOpened += (s, a) => { IsOpen = true; }; ToggleButton button = menu.Template.FindName("PART_ToggleButton", menu) as ToggleButton; button.Click += (s, a) => { IsOpen = true; button.IsChecked = false; }; }
public Form1() { InitializeComponent(); _applicationMenu = new RibbonApplicationMenu(_ribbon, (uint)RibbonMarkupCommands.cmdApplicationMenu); _buttonNew = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonNew); _buttonOpen = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonOpen); _buttonSave = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonSave); _buttonExit = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonExit); _applicationMenu.TooltipTitle = "Menu"; _applicationMenu.TooltipDescription = "Application main menu"; _buttonNew.ExecuteEvent += new EventHandler <ExecuteEventArgs>(_buttonNew_ExecuteEvent); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public org.pushingpixels.flamingo.api.common.popup.JPopupPanel getPopupPanel(final org.pushingpixels.flamingo.api.common.JCommandButton commandButton) public JPopupPanel getPopupPanel(JCommandButton commandButton) { if (appMenuButton.Parent is JRibbon) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.pushingpixels.flamingo.api.ribbon.JRibbon ribbon = (org.pushingpixels.flamingo.api.ribbon.JRibbon)appMenuButton.getParent(); JRibbon ribbon = (JRibbon)appMenuButton.Parent; RibbonApplicationMenu ribbonApplicationMenu = jRibbon.ApplicationMenu; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final CostOSRibbonApplicationMenuPopupPanel menuPopupPanel = new CostOSRibbonApplicationMenuPopupPanel(appMenuButton, ribbonApplicationMenu) CostOSRibbonApplicationMenuPopupPanel menuPopupPanel = new CostOSRibbonApplicationMenuPopupPanelAnonymousInnerClass(this, appMenuButton, ribbonApplicationMenu); costOSRibbonApplicationMenuPopupPanel.Customizer = new PopupPanelCustomizerAnonymousInnerClass(this); return(costOSRibbonApplicationMenuPopupPanel); } return(null); }
// initialize main menu void InitApplicationMenu() { // initialize menu RibbonApplicationMenu menu = this.ApplicationMenu; menu.DropDownWidth = 370; menu.AllowImageScaling = false; menu.SmallImage = Resources.AppMenuArrow; menu.Appearance = AppMenuAppearance.WholeForm; menu.DropDown += Menu_DropDown; // left menu items RibbonItemCollection items = menu.LeftPaneItems; items.ClearAndDisposeItems(); items.Add(CreateButton("New")); items.Add(CreateTab("OpenTab")); ((AppMenuTabs.OpenTab)((RibbonAppMenuTab)items["OpenTab"]).Control).RibbonApplicationMenu = menu; items.Add(CreateButton("Save")); items["Save"].SmallImage = null; items.Add(CreateTab("SaveAsTab")); ((AppMenuTabs.SaveAsTab)((RibbonAppMenuTab)items["SaveAsTab"]).Control).RibbonApplicationMenu = menu; items.Add(new RibbonSeparator()); items.Add(CreateTab("PrintTab")); _printTab = (AppMenuTabs.PrintTab)((RibbonAppMenuTab)items["PrintTab"]).Control; _printTab.Ribbon = this; _printTab.VisibleChanged += _printTab_VisibleChanged; //items.Add(CreateSplitButton("Print", // CreateHeaderLabel("PreviewAndPrint"), // CreateButton("Print"), // CreateButton("QuickPrint"), // CreateButton("PrintPreview"))); items.Add(CreateButton("ExportPdf")); items.Add(new RibbonSeparator()); items.Add(CreateButton("Exit")); _mruOpened = new RecentDocumentList(Settings.Default.OpenedFiles); _mruSaved = new RecentDocumentList(Settings.Default.SavedFiles); }
public CostOSRibbonApplicationMenuPopupPanelAnonymousInnerClass(PopupPanelCallbackAnonymousInnerClass outerInstance, JRibbonApplicationMenuButton appMenuButton, RibbonApplicationMenu ribbonApplicationMenu) : base(appMenuButton, ribbonApplicationMenu) { this.outerInstance = outerInstance; }
private void InitializeComponents() { // Instantiate Controls HelpButton = new RibbonHelpButton(ribbon, (uint)RibbonMarkupCommands.HelpButton); ApplicationMenu = new RibbonApplicationMenu(ribbon, (uint)RibbonMarkupCommands.ApplicationMenu); RecentItems = new RibbonRecentItems(ribbon, (uint)RibbonMarkupCommands.RecentItems); ButtonNew = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ButtonNew); ButtonOpen = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ButtonOpen); ButtonSave = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ButtonSave); SaveAs = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SaveAs); SaveAll = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SaveAll); Export = new RibbonDropDownButton(ribbon, (uint)RibbonMarkupCommands.Export); ExportAsPNG = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExportAsPNG); ExportAsJPG = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExportAsJPG); Close = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Close); ButtonExit = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ButtonExit); TabHome = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabHome); NewNode = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.NewNode); NewChildNode = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NewChildNode); NewLongNode = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NewLongNode); NewNodeAbove = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NewNodeAbove); NewNodeBelow = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NewNodeBelow); NewNodeParent = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NewNodeParent); GrpEdit = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpEdit); EditText = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.EditText); EditLong = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.EditLong); DeleteNode = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.DeleteNode); GrpClipboard = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpClipboard); Paste = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Paste); PasteAsText = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.PasteAsText); Cut = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Cut); Copy = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Copy); FormatPainter = new RibbonToggleButton(ribbon, (uint)RibbonMarkupCommands.FormatPainter); GrpFont = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpFont); RichFont = new RibbonFontControl(ribbon, (uint)RibbonMarkupCommands.RichFont); GrpFormat = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpFormat); BackColor = new RibbonDropDownColorPicker(ribbon, (uint)RibbonMarkupCommands.BackColor); ClearFormatting = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ClearFormatting); GrpIcons = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpIcons); IconsGallery = new RibbonInRibbonGallery(ribbon, (uint)RibbonMarkupCommands.IconsGallery); RemoveLastIcon = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.RemoveLastIcon); RemoveAllIcons = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.RemoveAllIcons); LaunchIconsDialog = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LaunchIconsDialog); TabEdit = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabEdit); GrpSelect = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpSelect); SelectAll = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectAll); SelectSiblings = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectSiblings); SelectAncestors = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectAncestors); SelectChildren = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectChildren); SelectDescendents = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendents); SelectDescendentsUpto1 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendentsUpto1); SelectDescendentsUpto2 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendentsUpto2); SelectDescendentsUpto3 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendentsUpto3); SelectDescendentsUpto4 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendentsUpto4); SelectDescendentsUpto5 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectDescendentsUpto5); ExpandOnSelect = new RibbonCheckBox(ribbon, (uint)RibbonMarkupCommands.ExpandOnSelect); SelectLevel = new RibbonDropDownButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel); SelectLevel1 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel1); SelectLevel2 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel2); SelectLevel3 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel3); SelectLevel4 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel4); SelectLevel5 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevel5); SelectLevelCurrent = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SelectLevelCurrent); GrpExpand = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpExpand); ExpandAll = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandAll); CollapseAll = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.CollapseAll); ToggleCurrent = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ToggleCurrent); ToggleBranch = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ToggleBranch); ExpandMapToCurrentLevel = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToCurrentLevel); ExpandMapToLevel1 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToLevel1); ExpandMapToLevel2 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToLevel2); ExpandMapToLevel3 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToLevel3); ExpandMapToLevel4 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToLevel4); ExpandMapToLevel5 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ExpandMapToLevel5); GrpNavigate = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNavigate); NavigateToCenter = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NavigateToCenter); NavigateToFirstSibling = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NavigateToFirstSibling); NavigateToLastSibling = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NavigateToLastSibling); GrpMove = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpMove); MoveUp = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveUp); MoveDown = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveDown); GrpSort = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpSort); SortAlphabetic = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SortAlphabetic); SortDueDate = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SortDueDate); SortNodeCount = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SortNodeCount); SortCreateDate = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SortCreateDate); SortModifiedDate = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.SortModifiedDate); SortOrder = new RibbonToggleButton(ribbon, (uint)RibbonMarkupCommands.SortOrder); GrpUndo = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpUndo); Undo = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Undo); Redo = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Redo); TabInsert = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabInsert); GrpHyperlink = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpHyperlink); Hyperlink = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Hyperlink); HyperlinkFile = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.HyperlinkFile); HyperlinkFolder = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.HyperlinkFolder); RemoveHyperlink = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.RemoveHyperlink); GrpNote = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNote); InsertNote = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.InsertNote); GrpTask = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpTask); AddTask = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTask); AddTaskToday = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTaskToday); AddTaskTomorrow = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTaskTomorrow); AddTaskNextWeek = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTaskNextWeek); AddTaskNextMonth = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTaskNextMonth); AddTaskNextQuarter = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AddTaskNextQuarter); CompleteTask = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.CompleteTask); RemoveTask = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.RemoveTask); TabFormat = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabFormat); GrpNodeFormat = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNodeFormat); NodeShape = new RibbonDropDownGallery(ribbon, (uint)RibbonMarkupCommands.NodeShape); ClearShapeFormat = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ClearShapeFormat); LineColor = new RibbonDropDownColorPicker(ribbon, (uint)RibbonMarkupCommands.LineColor); LinePattern = new RibbonDropDownButton(ribbon, (uint)RibbonMarkupCommands.LinePattern); LinePatternSolid = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LinePatternSolid); LinePatternDashed = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LinePatternDashed); LinePatternDotted = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LinePatternDotted); LinePatternMixed = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LinePatternMixed); LineThickness = new RibbonDropDownButton(ribbon, (uint)RibbonMarkupCommands.LineThickness); LineThickness1 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LineThickness1); LineThickness2 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LineThickness2); LineThickness4 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.LineThickness4); GrpNodeStyle = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNodeStyle); NodeStyleGallery = new RibbonInRibbonGallery(ribbon, (uint)RibbonMarkupCommands.NodeStyleGallery); CreateNodeStyle = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.CreateNodeStyle); GrpClearFormat = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpClearFormat); TabView = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabView); GrpViewTask = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpViewTask); ViewCalendar = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ViewCalendar); ViewTaskList = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ViewTaskList); GrpViewNote = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpViewNote); ViewNote = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ViewNote); TabGroupNote = new RibbonTabGroup(ribbon, (uint)RibbonMarkupCommands.TabGroupNote); TabNoteEditor = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabNoteEditor); GrpNoteFont = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNoteFont); GrpNoteClearFormat = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNoteClearFormat); GrpParagraph = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpParagraph); Bullets = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Bullets); Numbers = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Numbers); Outdent = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Outdent); Indent = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Indent); AlignLeft = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AlignLeft); AlignCenter = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AlignCenter); AlignRight = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.AlignRight); Justify = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.Justify); GrpNoteStyles = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNoteStyles); NoteHeading1 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteHeading1); NoteHeading2 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteHeading2); NoteHeading3 = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteHeading3); NoteNormal = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteNormal); GrpNoteTable = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNoteTable); NoteInsertTable = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteInsertTable); GrpNoteEditHtml = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpNoteEditHtml); NoteEditHtml = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.NoteEditHtml); TabGroupNoteTable = new RibbonTabGroup(ribbon, (uint)RibbonMarkupCommands.TabGroupNoteTable); TabNoteTableLayout = new RibbonTab(ribbon, (uint)RibbonMarkupCommands.TabNoteTableLayout); GrpCustomizeTable = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpCustomizeTable); ModifyTableProperties = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.ModifyTableProperties); GrpTableDelete = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpTableDelete); DeleteRow = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.DeleteRow); DeleteColumn = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.DeleteColumn); DeleteTable = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.DeleteTable); GrpTableInsert = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpTableInsert); InsertRowAbove = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.InsertRowAbove); InsertRowBelow = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.InsertRowBelow); InsertColumnLeft = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.InsertColumnLeft); InsertColumnRight = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.InsertColumnRight); GrpTableMove = new RibbonGroup(ribbon, (uint)RibbonMarkupCommands.GrpTableMove); MoveRowUp = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveRowUp); MoveRowDown = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveRowDown); MoveColumnLeft = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveColumnLeft); MoveColumnRight = new RibbonButton(ribbon, (uint)RibbonMarkupCommands.MoveColumnRight); }
/// <summary> /// Initialize Automation Peer for RibbonApplicationMenu /// </summary> public RibbonApplicationMenuAutomationPeer(RibbonApplicationMenu owner) : base(owner) { }
internal static int IndexOf(UIElementInfo info) { int pos = -1; object parent = info.Parent; // try to get the index of info.UIElement if (parent is RibbonGroup) { pos = ((RibbonGroup)parent).Items.IndexOf(info.UIElement as RibbonItem); } else if (parent is RibbonTab) { pos = ((RibbonTab)parent).Groups.IndexOf(info.UIElement as RibbonGroup); } else if (parent is RibbonDropDownBase) { if (parent is RibbonApplicationMenu) { RibbonApplicationMenu appMenu = ((RibbonApplicationMenu)parent); // RibbonApplicationMenu has three child collections, // so we use index range from 0 to 999 for BottomPaneItems, // index range from 1000 to 1999 for LeftPaneItems, and // index range starting with 2000 for RightPaneItems pos = appMenu.BottomPaneItems.IndexOf(info.UIElement as RibbonItem); if (pos < 0) { pos = appMenu.LeftPaneItems.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 1000; } else { pos = appMenu.RightPaneItems.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 2000; } } } } else if (parent is RibbonComboBox) { pos = ((RibbonComboBox)parent).MenuItems.IndexOf(info.UIElement as RibbonItem); if (pos < 0) { pos = ((RibbonComboBox)parent).Items.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 1000; } } } else if (parent is RibbonGallery) { pos = ((RibbonGallery)parent).MenuItems.IndexOf(info.UIElement as RibbonItem); if (pos < 0) { pos = ((RibbonGallery)parent).Items.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 1000; } } } else { pos = ((RibbonDropDownBase)parent).Items.IndexOf(info.UIElement as RibbonItem); } } else if (parent is RibbonItemContainer) { pos = ((RibbonItemContainer)parent).Items.IndexOf(info.UIElement as RibbonItem); if (parent is RibbonQat && pos == -1) { pos = ((RibbonQat)parent).MenuItems.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 1000; } } } else if (parent is RibbonListItem) { pos = ((RibbonListItem)parent).Items.IndexOf(info.UIElement as RibbonItem); } else if (parent is C1Ribbon) { C1Ribbon ribbon = (C1Ribbon)parent; if (ribbon.ApplicationMenu.Equals(info.UIElement)) { pos = 0; } else if (ribbon.ConfigToolBar.Equals(info.UIElement)) { pos = 1; } else if (ribbon.Qat.Equals(info.UIElement)) { pos = 2; } else { pos = ribbon.Tabs.IndexOf(info.UIElement as RibbonTab); if (pos >= 0) { pos += 1000; } } } else if (parent is C1StatusBar) { C1StatusBar bar = (C1StatusBar)parent; pos = bar.LeftPaneItems.IndexOf(info.UIElement as RibbonItem); if (pos < 0) { pos = bar.RightPaneItems.IndexOf(info.UIElement as RibbonItem); if (pos >= 0) { pos += 1000; } } } // if uiElement does not have an index, return -1 if (pos < 0) { pos = -1; } return(pos); }
internal static object FindUIElement(object parent, string name) { int pos; // Check if the name contains the UI element's index in the parent children collection instead of its real Name. // This way we handle UI elements whose Name property is not set. if (!int.TryParse(name, out pos)) { pos = -1; } object child = null; try { // check the parent object type, whether we need to handle it if (parent is RibbonGroup) { // if the name contains an index, try to get the child UI element by that index if (pos != -1) { child = ((RibbonGroup)parent).Items[pos]; } // otherwise, try to get the child UI element by its name else { child = ((RibbonGroup)parent).Items[name]; } } else if (parent is RibbonTab) { if (pos != -1) { child = ((RibbonTab)parent).Groups[pos]; } else { child = ((RibbonTab)parent).Groups[name]; } } else if (parent is RibbonDropDownBase) { if (parent is RibbonApplicationMenu) { RibbonApplicationMenu appMenu = ((RibbonApplicationMenu)parent); if (pos != -1) { // RibbonApplicationMenu has three child collections, // so we use index range from 0 to 999 for BottomPaneItems if (pos < 1000) { child = appMenu.BottomPaneItems[pos]; } // use index range from 1000 to 1999 for LeftPaneItems else if (pos < 2000) { child = appMenu.LeftPaneItems[pos - 1000]; } // use index range starting from 2000 for RightPaneItems else { child = appMenu.RightPaneItems[pos - 2000]; } } else { // RibbonApplicationMenu has three child collections, // so we look the child UI element up in all of them if (appMenu.BottomPaneItems.Contains(name)) { child = appMenu.BottomPaneItems[name]; } else if (appMenu.LeftPaneItems.Contains(name)) { child = appMenu.LeftPaneItems[name]; } else { child = appMenu.RightPaneItems[name]; } } } else if (parent is RibbonComboBox) { if (pos != -1) { // RibbonComboBox has two child collections, // so we use index range from 0 to 999 for MenuItems if (pos < 1000) { child = ((RibbonComboBox)parent).MenuItems[pos]; } // use index range starting from 1000 for Items else { child = ((RibbonComboBox)parent).Items[pos - 1000]; } } } else if (parent is RibbonGallery) { if (pos != -1) { if (pos < 1000) { child = ((RibbonGallery)parent).MenuItems[pos]; } else { child = ((RibbonGallery)parent).Items[pos - 1000]; } } } else { if (pos != -1) { child = ((RibbonDropDownBase)parent).Items[pos]; } else { child = ((RibbonDropDownBase)parent).Items[name]; } } } else if (parent is RibbonItemContainer) { if (pos != -1) { if (pos < 1000) { child = ((RibbonItemContainer)parent).Items[pos]; } else { child = ((RibbonQat)parent).MenuItems[pos - 1000]; } } else { if (((RibbonItemContainer)parent).Items.Contains(name)) { child = ((RibbonItemContainer)parent).Items[name]; } else { child = ((RibbonQat)parent).MenuItems[name]; } } } else if (parent is RibbonListItem) { if (pos != -1) { child = ((RibbonListItem)parent).Items[pos]; } else { child = ((RibbonListItem)parent).Items[name]; } } else if (parent is C1Ribbon) { C1Ribbon ribbon = (C1Ribbon)parent; if (pos != -1) { if (pos == 0) { child = ribbon.ApplicationMenu; } else if (pos == 1) { child = ribbon.ConfigToolBar; } else if (pos == 2) { child = ribbon.Qat; } else { child = ribbon.Tabs[pos - 1000]; } } else { child = ribbon.Tabs[name]; } } else if (parent is C1StatusBar) { C1StatusBar bar = (C1StatusBar)parent; if (pos != -1) { if (pos < 1000) { child = bar.LeftPaneItems[pos]; } else { child = bar.RightPaneItems[pos - 1000]; } } else { child = bar.LeftPaneItems[name]; if (child == null) { child = bar.RightPaneItems[name]; } } } } // an exception can occur if parent doesn't contain a child UI element with the specified name, // in that case we return null catch { } return(child); }
public CostOSRibbonApplicationMenuPopupPanel(JRibbonApplicationMenuButton paramJRibbonApplicationMenuButton, RibbonApplicationMenu paramRibbonApplicationMenu) { Layout = new BorderLayout(); Border = BorderFactory.createEmptyBorder(); if (paramRibbonApplicationMenu.DefaultCallback == null) { this.defaultPrimaryCallback = new PrimaryRolloverCallbackAnonymousInnerClass(this); } else { this.defaultPrimaryCallback = paramRibbonApplicationMenu.DefaultCallback; } CostOSApplicationMenuContainerPanel costOSApplicationMenuContainerPanel = new CostOSApplicationMenuContainerPanel(new BorderLayout()); costOSApplicationMenuContainerPanel.Background = SECONDARY_MENU_COLOR; JFrame jFrame = CostOSRootPaneUI.Resolver.MainFrame; costOSApplicationMenuContainerPanel.MinimumSize = new Dimension(jFrame.Width - 2, jFrame.Height - 55); costOSApplicationMenuContainerPanel.PreferredSize = new Dimension(jFrame.Width - 2, jFrame.Height - 55); costOSApplicationMenuContainerPanel.MaximumSize = new Dimension(jFrame.Width - 2, jFrame.Height - 55); this.panelLevel1 = new JPanel(); this.panelLevel1.Layout = new LayoutManagerAnonymousInnerClass(this); this.panelLevel1.Background = PRIMARY_MENU_COLOR; this.panelLevel1.Border = BorderFactory.createEmptyBorder(); if (paramRibbonApplicationMenu != null) { System.Collections.IList list = paramRibbonApplicationMenu.PrimaryEntries; if (list != null && list.Count > 0) { EmptyResizableIcon emptyResizableIcon = new EmptyResizableIcon(16); for (sbyte b = 0; b < list.Count; b++) { System.Collections.IList list1 = (System.Collections.IList)list[b]; foreach (RibbonApplicationMenuEntryPrimary ribbonApplicationMenuEntryPrimary in list1) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final JCommandAppMenuButton commandButton = new JCommandAppMenuButton(ribbonApplicationMenuEntryPrimary.getText(), emptyResizableIcon); JCommandAppMenuButton commandButton = new JCommandAppMenuButton(ribbonApplicationMenuEntryPrimary.Text, emptyResizableIcon); jCommandAppMenuButton.CommandButtonKind = ribbonApplicationMenuEntryPrimary.EntryKind; jCommandAppMenuButton.addActionListener(ribbonApplicationMenuEntryPrimary.MainActionListener); if (ribbonApplicationMenuEntryPrimary.RolloverCallback != null) { jCommandAppMenuButton.addRolloverActionListener(new RolloverActionListenerAnonymousInnerClass(this)); } else if (ribbonApplicationMenuEntryPrimary.SecondaryGroupCount == 0) { jCommandAppMenuButton.addRolloverActionListener(new RolloverActionListenerAnonymousInnerClass2(this)); } else { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback coreCallback = new org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback() RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback coreCallback = new PrimaryRolloverCallbackAnonymousInnerClass2(this, commandButton); jCommandAppMenuButton.addRolloverActionListener(new RolloverActionListenerAnonymousInnerClass3(this, commandButton, coreCallback)); } jCommandAppMenuButton.DisplayState = MENU_TILE_LEVEL_1; jCommandAppMenuButton.HorizontalAlignment = 10; jCommandAppMenuButton.PopupOrientationKind = JCommandButton.CommandButtonPopupOrientationKind.SIDEWARD; jCommandAppMenuButton.Enabled = ribbonApplicationMenuEntryPrimary.Enabled; jCommandAppMenuButton.Foreground = CostOSWindowsLookAndFeel.ribbonAppMenuButtonForegroundColor; this.panelLevel1.add(jCommandAppMenuButton); } if (b < list.Count - 1) { JPopupMenu.Separator separator = new SeparatorAnonymousInnerClass(this); this.panelLevel1.add(separator); } } } } costOSApplicationMenuContainerPanel.add(this.panelLevel1, "West"); this.panelLevel2 = new JPanel(); this.panelLevel2.Background = SECONDARY_MENU_COLOR; this.panelLevel2.Border = new BorderAnonymousInnerClass(this); this.panelLevel2.PreferredSize = new Dimension(30 * FlamingoUtilities.getFont(this.panelLevel1, new string[] { "Ribbon.font", "Button.font", "Panel.font" }).Size - 30, 10); this.defaultPrimaryCallback.menuEntryActivated(this.panelLevel2); costOSApplicationMenuContainerPanel.add(this.panelLevel2, "Center"); add(costOSApplicationMenuContainerPanel, "Center"); this.panelLevel1.doLayout(); firstLevelMenuWidth = (int)this.panelLevel1.PreferredSize.Width; }
/// <summary> /// Dựng menu ribbon của hệ thống theo user đăng nhập /// </summary> /// <param name="rbMenu">Control Menu ribbon được tham chiếu, xử lý rồi trả về</param> public void KhoiTaoMenu(ref Ribbon rbMenu) { try { string toolTip; ChucNangDto[] ChucNanglst = ClientInformation.ListChucNang.Select(e => e).ToArray(); IQueryable <ChucNangDto> sItem; string pathFolderImages = ApplicationConstant.defaultImageSource; // Lấy danh sách menu theo tên đăng nhập và mã đơn vị var sTab = ChucNanglst.Where(e => e.IDChucNangCha == 0).OrderBy(e => e.STT).ToList(); foreach (var Tab in sTab) { if (Tab.ThuocTinh.SplitByDelimiter("#")[2] == "RibbonApplicationMenu") { // Application menu RibbonApplicationMenu ram = new RibbonApplicationMenu(); ram.Label = Utilities.Common.LLanguage.SearchResourceByKey(Tab.TieuDe); if (!Tab.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Tab.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Tab.TieuDe; } ram.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); ram.KeyTip = Tab.ThuocTinh.SplitByDelimiter("#")[3]; ram.Uid = Tab.IDChucNang.ToString(); if (!Tab.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Tab.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Tab.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonMenuItem icon always small ram.SmallImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Tab.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); ram.SmallImageSource = bmp; } } catch { } } var sMenu = ChucNanglst.Where(e => e.IDChucNangCha == Tab.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Menu in sMenu) { switch (Menu.ThuocTinh.SplitByDelimiter("#")[2]) { case "RibbonApplicationSplitMenuItem": if (Menu.Quyen == 0) { goto case "RibbonApplicationMenuItem"; } var rasmi = new RibbonApplicationSplitMenuItem(); rasmi.Name = "ID" + Menu.IDChucNang.ToString(); rasmi.Header = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rasmi.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rasmi.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rasmi.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonApplicationSplitMenuItem icon always large rasmi.ImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // QuickAccessToolBar icon always small rasmi.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); rasmi.ImageSource = bmp; rasmi.QuickAccessToolBarImageSource = bmp; } } catch { } } rasmi.Tag = Menu; //rasmi.IsEnabled = Menu.Quyen > 0; // Items sItem = ChucNanglst.Where(e => e.IDChucNangCha == Menu.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Item in sItem) { var item = new RibbonApplicationMenuItem(); item.Name = "ID" + Item.IDChucNang.ToString(); item.Header = Utilities.Common.LLanguage.SearchResourceByKey(Item.TieuDe); if (!Item.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Item.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Item.TieuDe; } item.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); item.KeyTip = Item.ThuocTinh.SplitByDelimiter("#")[3]; item.Uid = Item.IDChucNang.ToString(); if (!Item.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Item.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonApplicationMenuItem icon always large item.ImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // QuickAccessToolBar icon always small item.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); item.ImageSource = bmp; item.QuickAccessToolBarImageSource = bmp; } } catch { } } item.Tag = Item; item.IsEnabled = Item.Quyen > 0; rasmi.Items.Add(item); } ram.Items.Add(rasmi); break; case "RibbonApplicationMenuItem": var rami = new RibbonApplicationMenuItem(); rami.Name = "ID" + Menu.IDChucNang.ToString(); rami.Header = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rami.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rami.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rami.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonApplicationMenuItem icon always large rami.ImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // QuickAccessToolBar icon always small rami.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); rami.ImageSource = bmp; rami.QuickAccessToolBarImageSource = bmp; } } catch { } } if (!Menu.ChucNang.IsNullOrEmptyOrSpace()) { rami.Tag = Menu; } //rami.IsEnabled = Menu.Quyen > 0; // Items sItem = ChucNanglst.Where(e => e.IDChucNangCha == Menu.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Item in sItem) { var item = new RibbonApplicationMenuItem(); item.Name = "ID" + Item.IDChucNang.ToString(); item.Header = Utilities.Common.LLanguage.SearchResourceByKey(Item.TieuDe); if (!Item.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Item.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Item.TieuDe; } item.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); item.KeyTip = Item.ThuocTinh.SplitByDelimiter("#")[3]; item.Uid = Item.IDChucNang.ToString(); if (!Item.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Item.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonApplicationMenuItem icon always large item.ImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // QuickAccessToolBar icon always small item.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); item.ImageSource = bmp; item.QuickAccessToolBarImageSource = bmp; } } catch { } } item.Tag = Item; item.IsEnabled = Item.Quyen > 0; rami.Items.Add(item); } ram.Items.Add(rami); break; default: Grid grid; if (ram.FooterPaneContent.IsNullOrEmpty()) { grid = new Grid(); grid.ColumnDefinitions.Add(new ColumnDefinition()); ColumnDefinition cd = new ColumnDefinition(); cd.Width = GridLength.Auto; grid.ColumnDefinitions.Add(cd); ram.FooterPaneContent = grid; } else { grid = (Grid)(ram.FooterPaneContent); } var rb = new RibbonButton(); rb.Name = "ID" + Menu.IDChucNang.ToString(); rb.Label = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rb.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rb.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rb.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); rb.LargeImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); rb.SmallImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Large") { rb.LargeImageSource = bmp; } else { rb.SmallImageSource = bmp; } } } catch { } } rb.Tag = Menu; rb.IsEnabled = Menu.Quyen > 0; grid.Children.Add(rb); Grid.SetColumn(rb, 1); break; } } rbMenu.ApplicationMenu = ram; } else { // Tabs RibbonTab tab = new RibbonTab(); Type rthType = new RibbonTabHeader().GetType(); tab.Header = Utilities.Common.LLanguage.SearchResourceByKey(Tab.TieuDe); if (!Tab.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Tab.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Tab.TieuDe; } tab.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); tab.HeaderStyle = new Style(rthType); tab.HeaderStyle.Setters.Add(new Setter(RibbonWindow.ToolTipProperty, tab.ToolTip)); tab.IsEnabled = Tab.Quyen > 0; tab.Uid = Tab.IDChucNang.ToString(); // Groups var sGroup = ChucNanglst.Where(e => e.IDChucNangCha == Tab.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Group in sGroup) { RibbonGroup group = new RibbonGroup(); group.Header = Utilities.Common.LLanguage.SearchResourceByKey(Group.TieuDe); group.IsEnabled = Group.Quyen > 0; // Buttons var sMenu = ChucNanglst.Where(e => e.IDChucNangCha == Group.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Menu in sMenu) { switch (Menu.ThuocTinh.SplitByDelimiter("#")[2]) { case "RibbonSplitButton": if (Menu.Quyen == 0) { goto case "RibbonMenuButton"; } var rsb = new RibbonSplitButton(); rsb.Name = "ID" + Menu.IDChucNang.ToString(); rsb.Label = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rsb.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rsb.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rsb.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); rsb.LargeImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); rsb.SmallImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Large") { rsb.LargeImageSource = bmp; } else { rsb.SmallImageSource = bmp; } } } catch { } } rsb.Tag = Menu; //rsb.IsEnabled = Menu.Quyen > 0; // Items sItem = ChucNanglst.Where(e => e.IDChucNangCha == Menu.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Item in sItem) { var item = new RibbonMenuItem(); item.Name = "ID" + Item.IDChucNang.ToString(); item.Header = Utilities.Common.LLanguage.SearchResourceByKey(Item.TieuDe); if (!Item.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Item.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Item.TieuDe; } item.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); item.KeyTip = Item.ThuocTinh.SplitByDelimiter("#")[3]; item.Uid = Item.IDChucNang.ToString(); if (!Item.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Item.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonMenuItem icon always small item.ImageSource = bmp; // QuickAccessToolBar icon always small item.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); item.ImageSource = bmp; item.QuickAccessToolBarImageSource = bmp; } } catch { } } item.Tag = Item; item.IsEnabled = Item.Quyen > 0; rsb.Items.Add(item); } group.Items.Add(rsb); break; case "RibbonMenuButton": var rmb = new RibbonMenuButton(); rmb.Name = "ID" + Menu.IDChucNang.ToString(); rmb.Label = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rmb.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rmb.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rmb.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); rmb.LargeImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); rmb.SmallImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Large") { rmb.LargeImageSource = bmp; } else { rmb.SmallImageSource = bmp; } } } catch { } } //rmb.IsEnabled = Menu.Quyen > 0; // Items sItem = ChucNanglst.Where(e => e.IDChucNangCha == Menu.IDChucNang).OrderBy(e => e.STT).AsQueryable(); foreach (var Item in sItem) { var item = new RibbonMenuItem(); item.Name = "ID" + Item.IDChucNang.ToString(); item.Header = Utilities.Common.LLanguage.SearchResourceByKey(Item.TieuDe); if (!Item.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Item.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Item.TieuDe; } item.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); item.KeyTip = Item.ThuocTinh.SplitByDelimiter("#")[3]; item.Uid = Item.IDChucNang.ToString(); if (!Item.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Item.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); // RibbonMenuItem icon always small item.ImageSource = bmp; // QuickAccessToolBar icon always small item.QuickAccessToolBarImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Item.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); item.ImageSource = bmp; item.QuickAccessToolBarImageSource = bmp; } } catch { } } item.Tag = Item; item.IsEnabled = Item.Quyen > 0; rmb.Items.Add(item); } group.Items.Add(rmb); break; default: var rb = new RibbonButton(); rb.Name = "ID" + Menu.IDChucNang.ToString(); rb.Label = Utilities.Common.LLanguage.SearchResourceByKey(Menu.TieuDe); if (!Menu.ThuocTinh.SplitByDelimiter("#")[0].IsNullOrEmptyOrSpace()) { toolTip = Menu.ThuocTinh.SplitByDelimiter("#")[0]; } else { toolTip = Menu.TieuDe; } rb.ToolTip = Utilities.Common.LLanguage.SearchResourceByKey(toolTip); rb.KeyTip = Menu.ThuocTinh.SplitByDelimiter("#")[3]; rb.Uid = Menu.IDChucNang.ToString(); if (!Menu.BieuTuong.IsNullOrEmptyOrSpace()) { try { BitmapImage bmp = new BitmapImage(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Both") { bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[0], UriKind.RelativeOrAbsolute); bmp.EndInit(); rb.LargeImageSource = bmp; bmp = new BitmapImage(); bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong.SplitByDelimiter("#")[1], UriKind.RelativeOrAbsolute); bmp.EndInit(); rb.SmallImageSource = bmp; } else { // Lagre or Small bmp.BeginInit(); bmp.UriSource = new Uri(pathFolderImages + Menu.BieuTuong, UriKind.RelativeOrAbsolute); bmp.EndInit(); if (Menu.ThuocTinh.SplitByDelimiter("#")[1] == "Large") { rb.LargeImageSource = bmp; } else { rb.SmallImageSource = bmp; } } } catch (Exception ex) { LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex); } } rb.Tag = Menu; rb.IsEnabled = Menu.Quyen > 0; group.Items.Add(rb); break; } } tab.Items.Add(group); } rbMenu.Items.Add(tab); } } } catch (Exception ex) { // Ghi log Exception LLogging.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), LLogging.LogType.ERR, ex); } }