/// <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); } }
/// <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) { if (ShadowBorder != null) { ShadowBorder.Dispose(); } ShadowBorder = new GraphicsPath(); ShadowBorder = DrawHelper.CreateCircle(Location.X, Location.Y, ClientRectangle.Width / 2 - 1); if (Width != Height) { Width = Math.Min(Width, Height); Height = Math.Min(Width, Height); } Invalidate(); }