public MaterialRaisedButton() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); Primary = true; hoverAnimationManager = new AnimationManager { Increment = 0.07, AnimationType = AnimationType.Linear }; animationManager = new AnimationManager(false) { Increment = 0.03, AnimationType = AnimationType.EaseOut }; hoverAnimationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationFinished += AnimationManager_OnAnimationFinished; AutoSizeMode = AutoSizeMode.GrowAndShrink; AutoSize = false; Font = new Font(MaterialSkinManager.ROBOTO_REGULAR_11.FontFamily, _fSize); Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, _roundedCorner); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.Clear(Parent.BackColor); using (var backgroundPath = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, 1f)) g.FillPath(backgroundBrush != null ? backgroundBrush : (Primary ? SkinManager.ColorScheme.PrimaryBrush : SkinManager.GetRaisedButtonBackgroundBrush()), backgroundPath); if (showAnimations && 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)), selected ? Color.Black : selectedColor)); var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } g.DrawString(textAllCaps ? Text.ToUpper() : Text, SkinManager.ROBOTO_MEDIUM_10, customFontColor ? fontBrush : SkinManager.GetRaisedButtonTextBrush(Primary, false), img != null ? Padding.Left + img.Width + 10 : Padding.Left, (Height - Font.Height) / 2); if (img != null) { //g.DrawImage(Properties.Resources.circle_white, new Rectangle(new Point(Padding.Left, Padding.Top), new Size(Height, Height))); int y = (Height - img.Height) / 2; g.DrawIcon(img, 5, y); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.Clear(Parent.BackColor); StringColor = ColorTranslator.FromHtml(fontcolor); EnabledBGColor = ColorTranslator.FromHtml(Backcolor); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); Region region = new Region(BG); G.FillPath(new SolidBrush(Enabled? EnabledBGColor:DisabledBGColor), BG); G.DrawPath(new Pen(Enabled ? EnabledBGColor : DisabledBGColor), BG); G.SetClip(region, CombineMode.Replace); //The Ripple Effect G.FillEllipse(new SolidBrush(Color.FromArgb(25, Color.Black)), xx - (SizeAnimation / 2), yy - (SizeAnimation / 2), SizeAnimation, SizeAnimation); G.DrawString(Text, font.Roboto_Medium9, new SolidBrush(StringColor), R, SF); }
private void UpdateTabRects() { //If there isn't a base tab control, the rects shouldn't be calculated //or if there aren't tab pages in the base tab control, the list should just be empty if (_baseTabControl == null || _baseTabControl.TabCount == 0 || SkinManager == null || _drawerItemRects == null) { _drawerItemRects = new List <Rectangle>(); _drawerItemPaths = new List <GraphicsPath>(); return; } if (_drawerItemRects.Count != _baseTabControl.TabCount) { _drawerItemRects = new List <Rectangle>(_baseTabControl.TabCount); _drawerItemPaths = new List <GraphicsPath>(_baseTabControl.TabCount); for (var i = 0; i < _baseTabControl.TabCount; i++) { _drawerItemRects.Add(new Rectangle()); _drawerItemPaths.Add(new GraphicsPath()); } } //Calculate the bounds of each tab header specified in the base tab control for (int i = 0; i < _baseTabControl.TabPages.Count; i++) { _drawerItemRects[i] = (new Rectangle( (int)(SkinManager.FORM_PADDING * 0.75) - (ShowIconsWhenHidden ? Location.X : 0), (TAB_HEADER_PADDING * 2) * i + (int)(SkinManager.FORM_PADDING >> 1), (Width + (ShowIconsWhenHidden ? Location.X : 0)) - (int)(SkinManager.FORM_PADDING * 1.5) - 1, drawerItemHeight)); _drawerItemPaths[i] = DrawHelper.CreateRoundRect(new RectangleF(_drawerItemRects[i].X - 0.5f, _drawerItemRects[i].Y - 0.5f, _drawerItemRects[i].Width, _drawerItemRects[i].Height), 4); } }
/// <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); ClickTimer.Interval = ClickSpeed; var G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; //G.Clear(BackColor); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, borderRadius); Region region = new Region(BG); if (AllowTransparency) { MakeTransparent(this, G); } else { G.FillPath(new SolidBrush(enabledBGColor), BG); } G.DrawPath(new Pen(enabledBorderColor), BG); G.SetClip(region, CombineMode.Replace); //The Ripple Effect G.FillEllipse(new SolidBrush(Color.FromArgb(rippleOpacity, rippleColor)), xx - (SizeAnimation / 2), yy - (SizeAnimation / 2), SizeAnimation, SizeAnimation); G.DrawString(Text, font.Roboto_Medium10, new SolidBrush(ForeColor), R, SF); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); var g = pevent.Graphics; g.TextRenderingHint = TextRenderingHint.AntiAlias; StringColor = ColorTranslator.FromHtml(fontcolor); ThumbnailBGColor = ColorTranslator.FromHtml(thumbnailcolor); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); var ThumbnailBG = DrawHelper.CreateLeftRoundRect(1, 1, 50, 49, 1); g.FillPath(new SolidBrush(BgColor), BG); g.DrawPath(new Pen(BorderColor), BG); g.FillPath(new SolidBrush(ThumbnailBGColor), ThumbnailBG); g.DrawPath(new Pen(ThumbnailBGColor), ThumbnailBG); if (image != null) { g.DrawImage(image, 3, 3, 48, 47); } if (Enabled) { g.DrawString(Text, SkinManager.ROBOTO_MEDIUM_10, new SolidBrush(StringColor), new PointF(58.6f, 9f)); } else { g.DrawString("Wait...", SkinManager.ROBOTO_MEDIUM_10, new SolidBrush(StringColor), new PointF(58.6f, 9f)); } g.TextRenderingHint = TextRenderingHint.AntiAlias; g.DrawString(information, SkinManager.ROBOTO_MEDIUM_10, new SolidBrush(ColorTranslator.FromHtml("#999999")), new PointF(59.1f, 26f)); }
protected override void OnPaint(PaintEventArgs pevent) { Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.Clear(base.Parent.BackColor); using (GraphicsPath path = DrawHelper.CreateRoundRect((float)base.ClientRectangle.X, (float)base.ClientRectangle.Y, (float)(base.ClientRectangle.Width - 1), (float)(base.ClientRectangle.Height - 1), 1f)) { graphics.FillPath(this.Primary ? this.SkinManager.ColorScheme.PrimaryBrush : this.SkinManager.GetRaisedButtonBackgroundBrush(), path); } if (this.animationManager.IsAnimating()) { for (int i = 0; i < this.animationManager.GetAnimationCount(); i++) { double progress = this.animationManager.GetProgress(i); Point source = this.animationManager.GetSource(i); SolidBrush brush = new SolidBrush(Color.FromArgb((int)(51.0 - (progress * 50.0)), Color.White)); int width = (int)((progress * base.Width) * 2.0); graphics.FillEllipse(brush, new Rectangle(source.X - (width / 2), source.Y - (width / 2), width, width)); } } StringFormat format = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; graphics.DrawString(this.Text.ToUpper(), this.SkinManager.ROBOTO_MEDIUM_10, this.SkinManager.GetRaisedButtonTextBrush(this.Primary), base.ClientRectangle, format); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.Clear(Parent.BackColor); using (var backgroundPath = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, 1f)) { g.FillPath(Primary ? SkinManager.PrimaryColorBrush : SkinManager.GetRaisedButtonBackgroundBrush(), backgroundPath); } 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)); } } g.DrawString(Text.ToUpper(), SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetRaisedButtonTextBrush(Primary), ClientRectangle, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
protected override void OnResize(EventArgs e) { base.OnResize(e); Height = 52; Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); }
public MaterialFlatButton() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); Primary = false; animationManager = new AnimationManager(false) { Increment = 0.03, AnimationType = AnimationType.EaseOut }; hoverAnimationManager = new AnimationManager { Increment = 0.07, AnimationType = AnimationType.Linear }; hoverAnimationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationProgress += sender => Invalidate(); animationManager.OnAnimationFinished += AnimationManager_OnAnimationFinished; AutoSizeMode = AutoSizeMode.GrowAndShrink; AutoSize = false; Margin = new Padding(4, 6, 4, 6); Padding = new Padding(0); Font = new Font(MaterialSkinManager.ROBOTO_REGULAR_11.FontFamily, _fSize); Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, _roundedCorner); }
public MaterialCard() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); Width = 294; Height = 348; DoubleBuffered = true; BackColor = Color.Transparent; AddLabel(); AddButton(); Controls.Add(InfoLabel); Controls.Add(OKButton); OKButton.Click += (sender, args) => ActionButtonClicked?.Invoke(this); OKButton.ClickAnimationFinished += sender => ActionButtonClickAnimationFinished?.Invoke(this); ResizeLabel(); Primary = true; AutoSize = true; Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2); }
/// <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) { TransInPaint(pevent.Graphics); //base.OnPaint(pevent); Graphics g = pevent.Graphics; g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; var checkMarkLine = new Rectangle(1, 1, 16, 16); var checkmarkPath = DrawHelper.CreateRoundRect(1, 1, 17, 17, 1); //EnabledCheckedColor = ColorTranslator.FromHtml(HexColor); SolidBrush BG = new SolidBrush(checkedColor); Pen Pen = new Pen(BG.Color) { Width = rectangleWidth }; g.FillPath(BG, checkmarkPath); g.DrawPath(Pen, checkmarkPath); g.FillRectangle(new SolidBrush(uncheckedColor), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum); g.DrawImageUnscaledAndClipped(CheckMarkBitmap(), checkMarkLine); g.DrawString(Text, font.Roboto_Medium10, new SolidBrush(ForeColor), 21, 0); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.Clear(Parent.BackColor); using (var checkmarkPath = DrawHelper.CreateRoundRect(0, 0, 16, 16, 2f)) { if (Checked) { g.FillPath(Enabled ? SkinManager.AccentColorBrush : SkinManager.GetCheckBoxOffDisabledBrush(), checkmarkPath); g.DrawLines(new Pen(Parent.BackColor, 2), new[] { new Point(3, 8), new Point(6, 11), new Point(13, 4) }); } else { g.FillPath(Enabled ? SkinManager.GetCheckboxOffBrush() : SkinManager.GetCheckBoxOffDisabledBrush(), checkmarkPath); g.FillRectangle(new SolidBrush(Parent.BackColor), 2, 2, 12, 12); } } g.DrawString(Text, SkinManager.FONT_BUTTON, Enabled ? SkinManager.GetMainTextBrush() : SkinManager.GetDisabledOrHintBrush(), 20, 0); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1); if (animationManager.IsAnimating()) { G.SetClip(BG); G.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var animationSource = animationManager.GetSource(i); using (Brush rippleBrush = new SolidBrush(SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.LightPrimaryColor : SkinManager.ColorScheme.DarkPrimaryColor)) { var rippleSize = (int)(animationValue * Math.Max(Width, Height) * 2.5); G.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } G.ResetClip(); G.SmoothingMode = SmoothingMode.None; } else { if (Primary) { G.FillPath(new SolidBrush(SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.LightPrimaryColor : SkinManager.ColorScheme.DarkPrimaryColor), BG); } } }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.Clear(Parent.BackColor); var checkMarkLine = new Rectangle(1, 1, 16, 16); var checkmarkPath = DrawHelper.CreateRoundRect(1, 1, 17, 17, 1); EnabledCheckedColor = ColorTranslator.FromHtml(HexColor); SolidBrush BG = new SolidBrush(Enabled ? Checked ? EnabledCheckedColor : EnabledUnCheckedColor : DisabledColor); Pen Pen = new Pen(BG.Color); g.FillPath(BG, checkmarkPath); g.DrawPath(Pen, checkmarkPath); g.SmoothingMode = SmoothingMode.None; g.FillRectangle(new SolidBrush(Color.White), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum); g.SmoothingMode = SmoothingMode.AntiAlias; //CheckMark g.DrawImageUnscaledAndClipped(CheckMarkBitmap(), checkMarkLine); //CheckBox Text g.DrawString(Text, font.Roboto_Medium10, new SolidBrush(Enabled ? EnabledStringColor : DisabledStringColor), 21, 0); }
protected override void OnPaint(PaintEventArgs pevent) { GraphicsPath path; Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.Clear(base.Parent.BackColor); int x = this.boxOffset + 9; double progress = this.animationManager.GetProgress(); int alpha = base.Enabled ? ((int)(progress * 255.0)) : this.SkinManager.GetCheckBoxOffDisabledColor().A; int num4 = base.Enabled ? ((int)(this.SkinManager.GetCheckboxOffColor().A *(1.0 - progress))) : this.SkinManager.GetCheckBoxOffDisabledColor().A; float width = (float)(progress * 8.0); float num6 = width / 2f; width = (float)(progress * 9.0); SolidBrush brush = new SolidBrush(Color.FromArgb(alpha, base.Enabled ? this.SkinManager.ColorScheme.AccentColor : this.SkinManager.GetCheckBoxOffDisabledColor())); Pen pen = new Pen(brush.Color); if (this.Ripple && this.rippleAnimationManager.IsAnimating()) { for (int i = 0; i < this.rippleAnimationManager.GetAnimationCount(); i++) { double num8 = this.rippleAnimationManager.GetProgress(i); Point point = new Point(x, x); SolidBrush brush2 = new SolidBrush(Color.FromArgb((int)(num8 * 40.0), ((bool)this.rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color)); int num9 = ((base.Height % 2) == 0) ? (base.Height - 3) : (base.Height - 2); int num10 = (this.rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? ((int)(num9 * (0.8 + (0.2 * num8)))) : num9; using (path = DrawHelper.CreateRoundRect((float)(point.X - (num10 / 2)), (float)(point.Y - (num10 / 2)), (float)num10, (float)num10, (float)(num10 / 2))) { graphics.FillPath(brush2, path); } brush2.Dispose(); } } Color color = DrawHelper.BlendColor(base.Parent.BackColor, base.Enabled ? this.SkinManager.GetCheckboxOffColor() : this.SkinManager.GetCheckBoxOffDisabledColor(), (double)num4); using (path = DrawHelper.CreateRoundRect((float)this.boxOffset, (float)this.boxOffset, 19f, 19f, 9f)) { graphics.FillPath(new SolidBrush(color), path); if (base.Enabled) { graphics.FillPath(brush, path); } } graphics.FillEllipse(new SolidBrush(base.Parent.BackColor), 2 + this.boxOffset, 2 + this.boxOffset, 15, 15); if (base.Checked) { using (path = DrawHelper.CreateRoundRect(x - num6, x - num6, width, width, 4f)) { graphics.FillPath(brush, path); } } SizeF ef = graphics.MeasureString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10); graphics.DrawString(this.Text, this.SkinManager.ROBOTO_MEDIUM_10, base.Enabled ? this.SkinManager.GetMainTextBrush() : this.SkinManager.GetDisabledOrHintBrush(), (float)(this.boxOffset + 0x16), (base.Height / 2) - (ef.Height / 2f)); brush.Dispose(); pen.Dispose(); }
/// <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) { TransInPaint(e.Graphics); base.OnPaint(e); //Bitmap B = new Bitmap(Width, Height); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; //G.Clear(Parent.BackColor); //Content Text Color InfoLabel.BackColor = cTextColor; InfoLabel.ForeColor = cColor; //Content OK OKButton.BackColor = lowerRectangle; #region Working Code //var PicBG = DrawHelper.CreateUpRoundRect(1, 1, 292, 164, 1); //var UpRoundedRec = DrawHelper.CreateUpRoundRect(1, 1, 291, 164, 1); //var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, borderRadius); //var ShadowBG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, borderRadius); #endregion var PicBG = DrawHelper.CreateUpRoundRect(1, 1, Width, 164, 1); var UpRoundedRec = DrawHelper.CreateUpRoundRect(1, 1, Width, 164, 1); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, borderRadius); var ShadowBG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, borderRadius); G.FillPath(new SolidBrush(emptyColor), ShadowBG); G.DrawPath(new Pen(emptyColor), ShadowBG); //Lower Rectangle G.FillPath(new SolidBrush(lowerRectangle), BG); G.DrawPath(new Pen(lowerBorder), BG); G.DrawString(Text, font.Roboto_Medium15, new SolidBrush(ForeColor), 12, 176); //G.FillRectangle(new SolidBrush(emptyColor), 16, InfoLabel.Location.Y + InfoLabel.Height + 14, 261, 1); G.FillRectangle(new SolidBrush(emptyColor), 16, InfoLabel.Location.Y + InfoLabel.Height + 14, Width - 30, 1); if (image != null) { G.SetClip(PicBG); //G.DrawImage(image, this.Width/2, this.Height/2, image.Width, image.Height); G.DrawImage(image, 1, 1, Width - 3, 164); } else { G.FillPath(new SolidBrush(emptyColor), UpRoundedRec); G.DrawPath(new Pen(emptyColor), UpRoundedRec); } //e.Graphics.DrawImage(B, 0, 0); }
protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.Clear(SkinManager.ColorScheme.PrimaryColor); if (Image != null) { int w = Convert.ToInt32(Image.Width * ImageScale); int h = Convert.ToInt32(Image.Height * ImageScale); int x = Convert.ToInt32((ACTION_BAR_HEIGHT - w) / 2); int y = Convert.ToInt32((ACTION_BAR_HEIGHT - h) / 2); g.DrawImage(Image, x + 1, y, w, h); } //Hover Color c = SkinManager.GetFlatButtonHoverBackgroundColor(); /* using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A * 0.5), c.RemoveAlpha()))) * g.FillRectangle(b, ClientRectangle);*/ var hoverBrush = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A * 0.5), c.RemoveAlpha())); using (var path = DrawHelper.CreateRoundRect(0, 0, ACTION_BAR_HEIGHT, ACTION_BAR_HEIGHT, ACTION_BAR_HEIGHT / 2)) g.FillPath(hoverBrush, path); //Ripple if (animationManager.IsAnimating()) { g.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i < animationManager.GetAnimationCount(); i++) { /*var animationValue = animationManager.GetProgress(i); * var animationSource = animationManager.GetSource(i); * * using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(151 - (animationValue * 150)), Color.White))) * { * var rippleSize = (int)(animationValue * Width * 2); * g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); * }*/ var animationValue = animationManager.GetProgress(i); var rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.White)); var rippleSize = (int)(animationValue * ACTION_BAR_HEIGHT); if (rippleSize <= 0) { rippleSize = 2; } var x = (ACTION_BAR_HEIGHT - rippleSize) / 2; using (var path = DrawHelper.CreateRoundRect(x, x, rippleSize, rippleSize, rippleSize / 2)) g.FillPath(rippleBrush, path); } } }
protected override void OnResize(EventArgs eventargs) { base.OnResize(eventargs); Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, _roundedCorner); }
protected override void OnResize(EventArgs e) { base.OnResize(e); ContentRect.Location = new Point(TitleRect.X, TitleRect.Bottom + 10); NameRect.Location = new Point(ContentRect.X, ContentRect.Bottom + 10); CardRectangle.Size = new Size(Math.Max(Math.Max(ContentRect.Size.Width, NameRect.Size.Width), TitleRect.Size.Width) + 20, NameRect.Bottom - TitleRect.Y + 20); CardShadow = DrawHelper.CreateRoundRect(CardRectangle, 10); Size = new Size(CardRectangle.Right + 20, CardRectangle.Bottom + 20); Invalidate(); }
protected override void OnPaint(PaintEventArgs pevent) { Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.Clear(base.Parent.BackColor); Rectangle clientRectangle = base.ClientRectangle; float x = (float)clientRectangle.X; clientRectangle = base.ClientRectangle; float y = (float)clientRectangle.Y; clientRectangle = base.ClientRectangle; float width = (float)(clientRectangle.Width - 1); clientRectangle = base.ClientRectangle; using (GraphicsPath path = DrawHelper.CreateRoundRect(x, y, width, (float)(clientRectangle.Height - 1), 1f)) { graphics.FillPath(this.Primary ? this.SkinManager.ColorScheme.PrimaryBrush : this.SkinManager.GetRaisedButtonBackgroundBrush(), path); } if (this._animationManager.IsAnimating()) { for (int i = 0; i < this._animationManager.GetAnimationCount(); i++) { double progress = this._animationManager.GetProgress(i); Point source = this._animationManager.GetSource(i); SolidBrush brush = new SolidBrush(Color.FromArgb((int)(51.0 - progress * 50.0), Color.White)); int num = (int)(progress * (double)base.Width * 2.0); graphics.FillEllipse(brush, new Rectangle(source.X - num / 2, source.Y - num / 2, num, num)); } } Rectangle rect = new Rectangle(8, 6, 24, 24); if (string.IsNullOrEmpty(this.Text)) { rect.X += 2; } if (this.Icon != null) { graphics.DrawImage(this.Icon, rect); } Rectangle clientRectangle2 = base.ClientRectangle; if (this.Icon != null) { clientRectangle2.Width -= 44; clientRectangle2.X += 36; } graphics.DrawString(this.Text.ToUpper(), this.SkinManager.ROBOTO_MEDIUM_10, this.SkinManager.GetRaisedButtonTextBrush(this.Primary), clientRectangle2, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); }
protected override void OnPaint(PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; graphics.Clear(Parent.BackColor); if (_buttonType == ButtonType.Default) { var BG = DrawHelper.CreateRoundRect(0.5f, 0.5f, Width - 1, Height - 1, 3); graphics.FillPath(new SolidBrush(enterFlag ? Color.FromArgb(25, ThemeColors.PrimaryColor) : Color.White), BG); graphics.DrawPath(new Pen(clickFlag ? ThemeColors.PrimaryColor : ThemeColors.OneLevelBorder, 1), BG); graphics.DrawString(Text, Font, new SolidBrush(enterFlag?ThemeColors.PrimaryColor:ThemeColors.MainText), new RectangleF(0, 0, Width, Height), StringAlign.Center); } else { var BG = DrawHelper.CreateRoundRect(0, 0, Width, Height, 3); var backColor = ThemeColors.PrimaryColor; switch (_buttonType) { case ButtonType.Primary: backColor = ThemeColors.PrimaryColor; break; case ButtonType.Success: backColor = ThemeColors.Success; break; case ButtonType.Info: backColor = ThemeColors.Info; break; case ButtonType.Waring: backColor = ThemeColors.Warning; break; case ButtonType.Danger: backColor = ThemeColors.Danger; break; default: break; } var brush = new SolidBrush(enterFlag ? (clickFlag ? backColor : Color.FromArgb(225, backColor)) : backColor); graphics.FillPath(brush, BG); if (!Enabled) { graphics.FillPath(new SolidBrush(Color.FromArgb(125, ThemeColors.OneLevelBorder)), BG); } graphics.DrawString(Text, Font, new SolidBrush(Color.White), new RectangleF(0, 0, Width, Height), StringAlign.Center); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.Clear(Parent.BackColor); StringColor = ColorTranslator.FromHtml(fontcolor); EnabledBGColor = ColorTranslator.FromHtml(Backcolor); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); Region region = new Region(BG); G.FillPath(new SolidBrush(Enabled ? EnabledBGColor : DisabledBGColor), BG); G.DrawPath(new Pen(Enabled ? EnabledBGColor : DisabledBGColor), BG); G.SetClip(region, CombineMode.Replace); //The Ripple Effect G.FillEllipse(new SolidBrush(Color.FromArgb(25, Color.Black)), xx - (SizeAnimation / 2), yy - (SizeAnimation / 2), SizeAnimation, SizeAnimation); //---------------------------- StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.Trimming = StringTrimming.None; stringFormat.FormatFlags = StringFormatFlags.DirectionVertical; Brush textBrush = new SolidBrush(this.ForeColor); Matrix storedState = G.Transform; if (bFlip) { G.RotateTransform(180f); G.TranslateTransform(-ClientRectangle.Width, -ClientRectangle.Height); } //G.DrawString(Text, font.Roboto_Medium9, new SolidBrush(StringColor), R, SF); G.DrawString( Text, font.Roboto_Medium9, new SolidBrush(StringColor), ClientRectangle, SF); G.Transform = storedState; }
protected override void OnCreateControl() { base.OnCreateControl(); Font = SkinManager.ROBOTO_MEDIUM_10; if (DesignMode) { return; } MouseState = MouseState.OUT; MouseEnter += (sender, args) => { MouseState = MouseState.HOVER; Invalidate(); }; MouseLeave += (sender, args) => { MouseLocation = new Point(-1, -1); MouseState = MouseState.OUT; Invalidate(); }; MouseDown += (sender, args) => { MouseState = MouseState.DOWN; if (Ripple && args.Button == MouseButtons.Left) { int boxOffset = Height / 2 - 8; using (var checkmarkPath = DrawHelper.CreateRoundRect(boxOffset, boxOffset, 16, 16, 2f)) { if (checkmarkPath.IsVisible(MouseLocation)) { rippleAnimationManager.SecondaryIncrement = 0; rippleAnimationManager.StartNewAnimation(AnimationDirection.InOutIn, data: new object[] { Checked }); } } } Invalidate(); }; MouseUp += (sender, args) => { MouseState = MouseState.HOVER; rippleAnimationManager.SecondaryIncrement = 0.08; Invalidate(); }; MouseMove += (sender, args) => { MouseLocation = args.Location; Invalidate(); }; }
protected override void OnResize(EventArgs e) { base.OnResize(e); Width = 294; if (!Growing) { this.Height = InfoLabel.Location.Y + InfoLabel.Height + 74; } Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2); }
/// <summary> /// Redraws the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Redraw(object sender, System.EventArgs e) { ShadowBorder = new GraphicsPath(); ShadowBorder = DrawHelper.CreateRoundRect(Location.X, Location.Y, ClientRectangle.Width, ClientRectangle.Height, 10); this.Region = new Region(DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height, 10)); Invalidate(); }
protected override void OnPaint(PaintEventArgs pevent) { int iCropping = ClientRectangle.Width / 3; var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; g.Clear(Parent.BackColor); this.Region = new Region(DrawHelper.CreateRoundRect(ClientRectangle.X + 3, ClientRectangle.Y + 3, ClientRectangle.Width - 3, ClientRectangle.Height - 3, 10)); using (var backgroundPath = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height, 3)) { g.FillPath(SkinManager.getCardsBrush(), backgroundPath); } if (_Teile.Count > 0) { if (HoveredItem >= 0) { g.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(_Teile[HoveredItem].ItemRect.X + offset, _Teile[HoveredItem].ItemRect.Y, _Teile[HoveredItem].ItemRect.Width, _Teile[HoveredItem].ItemRect.Height)); } //Click feedback if (animationManager.IsAnimating()) { double animationProgress = animationManager.GetProgress(); var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationProgress * 50)), Color.White)); var rippleSize = (int)(animationProgress * _Teile[SelectedItemIndex].ItemRect.Width * 1.75); g.SetClip(_Teile[SelectedItemIndex].ItemRect); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); g.ResetClip(); rippleBrush.Dispose(); } for (int i = 0; i < _Teile.Count; i++) { g.DrawString( _Teile[i].Text + (i == _Teile.Count - 1 ? "" : _Trennzeichen), SkinManager.FONT_CONTROL_SMALL, SkinManager.GetPrimaryTextBrush(), new Rectangle(_Teile[i].ItemRect.X + offset, _Teile[i].ItemRect.Y, _Teile[i].ItemRect.Width, _Teile[i].ItemRect.Height), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } } }
public MaterialPanel() { SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.ResizeRedraw, true); Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, _roundedCorner); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.TextRenderingHint = TextRenderingHint.AntiAlias; Color NonColor = MaterialSkinManager.GetDisabledOrHintColor(); var PicBG = DrawHelper.CreateRoundRect(1, 1, 292, 164, 1); var UpRoundedRec = DrawHelper.CreateRoundRect(1, 1, 291, 164, 1); var BG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 5, 1); var ShadowBG = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 4, 2); G.FillPath(new SolidBrush(NonColor), ShadowBG); G.DrawPath(new Pen(NonColor), ShadowBG); //if (MouseState == MouseState.HOVER) //{ // Color c = MaterialSkinManager.GetApplicationBackgroundColor(); // G.FillPath(new SolidBrush(Color.FromArgb((int)(0.7*c.A), c.RemoveAlpha())), BG); //} //else //{ G.FillPath(new SolidBrush(MaterialSkinManager.GetApplicationBackgroundColor()), BG); //} G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG); G.DrawString(Text, MaterialSkinManager.ROBOTO_MEDIUM_15, Primary ? MaterialSkinManager.ColorScheme.PrimaryBrush : MaterialSkinManager.GetPrimaryTextBrush(), 12, 176); G.SmoothingMode = SmoothingMode.None; G.FillRectangle(MaterialSkinManager.GetDividersBrush(), 16, InfoLabel.Bottom + 14, 261, 1); if (_image != null) { G.SetClip(PicBG); G.DrawImage(_image, 0, 0, 293, 166); } else { G.FillPath(new SolidBrush(NonColor), UpRoundedRec); G.DrawPath(new Pen(NonColor), UpRoundedRec); } G.DrawPath(new Pen(MaterialSkinManager.GetDividersColor()), BG); if (!DesignMode && Controls.Count > 0) { this.DrawChildShadow(G); } }
public MaterialSmallCard() { Height = 52; Width = 182; DoubleBuffered = true; BackColor = Color.Transparent; hoverAnimationManager = new AnimationManager { Increment = 0.08, AnimationType = AnimationType.Linear }; hoverAnimationManager.OnAnimationProgress += HoverAnimationManager_OnAnimationProgress; Shadow = null; ShadowShape = DrawHelper.CreateRoundRect(1, 1, Width - 3, Height - 3, 1); }