Example #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            shape     = new RoundedRectangleF(Width, Height, radius).Path;
            innerRect = new RoundedRectangleF(Width - 0.5f, Height - 0.5f, radius, 0.5f, 0.5f).Path;
            if (box.Height >= Height - 5)
            {
                Height = box.Height + 5;
            }
            inty         = (Height - box.Font.Height) / 2;
            act.Location = new Point(5, Height / 4);

            box.Location = new Point(intx, inty - 1);
            box.Width    = Width - (intx + 40);

            //clr.Location = new Point(intx + box.Width + 5, Height / 4);
            clr.Location = new Point(Width - 30, Height / 4);

            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            Bitmap   bmp = new Bitmap(Width, Height);
            Graphics grp = Graphics.FromImage(bmp);

            e.Graphics.DrawPath(Pens.Gray, shape);
            using (SolidBrush brush = new SolidBrush(background)) e.Graphics.FillPath(brush, innerRect);
            Transparenter.MakeTransparent(this, e.Graphics);
            base.OnPaint(e);
        }
Example #2
0
 protected override void OnResize(EventArgs e)
 {
     Width    = (Height - 2) * 2;
     diameter = Width / 2;
     artis    = 4 * diameter / 30;
     rect     = new RoundedRectangleF(2 * diameter, diameter + 2, diameter / 2, 1, 1);
     circle   = new RectangleF(!isOn ? 1 : Width - diameter - 1, 1, diameter, diameter);
     base.OnResize(e);
 }
Example #3
0
        public AsTextbox()
        {
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);

            act.Parent = this;
            box.Parent = this;
            clr.Parent = this;
            Controls.Add(act);
            Controls.Add(box);
            Controls.Add(clr);

            box.BorderStyle = BorderStyle.None;
            box.TextAlign   = HorizontalAlignment.Left;
            box.Font        = Font;

            this.BackColor = Color.Black;
            this.ForeColor = Color.White;
            background     = Color.Black;
            Text           = null;
            Font           = new Font("Trebuchet MS", 18);
            Size           = new Size(220, 40);

            DoubleBuffered = true;
            IsSearch       = false;
            ShowIcon       = true;

            box.BackColor = Color.Black;
            box.ForeColor = Color.White;
            roundedRect   = new RoundedRectangleF(Width, Height, irad);

            act.Size      = new Size(22, 22);
            act.BackColor = Color.Transparent;
            act.SizeMode  = System.Windows.Forms.PictureBoxSizeMode.StretchImage;

            clr.Text      = "X";
            clr.Radius    = 12;
            clr.Font      = new Font("Arial Rounded MT", 10, FontStyle.Bold);
            clr.Visible   = false;
            clr.Size      = new Size(24, 24);
            clr.Active1   = Color.White;
            clr.Active2   = Color.Gray;
            clr.Inactive1 = Color.White;
            clr.Inactive2 = Color.LightGray;

            box.TextChanged      += box_TextChanged;
            box.MouseDoubleClick += box_MouseDoubleClick;
            clr.Click            += clr_onClick;

            box.GotFocus  += box_GotFocus;
            box.LostFocus += box_LostFocus;
        }
Example #4
0
        public AsSwitch()
        {
            Cursor         = Cursors.Hand;
            DoubleBuffered = true;

            artis       = 4; //increment for sliding animation
            diameter    = 30;
            textEnabled = true;
            rect        = new RoundedRectangleF(2 * diameter, diameter + 2, diameter / 2, 1, 1);
            circle      = new RectangleF(1, 1, diameter, diameter);
            isOn        = true;
            borderColor = Color.Black;

            paintTicker.Tick    += paintTicker_Tick;
            paintTicker.Interval = 1;
        }
Example #5
0
        public AsButton()
        {
            Width       = 120;
            Height      = 30;
            stroke      = false;
            strokeColor = Color.Gray;
            inactive1   = Color.FromArgb(44, 188, 210);
            inactive2   = Color.FromArgb(33, 167, 188);
            active1     = Color.FromArgb(64, 168, 183);
            active2     = Color.FromArgb(36, 164, 183);

            radius      = 10;
            roundedRect = new RoundedRectangleF(Width, Height, radius);

            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer |
                     ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor |
                     ControlStyles.UserPaint, true);
            BackColor    = Color.Transparent;
            ForeColor    = Color.Black;
            Font         = new System.Drawing.Font("Trebuchet MS", 12, FontStyle.Bold);
            state        = MouseState.Leave;
            transparency = false;
        }
Example #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            #region Transparency
            if (transparency)
            {
                Transparenter.MakeTransparent(this, e.Graphics);
            }
            #endregion

            #region Drawing
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            roundedRect = new RoundedRectangleF(Width, Height, radius);
            e.Graphics.FillRectangle(Brushes.Transparent, this.ClientRectangle);

            int R1 = (active1.R + inactive1.R) / 2;
            int G1 = (active1.G + inactive1.G) / 2;
            int B1 = (active1.B + inactive1.B) / 2;

            int R2 = (active2.R + inactive2.R) / 2;
            int G2 = (active2.G + inactive2.G) / 2;
            int B2 = (active2.B + inactive2.B) / 2;

            Rectangle rect = new Rectangle(0, 0, Width, Height);

            if (this.Enabled)
            {
                if (state == MouseState.Leave)
                {
                    using (LinearGradientBrush inactiveGB = new LinearGradientBrush(rect, inactive1, inactive2, 90f))
                        e.Graphics.FillPath(inactiveGB, roundedRect.Path);
                }
                else if (state == MouseState.Enter)
                {
                    using (LinearGradientBrush activeGB = new LinearGradientBrush(rect, active1, active2, 90f))
                        e.Graphics.FillPath(activeGB, roundedRect.Path);
                }
                else if (state == MouseState.Down)
                {
                    using (LinearGradientBrush downGB = new LinearGradientBrush(rect, Color.FromArgb(R1, G1, B1), Color.FromArgb(R2, G2, B2), 90f))
                        e.Graphics.FillPath(downGB, roundedRect.Path);
                }
                if (stroke)
                {
                    using (Pen pen = new Pen(strokeColor, 1))
                        using (GraphicsPath path = new RoundedRectangleF(Width - (radius > 0 ? 0 : 1), Height - (radius > 0 ? 0 : 1), radius).Path)
                            e.Graphics.DrawPath(pen, path);
                }
            }
            else
            {
                Color linear1 = Color.FromArgb(190, 190, 190);
                Color linear2 = Color.FromArgb(210, 210, 210);
                using (LinearGradientBrush inactiveGB = new LinearGradientBrush(rect, linear1, linear2, 90f))
                {
                    e.Graphics.FillPath(inactiveGB, roundedRect.Path);
                    e.Graphics.DrawPath(new Pen(inactiveGB), roundedRect.Path);
                }
            }


            #endregion

            #region Text Drawing
            using (StringFormat sf = new StringFormat()
            {
                LineAlignment = StringAlignment.Center,
                Alignment = StringAlignment.Center
            })
                using (Brush brush = new SolidBrush(ForeColor))
                    e.Graphics.DrawString(Text, Font, brush, this.ClientRectangle, sf);
            #endregion
            base.OnPaint(e);
        }