Пример #1
0
 protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         this.buttonState = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
         this.DataGridView.InvalidateCell(this);
         if (this.DataGridView.SelectedRows.Count > 0)
         {
             FrmDataGridViewRow FDGVR = new FrmDataGridViewRow(this.DataGridView);
             FDGVR.ShowDialog();
             FDGVR.Dispose();
             this.buttonState = System.Windows.Forms.VisualStyles.PushButtonState.Default;
             this.DataGridView.InvalidateCell(this);
         }
     }
 }
Пример #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            RefreshTabSize(g);

            if (_Tabs.Count > 0)
            {
                _Draw_Tabs(g);
            }
            // Draw close button.
            if (Draw_Close)
            {
                System.Windows.Forms.VisualStyles.PushButtonState state = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
                if (Tab_Renderer.HitsCloseButton(Mouse_Moving, TabBarBounds))
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
                }
                if (Tab_Renderer.HitsCloseButton(Mouse_Holding, TabBarBounds))
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
                }
                if (!Can_Close)
                {
                    state = System.Windows.Forms.VisualStyles.PushButtonState.Disabled;
                }
                Tab_Renderer.DrawCloseButton(g, TabBarBounds, state);
            }

            Tab_Renderer.DrawScrollButtons(g, TabBarBounds, Mouse_Moving, Mouse_Holding, (Draw_Close), Overflow);

            // Top
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, this.Size.Width, Padding.Top - TabBarBounds.Height));

            // Left
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, Padding.Left, this.Size.Height));

            // Right
            g.FillRectangle(SystemBrushes.Control, new Rectangle(this.Size.Width - Padding.Right, 0, this.Size.Width, this.Size.Height));

            // Bottom
            g.FillRectangle(SystemBrushes.Control, new Rectangle(0, this.Size.Height - Padding.Bottom, this.Size.Width, this.Size.Height));
        }
Пример #3
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            if (Items.Count == 0)
            {
                return;
            }

            if (buttonMap.TryGetValue(e.Index, out var buttons))
            {
                for (int i = 0; i < buttons.Count; i++)
                {
                    Rectangle bounds = GetButtonBounds(e.Index, i);
                    System.Windows.Forms.VisualStyles.PushButtonState state = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
                    if (hoverItemIndex == e.Index && hoverButtonIndex == i)
                    {
                        if (mouseDown)
                        {
                            state = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
                        }
                        else
                        {
                            state = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
                        }
                    }
                    ButtonRenderer.DrawButton(e.Graphics, bounds, state);
                    if (string.IsNullOrEmpty(buttons[i]))
                    {
                        e.Graphics.FillEllipse(SystemBrushes.WindowText, bounds.Left + (bounds.Width - dotSize) / 2, bounds.Top + (bounds.Height - dotSize) / 2, dotSize, dotSize);
                    }
                    else
                    {
                        TextRenderer.DrawText(e.Graphics, buttons[i], Font, bounds, SystemColors.WindowText, TextFormatFlags.NoPadding | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
                    }
                }
            }
        }
Пример #4
0
        private void DrawButton(PaintEventArgs e, bool pressed = false)
        {
            // Set the background color to the parent if visual styles
            // are disabled, because DrawParentBackground will only paint
            // over the control background if visual styles are enabled.
            BackColor = Application.RenderWithVisualStyles?Color.Azure:Parent.BackColor;

            // If you comment out the call to DrawParentBackground,
            // the background of the control will still be visible
            // outside the pressed button, if visual styles are enabled.
            ButtonRenderer.DrawParentBackground(e.Graphics, ClientRectangle, this);

            System.Windows.Forms.VisualStyles.PushButtonState state = defaultButton?System.Windows.Forms.VisualStyles.PushButtonState.Default:System.Windows.Forms.VisualStyles.PushButtonState.Normal;
            if (mouseHot)
            {
                state = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
            }
            if (pressed)
            {
                state = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
            }
            if (!Enabled)
            {
                state = System.Windows.Forms.VisualStyles.PushButtonState.Disabled;
            }

            if (Image == null)
            {
                ButtonRenderer.DrawButton(e.Graphics, ClientRectangle, Focused, state);
            }
            else
            {
                Rectangle imageRectangle = new Rectangle(imagePadding + Padding.Left, (Height - Image.Height) / 2, Image.Width, Image.Height);
                ButtonRenderer.DrawButton(e.Graphics, ClientRectangle, Image, imageRectangle, Focused, state);
            }
        }
 public static void DrawButton(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string buttonText, System.Drawing.Font font, TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state)
 {
 }
 public static void DrawButton(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.PushButtonState state)
 {
 }
 // Methods
 public static bool IsBackgroundPartiallyTransparent(System.Windows.Forms.VisualStyles.PushButtonState state)
 {
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
 {
     base.OnMouseDown(e);
     pushState = System.Windows.Forms.VisualStyles.PushButtonState.Pressed;
 }
 protected override void OnMouseEnter(int rowIndex)
 {
     base.OnMouseEnter(rowIndex);
     pushState = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
     focused   = false;
 }
 protected override void OnEnter(int rowIndex, bool throughMouseClick)
 {
     pushState = System.Windows.Forms.VisualStyles.PushButtonState.Hot;
     focused   = false;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="rowIndex"></param>
 /// <param name="throughMouseClick"></param>
 protected override void OnLeave(int rowIndex, bool throughMouseClick)
 {
     base.OnLeave(rowIndex, throughMouseClick);
     pushState = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
     focused   = false;
 }
 /// <summary>
 ///
 /// </summary>
 public ButtonCellTemplate()
 {
     focused   = false;
     pushState = System.Windows.Forms.VisualStyles.PushButtonState.Normal;
 }