public bool CreateNewToolbarInfo(IUIX_CmdBar Bar, out ToolbarInfo BarInfo) { BarInfo = null; if (Bar == null) { return(false); } BarInfo = new ToolbarInfo(); if (BarInfo == null) { return(false); } BarInfo.m_nID = Bar.ID; int n = 0; string sTitle = Bar.Title; if (sTitle.Length == 0) { sTitle = m_Inst.GetLocalStr2(Bar.ID); } RemoveAllPrefixes(sTitle, out BarInfo.m_sTitle, out n); BarInfo.m_bStd = m_uiInst.CmdManager.IsStdBar(BarInfo.m_nID); BarInfo.m_bHidden = Bar.IsHidden || ((Bar.Line != null) && (Bar.Line.Pane != null) && Bar.Line.Pane.IsHidden); BarInfo.m_bVisible = !BarInfo.m_bHidden; BarInfo.m_bSpecial = Bar.IsSpecial; BarInfo.m_bTemp = Bar.IsTemp; return(true); }
public void CollectAllTabsAndBars() { m_MainTabs.Clear(); m_MainBars.Clear(); m_DocBars.Clear(); m_bRibbonUI = false; IUIX_CmdManager CMan = m_uiInst.CmdManager; IPXV_MainView MainView = m_Inst.ActiveMainView; IUIX_CmdPane ICPane = MainView.CmdPaneTop; IUIX_CmdRibbonTabs Tabs = ICPane.Tabs; m_bRibbonUI = ICPane.IsRibbonMode; List <IUIX_CmdBar> mainBars = new List <IUIX_CmdBar>(); //Getting all command bars for MainView for (uint i = 0; i < CMan.CmdBarsCount; i++) { IUIX_CmdBar Bar = CMan.CmdBar[(int)i]; if ((Bar.Owner != MainView.Obj) || Bar.IsPopupBox || Bar.IsPopupMenu || Bar.IsSpecial || (Bar.AppMenuContainer != null)) { continue; } mainBars.Add(Bar); } if (ICPane.QABar != null) { mainBars.Add(ICPane.QABar); } if (ICPane.QLBar != null) { mainBars.Add(ICPane.QLBar); } List <IUIX_CmdBar> docBars = new List <IUIX_CmdBar>(); IPXV_DocumentView DocView = m_Inst.ActiveDocView; if (DocView != null) { IUIX_Layout layout = DocView.Panes.Layout; IPXV_PagesView PagesView = DocView.PagesView; HashSet <IUIX_Obj> cmdOwners = new HashSet <IUIX_Obj>(); if (PagesView != null) { cmdOwners.Add(PagesView.Obj); } List <IUIX_CmdBar> viewBars = new List <IUIX_CmdBar>(); foreach (IUIX_Obj obj in cmdOwners) { viewBars.Clear(); //Getting all command bars for (uint j = 0; j < CMan.CmdBarsCount; j++) { IUIX_CmdBar Bar = CMan.CmdBar[(int)j]; if ((Bar.Owner != obj) || Bar.IsPopupBox || Bar.IsPopupMenu || Bar.IsSpecial || (Bar.AppMenuContainer != null)) { continue; } viewBars.Add(Bar); } if (viewBars.Count > 0) { docBars.InsertRange(docBars.Count, viewBars); } } } Dictionary <IUIX_CmdBar, ToolbarInfo> bars = new Dictionary <IUIX_CmdBar, ToolbarInfo>(); if (m_bRibbonUI) { if (Tabs != null) { for (uint i = 0; i < Tabs.Count; i++) { IUIX_CmdRibbonTab Tab = Tabs[i]; if (Tab.ContextualGroupID != 0) { continue; } ToolbarInfo TI = new ToolbarInfo(); TI.m_bIsTab = true; TI.m_nID = Tab.ID; string title = Tab.Title; int n = 0; RemoveAllPrefixes(title, out TI.m_sTitle, out n); TI.m_bStd = CMan.IsStdRibbonTab(TI.m_nID); TI.m_bHidden = Tab.Hidden || ICPane.IsHidden; TI.m_bVisible = !TI.m_bHidden; TI.m_bTemp = Tab.IsTemp; m_MainTabs.Add(TI); for (uint j = 0; j < Tab.Count; j++) { IUIX_CmdBar bar = Tab[j]; ToolbarInfo BarInfo; if (!CreateNewToolbarInfo(bar, out BarInfo)) { break; } BarInfo.m_bHidden = BarInfo.m_bHidden || Tab.IsBarHidden[(int)j] || ((bar.Line != null) && (bar.Line.Pane != null) && bar.Line.Pane.IsHidden); BarInfo.m_bVisible = !BarInfo.m_bHidden && TI.m_bVisible; ToolbarInfo it = null; if (!bars.TryGetValue(bar, out it)) { bars.Add(bar, BarInfo); } BarInfo.m_nTabID = TI.m_nID; TI.m_Bars.Add(BarInfo); } } } } // check for other bars foreach (IUIX_CmdBar Bar in mainBars) { ToolbarInfo it = null; if (bars.TryGetValue(Bar, out it)) { continue; } if (Tabs != null) { if (Tabs.IsContextualBar(Bar.ID)) { continue; } } ToolbarInfo BarInfo; if (!CreateNewToolbarInfo(Bar, out BarInfo)) { break; } bars.Add(Bar, BarInfo); m_MainBars.Add(BarInfo); } m_MainBars.Sort((a, b) => (a.m_sTitle.CompareTo(b.m_sTitle))); bars.Clear(); HashSet <int> addedBars = new HashSet <int>(); foreach (IUIX_CmdBar Bar in docBars) { int nBarID = Bar.ID; if (addedBars.Contains(nBarID)) { continue; } addedBars.Add(nBarID); ToolbarInfo BarInfo; if (!CreateNewToolbarInfo(Bar, out BarInfo)) { break; } BarInfo.m_bDoc = true; m_DocBars.Add(BarInfo); } m_DocBars.Sort((a, b) => (a.m_sTitle.CompareTo(b.m_sTitle))); }