/// <summary> /// Updates the layout of the Field that the controller manages. /// </summary> protected virtual void UpdateLayout() { titleLabel.Top = 3; titleLabel.Width = this.Width - (2 * 3); titleLabel.Left = 3; titleLabel.Height = StringMeasure.Measure(titleLabel, titleLabel.Text, titleLabel.ClientRectangle).Height; if (Content != null) { Content.Width = this.Width - (2 * 3); Content.Left = 3; Content.Top = titleLabel.Top + titleLabel.Height + 3; } errorPanel.Width = this.Width; errorPanel.Height = Content != null? Content.Top + Content.Height + 3 : 0; if (enabled) { descriptionLabel.Width = this.Width - (2 * 3); descriptionLabel.Left = 3; descriptionLabel.Top = errorPanel.Top + errorPanel.Height + 2; descriptionLabel.Height = StringMeasure.Measure(descriptionLabel, descriptionLabel.Text, descriptionLabel.ClientRectangle).Height; this.Height = descriptionLabel.Height + errorPanel.Height + 3; if (String.IsNullOrEmpty(descriptionLabel.Text)) { this.Height -= 3; } } else { this.Height = errorPanel.Height; } }
/// <summary> /// Show the notification on the screen /// </summary> /// <param name="info">the <see cref="FormInfo"/> object that contein information about the form</param> public void ShowNotification(FormRequestInfo info) { this.formInfo = info; name.Text = info.CompilationRequestId.ToString(); notified.Text = info.Time.ToString(ResourceManager.Instance.Culture); from.Text = info.From; fromPanel.Height = Math.Max(StringMeasure.Measure(from, info.From == null? "" : info.From, from.Bounds).Height, fromLabel.Height); if (info.Username == null || info.Username == "") { type.Text = "Public"; usernamePanel.Hide(); servicePanel.Hide(); tokenPanel.Hide(); contentPanel.Height = 146; } else { type.Text = "Private"; username.Text = info.Username; usernamePanel.Show(); service.Text = info.Service; servicePanel.Show(); token.Text = info.Token; tokenPanel.Show(); contentPanel.Height = 212; } }
private void MisureString() { this.Font = new Font("Tahoma", 7F, FontStyle.Regular); Label test = new Label(); test.Text = this.Text; test.Font = this.Font; float count = test.Font.Size; do { wstring = StringMeasure.Measure(test, test.Text, test.ClientRectangle).Width; this.Font = test.Font; count--; test.Font = new Font("Tahoma", count, FontStyle.Regular); } while (wstring >= this.Size.Width); test.Dispose(); }