Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Elegant Ribbon Tech Support » Navigation bar: button Collapse All
Subject Author Date
Marco Scarpa Mar 3, 2011 - 6:32 AM

Hi,


i’d like to know if i can create a NavigationBarGroup that on keypress open a form and doesn’t change the control of the navigationbar.


I mean, i need a simple button that looks like others NavigationBarGroup.


Is it possible?


Thanks


bye


Marco

Technical Support Mar 4, 2011 - 10:19 AM

Yes, it is possible. Could you please tell us how you are using your navigation bar items, in Action mode, or in Selection mode? In other words, what do you expect from the items on mouse click selection or some action to happen?

Marco Scarpa Mar 7, 2011 - 2:05 AM

Now the navigation bar is working in outlook mode, with ItemActionMode set in RadioSelection.


The first two bar items have to work in standard mode, showing the ContentControl.


The third bar item, instead, has to open a new form wihout changing anything on navigation bar.


Thanks


 


Marco

Technical Support Mar 9, 2011 - 12:37 PM

Please use the following sample code:

public partial class Form1 : Form
    {
        public class MyNavigationBarItem : NavigationBarItem
        {
            /// <summary>
            /// Overrides the member from the base class.
            /// </summary>
            protected override void OnMouseDown(MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Left || !Enabled)
                    return;

                Pressed = true;
                Capture = true;
            }

            /// <summary>
            /// Overrides the member from the base class.
            /// </summary>
            protected override void OnMouseUp(MouseEventArgs e)
            {
                Capture = false;
                Pressed = false;

                base.OnMouseUp(e);
            }
        }
        
        public Form1()
        {
            InitializeComponent();

            MyNavigationBarItem item = new MyNavigationBarItem();
            item.Text = "Click me";
            item.MouseUp += Item_MouseUp;
            navigationBarGroupItemsContainer1.Items.Add(item);
        }

        void Item_MouseUp(object sender, MouseEventArgs e)
        {
            MessageBox.Show("Hello");
        }
    }

Marco Scarpa Mar 3, 2011 - 10:01 AM

Thank you for the answer.


But i want that my custom navigationbaritem to be between the other standard navigationbaritem, in the NavigationBar.


Just like the sdandard ones but i you click it a form opens.


Is it possible?


 


thanks


 


marco

Technical Support Mar 3, 2011 - 8:02 AM

Your request is quite unusual but it is possible to achieve what you want. Please use the following code in your application:

        class MyNavigationBarItem : NavigationBarItem
        {
            public MyNavigationBarItem()
            {
                SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            }

            /// <summary>
            /// Overrides the member from the base class.
            /// </summary>
            protected override void OnMouseDown(MouseEventArgs e)
            {
                if (e.Button != MouseButtons.Left || !Enabled)
                    return;

                Pressed = true;
                Capture = true;
            }

            /// <summary>
            /// Overrides the member from the base class.
            /// </summary>
            protected override void OnMouseUp(MouseEventArgs e)
            {
                Capture = false;
                Pressed = false;
            }

            protected override void OnPaintForeground(PaintEventArgs e)
            {
                INavigationBarGroupItemsContainerPaintManager pm =
                    ((INavigationBarPaintManagerFactory)SkinManager.GetPaintManagerFactory(
                        Product.NavigationBar)).NavigationBarGroupItemsContainerPaintManager;

                if (pm != null)
                    pm.PaintItemForeground(this, e.Graphics);
            }

            protected override void PaintBackground(PaintEventArgs e)
            {
                PaintStandardBackground(e);

                if(!Hovered && !Pressed)
                {
                    ICommonPaintManager cpm =
                        ((ICommonPaintManagerFactory)SkinManager.GetPaintManagerFactory(
                            Product.Common)).CommonPaintManager;

                    Rectangle rect = ClientRectangle;
                    rect.Y++;
                    rect.Height--;
                    using (SolidBrush brush = new SolidBrush(cpm.BackgroundColor))
                        e.Graphics.FillRectangle(brush, rect);


                    const int borderWidth = 1;
                    rect.Size = new Size(rect.Width - borderWidth, rect.Height - borderWidth);
                    using (Pen pen = new Pen(cpm.BorderColor, borderWidth))
                        e.Graphics.DrawRectangle(pen, rect);
                }

                INavigationBarGroupItemsContainerPaintManager pm =
                    ((INavigationBarPaintManagerFactory)SkinManager.GetPaintManagerFactory(
                        Product.NavigationBar)).NavigationBarGroupItemsContainerPaintManager;

                if (pm != null)
                    pm.PaintItemBackground(this, e.Graphics);
            }
        }



        public MyForm()
        {
            InitializeComponent();

            MyNavigationBarItem i = new MyNavigationBarItem();
            i.Text = "I am a Button";
            i.Padding = new Padding(10);
            Controls.Add(i);
            i.Size = new Size(100, 20);
            i.Click += new EventHandler(i_Click);
        }

        void i_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Hello");
        }

Marco Scarpa Mar 4, 2011 - 6:15 AM


 


Thank you for the answer.




But i want that my custom navigationbaritem to be between the other standard navigationbaritem, in the NavigationBar.




Just like the sdandard ones but i you click it a form opens.




Is it possible?




 




thanks




 




marco