Exemple #1
0
        private void TM_Paint(object sender, PaintEventArgs e)
        {
            Graphics  gr   = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            Pen       pen  = new Pen(Color.Gray);

            pen.Width = 2;
            int intend      = 6;
            int intendCurve = 6;

            Ul.DrawCurvedRectangle(rect, gr, pen, intend, intendCurve);
            pen.Dispose();
        }
Exemple #2
0
        // Draws the button on the specified Grapics
        // in the specified state.
        //
        // Parameters:
        //  gr - The Graphics object on which to draw the button.
        //  pressed - If true, the button is drawn in the depressed state.
        void DrawButton(Graphics gr, bool pressed)
        {
            // Get a Graphics object from the background image.
            Graphics gr2 = Graphics.FromImage(DoubleBufferImage);

            // Fill solid up until where the gradient fill starts.
            if (this.StartOffset > 0)
            {
                if (this.FillDirection ==
                    Gl.FillDirection.LeftToRight)
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? EndColor : StartColor),
                        0, 0, this.StartOffset, Height);
                }
                else
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? EndColor : StartColor),
                        0, 0, Width, this.StartOffset);
                }
            }

            // Draw the gradient fill.
            Rectangle rc = this.ClientRectangle;

            if (this.FillDirection == Gl.FillDirection.LeftToRight)
            {
                rc.X     = this.StartOffset;
                rc.Width = rc.Width - this.StartOffset - this.EndOffset;
            }
            else
            {
                rc.Y      = this.StartOffset;
                rc.Height = rc.Height - this.StartOffset - this.EndOffset;
            }
            Gl.Fill(
                gr2,
                rc,
                pressed ? this.EndColor : this.StartColor,
                pressed ? this.StartColor : this.EndColor,
                this.FillDirection);

            // Fill solid from the end of the gradient fill
            // to the edge of the button.
            if (this.EndOffset > 0)
            {
                if (this.FillDirection ==
                    Gl.FillDirection.LeftToRight)
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? StartColor : EndColor),
                        rc.X + rc.Width, 0, this.EndOffset, Height);
                }
                else
                {
                    gr2.FillRectangle(
                        new SolidBrush(pressed ? StartColor : EndColor),
                        0, rc.Y + rc.Height, Width, this.EndOffset);
                }
            }

            // Draw the text.
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center; // alin by bottom StringAlignment.Far;
            Rectangle textRect = this.ClientRectangle;

            //            textRect.Height -= 10;
            gr2.DrawString(this.Text, this.Font,
                           new SolidBrush(this.ForeColor),
                           textRect, sf);

            // Draw the border.
            // Need to shrink the width and height by 1 otherwise
            // there will be no border on the right or bottom.
            rc = this.ClientRectangle;
            rc.Width--;
            rc.Height--;
            Pen pen = new Pen(SystemColors.WindowFrame);

            //    gr2.DrawRectangle(pen, rc);
            Pen penForCurve = new Pen(Color.Gray); // White

            penForCurve.Width = 1;
            int intend      = 3;
            int intendCurve = 2;

            //Rectangle rectForCurve = rc;
            ////rectForCurve.Width += intend*2;
            ////rectForCurve.Height += intend*2;
            //rectForCurve.X -= intend*2;
            //rectForCurve.Y -= intend*2;
            Ul.DrawCurvedRectangle(rc, gr2, penForCurve, intend, intendCurve);
            penForCurve.Dispose();

            // Draw from the background image onto the screen.
            gr.DrawImage(DoubleBufferImage, 0, 0);
            gr2.Dispose();
        }