protected void AlterarTextoFonte(Label label, string texto, int máximoCaracteresTexto) { if (texto.Length > máximoCaracteresTexto) texto = texto.Substring(0, máximoCaracteresTexto - 4) + " ..."; label.SuspendLayout(); label.Text = texto; AjustarTamanhoFonte(label); label.ResumeLayout(); }
public void AddProgressBarX(string title) { this.m_baseWnd.SuspendLayout(); Label label = new Label(); label.SuspendLayout(); label.AutoSize = false; label.Text = title; using (Graphics graphics = Graphics.FromHwnd(label.Handle)) { this.m_titleWidth = ((int) graphics.MeasureString(label.Text, this.m_Font).Width) + label.Margin.Size.Width; } label.Size = new Size(this.m_titleWidth, label.Font.Height); label.Location = new Point(this.m_baseWnd.Location.X + this.m_fromPt.X, (this.m_baseWnd.Location.Y + this.m_fromPt.Y) + (this.m_intervalBarH * this.m_ValuePair.Count)); ProgressBarX rx = new ProgressBarX(); rx.SuspendLayout(); rx.Size = new Size(this.m_barWidth, 0x17); rx.Style = ProgressBarStyle.Continuous; rx.Location = new Point((label.Location.X + label.Width) + 10, label.Location.Y - ((rx.Height - label.Height) >> 1)); Label label2 = new Label(); label2.SuspendLayout(); label2.AutoSize = true; label2.Size = new Size(50, label2.Font.Height); label2.Text = string.Empty; label2.Location = new Point((rx.Location.X + rx.Width) + 10, label.Location.Y); rx.TitleLable = label; rx.TextLable = label2; ValuePair item = new ValuePair(); item.Key = title; item.Value = rx; this.m_ValuePair.Add(item); this.m_baseWnd.Controls.Add(rx); this.m_baseWnd.Controls.Add(label); this.m_baseWnd.Controls.Add(label2); this.AdjustWindow(); label2.ResumeLayout(); rx.ResumeLayout(); label.ResumeLayout(); this.m_baseWnd.ResumeLayout(); this.m_baseWnd.PerformLayout(); }
public static Label Label(IXsdPart part, ToolTip tooltip = null) { try { if (String.IsNullOrWhiteSpace(part.Name)) { throw new ArgumentNullException(); } var label = new Label(); label.SuspendLayout(); label.ForeColor = System.Drawing.Color.Black; label.AutoSize = true; label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; label.Font = Methods.BaseFont; label.Size = new System.Drawing.Size(41, 13); label.Text = part.Name; label.Name = "l" + part.Name; if (tooltip != null) { tooltip.SetToolTip(label, part.Documentation); } if (part.Name == "HeaderLabel") { label.Visible = false; label.Margin = new System.Windows.Forms.Padding(0, 0, 0, 10); } label.ResumeLayout(); return label; } catch (Exception ex) { return null; } }
private void InitializeComponents() { nameLabel = new Label(); pathLabel = new Label(); nameTextBox = new TextBox(); pathTextBox = new TextBox(); okButton = new Button(); cancelButton = new Button(); this.SuspendLayout(); nameLabel.SuspendLayout(); pathLabel.SuspendLayout(); nameTextBox.SuspendLayout(); pathTextBox.SuspendLayout(); okButton.SuspendLayout(); cancelButton.SuspendLayout(); nameLabel.Text = "Name"; nameLabel.AutoSize = true; nameLabel.Location = new Point(3, 3); pathLabel.Text = "Path"; pathLabel.AutoSize = true; pathLabel.Location = new Point(3, 30); nameTextBox.Size = new Size(250, 19); nameTextBox.Location = new Point(40, 2); nameTextBox.BorderStyle = BorderStyle.FixedSingle; pathTextBox.Size = new Size(250, 19); pathTextBox.Location = new Point(40, 29); pathTextBox.BorderStyle = BorderStyle.FixedSingle; okButton.Text = "OK"; okButton.Size = new Size(75, 23); okButton.Location = new Point((300-75)/2, 60); okButton.FlatStyle = FlatStyle.Flat; okButton.Click += delegate { this.DialogResult = DialogResult.OK; this.Close(); }; cancelButton.Text = "Cancel"; cancelButton.Size = new Size(75, 23); cancelButton.Location = new Point(215, 60); cancelButton.FlatStyle = FlatStyle.Flat; cancelButton.Click += delegate { this.DialogResult = DialogResult.Cancel; this.Close(); }; this.Size = new Size(300, 120); this.FormBorderStyle = FormBorderStyle.FixedSingle; this.Text = "Jump target"; this.Controls.AddRange(new Control[]{ nameLabel, pathLabel, nameTextBox, pathTextBox, okButton, cancelButton }); nameLabel.ResumeLayout(false); pathLabel.ResumeLayout(false); nameTextBox.ResumeLayout(false); pathTextBox.ResumeLayout(false); okButton.ResumeLayout(false); cancelButton.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); }
public static Label OccursLabel(decimal maxCount) { try { var label = new Label(); label.SuspendLayout(); label.ForeColor = System.Drawing.Color.Black; label.AutoSize = true; label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; label.Font = Methods.BaseFont; label.BackColor = System.Drawing.Color.FromArgb(255, 195, 194); label.Size = new System.Drawing.Size(41, 13); label.Text = "Maximum of entries " + maxCount + " allowed"; label.Name = "OccursError"; label.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); label.Visible = true; label.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); label.Location = new System.Drawing.Point(0, 0); label.ResumeLayout(); return label; } catch (Exception ex) { return null; } }
public Label CreateLabel(string text, int xLocation, int width = -1) { var label = new Label(); label.SuspendLayout(); label.AutoSize = false; label.AutoEllipsis = true; label.Text = text; label.Font = font; label.Size = new Size(width == -1 ? TextRenderer.MeasureText(label.Text, label.Font).Width : width, this.barHeight); label.Location = new Point(xLocation, 0); label.TextAlign = ContentAlignment.MiddleLeft; // TODO: this doesn't work when there are ellipsis label.ResumeLayout(); return label; }