Exemplo n.º 1
0
 private void navBarControl1_CustomDrawLink(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e)
 {
     if (e.ObjectInfo.State == ObjectState.Hot || e.ObjectInfo.State == ObjectState.Pressed)
     {
         LinearGradientBrush brush;
         NavLinkInfoArgs     linkInfo = e.ObjectInfo as NavLinkInfoArgs;
         if (e.ObjectInfo.State == ObjectState.Hot)
         {
             brush = new LinearGradientBrush(e.RealBounds, Color.Orange, Color.PeachPuff,
                                             LinearGradientMode.Horizontal);
         }
         else
         {
             brush = new LinearGradientBrush(e.RealBounds, Color.PeachPuff, Color.Orange,
                                             LinearGradientMode.Horizontal);
         }
         e.Graphics.FillRectangle(Brushes.OrangeRed, e.RealBounds);
         Rectangle rect = e.RealBounds;
         rect.Inflate(-1, -1);
         e.Graphics.FillRectangle(brush, rect);
         if (e.Image != null)
         {
             Rectangle imageRect = linkInfo.ImageRectangle;
             imageRect.X   += (imageRect.Width - e.Image.Width) / 2;
             imageRect.Y   += (imageRect.Height - e.Image.Height) / 2;
             imageRect.Size = e.Image.Size;
             e.Graphics.DrawImageUnscaled(e.Image, imageRect);
         }
         e.Appearance.DrawString(e.Cache, e.Caption, linkInfo.RealCaptionRectangle, Brushes.White);
         e.Handled = true;
     }
 }
Exemplo n.º 2
0
        private void navBarControl1_CustomDrawLink(object sender, CustomDrawNavBarElementEventArgs e)
        {
            SizeF           textSize            = e.Cache.CalcTextSize(e.Caption, e.Appearance.Font, StringFormat.GenericDefault, e.RealBounds.Width);
            NavLinkInfoArgs args                = (NavLinkInfoArgs)e.ObjectInfo;
            Rectangle       newCaptionRectangle = args.RealCaptionRectangle;

            newCaptionRectangle.Width = Convert.ToInt32(textSize.Width);
            args.CaptionRectangle     = newCaptionRectangle;
        }
        private void navBarControl1_CustomDrawLink(object sender, DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e)
        {
            NavLinkInfoArgs args = e.ObjectInfo as NavLinkInfoArgs;

            if (args.Link == navBarControl1.SelectedLink)
            {
                e.Graphics.FillRectangle(Brushes.Red, e.RealBounds);
            }
        }
Exemplo n.º 4
0
        private void navBarControl1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //  selectedNavBarItem = navBarControl1.v
            NavBarHitInfo hit = navBarControl1.CalcHitInfo(e.Location);

            if ((!hit.InLink))
            {
                return;
            }
            FieldInfo      fi = typeof(NavBarControl).GetField("viewInfo", BindingFlags.NonPublic | BindingFlags.Instance);
            NavBarViewInfo vi = fi.GetValue(navBarControl1) as NavBarViewInfo;

            selectedNavBarItem = vi.HotTrackedLink.Item;
            NavLinkInfoArgs arg = vi.GetLinkInfo(hit.Link);
            Point           p   = new Point(arg.Bounds.X, arg.Bounds.Bottom);

            popupMenu1.ShowPopup(navBarControl1.PointToScreen(p));
        }