/* * PaintValue */ /// <summary> /// Paints a representation of the value of an object using the specified <see cref="T:System.Drawing.Design.PaintValueEventArgs"></see>. /// </summary> /// <param name="e">A <see cref="T:System.Drawing.Design.PaintValueEventArgs"></see> that indicates what to paint and where to paint it.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="e"/> is <see langword="null"/>.</para> /// </exception> public override void PaintValue(PaintValueEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (_imageEditor != null) { Image image = null; if (e.Value is int) { image = this.GetImage(e.Context, (int)e.Value, null, true); } else if (e.Value is string) { image = this.GetImage(e.Context, -1, (string)e.Value, false); } if (image != null) { _imageEditor.PaintValue(new PaintValueEventArgs(e.Context, image, e.Graphics, e.Bounds)); } } }
public void UITypeEditor_PaintValue_Invoke_Nop(PaintValueEventArgs e) { using (var image = new Bitmap(10, 10)) using (var graphics = Graphics.FromImage(image)) { var editor = new UITypeEditor(); editor.PaintValue(e); } }
/// <include file='doc\ImageIndexEditor.uex' path='docs/doc[@for="ImageIndexEditor.PaintValue"]/*' /> /// <devdoc> /// <para> /// Paints a representative value of the given object to the provided /// canvas. Painting should be done within the boundaries of the /// provided rectangle. /// </para> /// </devdoc> public override void PaintValue(PaintValueEventArgs e) { if (imageEditor != null && e.Value is int) { Image image = GetImage(e.Context, (int)e.Value); if (image != null) { imageEditor.PaintValue(new PaintValueEventArgs(e.Context, image, e.Graphics, e.Bounds)); } } }
protected override void OnPaint(PaintEventArgs e) { if (!IsEditing) { Graphics g = e.Graphics; Rectangle r = ClientRectangle; r.Inflate(-2, -2); int rh = r.Height; if (rh < 19) { rh = 19; } Rectangle rr = new Rectangle(r.X, r.Y, r.Width - rh, r.Height); Rectangle rrr = new Rectangle(r.X + rr.Width, r.Y, rh, r.Height); //do the custom rendering process here, albeit call it if (typeconv.CanConvertTo(typeof(double))) { sf.Alignment = StringAlignment.Far; } else { sf.Alignment = StringAlignment.Near; } if (Focused) { Rectangle cr = ClientRectangle; Drawing.Utils.PaintLineHighlight(null, SystemPens.Highlight, g, r.X - 1, r.Y - 1, r.Width + 1, r.Height + 1, false); } if (Value == null) { sf.Alignment = StringAlignment.Center; g.DrawString("Press F2 or double-click to edit", Font, Drawing.Factory.SolidBrush(SystemColors.GrayText), r, sf); } else { if (uieditor != null && uieditor.GetPaintValueSupported()) { uieditor.PaintValue(Value, g, rrr); g.DrawRectangle(SystemPens.WindowFrame, rrr); g.DrawString(typeconv.ConvertToString(Value), Font, SystemBrushes.ControlText, rr, sf); } else { g.DrawString(typeconv.ConvertToString(Value), Font, SystemBrushes.ControlText, r, sf); } } } base.OnPaint(e); }
public virtual void PaintValue(Graphics gfx, Rectangle rect) { UITypeEditor editor = GetEditor(); if (editor != null) { try { editor.PaintValue(this.ValueText, gfx, rect); } catch { // Some of our Editors throw NotImplementedException } } }
public override void PaintValue(PaintValueEventArgs e) { UITypeEditor editor = lookUpEditor(e.Context); if (editor != null) { PaintValueEventArgs e2 = new PaintValueEventArgs(e.Context, e.Value, e.Graphics, e.Bounds); editor.PaintValue(e2); return; //return editor.GetPaintValueSupported(context); } base.PaintValue(e); }
/// <summary> /// Draws the property editing representation, in the same way that the control /// presents the property in the GUI. Use this method to draw inactive properties /// when multitasking a single PropertyEditingControl.</summary> /// <param name="descriptor">Property descriptor</param> /// <param name="context">Type descriptor context</param> /// <param name="bounds">Bounds containing graphics</param> /// <param name="font">Font to use for rendering property text</param> /// <param name="brush">Brush for rendering property text</param> /// <param name="g">Graphics object</param> public static void DrawProperty( PropertyDescriptor descriptor, ITypeDescriptorContext context, Rectangle bounds, Font font, Brush brush, Graphics g) { object owner = context.Instance; if (owner == null) { return; } UITypeEditor editor = WinFormsPropertyUtils.GetUITypeEditor(descriptor, context); if (editor != null) { if (editor.GetPaintValueSupported(context)) { object value = descriptor.GetValue(owner); Rectangle paintRect = new Rectangle( bounds.Left + 1, bounds.Top + 1, PaintRectWidth, PaintRectHeight); editor.PaintValue(new PaintValueEventArgs(context, value, g, paintRect)); bounds.X += PaintRectTextOffset; bounds.Width -= PaintRectTextOffset; g.DrawRectangle(SystemPens.ControlDark, paintRect); } } string valueString = PropertyUtils.GetPropertyText(owner, descriptor); bounds.Height = font.Height; if (s_textFormat.CustomFlags == CustomStringFormatFlags.TrimLeftWithEllipses) { valueString = TrimStringLeftWithEllipses(valueString, bounds, font, g); } g.DrawString(valueString, font, brush, bounds, s_textFormat.Format); }
public override void PaintValue(PaintValueEventArgs e) { UITypeEditor editor = lookUpEditor(e.Context); if (editor != null) { if (typeof(WhiskeyPropertyContainer).IsAssignableFrom(e.Value.GetType())) { WhiskeyPropertyContainer wpc = (WhiskeyPropertyContainer)e.Value; PaintValueEventArgs e2 = new PaintValueEventArgs(e.Context, wpc.Value, e.Graphics, e.Bounds); editor.PaintValue(e2); return; } } base.PaintValue(e); }
public override void PaintValue(PaintValueEventArgs e) { object value = e.Value; if (value == OptionItem.VALUE_UNDEFINED) { Graphics g = e.Graphics; Font f = new Font("sansserif", e.Bounds.Height * 0.7f, FontStyle.Bold, GraphicsUnit.Pixel); g.DrawString("?", f, Brushes.Black, e.Bounds); return; } else if (delegateEditor != null) { delegateEditor.PaintValue(e); return; } }
protected override void DrawRowValueCellCore(CustomDrawRowValueCellEventArgs e, BaseEditPainter pb, BaseEditViewInfo bvi, BaseViewInfo vi) { MyPropertyGridControl grid = (MyPropertyGridControl)vi.Grid; RowProperties properties = e.Row.GetRowProperties(e.CellIndex); DescriptorContext context = grid.GetDescriptorContext(properties); UITypeEditor editor = grid.GetUITypeEditor(context); if (editor != null && editor.GetPaintValueSupported()) { int indent = 1; Size size = new Size(e.Bounds.Size.Height - 2 * indent, e.Bounds.Size.Height - 2 * indent); Rectangle bounds = new Rectangle(e.Bounds.X + indent, e.Bounds.Y + indent, size.Width, size.Height); PaintValueEventArgs args = new PaintValueEventArgs(context, grid.GetCellValue(properties.Row, 0), e.Cache.Graphics, bounds); editor.PaintValue(args); e.Cache.DrawRectangle(Pens.DarkGray, bounds); Rectangle textBounds = new Rectangle(e.Bounds.X + bounds.Width + 2 * indent + indent, e.Bounds.Y, e.Bounds.Width - bounds.Width + 2 * indent, e.Bounds.Height); grid.Appearance.RecordValue.DrawString(e.Cache, grid.GetCellDisplayText(properties.Row, 0), textBounds); } else { base.DrawRowValueCellCore(e, pb, bvi, vi); } }
public void UITypeEditor_PaintValue_NullCanvas_ThrowsArgumentNullException() { var editor = new UITypeEditor(); Assert.Throws <ArgumentNullException>("graphics", () => editor.PaintValue(new object(), null, Rectangle.Empty)); }
public override void PaintValue(PaintValueEventArgs e) { _parentEditor.PaintValue(new PaintValueEventArgs( CreateContext(e.Context), e.Value, e.Graphics, e.Bounds)); }
public override void PaintValue(PaintValueEventArgs e) { uiTypeEditor.PaintValue(e); }
public void PaintValue_PaintValueEventArgs_Null() { editor.PaintValue(null); }