/// <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)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            g.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
            g.SmoothingMode      = SmoothingMode.AntiAlias;


            if (Avatar == null)
            {
                g.FillPath(SkinManager.ColorScheme.PrimaryBrush, DrawHelper.CreateCircle(1, 1, Height / 2 - 1));
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                g.DrawString(AvatarLetter, AvatarFont, SkinManager.ACTION_BAR_TEXT_BRUSH(), TextRect, new StringFormat()
                {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                });
            }
            else
            {
                using (Brush brush = new TextureBrush(_AvatarScaled))
                {
                    g.FillEllipse(brush, new Rectangle(1, 1, Width - 1, Height - 1));
                }
            }
        }
 /// <summary>
 /// Raises the <see cref="E:System.Windows.Forms.Control.Resize" /> event.
 /// </summary>
 /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
 protected override void OnResize(EventArgs e)
 {
     if (Width > Height)
     {
         Height = Width;
     }
     else
     {
         Width = Height;
     }
     TextRect = new Rectangle(Convert.ToInt32(Width * 0.05), Convert.ToInt32(Height * 0.05), Convert.ToInt32(Width * 0.9), Convert.ToInt32(Height * 0.9));
     Region   = new Region(DrawHelper.CreateCircle(0, 0, Width / 2));
     CalculateAvatarFont();
     if (ShadowBorder != null)
     {
         ShadowBorder.Dispose();
     }
     ShadowBorder = new GraphicsPath();
     ShadowBorder = DrawHelper.CreateCircle(Location.X,
                                            Location.Y,
                                            ClientRectangle.Width / 2 - 1);
     if (_AvatarScaled != null)
     {
         _AvatarScaled.Dispose();
         _AvatarScaled = DrawHelper.ResizeImage(_Avater, Width, Height);
     }
 }
        public void OnPaint(PaintEventArgs e)
        {
            Graphics     g       = e.Graphics;
            GraphicsPath objPath = new GraphicsPath();

            g.FillRectangle(PrimaryDark, TopDark);
            g.FillRectangle(Primary, TopDefault);
            DrawHelper.drawShadow(g, DrawHelper.CreateCircle(Fab.X - 1, Fab.Y - 1, 20), 2, Color.Black);
            g.FillEllipse(Accent, Fab);
            g.DrawString(
                "Sample Text", SkinManager.FONT_CONTROL_SMALL, Text, TopDefault.Location);
        }
Beispiel #4
0
        private void Redraw(object sender, System.EventArgs e)
        {
            ShadowBorder = new GraphicsPath();
            ShadowBorder = DrawHelper.CreateCircle(Location.X + 5,
                                                   Location.Y + 5,
                                                   ClientRectangle.Width / 2 - 6);

            if (Width != Height)
            {
                Width  = Math.Min(Width, Height);
                Height = Math.Min(Width, Height);
            }
            Invalidate();
        }
        /// <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;
            GraphicsPath objPath = new GraphicsPath();

            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.Clear(SkinManager.GetApplicationBackgroundColor());
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.FillRectangle(PrimaryDark, TopDark);
            g.FillRectangle(Primary, TopDefault);
            DrawHelper.drawShadow(g, DrawHelper.CreateCircle(Fab.X - 1, Fab.Y - 1, 20), 2, Color.Black);
            g.FillEllipse(Accent, Fab);

            g.DrawString(
                PreviewPreset.Name,
                SkinManager.ROBOTO_REGULAR_11,
                Text, TopDefault);
            g.ResetClip();
        }
        /// <summary>
        /// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)" /> event.
        /// </summary>
        /// <param name="pevent">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs pevent)
        {
            int iCropping = ClientRectangle.Width / 3;
            var g         = pevent.Graphics;

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = TextRenderingHint.AntiAlias;


            Region = new Region(DrawHelper.CreateCircle(ClientRectangle.X,
                                                        ClientRectangle.Y,
                                                        ClientRectangle.Width / 2));


            g.Clear(SkinManager.ColorScheme.AccentColor);


            if (_Icon != null)
            {
                g.DrawImage(_Icon, ClientRectangle.X + iCropping / 2, ClientRectangle.X + iCropping / 2, ClientRectangle.Width - iCropping, ClientRectangle.Width - iCropping);
            }

            Color c = SkinManager.GetFlatButtonHoverBackgroundColor();

            using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())))
                g.FillEllipse(b, ClientRectangle);

            if (animationManager.IsAnimating())
            {
                for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = animationManager.GetProgress(i);
                    var animationSource = animationManager.GetSource(i);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White));
                    var rippleSize      = (int)(animationValue * Width * 2);
                    g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                }
            }
        }
Beispiel #7
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            int ShadowDepth = 5;
            int iCropping   = ClientRectangle.Width / 3;
            var g           = pevent.Graphics;

            g.SmoothingMode             = SmoothingMode.AntiAlias;
            g.TextRenderingHint         = TextRenderingHint.AntiAlias;
            ProgressBackgroundPen.Color = SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? farbeGetauscht ? SkinManager.ColorScheme.PrimaryColor : SkinManager.ColorScheme.LightPrimaryColor : farbeGetauscht ? SkinManager.ColorScheme.PrimaryColor : SkinManager.ColorScheme.DarkPrimaryColor;
            ProgressPen.Color           = SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? farbeGetauscht ? SkinManager.ColorScheme.LightPrimaryColor : SkinManager.ColorScheme.PrimaryColor : farbeGetauscht ? SkinManager.ColorScheme.DarkPrimaryColor : SkinManager.ColorScheme.PrimaryColor;


            g.Clear(Parent.BackColor);

            using (var backgroundPath = DrawHelper.CreateCircle(ClientRectangle.X + ShadowDepth,
                                                                ClientRectangle.Y + ShadowDepth,
                                                                ClientRectangle.Width / 2 - ShadowDepth))
            {
                g.FillPath(_ProgressFinished ? SkinManager.ColorScheme.DarkPrimaryBrush : SkinManager.ColorScheme.AccentBrush, backgroundPath);
            }

            if (_Icon != null && !_ProgressFinished)
            {
                g.DrawImage(_Icon, ClientRectangle.X + iCropping / 2, ClientRectangle.X + iCropping / 2, ClientRectangle.Width - iCropping, ClientRectangle.Width - iCropping);
            }

            Color c = SkinManager.GetFlatButtonHoverBackgroundColor();

            using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha())))
                g.FillEllipse(b, ClientRectangle);

            if (animationManager.IsAnimating())
            {
                for (int i = 0; i < animationManager.GetAnimationCount(); i++)
                {
                    var animationValue  = animationManager.GetProgress(i);
                    var animationSource = animationManager.GetSource(i);
                    var rippleBrush     = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White));
                    var rippleSize      = (int)(animationValue * Width * 2);
                    g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize));
                }
            }

            if (showProgress)
            {
                if (_ProgressFinished)
                {
                    g.DrawLine(new Pen(SkinManager.ACTION_BAR_TEXT_BRUSH(), 2), new Point(Convert.ToInt32(Width / 2.4), Height / 2), new Point(Width / 2, Convert.ToInt32(Height / 1.8)));
                    g.DrawLine(new Pen(SkinManager.ACTION_BAR_TEXT_BRUSH(), 2), new Point(Convert.ToInt32(Width / 1.6), Convert.ToInt32(Height / 2.8)), new Point(Width / 2, Convert.ToInt32(Height / 1.8)));
                    Region = new Region(DrawHelper.CreateCircle(ClientRectangle.X + ShadowDepth,
                                                                ClientRectangle.Y + ShadowDepth,
                                                                ClientRectangle.Width / 2 - ShadowDepth));
                }
                else
                {
                    g.DrawArc(ProgressBackgroundPen, ShadowDepth - 1, ShadowDepth - 1, Width - (ShadowDepth * 2), Height - (ShadowDepth * 2), 0, 360);
                    g.DrawArc(ProgressPen, ShadowDepth - 1, ShadowDepth - 1, Width - (ShadowDepth * 2), Height - (ShadowDepth * 2), CurrentProgressPosition.X, CurrentProgressPosition.Y);
                    Region = new Region(DrawHelper.CreateCircle(ClientRectangle.X + 1,
                                                                ClientRectangle.Y + 1,
                                                                ClientRectangle.Width / 2 - 1));
                }

                if (Image != null)
                {
                    // Create parallelogram for drawing image.
                    double  radius   = ClientRectangle.Width / 2 - ShadowDepth;
                    Point   ulCorner = new Point(ClientRectangle.X + ShadowDepth + (int)(radius / 3), ClientRectangle.Y + ShadowDepth + (int)(radius / 3));
                    Point   urCorner = new Point(ClientRectangle.X + ClientRectangle.Width - ShadowDepth - (int)(radius / 3), ClientRectangle.Y + ShadowDepth + (int)(radius / 3));
                    Point   llCorner = new Point(ClientRectangle.X + ShadowDepth + (int)(radius / 3), ClientRectangle.Y + ClientRectangle.Height - ShadowDepth - (int)(radius / 3));
                    Point[] destPara = { ulCorner, urCorner, llCorner };

                    // Draw image to screen.
                    g.DrawImage(Image, destPara);
                }
            }
            else
            {
                Region = new Region(DrawHelper.CreateCircle(ClientRectangle.X + ShadowDepth,
                                                            ClientRectangle.Y + ShadowDepth,
                                                            ClientRectangle.Width / 2 - ShadowDepth));
            }
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (!Visible && objAnimationManager.GetProgress() > 0)
            {
                Visible = true;
            }
            e.Graphics.FillRectangle(BackBrush, e.ClipRectangle);
            GraphicsPath Clip = new GraphicsPath();

            Clip.AddEllipse(CalculateCurrentRect());
            e.Graphics.SetClip(Clip);
            e.Graphics.Clear(MaterialSkinManager.Instance.GetApplicationBackgroundColor());
            e.Graphics.FillRectangle(new SolidBrush(((int)_Primary).ToColor()), PrimaryRect);
            e.Graphics.FillRectangle(new SolidBrush(((int)_PrimaryLight).ToColor()), LightPrimaryRect);
            e.Graphics.FillRectangle(new SolidBrush(((int)_PrimaryDark).ToColor()), DarkPrimaryRect);

            e.Graphics.FillRectangle(new SolidBrush(((int)_Accent).ToColor()), AccentRect);
            e.Graphics.FillRectangle(new SolidBrush(((int)_Text).ToColor()), TextShadeRect);

            GraphicsPath g;
            Color        FillColor = Color.FromArgb(80, Color.White);

            switch (Zustand)
            {
            case 0:
                g = new GraphicsPath();
                g.AddRectangle(new Rectangle(PrimaryRect.X - 2, PrimaryRect.Y - 2, PrimaryRect.Width, PrimaryRect.Height));
                DrawHelper.drawShadow(e.Graphics, g, 3, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(((int)_Primary).ToColor()), PrimaryRect);
                e.Graphics.FillRectangle(new SolidBrush(FillColor), PrimaryRect);
                break;

            case 1:
                g = new GraphicsPath();
                g.AddRectangle(new Rectangle(LightPrimaryRect.X - 2, LightPrimaryRect.Y - 2, LightPrimaryRect.Width, LightPrimaryRect.Height));
                DrawHelper.drawShadow(e.Graphics, g, 3, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(((int)_PrimaryLight).ToColor()), LightPrimaryRect);
                e.Graphics.FillRectangle(new SolidBrush(FillColor), LightPrimaryRect);
                break;

            case 2:
                g = new GraphicsPath();
                g.AddRectangle(new Rectangle(DarkPrimaryRect.X - 2, DarkPrimaryRect.Y - 2, DarkPrimaryRect.Width, DarkPrimaryRect.Height));
                g.AddRectangle(DarkPrimaryRect);
                DrawHelper.drawShadow(e.Graphics, g, 3, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(((int)_PrimaryDark).ToColor()), DarkPrimaryRect);
                e.Graphics.FillRectangle(new SolidBrush(FillColor), DarkPrimaryRect);
                break;

            case 3:
                g = new GraphicsPath();
                g.AddRectangle(new Rectangle(AccentRect.X - 2, AccentRect.Y - 2, AccentRect.Width, AccentRect.Height));
                g.AddRectangle(AccentRect);
                DrawHelper.drawShadow(e.Graphics, g, 3, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(((int)_Accent).ToColor()), AccentRect);
                e.Graphics.FillRectangle(new SolidBrush(FillColor), AccentRect);
                break;

            case 4:
                g = new GraphicsPath();
                g.AddRectangle(new Rectangle(TextShadeRect.X - 2, TextShadeRect.Y - 2, TextShadeRect.Width, TextShadeRect.Height));
                g.AddRectangle(TextShadeRect);
                DrawHelper.drawShadow(e.Graphics, g, 3, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(((int)_Text).ToColor()), TextShadeRect);
                e.Graphics.FillRectangle(new SolidBrush(FillColor), TextShadeRect);
                break;
            }

            foreach (ColorRect objRect in ColorRectangles[_ActiveKey])
            {
                e.Graphics.FillRectangle(new SolidBrush(objRect.Color), objRect.Rect);
            }

            if (HoveredIndex >= 0)
            {
                DrawHelper.drawShadow(e.Graphics, CurrentHoveredPath, 4, Color.Black);
                e.Graphics.FillRectangle(new SolidBrush(ColorRectangles[_ActiveKey][HoveredIndex].Color), ColorRectangles[_ActiveKey][HoveredIndex].Rect);
            }

            objPreview.OnPaint(e);
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            DrawHelper.drawShadow(e.Graphics, DrawHelper.CreateCircle(FabRect.X - 1, FabRect.Y - 1, 30), FabHovered ? 2 : 1, Color.Black);
            e.Graphics.FillEllipse(Brushes.HotPink, FabRect);
            Pen objLinePen = new Pen(Brushes.White, 3);

            e.Graphics.DrawLine(objLinePen, new Point(Convert.ToInt32(FabRect.Left + FabRect.Width * 0.2), Convert.ToInt32(FabRect.Top + FabRect.Height * 0.55)), new Point(Convert.ToInt32(FabRect.Left + FabRect.Width * 0.4), Convert.ToInt32(FabRect.Top + FabRect.Height * 0.80)));
            e.Graphics.DrawLine(objLinePen, new Point(Convert.ToInt32(FabRect.Left + FabRect.Width * 0.4), Convert.ToInt32(FabRect.Top + FabRect.Height * 0.80)), new Point(Convert.ToInt32(FabRect.Left + FabRect.Width * 0.8), Convert.ToInt32(FabRect.Top + FabRect.Height * 0.30)));

            e.Graphics.ResetClip();
        }