private int GetColumnBestHeight(GridBand column, int width, DevExpress.Utils.AppearanceObject app) { GridBandInfoArgs ex = null; BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo; viewInfo.GInfo.AddGraphics(null); ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); ex.SetAppearance(app); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, (int)(width - 10 * DpiXRel), 1000); } finally { viewInfo.GInfo.ReleaseGraphics(); } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; int Height = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); return(Height); }
protected int[] GetCharWidths() { GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); int[] widths = DevExpress.Utils.Text.TextUtils.GetMeasureString(info.Graphics, Text, Appearance.Font); info.ReleaseGraphics(); return(widths); }
private bool IsButtonRect(Point point, GridColumn column) { GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; GridColumnInfoArgs columnArgs = viewInfo.ColumnsInfo[column]; Rectangle buttonRect = CalcButtonRect(columnArgs, info.Graphics); info.ReleaseGraphics(); return(buttonRect.Contains(point)); }
private int GetColumnBestHeight(GridBand column, int width /*, GridBand parent_column*/) { /*GridBandInfoArgs ex = null; * * if (parent_column == null) * ex = viewInfo.BandsInfo[column]; * else * ex = viewInfo.BandsInfo[parent_column].Children[column]; * * GraphicsInfo grInfo = new GraphicsInfo(); * grInfo.AddGraphics(null); * ex.Cache = grInfo.Cache; * bool canDrawMore = true; * Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); * Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); * res.Height = Math.Max(res.Height, captionSize.Height); * res.Width += captionSize.Width; * //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; * grInfo.ReleaseGraphics(); * return res.Height;*/ GridBandInfoArgs ex = null; BandedGridViewInfo viewInfo = GridView.GetViewInfo() as BandedGridViewInfo; viewInfo.GInfo.AddGraphics(null); ex = new GridBandInfoArgs(null, viewInfo.GInfo.Cache); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); ex.SetAppearance(GridView.Appearance.BandPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, width, 1000); } finally { viewInfo.GInfo.ReleaseGraphics(); } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); return(captionSize.Height); }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; grInfo.ReleaseGraphics(); return(res.Height); }
void CalcMessageBounds() { int messageTop, messageLeft, messageWidth, messageHeight; messageTop = Spacing; messageLeft = (icon == null) ? Spacing : (this.iconRectangle.Left + this.iconRectangle.Width + Spacing); int maxFormWidth = this.MaximumSize.Width; if (maxFormWidth <= 0) { maxFormWidth = SystemInformation.WorkingArea.Width; } int maxTextWidth = maxFormWidth - Spacing - messageLeft; if (maxTextWidth < 10) { maxTextWidth = 10; } GraphicsInfo ginfo = new GraphicsInfo(); ginfo.AddGraphics(null); SizeF textSize = GetPaintAppearance().CalcTextSize(ginfo.Graphics, labelText, maxTextWidth); ginfo.ReleaseGraphics(); messageWidth = (int)Math.Ceiling(textSize.Width); int maxFormHeight = this.MaximumSize.Height; if (maxFormHeight <= 0) { maxFormHeight = SystemInformation.WorkingArea.Height; } int maxTextHeight = maxFormHeight - Spacing - ButtonsLayouter.ButtonHeight - Spacing - messageTop - SystemInformation.CaptionHeight; if (maxTextHeight < 10) { maxTextHeight = 10; } messageHeight = (int)Math.Ceiling(textSize.Height); if (messageHeight > maxTextHeight) { messageHeight = maxTextHeight; } messageWidth = messageWidth < memoWidth ? memoWidth : messageWidth; this.messageRectangle = new Rectangle(messageLeft, messageTop, messageWidth, messageHeight); }
private int GetColumnBestHeight(DevExpress.XtraGrid.Columns.GridColumn column) { try { DevExpress.XtraGrid.Views.Grid.ViewInfo.GridViewInfo viewInfo = GridView.GetViewInfo() as GridViewInfo; GridColumnInfoArgs ex = null; viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); ex.SetAppearance(GridView.Appearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, (int)(column.VisibleWidth - 10 * DpiXRel), 1000); } finally { viewInfo.GInfo.ReleaseGraphics(); } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.Caption); bool canDrawMore = true; Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; if (viewInfo.Painter != null) { res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; m_dictColumnHeight[column.Name] = res.Height; return(res.Height); } } catch (Exception ex) { MyLocalizer.XtraMessageBoxShow("В программе произошла ошибка. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(-1); }
private void CalcMessageBounds() { int y = Spacing; int x = (this.Message.Icon == null) ? Spacing : ((this.iconRectangle.Left + this.iconRectangle.Width) + Spacing); int width = this.MaximumSize.Width; if (width <= 0) { //width = SystemInformation.WorkingArea.Width; width = SystemInformation.WorkingArea.Width / 2; } int num6 = (width - Spacing) - x; if (num6 < 10) { num6 = 10; } GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); SizeF ef = this.GetPaintAppearance().CalcTextSize(info.Graphics, this.Message.Text, num6); info.ReleaseGraphics(); int num3 = (int)Math.Ceiling((double)ef.Width); int height = this.MaximumSize.Height; if (height <= 0) { height = SystemInformation.WorkingArea.Height; } int num8 = ((((height - Spacing) - this.buttons[0].Height) - Spacing) - y) - SystemInformation.CaptionHeight; if (num8 < 10) { num8 = 10; } int num4 = (int)Math.Ceiling((double)ef.Height); if (num4 > num8) { num4 = num8; } this.messageRectangle = new Rectangle(x, y, num3, num4); }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column, int height) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; if (ex == null) { viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); if (viewInfo.View.CanShowFilterButton(null)) { ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs()); } ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17); } finally { viewInfo.GInfo.ReleaseGraphics(); } } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); //res.Height = Math.Max(res.Height, captionSize.Height); res.Height = height; res.Width += captionSize.Width; //res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; //res =new Size(180, 33); grInfo.ReleaseGraphics(); return(res.Height); }
protected void colorPickEdit1_Paint(object sender, PaintEventArgs e) { var edit = (ColorPickEdit)sender; var viewInfo = (ColorEditViewInfo)edit.GetViewInfo(); var info = new GraphicsInfo(); info.AddGraphics(e.Graphics); var color = edit.Color.IsEmpty ? Color.White : edit.Color; using (var brush = new SolidBrush(color)) { info.Cache.FillRectangle(brush, viewInfo.ContentRect); } if (edit.Color.IsEmpty) { using (var brush = new SolidBrush(Color.FromArgb(135, 146, 159))) { info.Cache.DrawString("Default", DefaultFont, brush, viewInfo.ContentRect); } } info.ReleaseGraphics(); }
private int[] GetValuesWidths(Font font, string[] values) { GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); int[] widths = new int[values.Length]; int separatorWidth = GetSeparatorWidth(font, separatorChar, info.Graphics); for (int i = 0; i < values.Length - 1; i++) { widths.SetValue(DevExpress.Utils.Text.TextUtils.GetStringSize(info.Graphics, values[i], font).Width + separatorWidth, i); } widths.SetValue(DevExpress.Utils.Text.TextUtils.GetStringSize(info.Graphics, values[values.Length - 1], font).Width, values.Length - 1); info.ReleaseGraphics(); return(widths); }
private int GetColumnBestHeight(GridViewInfo viewInfo, GridColumn column) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[column]; if (ex == null) { viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); if (viewInfo.View.CanShowFilterButton(null)) { ex.InnerElements.Add(viewInfo.Painter.ElementsPainter.FilterButton, new GridFilterButtonInfoArgs()); } ex.SetAppearance(viewInfo.PaintAppearance.HeaderPanel); ex.Caption = column.Caption; ex.CaptionRect = new Rectangle(0, 0, column.Width - 20, 17); } finally { viewInfo.GInfo.ReleaseGraphics(); } } GraphicsInfo grInfo = new GraphicsInfo(); grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, column.GetCaption()); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width += captionSize.Width; res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; grInfo.ReleaseGraphics(); return res.Height; }
void CalcFinalSizes() { int buttonsTotalWidth = 0; foreach (SimpleButton button in buttons) { if (buttonsTotalWidth != 0) { buttonsTotalWidth += Spacing; } buttonsTotalWidth += button.Width; } int buttonsTop = this.messageRectangle.Bottom + 2 * Spacing; int wantedFormWidth = this.MinimumSize.Width; if (wantedFormWidth == 0) { wantedFormWidth = SystemInformation.MinimumWindowSize.Width; } int messageRectangleRight = this.messageRectangle.Right; if (messageRectangleRight < memoWidth) { messageRectangleRight = memoWidth; } if (wantedFormWidth < messageRectangleRight + Spacing) { wantedFormWidth = messageRectangleRight + Spacing; } if (wantedFormWidth < buttonsTotalWidth + Spacing + Spacing) { wantedFormWidth = buttonsTotalWidth + Spacing + Spacing; } GraphicsInfo ginfo = new GraphicsInfo(); ginfo.AddGraphics(null); try { using (StringFormat fmt = TextOptions.DefaultStringFormat.Clone() as StringFormat) { fmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; using (Font captionFont = ControlUtils.GetCaptionFont()) { int maxCaptionForcedWidth = SystemInformation.WorkingArea.Width / 3 * 2; int captionTextWidth = 1 + 4 + (int)ginfo.Cache.CalcTextSize(this.Text, captionFont, fmt, 0).Width; int captionTextWidthWithButtonsAndSpacing = captionTextWidth + SystemInformation.CaptionButtonSize.Width * 5 / 4; int captionWidth = Math.Min(maxCaptionForcedWidth, captionTextWidthWithButtonsAndSpacing); if (wantedFormWidth < captionWidth) { wantedFormWidth = captionWidth; } } } } finally { ginfo.ReleaseGraphics(); } this.Width = wantedFormWidth + 2 * SystemInformation.FixedFrameBorderSize.Width; this.Height = memoHeigth + buttonsTop + buttons[0].Height + Spacing + 2 * SystemInformation.FixedFrameBorderSize.Height + SystemInformation.CaptionHeight; int nextButtonPos = (this.Width - buttonsTotalWidth) / 2; for (int i = 0; i < buttons.Length; ++i) { buttons[i].Location = new Point(nextButtonPos, buttonsTop + memoHeigth); nextButtonPos += buttons[i].Width + Spacing; } if (icon == null) { this.messageRectangle.Offset((wantedFormWidth - (messageRectangleRight + Spacing)) / 2, 0); } if (icon != null && this.messageRectangle.Height < this.iconRectangle.Height) { this.messageRectangle.Offset(0, (this.iconRectangle.Height - this.messageRectangle.Height) / 2); } }
private bool IsButtonRect(Point point, GridColumn column) { GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); GridViewInfo viewInfo = view.GetViewInfo() as GridViewInfo; GridColumnInfoArgs columnArgs = viewInfo.ColumnsInfo[column]; Rectangle buttonRect = CalcButtonRect(columnArgs, info.Graphics); info.ReleaseGraphics(); return buttonRect.Contains(point); }
private int GetRowBestHeight(GridView _view, int row) { GridViewInfo viewInfo = _view.GetViewInfo() as GridViewInfo; int height = 0; for (int i = 0; i < _view.VisibleColumns.Count; i++) { GridColumnInfoArgs ex = viewInfo.ColumnsInfo[_view.Columns[i]]; if (ex == null) { viewInfo.GInfo.AddGraphics(null); ex = new GridColumnInfoArgs(viewInfo.GInfo.Cache, null); try { ex.InnerElements.Add(new DrawElementInfo(new GlyphElementPainter(), new GlyphElementInfoArgs(viewInfo.View.Images, 0, null), StringAlignment.Near)); viewInfo.PaintAppearance.Row.TextOptions.WordWrap = WordWrap.Wrap; if (viewInfo.PaintAppearance.Row.Font.Size < _view.Columns[i].AppearanceCell.Font.Size) { ex.SetAppearance(_view.Columns[i].AppearanceCell); } else { ex.SetAppearance(viewInfo.PaintAppearance.Row); } ex.Caption = Convert.ToString(_view.GetRowCellValue(row, _view.Columns[i])); ex.CaptionRect = new Rectangle(0, 0, _view.Columns[i].Width - 20, 17); } finally { viewInfo.GInfo.ReleaseGraphics(); } } GraphicsInfo grInfo = new GraphicsInfo(); ex.Appearance.TextOptions.WordWrap = WordWrap.Wrap; grInfo.AddGraphics(null); ex.Cache = grInfo.Cache; bool canDrawMore = true; string s; if (_view.Columns[i].ColumnEdit is RepositoryItemGridLookUpEdit) { RepositoryItemGridLookUpEdit Rep = _view.Columns[i].ColumnEdit as RepositoryItemGridLookUpEdit; s = Rep.GetDisplayTextByKeyValue(_view.GetRowCellValue(row, _view.Columns[i])); } else { String sf; s = Convert.ToString(_view.GetRowCellValue(row, _view.Columns[i])); if (_view.GetRowCellValue(row, _view.Columns[i]) is DateTime) { s = s.Substring(0, s.Length / 2); } } Size captionSize = CalcCaptionTextSize(grInfo.Cache, ex as HeaderObjectInfoArgs, s); Size res = ex.InnerElements.CalcMinSize(grInfo.Graphics, ref canDrawMore); res.Height = Math.Max(res.Height, captionSize.Height); res.Width = Math.Max(res.Width, captionSize.Width); res = viewInfo.Painter.ElementsPainter.Column.CalcBoundsByClientRectangle(ex, new Rectangle(Point.Empty, res)).Size; grInfo.ReleaseGraphics(); height = Math.Max(height, res.Height); } return(height); }
void CalcFinalSizes() { int buttonsTotalWidth = 0; foreach (SimpleButton button in buttons) { if (buttonsTotalWidth != 0) { buttonsTotalWidth += Spacing; } buttonsTotalWidth += button.Width; } int buttonsTop = this.messageRectangle.Bottom + Spacing; if (Message.Icon != null && (this.iconRectangle.Bottom + Spacing > buttonsTop)) { buttonsTop = this.iconRectangle.Bottom + Spacing; } int wantedFormWidth = this.MinimumSize.Width; if (wantedFormWidth == 0) { wantedFormWidth = SystemInformation.MinimumWindowSize.Width; } if (wantedFormWidth < this.messageRectangle.Right + Spacing) { wantedFormWidth = this.messageRectangle.Right + Spacing; } if (wantedFormWidth < buttonsTotalWidth + Spacing + Spacing) { wantedFormWidth = buttonsTotalWidth + Spacing + Spacing; } GraphicsInfo ginfo = new GraphicsInfo(); ginfo.AddGraphics(null); try { using (StringFormat fmt = TextOptions.DefaultStringFormat.Clone() as StringFormat) { fmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; using (Font captionFont = GetCaptionFont()) { int captionTextWidth = (int)Math.Ceiling(ginfo.Cache.CalcTextSize(this.Text, captionFont, fmt, 0).Width); int captionTextWidthWithMargins = captionTextWidth + GetBordersSizes().Width; int captionTextWidthWithButtonsAndSpacing = captionTextWidthWithMargins; if (this.ControlBox) { captionTextWidthWithButtonsAndSpacing += GetCloseButtonWidth(); } captionTextWidthWithButtonsAndSpacing += 2; int maxCaptionForcedWidth = SystemInformation.WorkingArea.Width / 3 * 2; int captionWidth = Math.Min(maxCaptionForcedWidth, captionTextWidthWithButtonsAndSpacing); if (wantedFormWidth < captionWidth) { wantedFormWidth = captionWidth; } } } } finally { ginfo.ReleaseGraphics(); } this.Width = wantedFormWidth + GetBordersSizes().Width; this.Height = buttonsTop + buttons[0].Height + Spacing + GetBordersSizes().Height; int nextButtonPos = (wantedFormWidth - buttonsTotalWidth) / 2; for (int i = 0; i < buttons.Length; ++i) { buttons[i].Location = new Point(nextButtonPos, buttonsTop); nextButtonPos += buttons[i].Width + Spacing; } if (Message.Icon == null) { this.messageRectangle.Offset((wantedFormWidth - (this.messageRectangle.Right + Spacing)) / 2, 0); } if (Message.Icon != null && this.messageRectangle.Height < this.iconRectangle.Height) { this.messageRectangle.Offset(0, (this.iconRectangle.Height - this.messageRectangle.Height) / 2); } }
private void CalcFinalSizes() { int num = 0; foreach (SimpleButton button in this.buttons) { if (num != 0) { num += Spacing; } num += button.Width; } int y = this.messageRectangle.Bottom + Spacing; if ((this.Message.Icon != null) && ((this.iconRectangle.Bottom + Spacing) > y)) { y = this.iconRectangle.Bottom + Spacing; } int width = this.MinimumSize.Width; if (width == 0) { width = SystemInformation.MinimumWindowSize.Width; } if (width < (this.messageRectangle.Right + Spacing)) { width = this.messageRectangle.Right + Spacing; } if (width < ((num + Spacing) + Spacing)) { width = (num + Spacing) + Spacing; } GraphicsInfo info = new GraphicsInfo(); info.AddGraphics(null); try { using (StringFormat format = TextOptions.DefaultStringFormat.Clone() as StringFormat) { format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; using (Font font = ControlUtils.GetCaptionFont()) { int num4 = (SystemInformation.WorkingArea.Width / 3) * 2; int num5 = 5 + ((int)info.Cache.CalcTextSize(this.Text, font, format, 0).Width); int num6 = num5 + ((SystemInformation.CaptionButtonSize.Width * 5) / 4); int num7 = Math.Min(num4, num6); if (width < num7) { width = num7; } } } } finally { info.ReleaseGraphics(); } base.Width = width + (2 * SystemInformation.FixedFrameBorderSize.Width); base.Height = (((y + this.buttons[0].Height) + Spacing) + (2 * SystemInformation.FixedFrameBorderSize.Height)) + SystemInformation.CaptionHeight; int x = (width - num) / 2; for (int i = 0; i < this.buttons.Length; i++) { this.buttons[i].Location = new Point(x, y); x += this.buttons[i].Width + Spacing; } if (this.Message.Icon == null) { this.messageRectangle.Offset((width - (this.messageRectangle.Right + Spacing)) / 2, 0); } if ((this.Message.Icon != null) && (this.messageRectangle.Height < this.iconRectangle.Height)) { this.messageRectangle.Offset(0, (this.iconRectangle.Height - this.messageRectangle.Height) / 2); } }