Ejemplo n.º 1
0
        /// <summary>
        /// Get the prev element in the ribbon control
        /// </summary>
        public void GetPrevButton()
        {
            mgDevX_RibbonControlBarItemCollection buttonArray = GetBarButtonItems();

            int targetItem = -1;

            foreach (mgDevX_RibbonControlBarItem kvp in buttonArray)
            {
                //if (((BarButtonItem)kvp.BarItemLink.Item).Down &&
                //    kvp.Page == this.SelectedPage)
                if (((BarButtonItem)kvp.BarItemLink.Item).Down)
                {
                    targetItem = buttonArray.IndexOf(kvp) - 1;
                    break;
                }
            }
            if (targetItem < 0)
            {
                targetItem = buttonArray.Count - 1;
            }

            // Make the page visible
            ActivatePageAndGroup(buttonArray[targetItem]);

            // Call the click event
            buttonArray[targetItem].BarItemLink.Item.PerformClick();

            buttonArray = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the currently selected button
        /// </summary>
        /// <returns></returns>
        public BarItemLink GetCurrentButton()
        {
            mgDevX_RibbonControlBarItemCollection buttonArray = GetBarButtonItems();
            BarItemLink btnItem = null;

            int targetItem = -1;

            foreach (mgDevX_RibbonControlBarItem kvp in buttonArray)
            {
                if (((BarButtonItem)kvp.BarItemLink.Item).Down &&
                    kvp.Page == this.SelectedPage)
                {
                    btnItem = kvp.BarItemLink;
                    break;
                }
            }

            return(btnItem);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the button items on the bar
        /// </summary>
        /// <returns>A collection of the bar Item Links</returns>
        //private Dictionary<int, BarItemLink> GetBarButtonItems()
        public mgDevX_RibbonControlBarItemCollection GetBarButtonItems()
        {
            mgDevX_RibbonControlBarItemCollection buttonArray = new mgDevX_RibbonControlBarItemCollection();

            #region Page Categories
            if (this.PageCategories.Count > 0)
            {
                foreach (RibbonPageCategory category in this.PageCategories)
                {
                    foreach (RibbonPage page in category.Pages)
                    {
                        if (page.Visible)
                        {
                            foreach (RibbonPageGroup group in page.Groups)
                            {
                                if (group.Visible)
                                {
                                    for (int i = 0; i < group.ItemLinks.Count; i++)
                                    {
                                        if (group.ItemLinks[i].Item is BarButtonItem &&
                                            ((BarButtonItem)group.ItemLinks[i].Item).Visibility != BarItemVisibility.Never &&
                                            !group.ItemLinks[i].Item.Name.StartsWith("btnPrint") &&
                                            !group.ItemLinks[i].Item.Name.StartsWith("btnPreview") &&
                                            !group.ItemLinks[i].Item.Name.StartsWith("btnRun") &&
                                            !group.ItemLinks[i].Item.Name.Equals("btnCopyChart") &&
                                            !group.ItemLinks[i].Item.Name.Equals("btnSaveChart"))
                                        {
                                            //((BarButtonItem)group.ItemLinks[i].Item).Down = false;
                                            //buttonArray.Add(buttonArray.Count, group.ItemLinks[i]);
                                            buttonArray.Add(new mgDevX_RibbonControlBarItem(page,
                                                                                            group,
                                                                                            group.ItemLinks[i]));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion Page Categories

            #region Uncheck Standard Buttons
            if (this.ShowPageHeadersMode != DevExpress.XtraBars.Ribbon.ShowPageHeadersMode.Hide)
            {
                foreach (RibbonPage page in this.Pages)
                {
                    if (page.Visible)
                    {
                        foreach (RibbonPageGroup group in page.Groups)
                        {
                            if (group.Visible)
                            {
                                for (int i = 0; i < group.ItemLinks.Count; i++)
                                {
                                    if (group.ItemLinks[i].Item is BarButtonItem &&
                                        ((BarButtonItem)group.ItemLinks[i].Item).Visibility != BarItemVisibility.Never &&
                                        !group.ItemLinks[i].Item.Name.StartsWith("btnPrint") &&
                                        !group.ItemLinks[i].Item.Name.StartsWith("btnPreview") &&
                                        !group.ItemLinks[i].Item.Name.StartsWith("btnRun") &&
                                        !group.ItemLinks[i].Item.Name.Equals("btnCopyChart") &&
                                        !group.ItemLinks[i].Item.Name.Equals("btnSaveChart"))
                                    {
                                        //((BarButtonItem)group.ItemLinks[i].Item).Down = false;
                                        //buttonArray.Add(buttonArray.Count, group.ItemLinks[i]);
                                        buttonArray.Add(new mgDevX_RibbonControlBarItem(page,
                                                                                        group,
                                                                                        group.ItemLinks[i]));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                RibbonPage page = this.SelectedPage;
                foreach (RibbonPageGroup group in page.Groups)
                {
                    if (group.Visible)
                    {
                        for (int i = 0; i < group.ItemLinks.Count; i++)
                        {
                            if (group.ItemLinks[i].Item is BarButtonItem &&
                                ((BarButtonItem)group.ItemLinks[i].Item).Visibility != BarItemVisibility.Never &&
                                !group.ItemLinks[i].Item.Name.StartsWith("btnPrint") &&
                                !group.ItemLinks[i].Item.Name.StartsWith("btnPreview") &&
                                !group.ItemLinks[i].Item.Name.StartsWith("btnRun") &&
                                !group.ItemLinks[i].Item.Name.Equals("btnCopyChart") &&
                                !group.ItemLinks[i].Item.Name.Equals("btnSaveChart"))
                            {
                                //((BarButtonItem)group.ItemLinks[i].Item).Down = false;
                                //buttonArray.Add(buttonArray.Count, group.ItemLinks[i]);
                                buttonArray.Add(new mgDevX_RibbonControlBarItem(page,
                                                                                group,
                                                                                group.ItemLinks[i]));
                            }
                        }
                    }
                }
            }
            #endregion Uncheck Standard Buttons

            return(buttonArray);
        }