Beispiel #1
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)
        {
            if (this.CellBehavior == ADGVColumnHeaderCellBehavior.SortingStandartGlyph)
            {
                switch (this.ActiveSortType)
                {
                case ADGVSortType.ASC:
                    this.SortGlyphDirection = SortOrder.Ascending;
                    break;

                case ADGVSortType.DESC:
                    this.SortGlyphDirection = SortOrder.Descending;
                    break;

                case ADGVSortType.None:
                    this.SortGlyphDirection = SortOrder.None;
                    break;
                }
            }
            else
            {
                this.SortGlyphDirection = SortOrder.None;
            }

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

            if (this.CellBehavior != ADGVColumnHeaderCellBehavior.SortingStandartGlyph && this.CellBehavior != ADGVColumnHeaderCellBehavior.DisabledHidden && paintParts.HasFlag(DataGridViewPaintParts.ContentBackground))
            {
                Image filterImage = Properties.Resources.AddFilter;

                if (this.cellBehavior == ADGVColumnHeaderCellBehavior.Sorting || this.ActiveFilterType == ADGVFilterType.None)
                {
                    switch (this.ActiveSortType)
                    {
                    case ADGVSortType.ASC:
                        filterImage = Properties.Resources.ASC;
                        break;

                    case ADGVSortType.DESC:
                        filterImage = Properties.Resources.DESC;
                        break;

                    case ADGVSortType.None:
                        filterImage = Properties.Resources.AddFilter;
                        break;
                    }
                }
                else
                {
                    switch (this.ActiveSortType)
                    {
                    case ADGVSortType.ASC:
                        filterImage = Properties.Resources.FilterASC;
                        break;

                    case ADGVSortType.DESC:
                        filterImage = Properties.Resources.FilterDESC;
                        break;

                    case ADGVSortType.None:
                        filterImage = Properties.Resources.Filter;
                        break;
                    }
                }

                this.filterButtonOffsetBounds = this.GetFilterButtonBounds(true);
                this.filterButtonImageBounds  = this.GetFilterButtonBounds(false);
                Rectangle buttonBounds = this.filterButtonOffsetBounds;
                if (buttonBounds != null && clipBounds.IntersectsWith(buttonBounds))
                {
                    ControlPaint.DrawBorder(graphics, buttonBounds, Color.Gray, ButtonBorderStyle.Solid);
                    buttonBounds.Inflate(-1, -1);
                    using (Brush b = new SolidBrush((this.CellBehavior != ADGVColumnHeaderCellBehavior.Disabled && this.filterButtonOver) ? Color.LightGray : Color.White))
                        graphics.FillRectangle(b, buttonBounds);

                    graphics.DrawImage(filterImage, buttonBounds);
                }
            }
        }
Beispiel #2
0
 protected override void OnPaint(PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, panel5.Bounds, Color.FromArgb(211, 211, 211), ButtonBorderStyle.Solid);
     base.OnPaint(e);
 }
Beispiel #3
0
        private void ToolTipExDraw(
            object sender, DrawToolTipEventArgs e)
        {
            Graphics  g      = e.Graphics;
            Rectangle bounds = e.Bounds;
            int       alpha  = (int)(_opacity * 255);

            int defaultXOffset   = 12;
            int defaultTopHeight = 36;

            int tipTextXOffset = 3;
            int tipTextYOffset = 3;

            if (Handle != IntPtr.Zero && _opacity < 1D)
            {
                IntPtr hDC = g.GetHdc();

                NativeMethods.BitBlt(
                    hDC, 0, 0, bounds.Width, bounds.Height,
                    _backDc.Hdc, 0, 0, 0xCC0020);
                g.ReleaseHdc(hDC);
            }

            Color backNormalColor = Color.FromArgb(
                alpha, this.BackColor);
            Color baseColor = Color.FromArgb(
                alpha, ColorTable.BackHover);
            Color borderColor = Color.FromArgb(
                alpha, ColorTable.Border);

            using (LinearGradientBrush brush = new LinearGradientBrush(
                       bounds,
                       backNormalColor,
                       baseColor,
                       LinearGradientMode.Vertical))
            {
                g.FillRectangle(brush, bounds);
            }

            ControlPaint.DrawBorder(
                g,
                bounds,
                borderColor,
                ButtonBorderStyle.Solid);

            Rectangle imageRect = Rectangle.Empty;
            Rectangle titleRect;
            Rectangle tipRect;

            if (base.ToolTipIcon != ToolTipIcon.None)
            {
                tipTextXOffset = defaultXOffset;
                tipTextYOffset = defaultTopHeight;

                imageRect = new Rectangle(
                    bounds.X + defaultXOffset - (ImageSize.Width - 16) / 2,
                    bounds.Y + (defaultTopHeight - _imageSize.Height) / 2,
                    _imageSize.Width,
                    _imageSize.Height);

                Image image    = _image;
                bool  bDispose = false;

                if (image == null)
                {
                    Icon icon = GetIcon();
                    if (icon != null)
                    {
                        image    = icon.ToBitmap();
                        bDispose = true;
                    }
                }

                if (image != null)
                {
                    using (InterpolationModeGraphics ig =
                               new InterpolationModeGraphics(g))
                    {
                        if (_opacity < 1D)
                        {
                            ToolTipRenderHelper.RenderAlphaImage(
                                g,
                                image,
                                imageRect,
                                (float)_opacity);
                        }
                        else
                        {
                            g.DrawImage(
                                image,
                                imageRect,
                                0,
                                0,
                                image.Width,
                                image.Height,
                                GraphicsUnit.Pixel);
                        }
                    }

                    if (bDispose)
                    {
                        image.Dispose();
                    }
                }
            }

            StringFormat sf = new StringFormat();

            sf.LineAlignment = StringAlignment.Center;

            if (!string.IsNullOrEmpty(base.ToolTipTitle))
            {
                tipTextXOffset = defaultXOffset;
                tipTextYOffset = defaultTopHeight;

                int x = imageRect.IsEmpty ?
                        defaultXOffset : imageRect.Right + 3;

                titleRect = new Rectangle(
                    x,
                    bounds.Y,
                    bounds.Width - x,
                    defaultTopHeight);

                Color foreColor = Color.FromArgb(
                    alpha, ColorTable.TitleFore);

                using (Brush brush = new SolidBrush(foreColor))
                {
                    g.DrawString(
                        base.ToolTipTitle,
                        _titleFont,
                        brush,
                        titleRect,
                        sf);
                }
            }

            if (!string.IsNullOrEmpty(e.ToolTipText))
            {
                tipRect = new Rectangle(
                    bounds.X + tipTextXOffset,
                    bounds.Y + tipTextYOffset,
                    bounds.Width - tipTextXOffset * 2,
                    bounds.Height - tipTextYOffset);

                sf = StringFormat.GenericTypographic;

                Color foreColor = Color.FromArgb(
                    alpha, ColorTable.TipFore);

                using (Brush brush = new SolidBrush(foreColor))
                {
                    g.DrawString(
                        e.ToolTipText,
                        e.Font,
                        brush,
                        tipRect,
                        sf);
                }
            }
        }
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     ControlPaint.DrawBorder(e.Graphics, ClientRectangle, borderColor, ButtonBorderStyle.Solid);
     e.Graphics.FillRectangle(new SolidBrush(headerColor), 1, 1, this.Size.Width - 2, 26);
 }
Beispiel #5
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, ClientRectangle, System.Drawing.Color.Black, ButtonBorderStyle.Outset);
 }
Beispiel #6
0
        //Sets all of the controls' colors
        private static void SetAllControlsColor(Control control, Color backColor, Color txtColor, Color multiLineBoxColor, Color buttonColor, Color gridColor, Color gridTxtColor, Color gridHeaderColor, Color activeTxtBoxColor, Color inactiveTxtBoxColor, Color groupBoxColor, Color secGridColor, Color secGridTxtColor, Color gridSelectColor, Color gridSelectTxtColor, Color secGridSelectColor, Color secGridSelectTxtColor, Color tabColor, Color tabTxtColor, Color pressedTabColor, Color pressedTabTxtColor, Color tabBorderColor, Color Hyperlink, string font, float fontSize)
        {
            //checks if the control is a TextBox
            if (control is TextBox)
            {
                //creates a TextBox variable to check whether or not it's a read only, multiline, or a regular box then sets appropriately
                TextBox box = control as TextBox;

                box.BorderStyle = BorderStyle.FixedSingle; //Sets the BorderStyle to FixedSingle to remove a white border around the textbox

                if (!box.ReadOnly)
                {
                    control.BackColor = activeTxtBoxColor; //If the box is not read only, it will set the active text box color
                }
                else if (box.Multiline)
                {
                    control.BackColor = multiLineBoxColor; //If the box is read only and is a multiline box, it will set as the multiline txt box color
                }
                else
                {
                    control.BackColor = inactiveTxtBoxColor; //If the box is read only and is not a multiline textbox, it will set as the inactive textbox color
                }
            }
            //checks if the control is a button and sets the color appropriately
            else if (control is Button)
            {
                Button button = control as Button;
                button.FlatStyle = FlatStyle.Flat; //Sets the FlatStyle to Flat to remove a white border around the button

                control.BackColor = buttonColor;
            }
            //checks if the control is a datagrid
            else if (control is DataGridView)
            {
                //Creates a DataGrid Variable in order to set the colors appropriately
                DataGridView grid = control as DataGridView;
                grid.RowHeadersBorderStyle    = DataGridViewHeaderBorderStyle.Single; //Sets the RowHeadersBorderStyle to single to remove the white border around the row headers
                grid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; //Sets the ColumnHeadersBorderStyle to single to remove the white border around the Column headers

                grid.BackColor                                          = multiLineBoxColor;
                grid.BackgroundColor                                    = multiLineBoxColor;
                grid.DefaultCellStyle.BackColor                         = gridColor;
                grid.DefaultCellStyle.SelectionBackColor                = gridColor;
                grid.DefaultCellStyle.SelectionForeColor                = gridTxtColor;
                grid.DefaultCellStyle.ForeColor                         = gridTxtColor;
                grid.DefaultCellStyle.SelectionBackColor                = gridSelectColor;
                grid.DefaultCellStyle.SelectionForeColor                = gridSelectTxtColor;
                grid.AlternatingRowsDefaultCellStyle.BackColor          = secGridColor;
                grid.AlternatingRowsDefaultCellStyle.ForeColor          = secGridTxtColor;
                grid.AlternatingRowsDefaultCellStyle.SelectionBackColor = secGridSelectColor;
                grid.AlternatingRowsDefaultCellStyle.SelectionForeColor = secGridSelectTxtColor;
                grid.ColumnHeadersDefaultCellStyle.BackColor            = gridHeaderColor;
                grid.ColumnHeadersDefaultCellStyle.SelectionBackColor   = gridHeaderColor;
                grid.ColumnHeadersDefaultCellStyle.SelectionForeColor   = gridTxtColor;
                grid.ColumnHeadersDefaultCellStyle.ForeColor            = gridTxtColor;
                grid.RowHeadersDefaultCellStyle.BackColor               = gridHeaderColor;
                grid.RowHeadersDefaultCellStyle.SelectionBackColor      = gridHeaderColor;
                grid.RowHeadersDefaultCellStyle.SelectionForeColor      = gridTxtColor;
                grid.RowHeadersDefaultCellStyle.ForeColor               = gridTxtColor;
                grid.GridColor                                          = gridTxtColor;

                grid.EnableHeadersVisualStyles = false;
            }
            //if the control is not a datagrid, button, or textbox, it'll set the color appropriately
            else
            {
                control.BackColor = backColor;
            }

            //Checks if the control is a group box so it can adjust the border appropriately
            if (control is GroupBox)
            {
                GroupBox   group = control as GroupBox;           // Creates a groupbox variable to adjust the border
                SolidBrush brush = new SolidBrush(groupBoxColor); //creates a brush variable for the group box color

                group.Paint += delegate(object o, PaintEventArgs p)
                {
                    p.Graphics.Clear(group.Parent.BackColor);                                                           //resets the background color of the groupbox
                    p.Graphics.DrawString(group.Text, group.Font, brush, 0, 0);                                         //resets the groupbox text to the group box color

                    ControlPaint.DrawBorder(p.Graphics, group.ClientRectangle, groupBoxColor, ButtonBorderStyle.Solid); //re-draws the border for the group box
                };
            }

            //Checks if the control is a toolstrip
            if (control is ToolStrip)
            {
                ToolStrip  strip = control as ToolStrip;                 //creates a toolstrip variable to adjust appropriately
                SolidBrush brush = new SolidBrush(backColor);            //creates a brush for the background color of the toolstrip
                strip.Renderer = new MySR(brush, txtColor, buttonColor); //calls the MySR class to change the colors (see class below)
            }

            //Checks if the control is a tab control
            if (control is TabControl)
            {
                TabControl tab = control as TabControl; //creates a tabcontrol variable to adjust appropriately

                //Calls the MyTab class to adjust the colors (see class below)
                tab = new MyTab(tab, pressedTabColor, tabColor, pressedTabTxtColor, tabTxtColor, tabBorderColor);
            }

            //Sets the text color
            control.ForeColor = txtColor;

            //Sets the LinkLabel color
            if (control is LinkLabel)
            {
                LinkLabel hyperlink = control as LinkLabel;
                hyperlink.LinkColor = Hyperlink;
            }

            //fixes the border
            if (control is ComboBox)
            {
                //creates a ToolStripComboBox variable to check whether or not it's a read only, multiline, or a regular box then sets appropriately
                ComboBox box = control as ComboBox;
                box.FlatStyle = FlatStyle.Flat;
                control       = new MyComboBox(activeTxtBoxColor);
            }

            control.Font = new Font(font, fontSize);

            //checks if the control has children
            if (control.HasChildren)
            {
                // Recursively call this method for each child control.
                foreach (Control childControl in control.Controls)
                {
                    //for the child control, it calls the SetAllControlsColor function to set the colors appropriately
                    SetAllControlsColor(childControl, backColor, txtColor, multiLineBoxColor, buttonColor, gridColor, gridTxtColor, gridHeaderColor, activeTxtBoxColor, inactiveTxtBoxColor, groupBoxColor, secGridColor, secGridTxtColor, gridSelectColor, gridSelectTxtColor, secGridSelectColor, secGridSelectTxtColor, tabColor, tabTxtColor, pressedTabColor, pressedTabTxtColor, tabBorderColor, Hyperlink, font, fontSize);
                }
            }
        }
Beispiel #7
0
 private void panelMain_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, this.panelMain.ClientRectangle, Color.White, ButtonBorderStyle.Solid);
 }
        void PaintWorker(PaintEventArgs e, bool up, CheckState state)
        {
            up = up && state == CheckState.Unchecked;

            ColorData  colors = PaintRender(e.Graphics).Calculate();
            LayoutData layout;

            if (Application.RenderWithVisualStyles)
            {
                //don't have the text-pressed-down effect when we use themed painting
                //this is for consistency with win32 app.
                layout = PaintLayout(e, true).Layout();
            }
            else
            {
                layout = PaintLayout(e, up).Layout();
            }

            Graphics g = e.Graphics;

            Button thisbutton = this.Control as Button;

            if (Application.RenderWithVisualStyles)
            {
                PaintThemedButtonBackground(e, Control.ClientRectangle, up);
            }
            else
            {
                Brush backbrush = null;
                if (state == CheckState.Indeterminate)
                {
                    backbrush = CreateDitherBrush(colors.highlight, colors.buttonFace);
                }

                try {
                    Rectangle bounds = Control.ClientRectangle;
                    if (up)
                    {
                        // We are going to draw a 2 pixel border
                        bounds.Inflate(-borderWidth, -borderWidth); // VS Whidbey #459900
                    }
                    else
                    {
                        // We are going to draw a 1 pixel border.
                        bounds.Inflate(-1, -1); // VS Whidbey #503487
                    }

                    PaintButtonBackground(e, bounds, backbrush);
                }
                finally {
                    if (backbrush != null)
                    {
                        backbrush.Dispose();
                        backbrush = null;
                    }
                }
            }

            PaintImage(e, layout);
            //inflate the focus rectangle to be consistent with the behavior of Win32 app
            if (Application.RenderWithVisualStyles)
            {
                layout.focus.Inflate(1, 1);
            }

            if (up & IsHighContrastHighlighted2())
            {
                var highlightTextColor = SystemColors.HighlightText;
                PaintField(e, layout, colors, highlightTextColor, false);

                if (Control.Focused && Control.ShowFocusCues)
                {
                    // drawing focus rectangle of HighlightText color
                    ControlPaint.DrawHighContrastFocusRectangle(g, layout.focus, highlightTextColor);
                }
            }
            else if (up & IsHighContrastHighlighted())
            {
                PaintField(e, layout, colors, SystemColors.HighlightText, true);
            }
            else
            {
                PaintField(e, layout, colors, colors.windowText, true);
            }

            if (!Application.RenderWithVisualStyles)
            {
                Rectangle r = Control.ClientRectangle;
                if (Control.IsDefault)
                {
                    r.Inflate(-1, -1);
                }

                DrawDefaultBorder(g, r, colors.windowFrame, this.Control.IsDefault);

                if (up)
                {
                    Draw3DBorder(g, r, colors, up);
                }
                else
                {
                    // contrary to popular belief, not Draw3DBorder(..., false);
                    //
                    ControlPaint.DrawBorder(g, r, colors.buttonShadow, ButtonBorderStyle.Solid);
                }
            }
        }
Beispiel #9
0
 private void labelActionMessage_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, labelActionMessage.DisplayRectangle, labelBorderColor, ButtonBorderStyle.Solid);
 }
Beispiel #10
0
 private void minBtn_Paint(object sender, PaintEventArgs e)
 {
     Control ctrl = sender as Control; ControlPaint.DrawBorder(e.Graphics, ctrl.ClientRectangle, ctrl.BackColor, ButtonBorderStyle.Solid);
 }
Beispiel #11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            int imageHeight;
            int imageWidth;
            int paddingX;
            int paddingY;


            Pen               dividerPen        = new Pen(this.DividerColor, 0);
            Brush             textBrush         = new SolidBrush(this.TextColor);
            Brush             disabledTextBrush = new SolidBrush(Color.Gray);
            Brush             bgBrush           = new SolidBrush(Color.Black);
            Color             borderColor       = Color.Black;
            ButtonBorderStyle btnBorderStyle    = ButtonBorderStyle.None;

            // Check if a ImageList exist
            ImageList list = GetImageList();

            if (list != null)
            {
                // if so get Height and Width
                imageHeight = list.ImageSize.Height;
                imageWidth  = list.ImageSize.Width;
            }
            else
            {
                // if not use default values
                imageHeight = this.ImageHeight;
                imageWidth  = this.ImageWidth;
            }

            // Check if the item has belongs to a MozPane
            if (m_mozPane != null)
            {
                // If so get the padding
                paddingX = m_mozPane.Padding.Horizontal;
                paddingY = m_mozPane.Padding.Vertical;
            }
            else
            {
                // use some kind of padding if no daddy is found
                paddingX = 1;
                paddingY = 1;
            }

            Rectangle textRect   = new Rectangle();
            Rectangle imageRect  = new Rectangle(0, 0, imageWidth, imageHeight);
            Rectangle borderRect = new Rectangle();

            StringFormat f = new StringFormat();

            Point borderLocation = new Point();

            borderLocation.X = 0;
            borderLocation.Y = 0;

            borderRect.Location = borderLocation;
            borderRect.Width    = this.Width;
            borderRect.Height   = this.Height;

            // Draw background
            e.Graphics.FillRectangle(new SolidBrush(this.BackgroundColor), this.DisplayRectangle);

            // Use Normal image for disabled state
            if (!this.Enabled)
            {
                this.m_state = MozItemState.Normal;
            }
            // A divider should not be able to be selected or recieve focus
            if (this.ItemStyle == MozItemStyle.Divider)
            {
                this.m_state = MozItemState.Normal;
            }

            // Check state for item, to decide image
            switch (m_state)
            {
            case MozItemState.Focus:
            {
                textBrush      = new SolidBrush(this.FocusText);
                bgBrush        = new SolidBrush(this.FocusColor);
                borderColor    = this.FocusBorderColor;
                btnBorderStyle = this.FocusBorderStyle;
                if (m_imageCollection.FocusImage != null)
                {
                    image = m_imageCollection.FocusImage;
                }
                else
                {
                    // if focusimage isnt set use Normal image
                    image = m_imageCollection.NormalImage;
                }
                break;
            }

            case MozItemState.Selected:
            {
                textBrush      = new SolidBrush(this.SelectedText);
                bgBrush        = new SolidBrush(this.SelectedColor);
                borderColor    = this.SelectedBorderColor;
                btnBorderStyle = this.SelectedBorderStyle;
                if (m_imageCollection.SelectedImage != null)
                {
                    image = m_imageCollection.SelectedImage;
                }
                else
                {
                    image = m_imageCollection.NormalImage;
                }
                break;
            }

            case MozItemState.Normal:
            {
                image          = m_imageCollection.NormalImage;
                bgBrush        = new SolidBrush(this.BackgroundColor);
                btnBorderStyle = this.NormalBorderStyle;
                borderColor    = this.BorderColor;
                break;
            }
            }

            e.Graphics.FillRectangle(bgBrush, borderRect);
            ControlPaint.DrawBorder(e.Graphics, borderRect, borderColor, btnBorderStyle);

            // check for itemStyle
            switch (m_itemStyle)
            {
            case MozItemStyle.Divider:
            {
                float ptY;
                float ptX;

                if (m_mozPane != null)
                {
                    // Check MozPane orientation
                    if (m_mozPane.Style == MozPaneStyle.Vertical)
                    {
                        ptY = borderRect.Top + (borderRect.Height / 2);
                        e.Graphics.DrawLine(dividerPen, borderRect.Left, ptY, borderRect.Right, ptY);
                    }
                    else
                    {
                        ptX = borderRect.Left + (borderRect.Width / 2);
                        e.Graphics.DrawLine(dividerPen, ptX, borderRect.Top, ptX, borderRect.Bottom);
                    }
                }
                else
                {
                    ptY = borderRect.Top + (borderRect.Height / 2);
                    e.Graphics.DrawLine(dividerPen, borderRect.Left, ptY, borderRect.Right, ptY);
                }

                break;
            }

            case MozItemStyle.Text:
            {
                f.Alignment     = StringAlignment.Center;
                f.LineAlignment = StringAlignment.Center;
                textRect        = borderRect;
                if (m_state == MozItemState.Selected)
                {
                    textRect.X += 1;
                    textRect.Y += 1;
                }
                if (this.Enabled)
                {
                    e.Graphics.DrawString(this.Text, this.Font, textBrush, textRect, f);
                }
                else
                {
                    e.Graphics.DrawString(this.Text, this.Font, disabledTextBrush, textRect, f);
                }
                break;
            }

            case MozItemStyle.Picture:
            {
                if (image != null)
                {
                    // center image
                    imageRect.X = ((borderRect.Width / 2) - (imageRect.Width / 2));
                    imageRect.Y = ((borderRect.Height / 2) - (imageRect.Height / 2));
                    if (m_state == MozItemState.Selected)
                    {
                        imageRect.X += 1;
                        imageRect.Y += 1;
                    }

                    if (this.Enabled)
                    {
                        if (image != null)
                        {
                            e.Graphics.DrawImage(image, imageRect);
                        }
                        else
                        if (image != null)
                        {
                            ControlPaint.DrawImageDisabled(e.Graphics, image, imageRect.X, imageRect.Y, this.BackgroundColor);
                        }
                    }
                }
                break;
            }

            case MozItemStyle.TextAndPicture:
            {
                f.LineAlignment = StringAlignment.Center;

                switch (m_textAlign)
                {
                case MozTextAlign.Bottom:
                {
                    f.Alignment     = StringAlignment.Center;
                    textRect.Height = this.Font.Height + (2 * 4);
                    textRect.Y      = borderRect.Bottom - textRect.Height;
                    textRect.X      = borderRect.X;
                    textRect.Width  = borderRect.Width;

                    imageRect.Y = borderRect.Top + 2;
                    imageRect.X = ((borderRect.Width / 2) - imageRect.Width / 2);
                    break;
                }

                case MozTextAlign.Top:
                {
                    f.Alignment     = StringAlignment.Center;
                    textRect.Height = this.Font.Height + (2 * 4);
                    textRect.Y      = borderRect.Top;
                    textRect.X      = borderRect.X;
                    textRect.Width  = borderRect.Width;

                    imageRect.Y = borderRect.Bottom - 2 - imageRect.Height;
                    imageRect.X = ((borderRect.Width / 2) - imageRect.Width / 2);
                    break;
                }

                case MozTextAlign.Right:
                {
                    f.Alignment     = StringAlignment.Near;
                    textRect.Height = borderRect.Height - 2 * 4;
                    textRect.Y      = borderRect.Top + 4;
                    textRect.X      = borderRect.X + 4 + imageRect.Width + 4;
                    textRect.Width  = borderRect.Width - 4 - imageRect.Width;

                    imageRect.X = 4;
                    imageRect.Y = ((borderRect.Height / 2) - (imageRect.Height / 2));
                    break;
                }

                case MozTextAlign.Left:
                {
                    f.Alignment     = StringAlignment.Near;
                    textRect.Height = borderRect.Height - 2 * 4;
                    textRect.Y      = borderRect.Top + 4;
                    textRect.X      = borderRect.X + 4;
                    textRect.Width  = borderRect.Width - 4 - imageRect.Width;

                    imageRect.X = borderRect.Right - 4 - imageRect.Width;
                    imageRect.Y = ((borderRect.Height / 2) - (imageRect.Height / 2));
                    break;
                }
                }

                // Check if enabled
                if (this.Enabled)
                {
                    if (m_state == MozItemState.Selected)
                    {
                        imageRect.X += 1;
                        imageRect.Y += 1;
                        textRect.X  += 1;
                        textRect.Y  += 1;
                    }
                    // draw image and text
                    if (image != null)
                    {
                        e.Graphics.DrawImage(image, imageRect);
                    }
                    e.Graphics.DrawString(this.Text, this.Font, textBrush, textRect, f);
                }
                else
                {
                    // Draw disabled image and text
                    if (image != null)
                    {
                        ControlPaint.DrawImageDisabled(e.Graphics, image, imageRect.X, imageRect.Y, this.BackColor);
                    }
                    e.Graphics.DrawString(this.Text, this.Font, disabledTextBrush, textRect, f);
                }

                break;
            }
            }

            // tidy up
            dividerPen.Dispose();
            textBrush.Dispose();
            disabledTextBrush.Dispose();
            bgBrush.Dispose();
        }
Beispiel #12
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle borderRect = new Rectangle(new Point(BUTTON.Location.X, BUTTON.Location.Y), BUTTON.Size);

            ControlPaint.DrawBorder(e.Graphics, borderRect, SystemColors.ActiveBorder, ButtonBorderStyle.Solid);
        }
Beispiel #13
0
        //Check and change expired dates END*************************************

        private void dataGridView1_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, this.dataGridView1.ClientRectangle, SystemColors.ControlLight, ButtonBorderStyle.Solid);
        }
Beispiel #14
0
 private void DrawPrgressBarBorder(Graphics g)
 {
     ControlPaint.DrawBorder(g, ClientRectangle, Color.FromArgb(0, 81, 152), ButtonBorderStyle.Solid);
 }
Beispiel #15
0
 private void pbPdf_MouseEnter(object sender, EventArgs e)
 {
     ControlPaint.DrawBorder(pictureBox2.CreateGraphics(), pictureBox2.ClientRectangle, Color.Orange, ButtonBorderStyle.Inset);
 }
Beispiel #16
0
        ///////////////////////////////////////////////////////////////////////
        ///

        // 테두리 색상 추가
        private void UserControl1_Paint(object sender, PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.Black, ButtonBorderStyle.Solid);
        }
Beispiel #17
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            #region для многострочного текста
            ///*chk if list box has any items*/
            //if(e.Index > -1)
            //{
            //    string s = Items[e.Index].ToString();

            //    /*Normal items*/
            //    if((e.State & DrawItemState.Focus)==0)
            //    {
            //        e.Graphics.FillRectangle(
            //            new SolidBrush(SystemColors.Window),
            //            e.Bounds);
            //        e.Graphics.DrawString(s,Font,
            //            new SolidBrush(SystemColors.WindowText),
            //            e.Bounds);
            //        e.Graphics.DrawRectangle(
            //            new Pen(SystemColors.Highlight),e.Bounds);
            //    }
            //    else /*Selected item, needs highlighting*/
            //    {
            //        e.Graphics.FillRectangle(
            //            new SolidBrush(SystemColors.Highlight),
            //            e.Bounds);
            //        e.Graphics.DrawString(s,Font,
            //            new SolidBrush(SystemColors.HighlightText),
            //            e.Bounds);
            //    }
            //}
            #endregion

            if (this.Items.Count == 0 || e.Index == -1)
            {
                return;
            }
            Rectangle rect = this.GetItemRectangle(e.Index);
            //  if( rect.Height == 13 )
            //      Console.WriteLine(this.Name + " draw " + rect.Height.ToString() + " (" + debugVar + ")");

            string text      = this.Items[e.Index].ToString();
            Brush  backRound = Brushes.White;
            #region DrawBorder
            if (this.SelectedIndex == e.Index)
            {
                if (this.Focused)
                {
                    backRound = brushSelected;
                }
                else
                {
                    backRound = Brushes.White;
                }

                e.Graphics.FillRectangle(backRound, rect);
                ControlPaint.DrawBorder(e.Graphics, rect, Color.Gray, ButtonBorderStyle.Solid);
            }
            else
            {
                e.Graphics.FillRectangle(backRound, rect);
            }
            #endregion

            ISentence  sentence  = this.Items[e.Index] as ISentence;
            IScoreUnit scoreUnit = this.Items[e.Index] as IScoreUnit;
            ScoreData  scoreData = null;
            if (scoreUnit != null && scoreUnit.IsHaveScore)
            {
                scoreData = scoreUnit.ScoreData;
            }

            if (sentence != null)
            {
                #region WordsToLearn
                if (sentence.WordsToLearn.Count > 0)
                {
                    string markedText = "";
                    int    startText  = -1;
                    // найдем ближайшее слово справа
                    foreach (string word in sentence.WordsToLearn)
                    {
                        startText = text.ToLower().IndexOf(word.ToLower());
                        if (startText == -1)
                        {
                            continue;
                        }
                        markedText = word;

                        int   markedTextLength = markedText.Length;
                        int   markedWidth      = TextRenderer.MeasureText(markedText, this.Font).Width - 7;
                        int   yLocation        = e.Bounds.Y + 1;
                        Point starForMarker    = new Point(0 + 2, yLocation);
                        if (startText != 0)
                        {
                            int widthText  = TextRenderer.MeasureText(text.Substring(0, startText), this.Font).Width;
                            int correction = 7;
                            if (this.Font.Size > 11)
                            {
                                correction += (int)(this.Font.Size - 11);
                            }
                            starForMarker = new Point(widthText - correction, yLocation + 2);
                        }
                        Rectangle boldedRect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2 - 3));
                        e.Graphics.FillRectangle(brushLight, boldedRect);
                        Ul.DoSmoothAngle(e.Graphics, backRound, boldedRect);

                        // Console.WriteLine(word);
                    }
                    e.Graphics.DrawLine(penLight, 0, rect.Y, 0, rect.Y + rect.Height);
                }
                #endregion

                #region ScoreState
                if (scoreData != null && scoreData.PrevState != ScoreState.Unknown)
                {
                    Point    starForMarker  = new Point(0 + 3, e.Bounds.Y + 1);
                    string   textForMeasure = "100";
                    string[] parts          = text.Split('-');
                    if (parts.Length > 1)
                    {
                        textForMeasure = parts[0];
                    }
                    int       markedWidth   = TextRenderer.MeasureText(textForMeasure, this.Font).Width - 9;
                    Rectangle areaForSelect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2));

                    if (scoreData.PrevState == ScoreState.HasError)
                    {
                        e.Graphics.FillRectangle(brErrors, areaForSelect);
                    }
                    else if (scoreData.PrevState == ScoreState.Warning)
                    {
                        e.Graphics.FillRectangle(brHints, areaForSelect);
                    }
                    else if (scoreData.PrevState == ScoreState.Complete)
                    {
                        e.Graphics.FillRectangle(brPasses, areaForSelect);
                    }

                    Ul.DoSmoothAngle(e.Graphics, backRound, areaForSelect);
                    //e.Graphics.DrawImage(im, rect.Location);
                }
                #endregion
            }

            #region отрисовка маркера выделяющего текст (старый (только для словаря) работающий механизм)
            if (this.MarkedItemIndex == e.Index && !string.IsNullOrEmpty(MarkedText) && text.IndexOf(this.MarkedText) != -1)
            {
                int   startText        = text.IndexOf(this.MarkedText);
                int   markedTextLength = this.MarkedText.Length;
                int   markedWidth      = TextRenderer.MeasureText(this.MarkedText, this.Font).Width - 3;
                Point starForMarker    = new Point(0 + 1, e.Bounds.Y + 1);
                if (startText != 0)
                {
                    starForMarker = new Point(TextRenderer.MeasureText(text.Substring(0, startText), this.Font).Width - 7, rect.Y + 1);
                }
                Rectangle boldedRect = new Rectangle(starForMarker, new Size(markedWidth, rect.Height - 2));
                e.Graphics.FillRectangle(brushLight, boldedRect);
            }
            #endregion

            Point pointStart = new Point(e.Bounds.X - 1, e.Bounds.Y - 1);
            if (text.StartsWith(SentenceTabSymbol))
            {
                pointStart = new Point(e.Bounds.X + 15, e.Bounds.Y - 2);
                text       = text.Replace(SentenceTabSymbol, "").TrimStart(' ');
            }
            TextRenderer.DrawText(e.Graphics, text, this.Font, pointStart, SystemColors.ControlText);
            // draw not black numbers
            string number = text.IndexOf('.') > 0 ? text.Substring(0, text.IndexOf('.') + 1) : ""; // this.Items[e.Index].ToString("#");
            if (!string.IsNullOrEmpty(number))
            {
                TextRenderer.DrawText(e.Graphics, number, this.Font, pointStart, Color.Gray);
            }
            //  base.OnDrawItem(e);
        }
Beispiel #18
0
 private void TyResult_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, TyResult.DisplayRectangle, Color.DeepSkyBlue, ButtonBorderStyle.Solid);
 }
 private void panel1_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Goldenrod, ButtonBorderStyle.Solid);
 }
 private void PT_formEnd_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.FromArgb(29, 26, 77), 2, ButtonBorderStyle.Solid, Color.FromArgb(29, 26, 77), 2, ButtonBorderStyle.Solid, Color.FromArgb(29, 26, 77), 2, ButtonBorderStyle.Solid, Color.FromArgb(29, 26, 77), 2, ButtonBorderStyle.Solid);
 }
Beispiel #21
0
        // GraphForm methods

        protected override void OnPaint(PaintEventArgs e)
        {
            ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.Black, ButtonBorderStyle.Solid);     // Draws borders
        }
 private void LabelOnPaint(object sender, PaintEventArgs e)
 => ControlPaint.DrawBorder(e.Graphics, ((Control)sender).DisplayRectangle, Color.Wheat, ButtonBorderStyle.Solid);
 protected override void OnPaint(PaintEventArgs pe)
 {
     base.OnPaint(pe);
     ControlPaint.DrawBorder(pe.Graphics, pe.ClipRectangle, Color.DarkGray, ButtonBorderStyle.Outset);
 }
Beispiel #24
0
 private void VeBorder(Control control, PaintEventArgs e, int r, int g, int b)
 {
     ControlPaint.DrawBorder(e.Graphics, control.ClientRectangle, Color.FromArgb(r, g, b), ButtonBorderStyle.Solid);
 }
        void MessageBox_Paint(object sender, PaintEventArgs e)
        {
            ExtendedGraphics g = new ExtendedGraphics(e.Graphics);

            ControlPaint.DrawBorder(g.Graphics, this.ClientRectangle, StyleManager.BackColor, ButtonBorderStyle.Solid);
        }
        // ========================================
        // method
        // ========================================
        // --- override ---
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            ControlPaint.DrawBorder(e.Graphics, ClientRectangle, _borderColor, ButtonBorderStyle.Solid);
        }
Beispiel #27
0
 void panel6_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, panel5.Bounds, Color.FromArgb(211, 211, 211), ButtonBorderStyle.Solid);
     base.OnPaint(e);
 }
Beispiel #28
0
 private void Panel1OnPaint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, this.panel1.ClientRectangle, Color.LightSteelBlue, ButtonBorderStyle.Solid);
 }
Beispiel #29
0
 void label12_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, label12.DisplayRectangle, Color.Red, ButtonBorderStyle.Solid);
 }
Beispiel #30
0
 private void ConnectForm_Paint(object sender, PaintEventArgs e)
 {
     ControlPaint.DrawBorder(e.Graphics, ClientRectangle, Color.FromArgb(80, 80, 80), ButtonBorderStyle.Solid);
 }