protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; int lineY = baseTextBox.Bottom + 3; if (!animationManager.IsAnimating()) { //No animation g.FillRectangle(baseTextBox.Focused ? MaterialSkinManager.ColorScheme.PrimaryBrush : MaterialSkinManager.GetDividersBrush(), baseTextBox.Location.X, lineY, baseTextBox.Width, baseTextBox.Focused ? 2 : 1); } else { //Animate int animationWidth = (int)(baseTextBox.Width * animationManager.GetProgress()); int halfAnimationWidth = animationWidth / 2; int animationStart = baseTextBox.Location.X + baseTextBox.Width / 2; //Unfocused background g.FillRectangle(MaterialSkinManager.GetDividersBrush(), baseTextBox.Location.X, lineY, baseTextBox.Width, 1); //Animated focus transition g.FillRectangle(MaterialSkinManager.ColorScheme.PrimaryBrush, animationStart - halfAnimationWidth, lineY, animationWidth, 2); } if (!DesignMode && Controls.Count > 0) { this.DrawChildShadow(g); } }
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); } }