public Style(String name, System.Drawing.Font font, System.Drawing.Color color, System.Windows.Forms.HorizontalAlignment alignment) { this.Name = name; this.Font = font; this.Color = System.Drawing.Color.FromArgb(color.ToArgb()); this.Alignment = alignment; }
/// <summary> /// 列信息构造函数 /// </summary> /// <param name="_title">显示名称</param> /// <param name="_name">字段名称</param> /// <param name="_length">字段列显示宽度</param> /// <param name="_align">对齐方式</param> /// <param name="_visble">是否显示</param> public ListColumnInfo(string _title, string _name, int _length, System.Windows.Forms.HorizontalAlignment _align, bool _visble) { columnTitle = _title; columnName = _name; columnLength = _length; hAlign = _align; visble = _visble; }
/// <summary> /// 列信息构造函数 /// </summary> /// <param name="_title">显示名称</param> /// <param name="_name">字段名称</param> /// <param name="_length">字段列显示宽度</param> /// <param name="_align">对齐方式</param> /// <param name="_visble">是否显示</param> public ListColumnInfo(string _title, string _name, int _length, System.Windows.Forms.HorizontalAlignment _align, bool _visble) { columnTitle = _title; columnName = _name; columnLength = _length; hAlign = _align; visble = _visble; }
public Style(String name) { this.Name = name; this.Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, (float)12); this.Color = EditorWindow.DefaultForeColor; this.Alignment = System.Windows.Forms.HorizontalAlignment.Left; }
private void AddTableRow(Table T, DataRow myDataRow, int NumeroRiga, int[] orderedcols, string PanelId) { if (T == null) { return; } if (myDataRow == null) { return; } DataTable TT = myDataRow.Table; //Nuova Riga TableRow TR1 = new TableRow(); //TR1.Height = 24; T.Rows.Add(TR1); if ((NumeroRiga & 1) == 0) { TR1.CssClass = "odd"; } TableCell T_Chk = new TableCell(); hwCheckBox HwC = new hwCheckBox(); HwC.ID = "Chk_Selector_" + PanelId + "_" + NumeroRiga; HwC.Tag = NumeroRiga.ToString(); T_Chk.Controls.Add(HwC); TR1.Cells.Add(T_Chk); for (int i = 0; i < orderedcols.Length; i++) { DataColumn C = TT.Columns[orderedcols[i]]; //Aggiungo tutte le celle. TableCell TC1 = new TableCell(); TC1.Text = GetValoreFormattato(myDataRow, C.ColumnName, HelpForm.GetFormatForColumn(C)); System.Windows.Forms.HorizontalAlignment HA = HelpForm.GetAlignForColumn(C); if (HA == System.Windows.Forms.HorizontalAlignment.Right) { TC1.HorizontalAlign = HorizontalAlign.Right; } else { TC1.HorizontalAlign = HorizontalAlign.Left; } TR1.Cells.Add(TC1); } }
public void WdColumnsAdd(string text, int width, System.Windows.Forms.HorizontalAlignment textAlign) // Since ColumnsAdd exists, it was referred to as WdColumnsAdd. { if (this.InvokeRequired) { WdColumnsAddCallback5 d = new WdColumnsAddCallback5(WdColumnsAdd); this.Invoke(d, new object[] { text, width, textAlign }); } else { this.Columns.Add(text, width, textAlign); } }
string GetAlignForColumn(DataColumn C) { System.Windows.Forms.HorizontalAlignment H = HelpForm.GetAlignForColumn(C); if (H == System.Windows.Forms.HorizontalAlignment.Center) { return(" align='center' "); } if (H == System.Windows.Forms.HorizontalAlignment.Right) { return(" align='right' "); } return(""); }
public virtual HorizontalAlignment Parse(System.Windows.Forms.HorizontalAlignment textAlign) { switch (textAlign) { case System.Windows.Forms.HorizontalAlignment.Center: return(HorizontalAlignment.Center); case System.Windows.Forms.HorizontalAlignment.Left: return(HorizontalAlignment.Left); case System.Windows.Forms.HorizontalAlignment.Right: return(HorizontalAlignment.Right); } return(HorizontalAlignment.Left); }
/// <summary> /// Writes text to line at given index. /// </summary> /// <param name="lineIndex">Index of line to modify. If line number is higher than last line (e.g. int.MaxValue), new line is created. If negative value is used (e.g -1), last line is used as base.</param> /// <param name="text">Text to be added.</param> /// <param name="left">Index at which text will be added.</param> /// <param name="width">Total width of given text.</param> /// <param name="alignment">Alignment of text.</param> /// <param name="wordWrap">If false, text will not be wrapped to next line in case it is too long to fit on one line.</param> /// <returns>Index of modified line. It may not be last line since word wrap can occurr.</returns> /// <exception cref="System.ArgumentOutOfRangeException">Left cannot be negative. -or- Width cannot be zero or negative.</exception> /// <exception cref="System.OverflowException">Operation would result in write at location which is beyond end of paper.</exception> public int Write(int lineIndex, string text, int left, int width, System.Windows.Forms.HorizontalAlignment alignment, bool wordWrap) { if (left < 0) { throw new System.ArgumentOutOfRangeException("left", left, Resources.ExceptionLeftCannotBeNegative); } if (width <= 0) { throw new System.ArgumentOutOfRangeException("width", width, Resources.ExceptionWidthCannotBeZeroOrNegative); } if (left + width > this.Width) { throw new System.OverflowException(string.Format(System.Globalization.CultureInfo.InvariantCulture, Resources.ExceptionOperationWouldResultInWriteAtLocationWhichIsBeyondEndOfPaper, left + width - 1, this.Width - 1)); } List <string> wrappedContent = new List <string>(); if (text.Length <= width) { wrappedContent.Add(text); } else //trim is needed { if (wordWrap == false) { wrappedContent.Add(text.Remove(width)); } else { while (text != null) { if (text.Length <= width) { wrappedContent.Add(text); text = null; } else { int i = text.LastIndexOfAny(new char[] { '\0' }, width); if (i < 0) //no space. { wrappedContent.Add(text.Substring(0, width)); text = text.Substring(width); } else //space found { wrappedContent.Add(text.Substring(0, i)); text = text.Substring(i + 1); } } } } } string[] newContent = new string[wrappedContent.Count]; for (int i = 0; i < wrappedContent.Count; ++i) { string curr = wrappedContent[i]; switch (alignment) { case System.Windows.Forms.HorizontalAlignment.Left: newContent[i] = curr.PadRight(width, '\0'); break; case System.Windows.Forms.HorizontalAlignment.Center: int addToLeft = (width - curr.Length) / 2; newContent[i] = curr.PadLeft(addToLeft + curr.Length, '\0').PadRight(width, '\0'); break; case System.Windows.Forms.HorizontalAlignment.Right: newContent[i] = curr.PadLeft(width, '\0'); break; default: newContent[i] = curr.PadRight(width, '\0'); break; } } int addLineCount = 0; if ((lineIndex >= this._lines.Count) || (this._lines.Count == 0)) //add new line { lineIndex = this._lines.Count; addLineCount = newContent.Length; } else if (lineIndex < 0) //check last line { lineIndex = this._lastLine; addLineCount = System.Math.Max(0, newContent.Length - (this._lines.Count - lineIndex)); } else //use existing line. { addLineCount = System.Math.Max(0, newContent.Length - (this._lines.Count - lineIndex)); } for (int i = 0; i < addLineCount; ++i) { this._lines.Add((new string('\0', this.Width)).ToCharArray()); } for (int i = 0; i < newContent.Length; ++i) { int x = lineIndex + i; for (int j = 0; j < width; ++j) { int y = left + j; if (newContent[i][j] != '\0') { this._lines[x][y] = newContent[i][j]; } } } this._lastLine = lineIndex; return(lineIndex); }
/// <summary> /// Adds new line with given text. /// </summary> /// <param name="text">Text to write</param> /// <param name="alignment">Alignment of text.</param> /// <param name="wordWrap">If false, text will not be wrapped to next line in case it is too long to fit on one line.</param> public int WriteLine(string text, System.Windows.Forms.HorizontalAlignment alignment, bool wordWrap) { return(Write(int.MaxValue, text, 0, this.Width, alignment, wordWrap)); }
/// <summary> /// Adds new line with given text. /// </summary> /// <param name="text">Text to write</param> /// <param name="alignment">Alignment of text.</param> public int WriteLine(string text, System.Windows.Forms.HorizontalAlignment alignment) { return(Write(int.MaxValue, text, 0, Width, alignment, true)); }
public Style(System.Windows.Forms.RichTextBox textbox) { this.Font = textbox.SelectionFont; this.Alignment = textbox.SelectionAlignment; this.Color = textbox.SelectionColor; }
protected System.Windows.Forms.HorizontalAlignment RtlTranslateHorizontal(System.Windows.Forms.HorizontalAlignment align);