コード例 #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rc = ClientRectangle;

            //Fill the entire client with the border color brush
            RoundRectPath path = new RoundRectPath(rc, mRounding, mRounding);
            Color grad = Color.FromArgb((mBorderColor.R + 100) <= 255 ? mBorderColor.R + 100 : 255, (mBorderColor.G + 100) <= 255 ? mBorderColor.G + 100 : 255, (mBorderColor.B + 100) <= 255 ? mBorderColor.B + 100 : 255);
            using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rc.X, rc.Y, rc.Width, rc.Height), grad, mBorderColor, LinearGradientMode.ForwardDiagonal)) {
                b.WrapMode = WrapMode.TileFlipX;
                g.FillPath(b, path);
            }

            //Deflate the rect and now draw the button
            rc.Inflate(-1, -1);
            path.Dispose();
            path = new RoundRectPath(rc, mRounding, mRounding);
            grad = Color.FromArgb((mBackColor.R + 150) <= 255 ? mBackColor.R + 100 : 255, (mBackColor.G + 150) <= 255 ? mBackColor.G + 150 : 255, (mBackColor.B + 150) <= 255 ? mBackColor.B + 150 : 255);
            using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rc.X, rc.Y - (rc.Height / 2), rc.Width, rc.Height + (rc.Height / 2)), grad, mBackColor, LinearGradientMode.Vertical)) {
                b.WrapMode = WrapMode.TileFlipX;
                g.FillPath(b, path);
            }
            path.Dispose();
        }
コード例 #2
0
 protected virtual void DrawItem(ListItemPaintArgs args)
 {
     Graphics g = args.Graphics;
     Rectangle rcItem = args.ItemRectangle;
     RoundRectPath path = new RoundRectPath(rcItem, mRounding, mRounding);
     using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcItem.X, rcItem.Y - (rcItem.Height / 2), rcItem.Width, rcItem.Height + (rcItem.Height / 2)), Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
         b.WrapMode = WrapMode.TileFlipX;
         g.FillPath(b, path);
     }
     using (Pen p = new Pen(mBorderColor, 1)) {
         g.DrawPath(p, path);
     }
     using (Brush b = new SolidBrush(Color.Black)) {
         g.DrawString(args.Item.Text, Font, b, args.TextRectangle, mFormat);
     }
     if (args.Item.Icon != null) {
         g.DrawIcon(args.Item.Icon, args.IconRectangle);
     }
     path.Dispose();
 }
コード例 #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rc = ClientRectangle;

            Graphics g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Color backColor;
            Color borderColor;
            Color foreColor;
            backColor = mBackColor;
            borderColor = mBorderColor;
            foreColor = ForeColor;
            Brush backBrush = new SolidBrush(backColor);
            Pen borderPen = new Pen(borderColor);
            Brush foreBrush = new SolidBrush(foreColor);

            switch (mIndicatorShape) {
                case IndicatorShape.Rectangle:
                    e.Graphics.FillRectangle(foreBrush, rc);
                    e.Graphics.DrawRectangle(borderPen, rc);
                    break;
                case IndicatorShape.RoundedRectangle:
                    e.Graphics.FillRectangle(backBrush, rc);
                    RoundRectPath path = new RoundRectPath(rc, mRounding, mRounding);
                    e.Graphics.FillPath(foreBrush, path);
                    e.Graphics.DrawPath(borderPen, path);
                    path.Dispose();

                    break;
                case IndicatorShape.Round:
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0, backColor.R,backColor.G,backColor.B)), rc);
                    rc = new Rectangle(rc.Left + 1, rc.Top + 1, rc.Width - 2, rc.Height - 2);
                    e.Graphics.FillEllipse(foreBrush, rc);
                    e.Graphics.DrawEllipse(borderPen, rc);
                    break;
            }

            g.DrawString(Text,Font, Brushes.Black,ClientRectangle,mFormat);
            backBrush.Dispose();
            borderPen.Dispose();
            foreBrush.Dispose();
        }
コード例 #4
0
        protected override void DrawItem(ListItemPaintArgs args)
        {
            Graphics g = args.Graphics;
            Rectangle rcItem = args.ItemRectangle;
            RoundRectPath path = new RoundRectPath(rcItem, mRounding, mRounding);
            ProcessListItem item = args.Item as ProcessListItem;

            using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcItem.X, rcItem.Y - (rcItem.Height / 2), rcItem.Width, rcItem.Height + (rcItem.Height / 2)), Color.White, item.BackColor, LinearGradientMode.Vertical)) {
                b.WrapMode = WrapMode.TileFlipX;
                g.FillPath(b, path);
            }
            if (item.Selected) {
                using (Pen p = new Pen(mBorderColor, 2)) {
                    g.DrawPath(p, path);
                }
            } else {
                using (Pen p = new Pen(mBorderColor, 1)) {
                    g.DrawPath(p, path);
                }
            }
            using (Brush b = new SolidBrush(item.ForeColor)) {
                g.DrawString(args.Item.Text, Font, b, args.TextRectangle, mFormat);
            }

            if (item.Icon != null && item.Status != ProcessStatusType.New) {
                g.DrawIcon(item.Icon, args.IconRectangle);
            }
            path.Dispose();
        }
コード例 #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rc = ClientRectangle;

            //Fill the entire client with the border color brush
            RoundRectPath path = new RoundRectPath(rc, mRounding, mRounding);
            Color grad = Color.FromArgb((mBorderColor.R + 100) <= 255 ? mBorderColor.R + 100 : 255, (mBorderColor.G + 100) <= 255 ? mBorderColor.G + 100 : 255, (mBorderColor.B + 100) <= 255 ? mBorderColor.B + 100 : 255);
            using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rc.X, rc.Y, rc.Width, rc.Height), grad, mBorderColor, LinearGradientMode.ForwardDiagonal)) {
                b.WrapMode = WrapMode.TileFlipX;
                g.FillPath(b, path);
            }

            Color backColor = mBackColor;
            Color foreColor = ForeColor;
            if (!Enabled) {
                backColor = Color.FromArgb(0xbb,0xbb,0xbb);
                foreColor = Color.Gray;
            }

            //Deflate the rect and now draw the button
            rc.Inflate(-1, -1);
            path.Dispose();
            path = new RoundRectPath(rc, mRounding, mRounding);
            if (this.Capture) {
                using (Brush b = new SolidBrush(backColor)) {
                    g.FillPath(b, path);
                }
            } else {
                grad = Color.FromArgb((backColor.R + 100) <= 255 ? backColor.R + 100 : 255, (backColor.G + 100) <= 255 ? backColor.G + 100 : 255, (backColor.B + 100) <= 255 ? backColor.B + 100 : 255);
                using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rc.X, rc.Y - (rc.Height / 2), rc.Width, rc.Height + (rc.Height / 2)), grad, backColor, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, path);
                }
            }

            //Draw the text
            using (Brush b = new SolidBrush(foreColor)) {
                g.DrawString(Text, Font, b, rc, mFormat);
            }
            path.Dispose();
        }
コード例 #6
0
ファイル: Grid.cs プロジェクト: eprimo/Linc-Reporting-Service
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            StringFormat format = new StringFormat();
            format.LineAlignment = StringAlignment.Center;

            Graphics g = e.Graphics;
            //Deflat rect for body
            Rectangle rcClient = ClientRectangle;
            rcClient.Width -= 3;
            rcClient.Height -= 3;
            rcClient.Offset(1, 1);

            if (g.Clip != null) g.Clip.Dispose();
            g.Clip = new Region(rcClient);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            if (mHeaderFont == null) {
                mHeaderFont = new Font(Font, FontStyle.Bold);
            }

            Rectangle rcHeader = new Rectangle(rcClient.X, rcClient.Y, rcClient.Width, mHeaderFont.Height + 10);
            Rectangle rcText = new Rectangle(0, 0, 1, rcHeader.Height);

            //Draw header background
            RoundRectPath path = new RoundRectPath(rcHeader, mRounding, mRounding);
            Color grad = Color.FromArgb((Color.LightGray.R + 150) <= 255 ? Color.LightGray.R + 100 : 255, (Color.LightGray.G + 150) <= 255 ? Color.LightGray.G + 150 : 255, (Color.LightGray.B + 150) <= 255 ? Color.LightGray.B + 150 : 255);
            using (LinearGradientBrush b = new LinearGradientBrush(new Rectangle(rcHeader.X, rcHeader.Y - (rcHeader.Height / 2), rcHeader.Width, rcHeader.Height + (rcHeader.Height / 2)), grad, Color.LightGray, LinearGradientMode.Vertical)) {
                b.WrapMode = WrapMode.TileFlipX;
                g.FillPath(b, path);
            }

            using (Pen p = new Pen(Color.DarkGray, 1)) {
                //g.DrawLine(p, new Point(rcHeader.Left, rcHeader.Bottom), new Point(rcHeader.Right, rcHeader.Bottom));
                g.DrawPath(p, path);
            }
            path.Dispose();

            //Draw header text
            rcText = rcHeader;
            foreach (GridColumn col in mColumns) {
                rcText.Width = col.Width;
                format.Alignment = col.Alignment;
                g.DrawString(col.HeaderText, mHeaderFont, Brushes.Black, rcText, format);
                rcText.Offset(col.Width, 0);
            }

            rcClient.Inflate(-1, -1);
            if (g.Clip != null) g.Clip.Dispose();
            g.Clip = new Region(rcClient);

            rcClient.Y = rcHeader.Bottom;
            rcClient.Height = ClientRectangle.Height - (rcHeader.Height + 1);
            if (g.Clip != null) g.Clip.Dispose();
            g.Clip = new Region(rcClient);

            int height = ((rcHeader.Height - 8) * (mRows.Count)) + 4;
            rcText.Height = mHeaderFont.Height + 2;
            mMaxScroll = rcClient.Height - height;
            if (mMaxScroll > 0) { // No scrolling needed
                mMaxScroll = 0;
                mScrollBar = new Rectangle(0, 0, 0, 0);
            } else {
                mScrollBar = new Rectangle(rcClient.Right - 33, rcClient.Y + 3, 30, rcClient.Height - 6);

                RoundRectPath thumbPath = new RoundRectPath(mScrollBar, mRounding, mRounding);
                using (LinearGradientBrush b = new LinearGradientBrush(mScrollBar, Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, thumbPath);
                }

                using (Pen p = new Pen(Color.DarkGray, 3)) {
                    p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
                    g.DrawLine(p, new Point(mScrollBar.X + 6, mScrollBar.Y + 18), new Point(mScrollBar.X + 15, mScrollBar.Y + 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, mScrollBar.Y + 18), new Point(mScrollBar.X + 15, mScrollBar.Y + 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 6, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                }

                for (int l = mScrollBar.Y + 24; l < mScrollBar.Bottom - 24; l += 4) {
                    g.DrawLine(Pens.DarkGray, new Point(mScrollBar.Location.X + 6, l), new Point(mScrollBar.Location.X + 24, l));
                }
                g.DrawPath(Pens.Black, thumbPath);

                rcClient.Width = rcClient.Width - (mScrollBar.Width + 6);
                if (g.Clip != null) g.Clip.Dispose();
                g.Clip = new Region(rcClient);
                thumbPath.Dispose();
                if (g.Clip != null) g.Clip.Dispose();
            }

            Brush bActive = new SolidBrush(Color.FromArgb(0xBC, 0xC9, 0xFE));
            Brush bError = new SolidBrush(Color.Pink);
            Brush bSuccess = new SolidBrush(Color.LightGreen);
            Brush bCustom = new SolidBrush(mCustomBackColor);

            //Fill Row back colors
            Rectangle rcRow = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width, mHeaderFont.Height + 2);
            for (int row = 0; row < mRows.Count; row++) {
                if (rcRow.Bottom > rcClient.Bottom) break;
                if (mSelectMode) {
                    if (row == mSelecedIndex) g.FillRectangle(bActive, rcRow);
                } else if (mRows[row].Style == GridRowStyle.Active) {
                    g.FillRectangle(bActive, rcRow);
                } else if (mRows[row].Style == GridRowStyle.Success) {
                    g.FillRectangle(bSuccess, rcRow);
                } else if (mRows[row].Style == GridRowStyle.Error) {
                    g.FillRectangle(bError, rcRow);
                } else if (mRows[row].Style == GridRowStyle.Custom) {
                    g.FillRectangle(bCustom, rcRow);
                }
                rcRow.Offset(0, rcRow.Height);
            }

            Brush textBrush = null;
            Brush customForeBrush = new SolidBrush(mCustomForeColor);
            rcRow = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width, mHeaderFont.Height + 2);
            foreach (GridRow row in mRows) {
                if (rcRow.Bottom > rcClient.Bottom)
                    break;
                rcText.X = rcRow.X;
                rcText.Y = rcRow.Y;
                for(int i = 0; i < mColumns.Count; i++) {
                    if (i < row.Values.Count) {
                        rcText.Width = mColumns[i].Width;
                        format.Alignment = mColumns[i].Alignment;
                        switch (row.Style) {
                            case GridRowStyle.Inactive:
                                textBrush = Brushes.Gray;
                                break;
                            case GridRowStyle.Custom:
                                textBrush = customForeBrush;
                                break;
                            default:
                                textBrush = Brushes.Black;
                                break;
                        }
                        format.FormatFlags = StringFormatFlags.NoWrap;
                        g.DrawString(row.Values[i], Font, textBrush, rcText, format);
                        rcText.Offset(mColumns[i].Width, 0);
                    }
                }

                rcRow.Offset(0, rcRow.Height);
            }
            bActive.Dispose();
            bError.Dispose();
            bSuccess.Dispose();
            bCustom.Dispose();
            customForeBrush.Dispose();
            format.Dispose();
        }
コード例 #7
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;
            Rectangle rcClient = ClientRectangle;
            rcClient.Inflate(-4, -4);

            Region originalClip = g.Clip;
            g.Clip = new Region(rcClient);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Size szSpace = new Size(4, 3);
            Rectangle rcItem;
            Rectangle rcText = new Rectangle(0, 0, 0, 0);
            Rectangle rcIcon = new Rectangle(0, 0, 0, 0);

            StringFormat iconTextFormat = new StringFormat();
            iconTextFormat.Alignment = StringAlignment.Center;
            iconTextFormat.LineAlignment = StringAlignment.Center;

            Color color1 = Color.White;
            Color color2 = Color.White;
            Brush textBrush = Brushes.Black;
            Brush iconBrush = Brushes.White;

            //First determine if the data will fit without the scrollbar
            rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - szSpace.Width, 0);
            for (int i = 0; i < Items.Count; i++) {
                ListItem item = Items[i];
                if (item.Icon != null) {
                    rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
                    rcText.X = rcIcon.Right + szSpace.Width;
                    rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
                } else {
                    rcIcon = new Rectangle(0, 0, 0, 0);
                    rcText.X = ItemPadding.Left + rcItem.X;
                    rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
                }

                Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
                rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
                item.Size = rcItem.Size;
                item.Location.X = rcItem.Location.X;
                item.Location.Y = rcItem.Location.Y + mCurrentY;
                rcText.Height = rcItem.Height;
                rcText.Y = rcItem.Y;
                rcIcon.Y = rcItem.Y + ((rcItem.Height - rcIcon.Height) / 2);

                rcItem.Offset(0, rcItem.Height + szSpace.Height);
            }

            mMaxScroll = ((rcItem.Bottom + mDefaultY) - (Height + mCurrentY));
            if (mMaxScroll < 0) { // No scrolling needed
                mMaxScroll = 0;
                mCurrentY = mDefaultY;
                mScrollBar = new Rectangle(0, 0, 0, 0);
            } else {
                mScrollBar = new Rectangle(rcClient.Right - 30, rcClient.Y, 30, rcClient.Height);
                RoundRectPath thumbPath = new RoundRectPath(mScrollBar, mRounding, mRounding);
                using (LinearGradientBrush b = new LinearGradientBrush(mScrollBar, Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, thumbPath);
                }

                using (Pen p = new Pen(Color.DarkGray, 3)) {
                    p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
                    g.DrawLine(p, new Point(mScrollBar.X + 6, 18), new Point(mScrollBar.X + 15, 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, 18), new Point(mScrollBar.X + 15, 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 6, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                }

                for (int l = 24; l < rcClient.Height - 24; l += 4) {
                    g.DrawLine(Pens.DarkGray, new Point(mScrollBar.Location.X + 6, l), new Point(mScrollBar.Location.X + 24, l));
                }
                g.DrawPath(Pens.Black, thumbPath);
                thumbPath.Dispose();
            }

            rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - ((mScrollBar.Width > 0) ? mScrollBar.Width + szSpace.Width : 0), 0);
            for (int i = 0; i < Items.Count; i++) {
                ListItem item = Items[i];

                if (item.Icon != null) {
                    rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
                    rcText.X = rcIcon.Right + szSpace.Width;
                    rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
                } else {
                    rcIcon = new Rectangle(0, 0, 0, 0);
                    rcText.X = ItemPadding.Left + rcItem.X;
                    rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
                }

                Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
                rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
                item.Size = rcItem.Size;
                item.Location.X = rcItem.Location.X;
                item.Location.Y = rcItem.Location.Y + mCurrentY;
                rcText.Height = rcItem.Height;
                rcText.Y = rcItem.Y;
                rcIcon.Y = rcItem.Y + ((rcItem.Height - rcIcon.Height) / 2);

                DrawItem(new ListItemPaintArgs(g, item, rcItem, rcText, rcIcon));
                rcItem.Offset(0, rcItem.Height + szSpace.Height);
            }

            iconTextFormat.Dispose();
            g.Clip.Dispose();
            g.Clip = originalClip;
        }