private void adjustScrollbars() { // Hide scrollbar when not needed. // http://devexpress.com/Support/Center/p/Q96633.aspx // Looking for a Windows Forms solution? // http://stackoverflow.com/questions/73110/how-can-i-show-scrollbars-on-a-system-windows-forms-textbox-only-when-the-text-d var vi = (MemoEditViewInfo)_edit.GetViewInfo(); using (var cache = new GraphicsCache(_edit.CreateGraphics())) { var h = ((IHeightAdaptable)vi).CalcHeight( cache, vi.MaskBoxRect.Width); var args = new ObjectInfoArgs { Bounds = new Rectangle(0, 0, vi.ClientRect.Width, h) }; var rect = vi.BorderPainter.CalcBoundsByClientRectangle(args); _edit.Properties.ScrollBars = rect.Height > _edit.Height ? ScrollBars.Vertical : ScrollBars.None; } }
public override void DrawObject(ObjectInfoArgs e) { TrackBarObjectInfoArgs tbe = e as TrackBarObjectInfoArgs; DrawBackground(tbe); if (this.AllowTick(tbe.ViewInfo)) { DrawPoints(tbe); } DrawMarker(tbe); }
public override void DrawObject(ObjectInfoArgs e) { Color color = DevExpress.LookAndFeel.LookAndFeelHelper.GetSystemColor(DevExpress.LookAndFeel.UserLookAndFeel.Default.ActiveLookAndFeel, SystemColors.Control); ProgressBarObjectInfoArgs ee = e as ProgressBarObjectInfoArgs; if (ee.FillBackground) { e.Cache.Paint.FillRectangle(e.Graphics, new SolidBrush(color), e.Bounds); } DrawBar(ee); }
protected override Brush GetNormalBackBrush(ObjectInfoArgs e) { if (e.State == ObjectState.Selected) { return(new SolidBrush(STATE_FOCUSED)); } if (e.State == ObjectState.Disabled) { return(new SolidBrush(STATE_DISABLED)); } return(new SolidBrush(STATE_NORMAL)); }
public static void SetScrollBarVisibility(this MemoEdit memoEdit) { MemoEditViewInfo vi = memoEdit.GetViewInfo() as MemoEditViewInfo; GraphicsCache cache = new GraphicsCache(memoEdit.CreateGraphics()); int h = (vi as IHeightAdaptable).CalcHeight(cache, vi.MaskBoxRect.Width); ObjectInfoArgs args = new ObjectInfoArgs(); args.Bounds = new Rectangle(0, 0, vi.ClientRect.Width, h); Rectangle rect = vi.BorderPainter.CalcBoundsByClientRectangle(args); cache.Dispose(); memoEdit.Properties.ScrollBars = rect.Height > memoEdit.Height ? ScrollBars.Vertical : ScrollBars.None; }
private void memoEditDescription_EditValueChanged(object sender, EventArgs e) { var vi = (MemoEditViewInfo)memoEditDescription.GetViewInfo(); using (var g = memoEditDescription.CreateGraphics()) { using (var cache = new GraphicsCache(g)) { var h = ((IHeightAdaptable)vi).CalcHeight(cache, vi.MaskBoxRect.Width); var width = (int)g.MeasureString(memoEditDescription.Text, vi.Appearance.Font, 0, vi.Appearance.GetStringFormat()).Width + 6; var args = new ObjectInfoArgs(cache, new Rectangle(0, 0, width, h), ObjectState.Normal); var rect = vi.BorderPainter.CalcBoundsByClientRectangle(args); memoEditDescription.Properties.ScrollBars = rect.Height > memoEditDescription.Height ? ScrollBars.Vertical : ScrollBars.None; } } }
public override void DrawObject(ObjectInfoArgs e) { TrackBarObjectInfoArgs tbe = e as TrackBarObjectInfoArgs; RepositoryItemTrackBar ri = tbe.ViewInfo.Item; DrawBackground(tbe); DrawTrackLine(tbe); if (this.AllowTick(tbe.ViewInfo)) { DrawPoints(tbe); } DrawThumbs(tbe); if (ri.ShowLabels) { DrawLabels(tbe); } }
public override void DrawObject(ObjectInfoArgs e) { //base.DrawObject(e); if (e is DiagramShapeObjectInfoArgs) { DiagramShapeObjectInfoArgs args = (DiagramShapeObjectInfoArgs)e; if (args.Item is DiagramShapeEx) { DiagramShapeEx imageShape = args.Item as DiagramShapeEx; if (imageShape == null) { return; } var newImage = imageShape.Image; if (newImage != null) { var w = 64; var left = e.Bounds.Left + (e.Bounds.Width - w) / 2; var top = e.Bounds.Top + (e.Bounds.Height - w) / 2; e.Graphics.DrawImage(newImage, left, top, w, w); var drawFont = new Font("Arial", 8); var drawBrush = new SolidBrush(Color.Black); var drawFormat = new StringFormat(); var ms = e.Graphics.MeasureString(imageShape.Content, drawFont); var x = (e.Bounds.Width - ms.Width) / 2; e.Graphics.DrawString(imageShape.Content, drawFont, drawBrush, e.Bounds.X + x, e.Bounds.Y + e.Bounds.Height, //new RectangleF(e.Bounds.X + x, e.Bounds.Y + e.Bounds.Height, e.Bounds.Width, 50), drawFormat); } else { base.DrawObject(e); } //e.Graphics.DrawString(imageShape.Content, newFont, Brushes.Black, new PointF(10, 10)); } } }
public void DrawObject(GraphicsCache cache, ObjectInfoArgs e) { if (e == null) { return; } RatingControlObjectInfoArgs ee = e as RatingControlObjectInfoArgs; GraphicsCache prev = e.Cache; e.Cache = cache; try { e.Cache.Paint.FillRectangle(e.Graphics, new SolidBrush(ee.BackgroundColor), e.Bounds); DrawStarsRect(ee); DrawTitlesRect(ee); DrawStarsRects(ee); DrawBorder(ee); } finally { e.Cache = prev; } }
public void DrawObject(GraphicsCache cache, ObjectInfoArgs e) { if (e == null) { return; } MyObjectInfoArgs ee = e as MyObjectInfoArgs; GraphicsCache prev = e.Cache; e.Cache = cache; try { e.Cache.Paint.FillRectangle(e.Graphics, new SolidBrush(ee.BackgroundColor), e.Bounds); DrawBar(ee); } finally { e.Cache = prev; } }
public override void DrawObject(ObjectInfoArgs e) { //base.DrawObject(e); if (e is DiagramShapeObjectInfoArgs) { DiagramShapeObjectInfoArgs args = (DiagramShapeObjectInfoArgs)e; if (args.Item is DiagramShapeEx) { DiagramShapeEx imageShape = args.Item as DiagramShapeEx; if (imageShape == null) return; var newImage = imageShape.Image; if (newImage != null) { var w = 64; var left = e.Bounds.Left + (e.Bounds.Width - w)/2; var top = e.Bounds.Top + (e.Bounds.Height - w)/2; e.Graphics.DrawImage(newImage, left, top, w, w); var drawFont = new Font("Arial", 8); var drawBrush = new SolidBrush(Color.Black); var drawFormat = new StringFormat(); var ms = e.Graphics.MeasureString(imageShape.Content, drawFont); var x = (e.Bounds.Width - ms.Width) / 2; e.Graphics.DrawString(imageShape.Content, drawFont, drawBrush,e.Bounds.X+x,e.Bounds.Y+e.Bounds.Height, //new RectangleF(e.Bounds.X + x, e.Bounds.Y + e.Bounds.Height, e.Bounds.Width, 50), drawFormat); } else { base.DrawObject(e); } //e.Graphics.DrawString(imageShape.Content, newFont, Brushes.Black, new PointF(10, 10)); } } }
public static Rectangle ReCalcObjectBounds(ObjectInfoArgs e, ICaptionCalculationMethodsProvider instance) { MyCheckObjectInfoArgs ee = e as MyCheckObjectInfoArgs; if (ee != null) { Rectangle glyphRect = ee.GlyphRect; Rectangle captionRect = ee.CaptionRect; if (ee.GlyphAlignment == HorzAlignment.Center && ee.VerticalGlyphAlignment != VerticalGlyphAlignment.Center) { Size cSize = instance.CalcCaptionSize(ee, e.Bounds.Width); captionRect = e.Bounds; captionRect.Width = Math.Min(cSize.Width, captionRect.Width); ee.CaptionRect = captionRect; if (ee.AllowHtmlString) { instance.CalcHtmlCaptionBounds(ee); } } captionRect.X = (ee.Bounds.Width - captionRect.Width) / 2; switch (ee.VerticalGlyphAlignment) { case VerticalGlyphAlignment.Top: glyphRect.Y = 2; captionRect.Y = glyphRect.Height - 4; break; case VerticalGlyphAlignment.Bottom: glyphRect.Y = ee.GlyphRect.Height + 2; captionRect.Y = 2; captionRect.Height -= glyphRect.Height + 2; break; default: return(ee.Bounds); } ee.GlyphRect = glyphRect; ee.CaptionRect = captionRect; } return(e.Bounds); }
private static void MemoEdit_TextChanged(object sender, EventArgs e) { var memoEdit = sender as MemoEdit; if (memoEdit != null) { var vi = memoEdit.GetViewInfo() as MemoEditViewInfo; if (vi != null) { var cache = new GraphicsCache(memoEdit.CreateGraphics()); var h = ((IHeightAdaptable)vi).CalcHeight(cache, vi.MaskBoxRect.Width); var args = new ObjectInfoArgs { Bounds = new Rectangle(0, 0, vi.ClientRect.Width, h) }; var rect = vi.BorderPainter.CalcBoundsByClientRectangle(args); cache.Dispose(); memoEdit.Properties.ScrollBars = rect.Height > memoEdit.Height ? ScrollBars.Vertical : ScrollBars.None; } } }
protected override void DrawPageHeaderBackground(ObjectInfoArgs e, bool upperPart) { }
public override void DrawCaption(ObjectInfoArgs e) { }
public override Rectangle CalcObjectBounds(ObjectInfoArgs e) { base.CalcObjectBounds(e); return(ReCalcObjectBounds(e, this)); }
public override void DrawCaption(ObjectInfoArgs e) { base.DrawCaption(e); }
public override Rectangle CalcObjectMinBounds(ObjectInfoArgs e) { base.CalcObjectMinBounds(e); return(MyFlatCheckObjectPainter.ReCalcObjectMinBounds(e)); }
protected override Color GetHotBorderColor(ObjectInfoArgs e, bool pressed) { return(HotBackColor); }
protected override Color GetHotBorderColor(ObjectInfoArgs e, bool pressed) { return(Color.Transparent); }
protected override Brush GetHotBackBrush(ObjectInfoArgs e, bool pressed) { return(new SolidBrush(ControlPaint.Dark((GetNormalBackBrush(e) as SolidBrush).Color, 0.2f))); }
public override void DrawObject(ObjectInfoArgs e) { base.DrawObject(e); DrawCustomButtons(e.Cache); }
protected override void OnPaint(PaintEventArgs e) { this.BackColor = Color.Transparent; ColorMatrix bm = null; //e.Graphics.DrawRectangle(SystemPens.Control, new Rectangle(this.Location, this.Size)); //e.Graphics.DrawRectangle(new Pen(Color.Transparent), new Rectangle(this.Location, this.Size)); if (!this.Enabled) { float af = -0.25f; bm = new ColorMatrix(new float[][] { new float[] { 1f, 0f, 0f, af, 0f }, new float[] { 0f, 1f, 0f, af, 0f }, new float[] { 0f, 0f, 1f, af, 0f }, new float[] { 0f, 0f, 0f, 1f, 0f }, new float[] { 0f, 0f, 0f, 0f, 1f } }); } else if (mouseIn) { if (hotTrack) { ObjectInfoArgs o = new ObjectInfoArgs(new GraphicsCache(e), new Rectangle(new Point(0, 0), this.Size), (mouseDown) ? ObjectState.Pressed : ObjectState.Hot); this.LookAndFeel.Painter.Button.DrawObject(o); } float bf = 0.07f; bm = new ColorMatrix(new float[][] { new float[] { 1f, 0f, 0f, 0f, 0f }, new float[] { 0f, 1f, 0f, 0f, 0f }, new float[] { 0f, 0f, 1f, 0f, 0f }, new float[] { 0f, 0f, 0f, 1f, 0f }, new float[] { bf, bf, bf, 0f, 1f } }); } if (this.image != null) { if (mouseDown && pressedImage != null) { drawImage = pressedImage; } else { if (altImage != null && toggle) { drawImage = altImage; } else { drawImage = image; } } Size imageSize; float widthToHeightRatio = Convert.ToSingle(drawImage.Size.Height) / Convert.ToSingle(drawImage.Size.Width); if (drawImage.Size.Width > drawImage.Size.Height) { imageSize = new Size(Convert.ToInt32(this.Size.Width * imageSizeRatio), Convert.ToInt32(this.Size.Width * imageSizeRatio * widthToHeightRatio)); } else { imageSize = new Size(Convert.ToInt32(this.Size.Height * imageSizeRatio * (1f / widthToHeightRatio)), Convert.ToInt32(this.Size.Width * imageSizeRatio)); } Point imageLocation = new Point((this.Size.Width / 2) - (imageSize.Width / 2), (this.Size.Height / 2) - (imageSize.Height / 2)); if (bm != null) { ImageAttributes ia = new ImageAttributes(); ia.SetColorMatrix(bm); e.Graphics.DrawImage(drawImage, new Rectangle(imageLocation, imageSize), 0, 0, drawImage.Size.Width, drawImage.Size.Height, GraphicsUnit.Pixel, ia); } else { e.Graphics.DrawImage(drawImage, new Rectangle(imageLocation, imageSize)); } } }
/// <summary>Draws the object.</summary> /// <param name="e">The e.</param> public override void DrawObject(ObjectInfoArgs e) { var infoArgs = e as RichToolTipItemInfoArgs; this.DrawText(infoArgs); }
protected override void DrawButton(ObjectInfoArgs e) { new RotateObjectPaintHelper().DrawRotated(e.Cache, GetButtonInfoArgs(e), ButtonPainter, RotateFlipType.RotateNoneFlipX); }
public override Rectangle CalcObjectMinBounds(ObjectInfoArgs e) { return(Rectangle.Empty); }