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 IWrappedObjectWithText FindItemInRibbon(List <string> items) { String tabText = items[0]; RibbonTabWrapper tab; tab = lribbon.Tabs.FindElement(tabText); // We search the tab in the Tabs of the ribbon if (tab == null) { if (lribbon.SelectedTab.Text.ToLower().Equals(tabText)) { tab = lribbon.SelectedTab; } /* else * { * // if(!lribbon.SelectedTab.Text.ToLower().Equals(tabText)) * } */ } #region Listallribbons if (lbaseGlobals.isListallribbons && (tab != null)) { // jetzt alle Ribbons merken, die im RibbonTab vorhanden sind Logger.Instance.Log(this, "Ribbons, die im TAB " + this + "vorhanden sind"); rTab = tab.Text; // allRibbons = allRibbons + tab.Text + rDelemPath; // return null; } #region TabGroup.FindElement if (tab == null) // The Tab was not found in the 'normal' tabs, we have to search the contextual Tabs { for (int currentGroupIndex = 0; currentGroupIndex < lribbon.ContextualTabGroups.Count; currentGroupIndex++) { RibbonContextualTabGroupWrapper tabGroup = lribbon.ContextualTabGroups[currentGroupIndex]; tab = tabGroup.Tabs.FindElement(tabText); if (lbaseGlobals.isListallribbons && (tab != null)) { rTab = tab.Text; } // allRibbons = allRibbons + tab.Text + rDelemPath; if (tab != null) { break; } } } if (tab == null) // The Tab was still not found { if (lbaseGlobals.isOptional == true) { // throw new OptionalException("Ribbon Menü ignoriert, da optional."); Logger.Instance.Log(this, "Optional Ribbon: " + this); // return "Ribbon Menü ignoriert, da optional."; // return ReturnOK; // Exception( ); // throw new ItemNotFoundException("Der Tab >" + tabText + "< wurde nicht gefunden!"); return(null); } else { // Ribbon->RibbonBar->Der Tab >GENERISCHE TABELLEN-DATEN - ÜBERSICHT< wurde nicht gefunden! throw new ItemNotFoundException("Der Tab >" + tabText + "< wurde nicht gefunden!"); } } #endregion TabGroup.FindElement lribbon.SelectedTab = tab; #region isListallribbons if (lbaseGlobals.isListallribbons) { int countGroups = tab.Groups.Count; for (int nGroup = 0; nGroup < countGroups; nGroup++) { RibbonGroupWrapper tGroup = tab.Groups[nGroup]; rGroup = tGroup.Text; // allRibbons = allRibbons + rGroup + rDelemPath; // Gruppe ergänzen // Alle Items unter der Gruppe ergänzen int countItems = tGroup.Items.Count; for (int nItem = 0; nItem < countItems; nItem++) { // allItemsInGroup = tGroup.Items // GetType().Name; // tab.Groups[nGroup].Items; allRibbons = allRibbons + rTab + rDelemPath + rGroup + rDelemPath + tGroup.Items[nItem].Text + rDelem; // Item ergänzen und Delemiter if (tGroup.Items[nItem].Text == lastRibbon) // || (nGroup == countGroups && nItem == countItems)) { lbaseGlobals.isListallribbons = false; // hier noch allRibbons vor dem Ausstieg in eine Datei schreiben c_textdatei.WriteFile(ModulFile, "Alle Ribbons des TABS " + rTab + ":\r\n" + allRibbons + "\r\n"); /* * // OpenFileDialog * System.IO.StreamReader sr = new * System.IO.StreamReader(ModulFile); * * MessageBox.Show(sr.ReadToEnd()); * sr.Close(); */ MessageBox.Show("Angelegt in der Datei: \r\n" + ModulFile + "\r\n\r\n" + allRibbons, "Alle Ribbons zu TAB " + rTab); // ModulFile allRibbons = ""; return(null); // throw new ListallRibbonsException("Alle Ribbons des TABS: + \r\n" + allRibbons); // return null; // hier in Datei schreiben } } } lbaseGlobals.isListallribbons = false; // hier noch allRibbons vor dem Ausstieg in eine Datei schreiben c_textdatei.WriteFile(ModulFile, "Alle Ribbons des TABS " + rTab + ":\r\n" + allRibbons + "\r\n"); MessageBox.Show("Angelegt in der Datei: \r\n" + ModulFile + "\r\n\r\n" + allRibbons, "Alle Ribbons zu TAB " + rTab); // ModulFile allRibbons = ""; return(null); } #endregion isListallribbons items = items.Skip(1).ToList(); if (items.Count == 0 && (lbaseGlobals.isListallribbons == false)) // no more elements in the list, only the tab change is wanted { return(tab); } #endregion Listallribbons String groupText = items[0]; RibbonGroupWrapper group = tab.Groups[groupText]; items = items.Skip(1).ToList(); if (items.Count == 0) //no more elements in the list, only a verification that the group exists was done { return(group); } if (!group.Enabled) { throw new NotEnabledException("Die Gruppe >" + groupText + "< ist nicht enabled."); } RibbonItemWrapper foundItem = group.Items[items[0]]; items = items.Skip(1).ToList(); Logger.Instance.Log("foundItem, items: " + foundItem + ", " + items); return(FindItemInSubMenu(foundItem, items)); }