Esempio n. 1
0
 protected override void OnPaint(PaintEventArgs e)
 {
     Transparenter.MakeTransparent(this, e.Graphics);
     #region Drawing
     e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     int    length    = Math.Min(Width, Height);
     PointF center    = new PointF(length / 2, length / 2);
     int    bigRadius = length / 2 - radius;
     float  unitAngle = 360 / n;
     if (spin)
     {
         circleIndex++;
         circleIndex = circleIndex >= n ? circleIndex % n : circleIndex;
     }
     for (int i = 0; i < n; i++)
     {
         float  c1X  = center.X + (float)(bigRadius * Math.Cos(unitAngle * i * Math.PI / 180));
         float  c1Y  = center.Y + (float)(bigRadius * Math.Sin(unitAngle * i * Math.PI / 180));
         PointF loc1 = new PointF(c1X - radius, c1Y - radius);
         if (i == circleIndex)
         {
             using (SolidBrush brush = new SolidBrush(index))
                 e.Graphics.FillEllipse(brush, loc1.X, loc1.Y, 2 * radius, 2 * radius);
         }
         else
         {
             using (SolidBrush brush = new SolidBrush(other))
                 e.Graphics.FillEllipse(brush, loc1.X, loc1.Y, 2 * radius, 2 * radius);
         }
     }
     #endregion
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (fullTransparency)
            {
                Transparenter.MakeTransparent(this, e.Graphics);
            }
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            int    length    = Math.Min(Width, Height);
            PointF center    = new PointF(length / 2, length / 2);
            float  bigRadius = length / 2 - radius - (n - 1) * increment;
            float  unitAngle = 360 / n;

            next++;
            next = next >= n ? 0 : next;
            int a = 0;

            for (int i = next; i < next + n; i++)
            {
                int    factor  = i % n;
                float  c1X     = center.X + (float)(bigRadius * Math.Cos(unitAngle * factor * Math.PI / 180));
                float  c1Y     = center.Y + (float)(bigRadius * Math.Sin(unitAngle * factor * Math.PI / 180));
                float  currRad = radius + a * increment;
                PointF c1      = new PointF(c1X - currRad, c1Y - currRad);
                e.Graphics.FillEllipse(Brushes.Black, c1.X, c1.Y, 2 * currRad, 2 * currRad);
                using (Pen pen = new Pen(Color.White, 2))
                    e.Graphics.DrawEllipse(pen, c1.X, c1.Y, 2 * currRad, 2 * currRad);
                a++;
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }