/// <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));
                }
            }
        }
Example #2
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));
            }
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            HoverBrush          = new SolidBrush(Color.FromArgb(100, SkinManager.ColorScheme.PrimaryColor));

            g.Clear(SkinManager.GetCardsColor());

            DrawHelper.drawShadow(g, ShadowPath, 8, SkinManager.GetCardsColor());

            g.FillRectangle(SkinManager.ColorScheme.DarkPrimaryBrush, TopDayRect);
            g.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, TopDateRect);

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;


            g.DrawString(CurrentDate.ToString("dddd"), TopDayFont, SkinManager.ACTION_BAR_TEXT_BRUSH(), TopDayRect, new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            });
            g.DrawString(CurrentDate.ToString("MMMM"), MonthFont, SkinManager.ACTION_BAR_TEXT_BRUSH(), MonthRect, new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Far
            });
            g.DrawString(CurrentDate.ToString("dd"), DayFont, SkinManager.ACTION_BAR_TEXT_BRUSH(), DayRect, new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            });
            g.DrawString(CurrentDate.ToString("yyyy"), YeahrFont, new SolidBrush(Color.FromArgb(80, SkinManager.ACTION_BAR_TEXT())), YearRect, new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            });

            g.DrawString(CurrentDate.ToString("MMMM"), SkinManager.ROBOTO_REGULAR_11, SkinManager.GetPrimaryTextBrush(), CurrentCal_Header, new StringFormat {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            });

            if (HoverX >= 0)
            {
                g.FillEllipse(HoverBrush, DateRectangles[HoverX][HoverY].Rect);
            }

            g.FillEllipse(SkinManager.ColorScheme.PrimaryBrush, DateRectangles[SelectedX][SelectedY].Rect);
            if (recentHovered)
            {
                g.FillEllipse(HoverBrush, PreviousCal);
            }

            if (nextHovered)
            {
                g.FillEllipse(HoverBrush, NextCal);
            }

            using (var ButtonPen = new Pen(SkinManager.GetPrimaryTextBrush(), 2))
            {
                g.DrawLine(ButtonPen,
                           (int)(PreviousCal.X + PreviousCal.Width * 0.6),
                           (int)(PreviousCal.Y + PreviousCal.Height * 0.4),
                           (int)(PreviousCal.X + PreviousCal.Width * 0.4),
                           (int)(PreviousCal.Y + PreviousCal.Height * 0.5));

                g.DrawLine(ButtonPen,
                           (int)(PreviousCal.X + PreviousCal.Width * 0.6),
                           (int)(PreviousCal.Y + PreviousCal.Height * 0.6),
                           (int)(PreviousCal.X + PreviousCal.Width * 0.4),
                           (int)(PreviousCal.Y + PreviousCal.Height * 0.5));

                g.DrawLine(ButtonPen,
                           (int)(NextCal.X + NextCal.Width * 0.4),
                           (int)(NextCal.Y + NextCal.Height * 0.4),
                           (int)(NextCal.X + NextCal.Width * 0.6),
                           (int)(NextCal.Y + NextCal.Height * 0.5));

                g.DrawLine(ButtonPen,
                           (int)(NextCal.X + NextCal.Width * 0.4),
                           (int)(NextCal.Y + NextCal.Height * 0.6),
                           (int)(NextCal.X + NextCal.Width * 0.6),
                           (int)(NextCal.Y + NextCal.Height * 0.5));
            }

            DateTime FirstDay = FirstDayOfMonth(CurrentDate);

            for (int i = 0; i < 7; i++)
            {
                string strName;
                int    DayOfWeek = (int)DateTime.Now.DayOfWeek - 1;
                if (DayOfWeek < 0)
                {
                    DayOfWeek = 6;
                }

                strName = DateTime.Now.AddDays(-DayOfWeek + i).ToString("ddd");
                g.DrawString(strName, SkinManager.ROBOTO_MEDIUM_11, SkinManager.GetSecondaryTextBrush(), DateRectangles[0][i].Rect, new StringFormat {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                });
            }
            for (DateTime date = FirstDay; date <= LastDayOfMonth(CurrentDate); date = date.AddDays(1))
            {
                int WeekOfMonth = GetWeekNumber(date, FirstDay);
                int DayOfWeek   = (int)date.DayOfWeek - 1;
                if (DayOfWeek < 0)
                {
                    DayOfWeek = 6;
                }

                g.DrawString(date.Day.ToString(), SkinManager.ROBOTO_MEDIUM_11, SkinManager.GetPrimaryTextBrush(), DateRectangles[WeekOfMonth][DayOfWeek].Rect, new StringFormat {
                    Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                });
            }
        }