private IClickableRibbonItem FindItemInSubMenu(RibbonItemWrapper startWrapper, List <String> items) { RibbonItemWrapper currWrapper = startWrapper; while (items.Count > 0) // We still have elements to find { if (currWrapper is RibbonDropDownBaseWrapper) { // Z.B. [MENU]DATEI->Beenden RibbonDropDownBaseWrapper currDropDownWrapper = currWrapper as RibbonDropDownBaseWrapper; currDropDownWrapper.DroppedDown = true; String currItemToFind = items[0]; items = items.Skip(1).ToList(); // Thread.Sleep(2000); currWrapper = currDropDownWrapper.Items[currItemToFind]; } else { throw new NotSupportedException("Das Item >" + currWrapper.Text + "< ist kein gültiges DropDownItem (RibbonMenu oder SplitButton)!"); } } // We're on the last item. We'll click it. if (currWrapper is IClickableRibbonItem) { return(currWrapper as IClickableRibbonItem); } else { throw new NotSupportedException("Das Item >" + currWrapper.Text + "< ist kein gültiger Button!"); } }
private IClickableRibbonItem FindItemInMenu(List <string> items) { if (items.Count < 2) { throw new NotSupportedException("Bitte geben Sie zumindest zwei Menüebenen ein!"); } RibbonApplicationMenuWrapper applicationMenu = lribbon.ApplicationMenu; if (!StringHelpers.DoStringsMatch(applicationMenu.Text, items[0])) { throw new ItemNotFoundException("Das Menü >" + items[0] + "< wurde nicht gefunden!"); } items = items.Skip(1).ToList(); RibbonDropDownBaseWrapper currBaseWrapper = applicationMenu; return(FindItemInSubMenu(currBaseWrapper, items)); }