예제 #1
0
 public PaintValueEventArgs(ITypeDescriptorContext context, object value, Graphics graphics, Rectangle_ bounds)
 {
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     this.context  = context;
     this.value    = value;
     this.graphics = graphics;
     this.bounds   = bounds;
 }
예제 #2
0
        public bool IconRectangleContains(int x, int y)
        {
            if (!ShowIcon)
            {
                return(false);
            }

            Rectangle_ icon = ThemeEngine.Current.ManagedWindowGetTitleBarIconArea(this);

            return(icon.Contains(x, y));
        }
예제 #3
0
        public static void DrawTabPage(Graphics g, Rectangle_ bounds)
        {
            if (!IsSupported)
            {
                throw new InvalidOperationException();
            }

            VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);;

            vsr.DrawBackground(g, bounds);
        }
예제 #4
0
        public static void DrawVerticalThumbGrip(Graphics g, Rectangle_ bounds, ScrollBarState state)
        {
            if (!IsSupported)
            {
                throw new InvalidOperationException();
            }

            VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ScrollBar.GripperVertical.Normal);;

            vsr.DrawBackground(g, bounds);
        }
예제 #5
0
            private void compute_rects()
            {
                int top_button_height;
                int bottom_button_height;

                top_button_height    = ClientSize.Height / 2;
                bottom_button_height = ClientSize.Height - top_button_height;

                top_button_rect    = new Rectangle_(0, 0, ClientSize.Width, top_button_height);
                bottom_button_rect = new Rectangle_(0, top_button_height, ClientSize.Width, bottom_button_height);
            }
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle_ textRectangle, Color_ textColor, Font textFont, ContentAlignment textAlign)
            : base(g, item)
        {
            this.text           = text;
            this.text_rectangle = textRectangle;
            this.text_color     = textColor;
            this.text_font      = textFont;
            this.text_direction = item.TextDirection;

            switch (textAlign)
            {
            case ContentAlignment.BottomCenter:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.BottomLeft:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Left;
                break;

            case ContentAlignment.BottomRight:
                this.text_format = TextFormatFlags.Bottom | TextFormatFlags.Right;
                break;

            case ContentAlignment.MiddleCenter:
                this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.MiddleLeft:
            default:
                this.text_format = (TextFormatFlags.VerticalCenter | TextFormatFlags.Left);
                break;

            case ContentAlignment.MiddleRight:
                this.text_format = TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
                break;

            case ContentAlignment.TopCenter:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter;
                break;

            case ContentAlignment.TopLeft:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.Left;
                break;

            case ContentAlignment.TopRight:
                this.text_format = TextFormatFlags.Top | TextFormatFlags.Right;
                break;
            }

            if ((Application.KeyboardCapture == null || !ToolStripManager.ActivatedByKeyboard) && !SystemInformation.MenuAccessKeysUnderlined)
            {
                this.text_format |= TextFormatFlags.HidePrefix;
            }
        }
예제 #7
0
        public static void DrawVerticalChunks(Graphics g, Rectangle_ bounds)
        {
            if (!IsSupported)
            {
                throw new InvalidOperationException();
            }

            VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.ProgressBar.ChunkVertical.Normal);

            vsr.DrawBackground(g, bounds);
        }
예제 #8
0
        Rectangle_ GetRealThumbRectangle()
        {
            Rectangle_ result = thumb_pos;

            if (Orientation == Orientation.Vertical)
            {
                result.Width  = thumb_pos.Height;
                result.Height = thumb_pos.Width;
            }
            return(result);
        }
        public void DrawFocus(Rectangle_ bounds, bool cellsPaintSelectionBackground)
        {
            if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
            {
                throw new InvalidOperationException("Invalid RowIndex.");
            }

            DataGridViewRow row = dataGridView.GetRowInternal(rowIndex);

            row.PaintCells(graphics, clipBounds, bounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, DataGridViewPaintParts.Focus);
        }
 public void PaintCellsBackground(Rectangle_ clipBounds, bool cellsPaintSelectionBackground)
 {
     if (cellsPaintSelectionBackground)
     {
         PaintCells(clipBounds, DataGridViewPaintParts.All);
     }
     else
     {
         PaintCells(clipBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.SelectionBackground);
     }
 }
        public void PaintCells(Rectangle_ clipBounds, DataGridViewPaintParts paintParts)
        {
            if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
            {
                throw new InvalidOperationException("Invalid RowIndex.");
            }

            DataGridViewRow row = dataGridView.GetRowInternal(rowIndex);

            row.PaintCells(graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts);
        }
예제 #12
0
        protected override void OnRenderImageMargin(ToolStripRenderEventArgs e)
        {
            if (!(e.ToolStrip is ToolStripOverflow))
            {
                Rectangle_ side_gradient = new Rectangle_(1, 2, 24, e.ToolStrip.Height - 3);
                using (LinearGradientBrush b = new LinearGradientBrush(side_gradient, this.ColorTable.ToolStripGradientBegin, this.ColorTable.ToolStripGradientEnd, LinearGradientMode.Horizontal))
                    e.Graphics.FillRectangle(b, side_gradient);
            }

            base.OnRenderImageMargin(e);
        }
예제 #13
0
 public DrawToolTipEventArgs(Graphics graphics, IWin32Window associatedWindow, Control associatedControl, Rectangle_ bounds, string toolTipText, Color_ backColor, Color_ foreColor, Font font)
 {
     this.graphics           = graphics;
     this.associated_window  = associatedWindow;
     this.associated_control = associatedControl;
     this.bounds             = bounds;
     this.tooltip_text       = toolTipText;
     this.back_color         = backColor;
     this.fore_color         = foreColor;
     this.font = font;
 }
예제 #14
0
        public static void DrawParentBackground(Graphics g, Rectangle_ bounds, Control childControl)
        {
            if (!VisualStyleRenderer.IsSupported)
            {
                return;
            }

            VisualStyleRenderer vsr = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Default);

            vsr.DrawParentBackground(g, bounds, childControl);
        }
예제 #15
0
 protected internal override void Edit(CurrencyManager source, int rowNum, Rectangle_ bounds, bool readOnly, string displayText, bool cellIsVisible)
 {
     editing_row   = rowNum;
     model_state   = FromValueToState(GetColumnValueAtRow(source, rowNum));
     editing_state = model_state | CheckState.Selected;
     // XXX
     // this needs to not use the current cell
     // bounds, but the bounds of the cell for this
     // column/rowNum.
     grid.Invalidate(grid.GetCurrentCellBounds());
 }
예제 #16
0
        public Region GetBackgroundRegion(IDeviceContext dc, Rectangle_ bounds)
        {
            if (dc == null)
            {
                throw new ArgumentNullException("dc");
            }

            Region result;

            last_hresult = VisualStyles.UxThemeGetThemeBackgroundRegion(theme, dc, this.part, this.state, bounds, out result);
            return(result);
        }
예제 #17
0
        public static void DrawTextBox(Graphics g, Rectangle_ bounds, string textBoxText, Font font, Rectangle_ textBounds, TextFormatFlags flags, TextBoxState state)
        {
            if (!IsSupported)
            {
                throw new InvalidOperationException();
            }

            VisualStyleRenderer vsr;

            switch (state)
            {
            case TextBoxState.Assist:
                vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Assist);
                break;

            case TextBoxState.Disabled:
                vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Disabled);
                break;

            case TextBoxState.Hot:
                vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Hot);
                break;

            case TextBoxState.Normal:
            case TextBoxState.Readonly:
            default:
                vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
                break;

            case TextBoxState.Selected:
                vsr = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Selected);
                break;
            }

            vsr.DrawBackground(g, bounds);

            if (textBounds == Rectangle_.Empty)
            {
                textBounds = new Rectangle_(bounds.Left + 3, bounds.Top + 3, bounds.Width - 6, bounds.Height - 6);
            }

            if (textBoxText != String.Empty)
            {
                if (state == TextBoxState.Disabled)
                {
                    TextRenderer.DrawText(g, textBoxText, font, textBounds, SystemColors.GrayText, flags);
                }
                else
                {
                    TextRenderer.DrawText(g, textBoxText, font, textBounds, SystemColors.ControlText, flags);
                }
            }
        }
예제 #18
0
        public void DrawStretched(Graphics g, Rectangle_ targetRect)
        {
            if (cursor == null && std_cursor != (StdCursor)(-1))
            {
                cursor = XplatUI.DefineStdCursorBitmap(std_cursor);
            }

            if (cursor != null)
            {
                g.DrawImage(cursor, targetRect, new Rectangle_(0, 0, cursor.Width, cursor.Height), GraphicsUnit.Pixel);
            }
        }
예제 #19
0
        public Rectangle_ DrawEdge(IDeviceContext dc, Rectangle_ bounds, Edges edges, EdgeStyle style, EdgeEffects effects)
        {
            if (dc == null)
            {
                throw new ArgumentNullException("dc");
            }

            Rectangle_ result;

            last_hresult = VisualStyles.UxThemeDrawThemeEdge(theme, dc, this.part, this.state, bounds, edges, style, effects, out result);
            return(result);
        }
예제 #20
0
 internal void Draw(Rectangle_ rect)
 {
     if (Wnd.IsHandleCreated)
     {
         Point_         pt     = XplatUI.GetMenuOrigin(Wnd.window.Handle);
         Message        m      = Message.Create(Wnd.window.Handle, (int)Msg.WM_PAINT, IntPtr.Zero, IntPtr.Zero);
         PaintEventArgs pevent = XplatUI.PaintEventStart(ref m, Wnd.window.Handle, false);
         pevent.Graphics.SetClip(new Rectangle_(rect.X + pt.X, rect.Y + pt.Y, rect.Width, rect.Height));
         Draw(pevent, Rect);
         XplatUI.PaintEventEnd(ref m, Wnd.window.Handle, false);
     }
 }
예제 #21
0
        public virtual Rectangle_ GetRightScrollRect(System.Windows.Forms.TabControl tab)
        {
            switch (tab.Alignment)
            {
            case TabAlignment.Top:
                return(new Rectangle_(tab.ClientRectangle.Right - (scrollerWidth), tab.ClientRectangle.Top + 1, scrollerWidth, scrollerWidth));

            default:
                Rectangle_ panel_rect = GetTabPanelRect(tab);
                return(new Rectangle_(tab.ClientRectangle.Right - (scrollerWidth), panel_rect.Bottom + 2, scrollerWidth, scrollerWidth));
            }
        }
예제 #22
0
        protected override void Paint(Graphics graphics, Rectangle_ clipBounds, Rectangle_ cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            // Prepaint
            DataGridViewPaintParts pre = DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground;

            pre = pre & paintParts;

            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, pre);

            // Paint content background
            if ((paintParts & DataGridViewPaintParts.ContentBackground) == DataGridViewPaintParts.ContentBackground)
            {
                Color_ color = Selected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;
                Pen    p     = ThemeEngine.Current.ResPool.GetPen(color);
                int    x     = cellBounds.Left + 6;

                if (DataGridView.CurrentRow != null && DataGridView.CurrentRow.Index == rowIndex)
                {
                    DrawRightArrowGlyph(graphics, p, x, cellBounds.Top + (cellBounds.Height / 2) - 4);
                    x += 7;
                }

                if (DataGridView.Rows[rowIndex].IsNewRow)
                {
                    DrawNewRowGlyph(graphics, p, x, cellBounds.Top + (cellBounds.Height / 2) - 4);
                }
            }

            // Paint content
            if ((paintParts & DataGridViewPaintParts.ContentForeground) == DataGridViewPaintParts.ContentForeground)
            {
                Color_ color = Selected ? cellStyle.SelectionForeColor : cellStyle.ForeColor;

                TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.TextBoxControl;

                Rectangle_ contentbounds = cellBounds;
                contentbounds.Height -= 2;
                contentbounds.Width  -= 2;

                if (formattedValue != null)
                {
                    TextRenderer.DrawText(graphics, formattedValue.ToString(), cellStyle.Font, contentbounds, color, flags);
                }
            }

            // Postpaint
            DataGridViewPaintParts post = DataGridViewPaintParts.Border | DataGridViewPaintParts.ErrorIcon;

            post = post & paintParts;

            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, post);
        }
예제 #23
0
        public void DrawImage(Graphics g, Rectangle_ bounds, Image image)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            g.DrawImage(image, bounds);
        }
예제 #24
0
        protected virtual void DrawBackground(Graphics dc, Rectangle_ area, TabControl tab)
        {
            Brush brush = SystemBrushes.Control;

            dc.FillRectangle(brush, area);
            Rectangle_ panel_rect = GetTabPanelRect(tab);

            if (tab.Appearance == TabAppearance.Normal)
            {
                ControlPaint.DrawBorder3D(dc, panel_rect, Border3DStyle.RaisedInner, Border3DSide.Left | Border3DSide.Top);
                ControlPaint.DrawBorder3D(dc, panel_rect, Border3DStyle.Raised, Border3DSide.Right | Border3DSide.Bottom);
            }
        }
예제 #25
0
        public virtual void DrawPopupPressedRadioButton(Graphics g, Rectangle_ bounds, Color_ backColor, Color_ foreColor, bool isChecked)
        {
            g.FillPie(SystemBrushes.ControlLightLight, bounds, 0, 359);
            g.DrawArc(SystemPens.ControlLight, bounds.X + 1, bounds.Y + 1, bounds.Width - 2, bounds.Height - 2, 0, 359);

            g.DrawArc(SystemPens.ControlDark, bounds, 135, 180);
            g.DrawArc(SystemPens.ControlLightLight, bounds, 315, 180);

            if (isChecked)
            {
                DrawFlatRadioGlyphDot(g, bounds, SystemColors.ControlDarkDark);
            }
        }
예제 #26
0
 public DataGridViewRowPostPaintEventArgs(DataGridView dataGridView, Graphics graphics, Rectangle_ clipBounds, Rectangle_ rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow)
 {
     this.dataGridView        = dataGridView;
     this.graphics            = graphics;
     this.clipBounds          = clipBounds;
     this.rowBounds           = rowBounds;
     this.rowIndex            = rowIndex;
     this.rowState            = rowState;
     this.errorText           = errorText;
     this.inheritedRowStyle   = inheritedRowStyle;
     this.isFirstDisplayedRow = isFirstDisplayedRow;
     this.isLastVisibleRow    = isLastVisibleRow;
 }