/// <summary> /// 컨트롤을 부모컨트롤에 정렬을 한다. /// </summary> /// <param name="ctrl"></param> /// <param name="ali"></param> public static void ControlAlign(Control ctrl, System.Drawing.ContentAlignment ali) { //부모가 없으면 안된다. if (ctrl.Parent == null) { return; } System.Drawing.StringAlignment H; System.Drawing.StringAlignment V; int al = (int)ali; //세로 정리 switch (ali) { case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.TopRight: V = System.Drawing.StringAlignment.Near; break; case System.Drawing.ContentAlignment.MiddleRight: case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.MiddleCenter: V = System.Drawing.StringAlignment.Center; break; default: V = System.Drawing.StringAlignment.Far; break; } //가로 정리 switch (ali) { case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.BottomLeft: H = System.Drawing.StringAlignment.Near; break; case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.BottomCenter: H = System.Drawing.StringAlignment.Center; break; default: H = System.Drawing.StringAlignment.Far; break; } Control p = ctrl.Parent; ctrl.Left = ControlAlign_GetValue(p.Width, ctrl.Width, H); ctrl.Top = ControlAlign_GetValue(p.Height, ctrl.Height, V); }
/// <summary> /// 컨트롤 위치를 정렬한다. - 부모 컨트롤 사이즈가 변경시 마다 정렬을 하여 준다 /// </summary> /// <param name="ctrl"></param> /// <param name="ali"></param> public static void Control_SetAlignment(Control ctrl, System.Drawing.ContentAlignment ali) { if (ctrl.Parent == null) { return; } if (SetAlignment_ArrList == null) { SetAlignment_ArrList = new System.Collections.Generic.Dictionary <Control, System.Drawing.ContentAlignment>(); } if (SetAlignment_ParArrList == null) { SetAlignment_ParArrList = new System.Collections.Generic.List <Control>(); } if (!SetAlignment_ParArrList.Contains(ctrl.Parent)) { ctrl.Parent.SizeChanged += Parent_SizeChanged; SetAlignment_ParArrList.Add(ctrl.Parent); } if (!SetAlignment_ArrList.ContainsKey(ctrl)) { SetAlignment_ArrList.Add(ctrl, ali); } }
public FlatButton(string name, bool small = false, System.Drawing.ContentAlignment texAlign = System.Drawing.ContentAlignment.MiddleCenter) { Name = "btn" + name; //FlatAppearance.BorderColor = System.Drawing.Color.White; FlatAppearance.BorderSize = 0; FlatAppearance.MouseDownBackColor = colors.DarkGray1; FlatAppearance.MouseOverBackColor = colors.DarkGray1; FlatStyle = System.Windows.Forms.FlatStyle.Flat; ForeColor = colors.White1; Location = new System.Drawing.Point(0, 0); Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); TextAlign = texAlign; Font = new System.Drawing.Font("Microsoft YaHei UI", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Size = new System.Drawing.Size(120, 63); if (small) { Font = new System.Drawing.Font("Microsoft YaHei UI", 10.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Size = new System.Drawing.Size(120, 30); } Text = name; UseVisualStyleBackColor = true; BackColor = colors.Blue1; // Click += new System.EventHandler(this.btnNext_Click); }
/// <summary> /// 화면에 메시지 창을 띄운다. /// </summary> /// <param name="msg">메시지</param> /// <param name="monitor">띄울 모니터 번호</param> /// <param name="align">창 위치</param> /// <param name="autoclose">자동을 닫힐 시간 ms, 0:자동으로 안 닫힘</param> public static void NoticePopUp(string msg, int monitor = 0, System.Drawing.ContentAlignment align = System.Drawing.ContentAlignment.BottomRight , int autoclose = 0, Form frm = null, delNoticePopUp_CMD cmd = null) { if (frm != null) { if (frm.InvokeRequired) { frm.Invoke(new delNoticePopUp(NoticePopUp), msg, monitor, align, autoclose, frm, cmd); return; } } Function.form.popNotice p = new form.popNotice(msg, monitor, align, autoclose); p.OnNoticePopUp_CMD = cmd; if (frm != null) { p.Show(frm); } else { p.Show(); } }
public virtual Tuple <HorizontalAlignment, VerticalAlignment> Parse(System.Drawing.ContentAlignment alignment) { switch (alignment) { case System.Drawing.ContentAlignment.BottomCenter: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.BottomLeft: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.BottomRight: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.MiddleCenter: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.MiddleLeft: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.MiddleRight: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.TopLeft: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.TopCenter: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); case System.Drawing.ContentAlignment.TopRight: return(new Tuple <HorizontalAlignment, VerticalAlignment>(HorizontalAlignment.Center, VerticalAlignment.Bottom)); } throw new ArgumentOutOfRangeException("alignment"); }
public static TextFormatFlags GetAlignmentFlags(System.Drawing.ContentAlignment alignment) { switch (alignment) { case System.Drawing.ContentAlignment.BottomCenter: return(TextFormatFlags.HorizontalCenter | TextFormatFlags.Bottom); case System.Drawing.ContentAlignment.BottomLeft: return(TextFormatFlags.Left | TextFormatFlags.Bottom); case System.Drawing.ContentAlignment.BottomRight: return(TextFormatFlags.Right | TextFormatFlags.Bottom); case System.Drawing.ContentAlignment.MiddleCenter: return(TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); case System.Drawing.ContentAlignment.MiddleLeft: return(TextFormatFlags.Left | TextFormatFlags.VerticalCenter); case System.Drawing.ContentAlignment.MiddleRight: return(TextFormatFlags.Right | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); case System.Drawing.ContentAlignment.TopCenter: return(TextFormatFlags.HorizontalCenter | TextFormatFlags.Top); case System.Drawing.ContentAlignment.TopLeft: return(TextFormatFlags.Left | TextFormatFlags.Top); case System.Drawing.ContentAlignment.TopRight: return(TextFormatFlags.Right | TextFormatFlags.Top); } return(TextFormatFlags.Default); }
public static void ContentToHorzVertAlign(System.Drawing.ContentAlignment ca, out HorizontalAlignment horz, out VerticalAlignment vert) { switch (ca) { case System.Drawing.ContentAlignment.TopLeft: horz = HorizontalAlignment.Left; vert = VerticalAlignment.Top; break; case System.Drawing.ContentAlignment.TopCenter: horz = HorizontalAlignment.Center; vert = VerticalAlignment.Top; break; case System.Drawing.ContentAlignment.TopRight: horz = HorizontalAlignment.Right; vert = VerticalAlignment.Top; break; case System.Drawing.ContentAlignment.MiddleLeft: horz = HorizontalAlignment.Left; vert = VerticalAlignment.Center; break; case System.Drawing.ContentAlignment.MiddleCenter: horz = HorizontalAlignment.Center; vert = VerticalAlignment.Center; break; case System.Drawing.ContentAlignment.MiddleRight: horz = HorizontalAlignment.Right; vert = VerticalAlignment.Center; break; case System.Drawing.ContentAlignment.BottomLeft: horz = HorizontalAlignment.Left; vert = VerticalAlignment.Bottom; break; case System.Drawing.ContentAlignment.BottomCenter: horz = HorizontalAlignment.Center; vert = VerticalAlignment.Bottom; break; case System.Drawing.ContentAlignment.BottomRight: horz = HorizontalAlignment.Right; vert = VerticalAlignment.Bottom; break; default: System.Diagnostics.Debug.Assert(false, "Unknown content alignment"); goto case System.Drawing.ContentAlignment.TopLeft; } }
static public void setButtonTextAlignment(System.Drawing.ContentAlignment contentAlignment, Form form, ref Kbtn kbtn) { //Então, como você pode ver, o burro aqui tentou definir para todos os botões kbtn do formulário. Esse método será usado posteriormente para apenas um botão naquele sistema de clicar na propriedade //e depois no botão para aplicá-lo a propriedade (se o <UX DESIGNER> deixar). //foreach (Control c in form.Controls) //{ // if (c is Kbtn) // { // (c as Button).TextAlign = contentAlignment; // } //} }
/// <summary> /// ContentAlignment tipini VerticalAlignment tipine çevirir /// </summary> /// <param name="alignment">Çevirilecek tip</param> /// <returns>VerticalAlignment tipinde dönüş yapar</returns> public static VerticalAlignment ContentAligmentToVerticalAlign(System.Drawing.ContentAlignment alignment) { if ((alignment & (System.Drawing.ContentAlignment.MiddleLeft | System.Drawing.ContentAlignment.MiddleCenter | System.Drawing.ContentAlignment.MiddleRight)) != 0) { return(VerticalAlignment.Center); } else if ((alignment & (System.Drawing.ContentAlignment.BottomLeft | System.Drawing.ContentAlignment.BottomCenter | System.Drawing.ContentAlignment.BottomRight)) != 0) { return(VerticalAlignment.Bottom); } return(VerticalAlignment.Top); }
/// <summary> /// ContentAlignment tipini HorizontalAlign tipine çevirir /// </summary> /// <param name="alignment">Çevirilecek tip</param> /// <returns>HorizontalAlign tipinde dönüş yapar</returns> public static HorizontalAlign ContentAligmentToHorizontalAlign(System.Drawing.ContentAlignment alignment) { if ((alignment & (System.Drawing.ContentAlignment.TopCenter | System.Drawing.ContentAlignment.MiddleCenter | System.Drawing.ContentAlignment.BottomCenter)) != 0) { return(HorizontalAlign.Center); } else if ((alignment & (System.Drawing.ContentAlignment.TopRight | System.Drawing.ContentAlignment.MiddleRight | System.Drawing.ContentAlignment.BottomRight)) != 0) { return(HorizontalAlign.Right); } return(HorizontalAlign.Left); }
/// <summary> /// Determines if the <paramref name="contentAlignment" /> parameter is one of the defined enumerations. This method is /// more efficient than using <see cref="Enum.IsDefined" />, since <see cref="Enum.IsDefined" /> uses reflection. /// </summary> /// <param name="contentAlignment">A of <see cref="System.Drawing.ContentAlignment" /> to test.</param> /// <returns>Returns true if contentAlignment is one of the defined items in the enumeration; otherwise returns false.</returns> public static bool IsValidContentAlignment(System.Drawing.ContentAlignment contentAlignment) { switch (contentAlignment) { case System.Drawing.ContentAlignment.BottomCenter: case System.Drawing.ContentAlignment.BottomLeft: case System.Drawing.ContentAlignment.BottomRight: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.MiddleRight: case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.TopRight: break; default: return(false); } return(true); }
private static ParagraphAlignment ToParagraphAlignment(System.Drawing.ContentAlignment alignment) { switch (alignment) { case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.TopRight: return(ParagraphAlignment.Near); case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.MiddleRight: return(ParagraphAlignment.Center); case System.Drawing.ContentAlignment.BottomLeft: case System.Drawing.ContentAlignment.BottomCenter: case System.Drawing.ContentAlignment.BottomRight: return(ParagraphAlignment.Far); default: throw new InvalidEnumArgumentException(nameof(alignment), (int)alignment, typeof(System.Drawing.ContentAlignment)); } }
public System.Drawing.SizeF MeasureString(string text, System.Drawing.Font font, System.Drawing.ContentAlignment alignment) { var format = CreateTextFormat(font); format.TextAlignment = ToTextAlignment(alignment); format.ParagraphAlignment = ToParagraphAlignment(alignment); var metricsLayout = new TextLayout(_writeFactory, text, format, float.MaxValue, float.MaxValue); var height = metricsLayout.Metrics.Height; var width = metricsLayout.Metrics.Width; _frameResources.Add(metricsLayout); return(new System.Drawing.SizeF(width, height)); }
protected override void RenderChart(System.Drawing.Graphics graphics, Palette palette, Bamboo.Css.StyleStack styleStack, System.Drawing.RectangleF rectangle, string title, Bamboo.DataStructures.Table table) { styleStack.PushTag("Table"); string backColor = (string)styleStack["BackColor"]; Bamboo.Css.Font font = (Bamboo.Css.Font)styleStack["Font"]; string foreColor = (string)styleStack["ForeColor"]; int padding = (int)styleStack["Padding"]; //TODO put in stylesheet System.Drawing.Font titleFont = palette.Font(font.Name, font.Size * 1.2f, System.Drawing.FontStyle.Bold); System.Drawing.Pen backColorPen = palette.Pen(backColor); System.Drawing.Brush backColorBrush = palette.Brush(backColor); System.Drawing.Brush foreColorBrush = palette.Brush(foreColor); // Background graphics.DrawRectangle(backColorPen, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); graphics.FillRectangle(backColorBrush, rectangle); rectangle = new System.Drawing.RectangleF(rectangle.Left + padding, rectangle.Top + padding, rectangle.Width - padding - padding, rectangle.Height - padding - padding); // Title if (title != null) { rectangle = DrawTitle(title, titleFont, foreColorBrush, graphics, rectangle); } List <Cell[]> cellsList = new List <Cell[]>(); Cell[] cells; int x; int y = 0; // // Get a table of column headers. // int[] columnHeaders = new int[this._columnColumns.Count]; for (int i = 0; i < columnHeaders.Length; i++) { columnHeaders[i] = i; } Bamboo.DataStructures.Table columnHeadersTable = Bamboo.Sql2.Iterators.GroupByIterator.Group(table, columnHeaders); // // Calculate the width of the cell arrays (i.e., table rows). // int width = (this._columnColumns.Count == 0) ? this._rowColumns.Count + this._dataColumns.Count : this._rowColumns.Count + (columnHeadersTable.Rows.Count * this._dataColumns.Count); // // Create the column headers. // styleStack.PushTag("Header"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; System.Drawing.ContentAlignment textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int i = 0; i < this._columnColumns.Count; i++) { cells = new Cell[width]; cellsList.Add(cells); x = this._rowColumns.Count; Bamboo.DataStructures.Tuple row = null; for (int j = 0; j < columnHeadersTable.Rows.Count; j++) { Bamboo.DataStructures.Tuple row2 = columnHeadersTable.Rows[j]; if (row == null || !row.Equals(0, row2, 0, i + 1)) { //TODO push header // Bamboo.Css.StyleRule styleRule = GetStyle(styleSheet, "Header", this2._columnColumns, row2, i + 1); cells[x].HasValue = true; cells[x].Type = CellType.Header; cells[x].Colspan = this._dataColumns.Count; cells[x].Rowspan = 1; cells[x].Value = row2[i]; // if (styleRule == null) // { cells[x].BackgroundColor = backColor; cells[x].ForegroundColor = foreColor; cells[x].TextAlign = textAlign; // } // else // { // cells[x].BackgroundColor = (string)styleRule["BackColor"]; // cells[x].ForegroundColor = (string)styleRule["ForeColor"]; // cells[x].TextAlign = (System.Drawing.ContentAlignment)styleRule["TextAlign"]; // } } else { int k = 1; int index = x - k; k++; while (cells[index].Colspan == 0) { index = x - k; k++; } cells[index].Colspan += this._dataColumns.Count; } row = row2; x += this._dataColumns.Count; } y++; } cells = new Cell[width]; cellsList.Add(cells); x = this._rowColumns.Count; for (int i = 0; i < Math.Max(columnHeadersTable.Rows.Count, 1); i++) { for (int k = 0; k < this._dataColumns.Count; k++) { // Bamboo.Css.StyleRule styleRule = GetStyle(styleSheet, new Statibase.Tuple(new object[] { this2._dataColumns[k] }), 0, 1); cells[x].HasValue = true; cells[x].Type = CellType.Header; cells[x].Colspan = 1; cells[x].Rowspan = 1; cells[x].Value = this._dataColumns[k]; // if (styleRule == null) // { cells[x].BackgroundColor = backColor; cells[x].ForegroundColor = foreColor; cells[x].TextAlign = textAlign; // } // else // { // cells[x].BackgroundColor = (string)styleRule["BackColor"]; // cells[x].ForegroundColor = (string)styleRule["ForeColor"]; // cells[x].TextAlign = (System.Drawing.ContentAlignment)styleRule["TextAlign"]; // } x++; } } y++; styleStack.PopTag(); backColor = (string)styleStack["BackColor"]; // // Add the empty cell if necessary. // if (this._rowColumns.Count > 0) { cellsList[0][0].HasValue = true; cellsList[0][0].Type = CellType.Empty; cellsList[0][0].Colspan = this._rowColumns.Count; cellsList[0][0].Rowspan = this._columnColumns.Count + 1; cellsList[0][0].BackgroundColor = backColor; } // // Get a table of row headers. // int[] rowHeadersPlusData = new int[this._columnColumns.Count + this._rowColumns.Count + this._dataColumns.Count]; int ii = 0; for (int i = 0; i < this._rowColumns.Count; i++) { rowHeadersPlusData[ii] = this._columnColumns.Count + i; ii++; } for (int i = 0; i < this._columnColumns.Count; i++) { rowHeadersPlusData[ii] = i; ii++; } for (int i = 0; i < this._dataColumns.Count; i++) { rowHeadersPlusData[ii] = this._columnColumns.Count + this._rowColumns.Count + i;; ii++; } table = Bamboo.Sql2.Iterators.OrderByIterator.Sort(table, rowHeadersPlusData); // // Fill in the row headers and data. // if (this._rowColumns.Count > 0) { int[] rowHeaderIndexes = new int[this._rowColumns.Count]; int[] yPositions = new int[columnHeadersTable.Rows.Count + 1]; cells = new Cell[width]; styleStack.PushTag("Header"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int j = 0; j < this._rowColumns.Count; j++) { // Bamboo.Css.StyleRule styleRule = GetStyle(styleSheet, table.Rows[0], this2._columnColumns.Count + j, 1); cells[j].HasValue = true; cells[j].Type = CellType.Header; cells[j].Colspan = 1; cells[j].Rowspan = 1; cells[j].Value = table.Rows[0][this._columnColumns.Count + j]; // if (styleRule == null) // { cells[j].BackgroundColor = backColor; cells[j].ForegroundColor = foreColor; cells[j].TextAlign = textAlign; // } // else // { // cells[j].BackgroundColor = (string)styleRule["BackColor"]; // cells[j].ForegroundColor = (string)styleRule["ForeColor"]; // cells[j].TextAlign = (System.Drawing.ContentAlignment)styleRule["TextAlign"]; // } rowHeaderIndexes[j] = cellsList.Count; } styleStack.PopTag(); styleStack.PushTag("Cell"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int k = this._rowColumns.Count; k < width; k++) { cells[k].HasValue = true; cells[k].Type = CellType.Cell; cells[k].Colspan = 1; cells[k].Rowspan = 1; cells[k].BackgroundColor = backColor; cells[k].ForegroundColor = foreColor; cells[k].TextAlign = textAlign; } styleStack.PopTag(); for (int l = 0; l < yPositions.Length; l++) { yPositions[l] = cellsList.Count; } cellsList.Add(cells); Bamboo.DataStructures.Tuple previousRow = null; for (int i = 0; i < table.Rows.Count; i++) { Bamboo.DataStructures.Tuple row = table.Rows[i]; if (previousRow != null) { for (int j = 0; j < this._rowColumns.Count; j++) { //TODO use an array of values instead of fetching the last row. if (!cellsList[rowHeaderIndexes[j]][j].Value.Equals(row[this._columnColumns.Count + j])) { // Bamboo.Css.StyleRule styleRule = GetStyle(styleSheet, row, this2._columnColumns.Count + j, 1); styleStack.PushTag("Header"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; // The row keys have changed. Write a new row. cells = new Cell[width]; cells[j].HasValue = true; cells[j].Type = CellType.Header; cells[j].Colspan = 1; cells[j].Rowspan = 1; cells[j].Value = row[this._columnColumns.Count + j]; // if (styleRule == null) // { cells[j].BackgroundColor = backColor; cells[j].ForegroundColor = foreColor; cells[j].TextAlign = textAlign; // } // else // { // cells[j].BackgroundColor = (string)styleRule["BackColor"]; // cells[j].ForegroundColor = (string)styleRule["ForeColor"]; // cells[j].TextAlign = (System.Drawing.ContentAlignment)styleRule["TextAlign"]; // } rowHeaderIndexes[j] = cellsList.Count; for (int k = 0; k < j; k++) { cellsList[rowHeaderIndexes[k]][k].Rowspan++; } for (int k = (j + 1); k < this._rowColumns.Count; k++) { cells[k].HasValue = true; cells[k].Type = CellType.Header; cells[k].Colspan = 1; cells[k].Rowspan = 1; cells[k].Value = row[this._columnColumns.Count + k]; // if (styleRule == null) // { cells[k].BackgroundColor = backColor; cells[k].ForegroundColor = foreColor; cells[k].TextAlign = textAlign; // } // else // { // cells[k].BackgroundColor = (string)styleRule["BackColor"]; // cells[k].ForegroundColor = (string)styleRule["ForeColor"]; // cells[k].TextAlign = (System.Drawing.ContentAlignment)styleRule["TextAlign"]; // } rowHeaderIndexes[k] = cellsList.Count; } styleStack.PopTag(); styleStack.PushTag("Cell"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int k = this._rowColumns.Count; k < width; k++) { cells[k].HasValue = true; cells[k].Type = CellType.Cell; cells[k].Colspan = 1; cells[k].Rowspan = 1; cells[k].BackgroundColor = backColor; cells[k].ForegroundColor = foreColor; cells[k].TextAlign = textAlign; } styleStack.PopTag(); for (int l = 0; l < yPositions.Length; l++) { yPositions[l] = cellsList.Count; } cellsList.Add(cells); break; } } } if (columnHeadersTable.Rows.Count == 0) { int columnNumber = 0; x = (columnNumber * this._dataColumns.Count) + this._rowColumns.Count; y = yPositions[columnNumber]; while (y >= cellsList.Count) { cells = new Cell[width]; for (int k = 0; k < this._rowColumns.Count; k++) { cellsList[rowHeaderIndexes[k]][k].Rowspan++; } styleStack.PushTag("Cell"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int k = this._rowColumns.Count; k < width; k++) { cells[k].HasValue = true; cells[k].Type = CellType.Cell; cells[k].Colspan = 1; cells[k].Rowspan = 1; cells[k].BackgroundColor = backColor; cells[k].ForegroundColor = foreColor; cells[k].TextAlign = textAlign; } styleStack.PopTag(); cellsList.Add(cells); } for (int j = 0; j < this._dataColumns.Count; j++) { cellsList[y][x + j].Value = row[this._columnColumns.Count + this._rowColumns.Count + j]; } yPositions[columnNumber]++; } else { for (int m = 0; m < columnHeadersTable.Rows.Count; m++) { Bamboo.DataStructures.Tuple columnRow = columnHeadersTable.Rows[m]; if (row.Equals(0, columnRow, 0, this._columnColumns.Count)) { int columnNumber = m; x = (columnNumber * this._dataColumns.Count) + this._rowColumns.Count; y = yPositions[columnNumber]; while (y >= cellsList.Count) { cells = new Cell[width]; for (int k = 0; k < this._rowColumns.Count; k++) { cellsList[rowHeaderIndexes[k]][k].Rowspan++; } styleStack.PushTag("Cell"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int k = this._rowColumns.Count; k < width; k++) { cells[k].HasValue = true; cells[k].Type = CellType.Cell; cells[k].Colspan = 1; cells[k].Rowspan = 1; cells[k].BackgroundColor = backColor; cells[k].ForegroundColor = foreColor; cells[k].TextAlign = textAlign; } styleStack.PopTag(); cellsList.Add(cells); } for (int j = 0; j < this._dataColumns.Count; j++) { cellsList[y][x + j].Value = row[this._columnColumns.Count + this._rowColumns.Count + j]; } yPositions[columnNumber]++; break; } } } previousRow = row; } } Render(graphics, palette, styleStack, cellsList, rectangle); styleStack.PopTag(); }
// Methods public static bool IsValidContentAlignment(System.Drawing.ContentAlignment contentAlign) { }
public ToolStripItemTextRenderEventArgs(System.Drawing.Graphics g, ToolStripItem item, string text, System.Drawing.Rectangle textRectangle, System.Drawing.Color textColor, System.Drawing.Font textFont, System.Drawing.ContentAlignment textAlign) { }
private LegendCell CreateNewLegendCell(LegendCellType cellType, System.Drawing.Font cellFont, string text, System.Drawing.ContentAlignment cellAlignment) { LegendCell legendCell = new LegendCell(); legendCell.CellType = cellType; legendCell.Font = cellFont; legendCell.Text = text; legendCell.Alignment = cellAlignment; legendCell.ToolTip = Resources.lang.ChartZoomFeature; return(legendCell); }
private static System.Drawing.PointF AlignTextOrigin(System.Drawing.PointF origin, System.Drawing.SizeF size, System.Drawing.ContentAlignment alignment) { float x; switch (alignment) { case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.BottomLeft: x = origin.X; break; case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.BottomCenter: x = origin.X - size.Width; break; case System.Drawing.ContentAlignment.TopRight: case System.Drawing.ContentAlignment.MiddleRight: case System.Drawing.ContentAlignment.BottomRight: x = origin.X - size.Width * 2; break; default: throw new ArgumentOutOfRangeException(nameof(alignment), alignment, null); } float y; switch (alignment) { case System.Drawing.ContentAlignment.TopLeft: case System.Drawing.ContentAlignment.TopCenter: case System.Drawing.ContentAlignment.TopRight: y = origin.Y; break; case System.Drawing.ContentAlignment.MiddleLeft: case System.Drawing.ContentAlignment.MiddleCenter: case System.Drawing.ContentAlignment.MiddleRight: y = origin.Y - size.Height; break; case System.Drawing.ContentAlignment.BottomLeft: case System.Drawing.ContentAlignment.BottomCenter: case System.Drawing.ContentAlignment.BottomRight: y = origin.Y - size.Height * 2; break; default: throw new ArgumentOutOfRangeException(nameof(alignment), alignment, null); } return(new System.Drawing.PointF(x, y)); }
protected override void RenderChart(System.Drawing.Graphics graphics, Palette palette, Bamboo.Css.StyleStack styleStack, System.Drawing.RectangleF rectangle, string title, Bamboo.DataStructures.Table table) { styleStack.PushTag("Table"); string backColor = (string)styleStack["BackColor"]; Bamboo.Css.Font font = (Bamboo.Css.Font)styleStack["Font"]; string foreColor = (string)styleStack["ForeColor"]; int padding = (int)styleStack["Padding"]; //TODO put in stylesheet System.Drawing.Font titleFont = palette.Font(font.Name, font.Size * 1.2f, System.Drawing.FontStyle.Bold); System.Drawing.Pen backColorPen = palette.Pen(backColor); System.Drawing.Brush backColorBrush = palette.Brush(backColor); System.Drawing.Brush foreColorBrush = palette.Brush(foreColor); // Background graphics.DrawRectangle(backColorPen, rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height); graphics.FillRectangle(backColorBrush, rectangle); rectangle = new System.Drawing.RectangleF(rectangle.Left + padding, rectangle.Top + padding, rectangle.Width - padding - padding, rectangle.Height - padding - padding); // Title if (title != null) { rectangle = DrawTitle(title, titleFont, foreColorBrush, graphics, rectangle); } int width = table.Columns.Count; int height = table.Rows.Count; List <Cell[]> cellsList = new List <Cell[]>(height + 1); Cell[] cells; styleStack.PushTag("Header"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; System.Drawing.ContentAlignment textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; cells = new Cell[width]; for (int x = 0; x < width; x++) { cells[x].HasValue = true; cells[x].Type = CellType.Header; cells[x].Colspan = 1; cells[x].Rowspan = 1; cells[x].Value = table.Columns[x]; cells[x].BackgroundColor = backColor; cells[x].ForegroundColor = foreColor; cells[x].TextAlign = textAlign; } cellsList.Add(cells); styleStack.PopTag(); styleStack.PushTag("Cell"); backColor = (string)styleStack["BackColor"]; foreColor = (string)styleStack["ForeColor"]; textAlign = (System.Drawing.ContentAlignment)styleStack["TextAlign"]; for (int y = 0; y < height; y++) { Bamboo.DataStructures.Tuple row = table.Rows[y]; cells = new Cell[width]; for (int x = 0; x < width; x++) { //TODO push cell. cells[x].HasValue = true; cells[x].Type = CellType.Cell; cells[x].Colspan = 1; cells[x].Rowspan = 1; cells[x].Value = row[x]; cells[x].BackgroundColor = backColor; cells[x].ForegroundColor = foreColor; cells[x].TextAlign = textAlign; } cellsList.Add(cells); } styleStack.PopTag(); Render(graphics, palette, styleStack, cellsList, rectangle); styleStack.PopTag(); }
public static void excuteTips(Form form, string strMsg, MessageBoxIcon icon = MessageBoxIcon.Information, System.Drawing.ContentAlignment location = System.Drawing.ContentAlignment.MiddleCenter, int intAutoColseTime = 3000, bool bShowCloseBtn = false) { Wells.WellsMetroControl.Forms.TipsState status = WellsMetroControl.Forms.TipsState.Default; if (icon == MessageBoxIcon.Error) { status = WellsMetroControl.Forms.TipsState.Error; } else if (icon == MessageBoxIcon.Warning) { status = WellsMetroControl.Forms.TipsState.Warning; } else if (icon == MessageBoxIcon.None) { status = WellsMetroControl.Forms.TipsState.Success; } else if (icon == MessageBoxIcon.Information) { status = WellsMetroControl.Forms.TipsState.Info; } Wells.WellsMetroControl.Forms.FrmTips.ShowTips(form, strMsg, intAutoColseTime, bShowCloseBtn, location, null, Wells.WellsMetroControl.Forms.TipsSizeMode.Large, null, status); }
public void DrawString(string text, System.Drawing.PointF origin, System.Drawing.Font font, System.Drawing.Color color, System.Drawing.ContentAlignment alignment, float angle) { var size = MeasureString(text, font, alignment); var format = CreateTextFormat(font); format.TextAlignment = ToTextAlignment(alignment); format.ParagraphAlignment = ToParagraphAlignment(alignment); var transform = Math.Abs(angle) > Math.PI / 180 ? Matrix3x2.Rotation(angle, ToRawVector2(origin)) : (Matrix3x2?)null; var layout = new TextLayout(_writeFactory, text, format, size.Width * 2, size.Height * 2, 1, transform, true); layout.ParagraphAlignment = ToParagraphAlignment(alignment); layout.TextAlignment = ToTextAlignment(alignment); var brush = CreateSolidColorBrush(color); var alignedOrigin = AlignTextOrigin(origin, size, alignment); if (transform.HasValue) { _renderTarget.Transform = transform.Value; } _renderTarget.DrawTextLayout(SnapToGrid(ToRawVector2(alignedOrigin)), layout, brush, DrawTextOptions.None); _renderTarget.Transform = Matrix3x2.Identity; // 2cache? _frameResources.Add(layout); }
public void SetAlignment(System.Drawing.ContentAlignment orient) { ((Label)GetControl()).TextAlign = orient; }
protected System.Drawing.ContentAlignment RtlTranslateContent(System.Drawing.ContentAlignment align);