Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics   G          = e.Graphics;
            Rectangle  ItemBounds = default(Rectangle);
            SolidBrush TextBrush  = new SolidBrush(Color.Empty);
            int        SOFF       = 0;

            G.Clear(Color.FromArgb(236, 237, 239));

            for (int TabItemIndex = 0; TabItemIndex <= this.TabCount - 1; TabItemIndex++)
            {
                ItemBounds = this.GetTabRect(TabItemIndex);

                if (!(TabItemIndex == SelectedIndex))
                {
                    SOFF = 2;

                    G.FillPath(DesignFunctions.ToBrush(10, Color.Black), DesignFunctions.RoundRect(new Rectangle(new Point(ItemBounds.X, ItemBounds.Y + SOFF), new Size(ItemBounds.Width, ItemBounds.Height)), 2));
                    G.DrawPath(DesignFunctions.ToPen(90, Color.Black), DesignFunctions.RoundRect(new Rectangle(new Point(ItemBounds.X, ItemBounds.Y + SOFF), new Size(ItemBounds.Width, ItemBounds.Height)), 2));

                    StringFormat sf = new StringFormat();
                    sf.LineAlignment = StringAlignment.Center;
                    sf.Alignment     = StringAlignment.Center;
                    TextBrush.Color  = Color.FromArgb(80, 80, 80);
                    try
                    {
                        G.DrawString(TabPages[TabItemIndex].Text, new Font(Font.Name, Font.Size - 1), TextBrush, new Rectangle(GetTabRect(TabItemIndex).Location, GetTabRect(TabItemIndex).Size), sf);
                        TabPages[TabItemIndex].BackColor = Color.FromArgb(236, 237, 239);
                    }
                    catch
                    {
                    }
                }
            }

            G.FillPath(DesignFunctions.ToBrush(236, 237, 239), DesignFunctions.RoundRect(0, ItemSize.Height - 1, Width - 1, Height - ItemSize.Height - 1, 2));
            G.DrawPath(DesignFunctions.ToPen(150, 151, 153), DesignFunctions.RoundRect(0, ItemSize.Height - 1, Width - 1, Height - ItemSize.Height - 1, 2));

            for (int TabItemIndex = 0; TabItemIndex <= this.TabCount - 1; TabItemIndex++)
            {
                ItemBounds = this.GetTabRect(TabItemIndex);


                if (TabItemIndex == SelectedIndex)
                {
                    G.FillPath(DesignFunctions.ToBrush(236, 237, 239), DesignFunctions.RoundRect(new Rectangle(new Point(ItemBounds.X - 2, ItemBounds.Y), new Size(ItemBounds.Width + 3, ItemBounds.Height - 2)), 2));
                    G.DrawPath(DesignFunctions.ToPen(150, 151, 153), DesignFunctions.RoundRect(new Rectangle(new Point(ItemBounds.X - 2, ItemBounds.Y), new Size(ItemBounds.Width + 2, ItemBounds.Height - 2)), 2));

                    G.FillRectangle(DesignFunctions.ToBrush(236, 237, 239), new Rectangle(new Point(ItemBounds.X - 1, ItemBounds.Y + 1), new Size(ItemBounds.Width + 1, ItemBounds.Height)));
                    SOFF = 0;

                    StringFormat sf = new StringFormat();
                    sf.LineAlignment = StringAlignment.Center;
                    sf.Alignment     = StringAlignment.Center;
                    TextBrush.Color  = Color.FromArgb(80, 80, 80);
                    try
                    {
                        G.DrawString(TabPages[TabItemIndex].Text, Font, TextBrush, new Rectangle(new Point(Convert.ToInt32(GetTabRect(TabItemIndex).Location), SOFF), GetTabRect(TabItemIndex).Size), sf);
                        TabPages[TabItemIndex].BackColor = Color.FromArgb(236, 237, 239);
                    }
                    catch
                    {
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics G = e.Graphics;

            G.SmoothingMode = SmoothingMode.HighQuality;

            //Background
            G.FillPath(new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 4));

            G.DrawPath(DesignFunctions.ToPen(50, Color.White), DesignFunctions.RoundRect(0, 1, Width - 1, Height - 2, 4));
            G.DrawPath(DesignFunctions.ToPen(150, 100, 70), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 4));
            switch (Enabled)
            {
            case true:
                switch (State)
                {
                case MouseState.Over:
                    G.FillPath(new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(50, Color.White), Color.Transparent), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 4));
                    break;

                case MouseState.Down:
                    G.FillPath(new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(50, Color.Black), Color.Transparent), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 4));
                    break;
                }

                G.DrawString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular), DesignFunctions.ToBrush(100, Color.White), new Point(Convert.ToInt32((Width / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), Convert.ToInt32((Height / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2)) + 1));
                G.DrawString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular), DesignFunctions.ToBrush(200, Color.Black), new Point(Convert.ToInt32((Width / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), Convert.ToInt32((Height / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2))));
                break;

            case false:
                G.DrawString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular), Brushes.White, new Point(Convert.ToInt32((Width / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)) + 1, Convert.ToInt32((Height / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2)) + 1));
                G.DrawString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular), Brushes.Gray, new Point(Convert.ToInt32((Width / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Width / 2)), Convert.ToInt32((Height / 2) - (G.MeasureString(Text, new Font(Font.FontFamily, Font.Size, FontStyle.Regular)).Height / 2))));
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics G = e.Graphics;

            Bar = new Rectangle(10, 10, Width - 21, Height - 21);
            G.Clear(Parent.FindForm().BackColor);
            G.SmoothingMode = SmoothingMode.AntiAlias;

            DesignFunctions.PillStyle styles = new DesignFunctions.PillStyle();
            styles.Left  = true;
            styles.Right = true;
            //Background
            LinearGradientBrush BackLinear = new LinearGradientBrush(new Point(0, Convert.ToInt32((Height / 2) - (Track.Height / 2))), new Point(0, Convert.ToInt32((Height / 2) + (Track.Height / 2))), Color.FromArgb(50, Color.Black), Color.Transparent);

            //G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3))

            G.FillPath(BackLinear, (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle
            {
                Left  = true,
                Right = true
            }));

            G.FillPath(BackLinear, (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle
            {
                Left  = true,
                Right = true
            }));
            G.DrawPath(DesignFunctions.ToPen(50, Color.Black), (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle
            {
                Left  = true,
                Right = true
            }));

            BackLinear.Dispose();

            //Fill
            if (ToggleLocation > 0)
            {
                G.FillPath(new LinearGradientBrush(new Point(0, Convert.ToInt32((Height / 2) - Track.Height / 2)), new Point(1, Convert.ToInt32((Height / 2) + Track.Height / 2)), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), (GraphicsPath)DesignFunctions.Pill(1, Convert.ToInt32((Height / 2) - Track.Height / 2), Convert.ToInt32(Bar.Width * (ToggleLocation / 100)) + Convert.ToInt32(Track.Width / 2), Track.Height - 3, new DesignFunctions.PillStyle
                {
                    Left  = true,
                    Right = true
                }));
                G.DrawPath(DesignFunctions.ToPen(100, Color.White), (GraphicsPath)DesignFunctions.Pill(1, Convert.ToInt32((Height / 2) - Track.Height / 2 + 1), Convert.ToInt32(Bar.Width * (ToggleLocation / 100)) + Convert.ToInt32(Track.Width / 2), Track.Height - 5, new DesignFunctions.PillStyle
                {
                    Left  = true,
                    Right = true
                }));
            }

            if (Toggled)
            {
                G.DrawString("ON", new Font("Arial", 6, FontStyle.Bold), DesignFunctions.ToBrush(150, Color.Black), new Rectangle(0, -1, Width - Track.Width + Track.Width / 3, Height), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }
            else
            {
                G.DrawString("OFF", new Font("Arial", 6, FontStyle.Bold), DesignFunctions.ToBrush(150, Color.Black), new Rectangle(Track.Width - Track.Width / 3, -1, Width - Track.Width + Track.Width / 3, Height), new StringFormat
                {
                    Alignment     = StringAlignment.Center,
                    LineAlignment = StringAlignment.Center
                });
            }

            //Button
            G.FillEllipse(Brushes.White, Bar.X + Convert.ToInt32(Bar.Width * (ToggleLocation / 100)) - Convert.ToInt32(Track.Width / 2), Bar.Y + Convert.ToInt32((Bar.Height / 2)) - Convert.ToInt32(Track.Height / 2), Track.Width, Track.Height);
            G.DrawEllipse(DesignFunctions.ToPen(50, Color.Black), Bar.X + Convert.ToInt32(Bar.Width * (ToggleLocation / 100) - Convert.ToInt32(Track.Width / 2)), Bar.Y + Convert.ToInt32((Bar.Height / 2)) - Convert.ToInt32(Track.Height / 2), Track.Width, Track.Height);
        }