private static GUIControl.Alignment ConvertAlignment(ColumnDisplay.Alignment alignment) { if (alignment == ColumnDisplay.Alignment.Center) { return(GUIControl.Alignment.Center); } if (alignment == ColumnDisplay.Alignment.Left) { return(GUIControl.Alignment.Left); } return(GUIControl.Alignment.Right); }
private GUIControl CreateControl(int posX, int posY, int width, int height, ColumnDisplay.Alignment alignment, string label, string font, int fontSize, Style style, int nbMax, int columnIndex) { // always start with a space string strLabel = " " + label; // shrink text for small labels if (nbMax <= 6 && strLabel.Length > nbMax) { strLabel = strLabel.Substring(0, nbMax); } int px = posX; if (alignment == ColumnDisplay.Alignment.Right) { px = posX + width; } // create the control GUIControl control = null; try { GUILabelControl labelControl = new GUILabelControl(GetID); labelControl._positionX = px; labelControl._positionY = posY; labelControl._width = width; labelControl._height = height; labelControl.FontName = font; labelControl.Label = strLabel; labelControl.TextColor = style.ForeColor; labelControl.TextAlignment = ConvertAlignment(alignment); control = labelControl; } catch (Exception exc) { Tools.LogError(String.Format("bad {0}", strLabel), exc); control = null; } return(control); }
public ColumnDisplay(string strCol) { int c = 0; if (false == int.TryParse(strCol.Trim(), out c)) { // default size c = 5; } Size = Math.Abs(c); Alignement = ColumnDisplay.Alignment.Right; if (strCol.StartsWith("-")) { Alignement = ColumnDisplay.Alignment.Left; } else if (strCol.StartsWith("+")) { Alignement = ColumnDisplay.Alignment.Center; } }
public Control CreateControl(int posX, int posY, int width, int height, ColumnDisplay.Alignment alignement, string label, string font, int fontSize, Style style, int nbMax, int columnIndex) { string strLabel = label; // always start with a space strLabel = " " + label; // shrink text for small labels if (nbMax <= 6 && strLabel.Length > nbMax) { strLabel = strLabel.Substring(0, nbMax); } // create the control Label control = new Label() { Left = posX, Top = posY, AutoSize = false, //AutoEllipsis = true, Width = width, Height = height, Text = strLabel, BorderStyle = BorderStyle.FixedSingle, ForeColor = Color.FromArgb((int)style.ForeColor), TextAlign = alignement == ColumnDisplay.Alignment.Center ? ContentAlignment.MiddleCenter : (alignement == ColumnDisplay.Alignment.Left ? ContentAlignment.MiddleLeft : ContentAlignment.MiddleRight) }; control.Tag = columnIndex; control.ContextMenuStrip = contextMenuStrip1; return(control); }
public ColumnDisplay(int size, ColumnDisplay.Alignment alignment) { Size = Math.Abs(size); Alignement = alignment; }