public void UpdateSize(float scale) { if (IsDisposed) { DPIManager.Unregister(this); return; } SuspendLayout(); int border = DPIManager.Adjust(4, scale); int dborder = border * 2; picture.Location = new Point(border, border); picture.Size = new Size(DPIManager.Adjust(44, scale), DPIManager.Adjust(44, scale)); Height = DPIManager.Adjust(52, scale); Size labelSize = TextRenderer.MeasureText(TitleText, title.Font); Size plabelSize = TextRenderer.MeasureText(PlayerText, players.Font); float reservedSpaceLabel = this.Width - picture.Width; if (labelSize.Width > reservedSpaceLabel) { // make text smaller int charSize = TextRenderer.MeasureText("g", title.Font).Width; int toRemove = (int)((reservedSpaceLabel - labelSize.Width) / (float)charSize); toRemove = Math.Max(toRemove + 3, 7); title.Text = TitleText.Remove(TitleText.Length - toRemove, toRemove) + "..."; } else { title.Text = TitleText; } players.Text = PlayerText; title.Size = labelSize; players.Size = plabelSize; float height = this.Height / 2.0f; float lheight = labelSize.Height / 2.0f; title.Location = new Point(picture.Width + picture.Left + border, (int)(height - labelSize.Height) /*(int)(height - lheight)*/); players.Location = new Point(picture.Width + picture.Left + border + playerIcon.Width + 10, (int)height); playerIcon.Location = new Point(picture.Width + picture.Left + border + 10, (int)height); playerIcon.Size = new Size(DPIManager.Adjust(players.Size.Height, scale), DPIManager.Adjust(players.Size.Height, scale)); ResumeLayout(); }
public void UpdateSize(float scale) { if (IsDisposed) { DPIManager.Unregister(this); return; } SuspendLayout(); int border = DPIManager.Adjust(8, scale); int dborder = border * 2; checkbox.Location = new Point(12, 11); checkbox.Size = new Size(30, 30); Height = DPIManager.Adjust(52, scale); Size labelSize = TextRenderer.MeasureText(TitleText, title.Font); float reservedSpaceLabel = this.Width - checkbox.Width; if (labelSize.Width > reservedSpaceLabel) { // make text smaller int charSize = TextRenderer.MeasureText("g", title.Font).Width; int toRemove = (int)((reservedSpaceLabel - labelSize.Width) / (float)charSize); toRemove = Math.Max(toRemove + 3, 7); title.Text = TitleText.Remove(TitleText.Length - toRemove, toRemove) + "..."; } else { title.Text = TitleText; } title.Size = labelSize; float height = this.Height / 2.0f; float lheight = labelSize.Height / 2.0f; title.Location = new Point(checkbox.Width + checkbox.Left + border, (int)(height - lheight)); ResumeLayout(); }