public override void PaintValue(PaintValueEventArgs e) { var ts = (TextStyle) e.Value; using (var b = new SolidBrush(ts.BackColor)) { e.Graphics.FillRectangle(b, e.Bounds); } FontStyle fs = FontStyle.Regular; if (ts.Bold) fs |= FontStyle.Bold; if (ts.Italic) fs |= FontStyle.Italic; if (ts.Underline) fs |= FontStyle.Underline; var f = new Font("arial", 8f, fs); using (var b = new SolidBrush(ts.ForeColor)) { e.Graphics.DrawString("abc", f, b, e.Bounds); } f.Dispose(); }
/// <summary> /// Draw a preview of the <see cref="ColorPair"/> /// </summary> /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding /// rectangle</param> public override void PaintValue(PaintValueEventArgs e) { ColorPair colorPair = (ColorPair)e.Value ; using ( SolidBrush b = new SolidBrush(colorPair.Background)) { e.Graphics.FillRectangle(b, e.Bounds); } // Draw the text "ab" using the Foreground/Background values from the ColorPair using(SolidBrush b = new SolidBrush(colorPair.Foreground)) { using(Font f = new Font("Arial",6)) { RectangleF temp = new RectangleF(e.Bounds.Left,e.Bounds.Top,e.Bounds.Height,e.Bounds.Width) ; temp.Inflate(-2,-2) ; // Set up how we want the text drawn StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap) ; format.Trimming = StringTrimming.EllipsisCharacter ; format.Alignment = StringAlignment.Center ; format.LineAlignment = StringAlignment.Center ; // save the Smoothing mode of the Graphics object so we can restore it SmoothingMode saveMode = e.Graphics.SmoothingMode ; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias ; e.Graphics.DrawString("ab",f,b,temp,format) ; e.Graphics.SmoothingMode = saveMode ; } } }
public override void PaintValue(PaintValueEventArgs e) { try { if(e==null || e.Value==null) return; int iIndex=(int)e.Value; System.Drawing.Image img=this.GetImage(e.Context,iIndex); if(img==null) return; PaintValueEventArgs pi=new PaintValueEventArgs(e.Context,img,e.Graphics,e.Bounds); if (img != null) { Rectangle r = e.Bounds; r.Width--; r.Height--; e.Graphics.DrawRectangle(SystemPens.WindowFrame, r); e.Graphics.DrawImage(img, e.Bounds); } //m_ImageEditor.PaintValue(pi); //m_ImageEditor.PaintValue(img,e.Graphics,e.Bounds); } catch{} }
public override void PaintValue(PaintValueEventArgs e) { WebControl control = e.Context.Instance as WebControl; // Fills the left rectangle with a color. e.Graphics.FillRegion(new SolidBrush(control.BackColor), new Region(e.Bounds)); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { int iImageIndex = -1; if (e.Value != null) { iImageIndex = Convert.ToInt32(e.Value); } else { return; } if (e.Context.Instance == null) { return; } ImageList myImageList = GetImageList(e.Context.Instance); if (myImageList != null && myImageList.Images.Count > 0 && iImageIndex >= 0 && iImageIndex < myImageList.Images.Count) { e.Graphics.DrawImage(myImageList.Images[iImageIndex], e.Bounds); } else { e.Graphics.DrawLine(Pens.Black, e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Right - 1, e.Bounds.Bottom - 1); e.Graphics.DrawLine(Pens.Black, e.Bounds.Right - 1, e.Bounds.Y + 1, e.Bounds.X + 1, e.Bounds.Bottom - 1); } }
//下面两个函数是为了在PropertyGrid中显示一个辅助的效果 //可以不用重写 public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { List <Color> cl = e.Value as List <Color>; if (cl == null) { ColorProp cp = e.Value as ColorProp; cl = cp.colorList; } int normalX = (e.Bounds.Width / 2); int normalY = (e.Bounds.Height / 2); int curY = e.Bounds.Y; for (int i = 0; i < cl.Count; i++) { e.Graphics.FillRectangle(new SolidBrush(cl[i]), e.Bounds.X + (i * 10), e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); } e.Graphics.FillEllipse(new SolidBrush(Color.White), e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 3, e.Bounds.Height - 3); e.Graphics.FillEllipse(new SolidBrush(Color.SlateGray), normalX + e.Bounds.X - 1, normalY + e.Bounds.Y - 1, 3, 3); double radians = 5; e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red), 1), normalX + e.Bounds.X, normalY + e.Bounds.Y, e.Bounds.X + (normalX + (int)((double)normalX * Math.Cos(radians))), e.Bounds.Y + (normalY + (int)((double)normalY * Math.Sin(radians)))); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { int imageIndex = -1; // value is the image index if (e.Value != null) { try { imageIndex = (int)Convert.ToUInt16(e.Value.ToString()); } catch { } } // no instance, or the instance represents an undefined image if ((e.Context.Instance == null) || (imageIndex < 0)) { return; } // get the image set ImageList imageList = GetImageList(e.Context.Instance); // make sure everything is valid if ((imageList == null) || (imageList.Images.Count == 0) || (imageIndex >= imageList.Images.Count)) { return; } // Draw the preview image e.Graphics.DrawImage(imageList.Images[imageIndex], e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (!(e.Context.Instance is KrbTabControl)) return; var parent = (KrbTabControl)e.Context.Instance; var caption = (ButtonsCaption)e.Value; using (var brush = new LinearGradientBrush(e.Bounds, parent.GradientCaption.InactiveCaptionColorStart, parent.GradientCaption.InactiveCaptionColorEnd, parent.GradientCaption.CaptionGradientStyle)) { var bl = new Blend(2) { Factors = new[] { 0.1F, 1.0F }, Positions = new[] { 0.0F, 1.0F } }; brush.Blend = bl; e.Graphics.FillRectangle(brush, e.Bounds); Image captionDropDown = Resources.DropDown; using (var attributes = new ImageAttributes()) { var map = new[] { new ColorMap {OldColor = Color.White, NewColor = Color.Transparent}, new ColorMap {OldColor = Color.Black, NewColor = caption.InactiveCaptionButtonsColor} }; attributes.SetRemapTable(map); var rect = e.Bounds; rect.Inflate(-3, 0); e.Graphics.DrawImage(captionDropDown, rect, 0, 0, captionDropDown.Width, captionDropDown.Height, GraphicsUnit.Pixel, attributes); } } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs pe) { int imageIndex = -1; // value is the image index if (pe.Value != null) { try { imageIndex = (int)Convert.ToUInt16(pe.Value.ToString()); } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(ImageMapEditor)); MessageDxUtil.ShowError(ex.Message); } } // no instance, or the instance represents an undefined image if ((pe.Context.Instance == null) || (imageIndex < 0)) { return; } // get the image set ImageList imageList = GetImageList(pe.Context.Instance); // make sure everything is valid if ((imageList == null) || (imageList.Images.Count == 0) || (imageIndex >= imageList.Images.Count)) { return; } // Draw the preview image pe.Graphics.DrawImage(imageList.Images[imageIndex], pe.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { var inheritableColor = (InheritableColor)e.Value; using (var brush = new SolidBrush(inheritableColor.Value)) e.Graphics.FillRectangle(brush, e.Bounds); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { using (System.Drawing.Brush br = new System.Drawing.SolidBrush(System.Drawing.Color.FromName(e.Value.ToString()))) { e.Graphics.FillRectangle(br, e.Bounds); } }
/// <summary> /// Draw a preview of the <see cref="GradientColor"/> /// </summary> /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding /// rectangle</param> public override void PaintValue(PaintValueEventArgs e) { GradientColor gradientColor = (GradientColor)e.Value ; using ( LinearGradientBrush b = gradientColor.GetBrush(e.Bounds,LinearGradientMode.Horizontal)) { e.Graphics.FillRectangle(b, e.Bounds); } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs pe) { int imageIndex = -1; if (pe.Value != null) { try { imageIndex = (int)Convert.ToUInt16(pe.Value.ToString()); } catch { } } if ((pe.Context.Instance == null) || (imageIndex < 0)) { return; } ImageList imageList = GetImageList(pe.Context.Instance); if ((imageList == null) || (imageList.Images.Count == 0) || (imageIndex >= imageList.Images.Count)) { return; } pe.Graphics.DrawImage(imageList.Images[imageIndex], pe.Bounds); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { e.Graphics.Clear(Color.White); Type valType = e.Value.GetType(); System.Reflection.PropertyInfo startColorInfo = valType.GetProperty("StartColor"); System.Drawing.Color startColor = (Color)startColorInfo.GetValue(e.Value, null); System.Reflection.PropertyInfo endColorInfo = valType.GetProperty("EndColor"); System.Drawing.Color endColor = (Color)endColorInfo.GetValue(e.Value, null); System.Reflection.PropertyInfo fillDirectionInfo = valType.GetProperty("FillDirection"); Type fillDirType = fillDirectionInfo.PropertyType; string[] fillDirNames = Enum.GetNames(fillDirType); int[] fillDirValues = (int[])Enum.GetValues(fillDirType); System.Collections.Generic.Dictionary <int, string> fillDirValNameDict = new System.Collections.Generic.Dictionary <int, string>(); for (int cnt = 0; cnt <= fillDirValues.Length - 1; cnt++) { fillDirValNameDict.Add(fillDirValues[cnt], fillDirNames[cnt]); } int fillDir = (int)fillDirectionInfo.GetValue(e.Value, null); if (startColor == System.Drawing.Color.Transparent || endColor == System.Drawing.Color.Transparent) { return; } LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, startColor, endColor, fillDir == 0 ? LinearGradientMode.Horizontal : LinearGradientMode.Vertical); e.Graphics.FillRectangle(brush, e.Bounds); }
/// <summary> /// Paints a representation of the value of an object using the specified <see cref="T:System.Drawing.Design.PaintValueEventArgs"/>. /// </summary> /// <param name="e">A <see cref="T:System.Drawing.Design.PaintValueEventArgs"/> that indicates what to paint and where to paint it.</param> public override void PaintValue(PaintValueEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; Point center = new Point { X = e.Bounds.Width / 2, Y = e.Bounds.Height / 2 }; var backgroundBrush = Brushes.SteelBlue; var circleBrush = Brushes.White; var centerBrush = Brushes.Black; var anglePen = new Pen(Brushes.Red, 1f); // Fill background and ellipse and center point... e.Graphics.FillRectangle(backgroundBrush, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); e.Graphics.FillEllipse(circleBrush, e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 3, e.Bounds.Height - 3); e.Graphics.FillEllipse(centerBrush, center.X + e.Bounds.X - 1, center.Y + e.Bounds.Y - 1, 3, 3); // Draw line along the current Angle... float radians = (float)e.Value; e.Graphics.DrawLine(anglePen, center.X + e.Bounds.X, center.Y + e.Bounds.Y, e.Bounds.X + (center.X + (int)((float)center.X * Calculator.Cos(radians))), e.Bounds.Y + (center.Y + (int)((float)center.Y * Calculator.Sin(radians)))); }
public override void PaintValue(PaintValueEventArgs pe) { Image image = null; int imageIndex = 0; if (!int.TryParse(pe.Value.ToString(), out imageIndex)) return; ImageList imageList = null; PropertyDescriptorCollection PropertyCollection = TypeDescriptor.GetProperties(instance); PropertyDescriptor property; if ((property = PropertyCollection.Find("LargeImages", false)) != null) imageList = (ImageList)property.GetValue(instance); if ((imageList != null) && (imageList.Images.Count > imageIndex) && (imageIndex >= 0)) { image = imageList.Images[imageIndex]; } if (imageIndex < 0 || image == null) { pe.Graphics.DrawLine(Pens.Black, pe.Bounds.X + 1, pe.Bounds.Y + 1, pe.Bounds.Right - 1, pe.Bounds.Bottom - 1); pe.Graphics.DrawLine(Pens.Black, pe.Bounds.Right - 1, pe.Bounds.Y + 1, pe.Bounds.X + 1, pe.Bounds.Bottom - 1); } else { pe.Graphics.DrawImage(image, pe.Bounds); } }
public override void PaintValue(PaintValueEventArgs e) { var val = (bool?) e.Value; ControlPaint.DrawCheckBox(e.Graphics, e.Bounds, (val ?? false) ? ButtonState.Checked : ButtonState.Normal); }
/// <summary> /// Paints a representation of the value of an object using the specified <see cref="T:System.Drawing.Design.PaintValueEventArgs"/>. /// </summary> /// <param name="e">A <see cref="T:System.Drawing.Design.PaintValueEventArgs"/> that indicates what to paint and where to paint it.</param> public override void PaintValue(PaintValueEventArgs e) { Brush backgroundBrush = new SolidBrush(Color.FromArgb((int)((float)e.Value * 255f), Color.White)); e.Graphics.FillRectangle(Brushes.Black, e.Bounds); e.Graphics.FillRectangle(backgroundBrush, e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is string && !string.IsNullOrEmpty((string)e.Value)) { e.Graphics.DrawImage(global::Seal.Properties.Resources.error, 3, 0, 16, 16); } }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is Color && ((Color)e.Value).A <= byte.MaxValue) { Color xnacolor = (Color)e.Value; System.Drawing.Color syscolor = System.Drawing.Color.FromArgb(xnacolor.A, xnacolor.R, xnacolor.G, xnacolor.B); int oneThird = e.Bounds.Width / 3; using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray)) { e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, 4, 4)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 1, 4, 4)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 1, 2, 4)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 5, e.Bounds.Y + 5, 4, 4)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 13, e.Bounds.Y + 5, 4, 4)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 1, e.Bounds.Y + 9, 4, 3)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 9, e.Bounds.Y + 9, 4, 3)); e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X + 17, e.Bounds.Y + 9, 2, 3)); } using (System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(syscolor)) { e.Graphics.FillRectangle(brush, new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 1)); } } if (e.Value is System.Drawing.Color) { base.PaintValue(e); } }
public override void PaintValue(PaintValueEventArgs e) { Graphics g = e.Graphics; GradientInfo gradient = (GradientInfo)e.Value; gradient.Draw(g, e.Bounds); g.DrawRectangleProper(Pens.Black, e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (this.innerEditor != null) { this.innerEditor.PaintValue(e); } base.PaintValue(e); }
/// <summary> /// Draw a representation of our value /// </summary> public override void PaintValue(PaintValueEventArgs e) { IBrushData bd = e.Value as IBrushData; if (bd == null) base.PaintValue(e); else e.Graphics.FillRectangle(BlockFormat.PrepareBrushForDrawing(bd.GetBrush(), e.Bounds), e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { Hatcher hatch = e.Value as Hatcher; using (HatchBrush brush = new HatchBrush(hatch.HatchType, hatch.ForeColor, hatch.BackColor)) { e.Graphics.FillRectangle(brush, e.Bounds); } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { Bitmap img = new Bitmap(19, 12); Graphics gr = Graphics.FromImage(img); gr.Clear(Color.FromArgb(255, 240, 225)); e.Graphics.DrawImage(img, new Point(2, 2)); base.PaintValue(e); }
// Draws a representation of the property's value. public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { IMethodSelector ts = (IMethodSelector)MathNode.GetService(typeof(IMethodSelector)); if (ts != null) { ts.PaintValue(e); } }
public override void PaintValue(PaintValueEventArgs e) { if ((e.Value as DirectoryInfo).Exists) e.Graphics.DrawImage(Properties.Resources.Folder.ToBitmap(), e.Bounds); else e.Graphics.DrawImage(Properties.Resources.FolderBad.ToBitmap(), e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is OpenTK.Graphics.Color4) { var col = (OpenTK.Graphics.Color4)e.Value; base.PaintValue(new PaintValueEventArgs(e.Context, Color.FromArgb(col.ToArgb()), e.Graphics, e.Bounds)); } base.PaintValue(e); }
/// <summary> /// Performs custom actions on PaintValue events. Paints a representative value of the given object to the provided canvas</summary> /// <param name="e">PaintValueEventArgs indicating what to paint and where to paint it</param> public override void PaintValue(PaintValueEventArgs e) { TypeConverter converter = e.Context.PropertyDescriptor.Converter; object value = converter.ConvertTo(e.Value, typeof(Color)); // convert from underlying type to Color if (value != null && value is Color) { Color color = (Color)value; base.PaintValue(new PaintValueEventArgs(e.Context, color, e.Graphics, e.Bounds)); } }
public override void PaintValue(PaintValueEventArgs pe) { try { Color c = Color.FromArgb(((MyColor)pe.Value).R, ((MyColor)pe.Value).G, ((MyColor)pe.Value).B); Brush br = new SolidBrush(c); pe.Graphics.FillRectangle(br, pe.Bounds); } catch { } }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value != null) { Image img = GetImage((int)e.Value); if (img != null) e.Graphics.DrawImage(img, e.Bounds); } }
public override void PaintValue( System.Drawing.Design.PaintValueEventArgs e) { GradientFill fill = (GradientFill)e.Value; LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, fill.ColorA, fill.ColorB, fill.GradientFillStyle); // Paint the thumbnail. e.Graphics.FillRectangle(brush, e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value != null) { if ((bool)e.Value == true) e.Graphics.DrawImage(Properties.Resources.validateBlue, e.Bounds); else e.Graphics.DrawImage(Properties.Resources.cancelOrange, e.Bounds); } }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is ColorValue) { using (Brush brush = new SolidBrush(ColorValueConverter.ToColor((ColorValue)e.Value))) { e.Graphics.FillRectangle(brush, e.Bounds); } } }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value is Color) { Color color = (Color) e.Value; SolidBrush brush = new SolidBrush(color); e.Graphics.FillRectangle(brush, e.Bounds); brush.Dispose(); } }
public override void PaintValue( PaintValueEventArgs args ) { MetalGradient gradient = (MetalGradient)args.Value; LinearGradientBrush gradientBrush = new LinearGradientBrush( args.Bounds, gradient.Top, gradient.Bottom, 90.0f ); args.Graphics.FillRectangle( gradientBrush, args.Bounds ); gradientBrush.Dispose(); }
/// <summary> /// Paints a representative value of the given object to the provided /// canvas. Painting should be done within the boundaries of the /// provided rectangle. /// </summary> public override void PaintValue(PaintValueEventArgs e) { if (e?.Value is Image image) { Rectangle r = e.Bounds; r.Width--; r.Height--; e.Graphics.DrawRectangle(SystemPens.WindowFrame, r); e.Graphics.DrawImage(image, e.Bounds); } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { if (e.Value is System.Drawing.Image) { System.Drawing.Rectangle rectangle = e.Bounds; rectangle.Width--; rectangle.Height--; e.Graphics.DrawRectangle(System.Drawing.SystemPens.WindowFrame, rectangle); e.Graphics.DrawImage((System.Drawing.Image)e.Value, e.Bounds); } }
public override void PaintValue (PaintValueEventArgs e) { Graphics G = e.Graphics; if (e.Value != null) { Image I = (Image) e.Value; G.DrawImage (I, e.Bounds); } G.DrawRectangle (Pens.Black, e.Bounds); }
public override void PaintValue(PaintValueEventArgs e) { if (e.Value != null) { CoronaGameProject.OrientationScreen value = (CoronaGameProject.OrientationScreen)e.Value; if (value == CoronaGameProject.OrientationScreen.Landscape) e.Graphics.DrawImage(Properties.Resources.paysageIcon, e.Bounds); else if (value == CoronaGameProject.OrientationScreen.Portrait) e.Graphics.DrawImage(Properties.Resources.portraitIcon, e.Bounds); } }
public override void PaintValue(PaintValueEventArgs e) { if (e == null) throw new ArgumentNullException(); var gradient = (GradientTab)e.Value; using (var brush = new LinearGradientBrush(e.Bounds, gradient.ColorStart, gradient.ColorEnd, gradient.GradientStyle)) { e.Graphics.FillRectangle(brush, e.Bounds); } }
public override void PaintValue(PaintValueEventArgs e) { MindFusion.FlowChartX.Brush brush = e.Value as MindFusion.FlowChartX.Brush; if (brush == null) return; System.Drawing.Brush gdiBrush = brush.CreateGDIBrush(e.Bounds); e.Graphics.FillRectangle(gdiBrush, e.Bounds); gdiBrush.Dispose(); }
public void Ctor_PropertiesAssignedCorrectly() { using (var bm = new Bitmap(20, 20)) using (var graphics = Graphics.FromImage(bm)) { var paintValueEventArgs = new PaintValueEventArgs(null, bm, graphics, Rectangle.Empty); Assert.Null(paintValueEventArgs.Context); Assert.Equal(bm, paintValueEventArgs.Value); Assert.Equal(graphics, paintValueEventArgs.Graphics); Assert.Equal(Rectangle.Empty, Rectangle.Empty); } }
public override void PaintValue(PaintValueEventArgs e) { Graphics G = e.Graphics; if (e.Value != null) { Image I = (Image)e.Value; G.DrawImage(I, e.Bounds); } G.DrawRectangle(Pens.Black, e.Bounds); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { Bitmap bm = new Bitmap(e.Bounds.Width + 4, e.Bounds.Height + 4, e.Graphics); Graphics g = Graphics.FromImage(bm); ShapeType shape = (ShapeType)e.Value; GraphicsPath path = new GraphicsPath(); ZeroitCustomControl.updateOutline(ref path, shape, e.Bounds.Width - 5, e.Bounds.Height - 5, 2); g.FillPath(Brushes.Yellow, path); g.DrawPath(Pens.Red, path); e.Graphics.DrawImage(bm, 3, 3, new Rectangle(new Point(0, 0), new Size(e.Bounds.Width, e.Bounds.Height)), GraphicsUnit.Pixel); }
/// <summary> /// Tries to render sample of text in specified font and style, /// throwing exception if specified font does not support that style... /// </summary> private static void DrawFontSample(PaintValueEventArgs e, FontFamily fontFamily, FontStyle fontStyle) { float fontSize = e.Bounds.Height / ScaleFactor; using (var font = new Font(fontFamily, fontSize, fontStyle, GraphicsUnit.Pixel)) { var sf = new StringFormat(StringFormatFlags.NoWrap | StringFormatFlags.NoFontFallback) { LineAlignment = StringAlignment.Far }; e.Graphics.DrawString("abcd", font, SystemBrushes.ActiveCaptionText, e.Bounds, sf); } }
public override void PaintValue(PaintValueEventArgs e) { Image image = e.Value as Image; if (image != null) { Rectangle bounds = e.Bounds; bounds.Width--; bounds.Height--; e.Graphics.DrawRectangle(SystemPens.WindowFrame, bounds); e.Graphics.DrawImage(image, e.Bounds); } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { // Make sure we are dealing with an actual texture. if (e.Value is Texture) { // Get the texture. Texture tex = e.Value as Texture; if (tex.TextureName != 0) { e.Graphics.DrawImage(tex.ToBitmap(), e.Bounds); } } }
public override void PaintValue(PaintValueEventArgs e) { Graphics G = e.Graphics; if (e.Value != null) { Icon i = (Icon)e.Value; Image img = i.ToBitmap(); G.DrawImage(img, e.Bounds); img.Dispose(); } G.DrawRectangle(Pens.Black, e.Bounds); }
// Draws a representation of the property's value. public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { ImageID imgid = (ImageID)e.Value; if (imgid.SelectedImage != null) { e.Graphics.DrawImage(imgid.SelectedImage, e.Bounds); } else { Font ft = new Font("Times New Roman", e.Bounds.Height, GraphicsUnit.Pixel); e.Graphics.DrawString(imgid.ID.ToString(), ft, Brushes.Black, (float)0, (float)0); } }
// Draws a representation of the property's value. public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { int normalX = (e.Bounds.Width / 2); int normalY = (e.Bounds.Height / 2); // Fill background and ellipse and center point. e.Graphics.FillRectangle(new SolidBrush((Color)e.Value), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); // Draw line along the current angle. //double radians = ((double)e.Value * Math.PI) / (double)180; //e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red), 1), normalX + e.Bounds.X, normalY + e.Bounds.Y, // e.Bounds.X + (normalX + (int)((double)normalX * Math.Cos(radians))), // e.Bounds.Y + (normalY + (int)((double)normalY * Math.Sin(radians)))); }
// Draws a representation of the property's value. public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { /*int normalX = (e.Bounds.Width / 2); * int normalY = (e.Bounds.Height / 2); * * // Fill background and ellipse and center point. * e.Graphics.FillRectangle(new SolidBrush(Color.DarkBlue), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); * e.Graphics.FillEllipse(new SolidBrush(Color.White), e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 3, e.Bounds.Height - 3); * e.Graphics.FillEllipse(new SolidBrush(Color.SlateGray), normalX + e.Bounds.X - 1, normalY + e.Bounds.Y - 1, 3, 3); * * // Draw line along the current angle. * double radians = ((double)e.Value * Math.PI) / (double)180; * e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red), 1), normalX + e.Bounds.X, normalY + e.Bounds.Y, * e.Bounds.X + (normalX + (int)((double)normalX * Math.Cos(radians))), * e.Bounds.Y + (normalY + (int)((double)normalY * Math.Sin(radians))));*/ }
/// <summary> /// /// </summary> /// <param name="e"></param> public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { if (e.Value == null) { return; } if (e.Value is System.Windows.Media.SolidColorBrush) { System.Windows.Media.SolidColorBrush b = (System.Windows.Media.SolidColorBrush)e.Value; Color c = Color.FromArgb( b.Color.A, b.Color.R, b.Color.G, b.Color.B); e.Graphics.FillRectangle(new SolidBrush(c), e.Bounds); } }
private static void DrawFontSample(PaintValueEventArgs e, FontFamily fontFamily, FontStyle fontStyle) { float emSize = (float)(((double)e.Bounds.Height) / 1.2); Font font = new Font(fontFamily, emSize, fontStyle, GraphicsUnit.Pixel); if (font != null) { try { e.Graphics.DrawString("abcd", font, SystemBrushes.ActiveCaptionText, e.Bounds); } finally { font.Dispose(); } } }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { // base.PaintValue(e); VD2PropertyStore datainstance = null; if (e.Context.Instance.GetType().IsSubclassOf(typeof(VD2PropertyStore))) { datainstance = (VD2PropertyStore)e.Context.Instance; } Color indicatorcolor = new Color(); if (datainstance != null) { if (datainstance.PropertyExists(e.Context.PropertyDescriptor.Name)) { if (datainstance.PropertyEdited(e.Context.PropertyDescriptor.Name)) { indicatorcolor = Color.Yellow; } else { indicatorcolor = Color.Green; } } else { if (datainstance.PropertyEdited(e.Context.PropertyDescriptor.Name)) { indicatorcolor = Color.Orange; } else if (datainstance.PropertyExistsInBaseData(e.Context.PropertyDescriptor.Name)) { indicatorcolor = Color.Blue; } else { indicatorcolor = Color.Red; } } } e.Graphics.FillRectangle(new SolidBrush(indicatorcolor), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); //e.Graphics.DrawString(e.Value.ToString(), new Font("Arial", 8), new SolidBrush(Color.White), new RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height)); }
//下面两个函数是为了在PropertyGrid中显示一个辅助的效果 //可以不用重写 public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { List <Color> cl = e.Value as List <Color>; if (cl == null) { ColorProp cp = e.Value as ColorProp; cl = cp.colorList; } int normalX = (e.Bounds.Width / 2); int normalY = (e.Bounds.Height / 2); int curY = e.Bounds.Y; for (int i = 0; i < cl.Count; i++) { e.Graphics.FillRectangle(new SolidBrush(cl[i]), e.Bounds.X + (i * 10), e.Bounds.Y, 10, e.Bounds.Height); } }
public override void PaintValue(PaintValueEventArgs e) { Graphics G = e.Graphics; // Draw the background G.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds); // Draw the sample string string fontName = e.Value as string; if (fontName != null && fontName.Length > 0) { using (Font font = new Font(fontName, e.Bounds.Height, FontStyle.Regular, GraphicsUnit.Pixel)) { G.DrawString(PreviewString, font, SystemBrushes.ActiveCaptionText, e.Bounds); } } // Draw the border again to ensure it is not overlapped by the text G.DrawRectangle(Pens.Black, e.Bounds); }
public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { Image image = null; switch ((int)e.Value) { case 1: image = global::BookListWF.Properties.Resources.fantasy; break; case 2: image = global::BookListWF.Properties.Resources.detective; break; default: image = global::BookListWF.Properties.Resources.poetry; break; } e.Graphics.DrawImage(image, 0, 0, e.Bounds.Width, e.Bounds.Height); }
public override void PaintValue(PaintValueEventArgs e) { Icon icon = e.Value as Icon; if (icon != null) { Size size = icon.Size; Rectangle bounds = e.Bounds; if (icon.Width < bounds.Width) { bounds.X = (bounds.Width - icon.Width) / 2; bounds.Width = icon.Width; } if (icon.Height < bounds.Height) { bounds.X = (bounds.Height - icon.Height) / 2; bounds.Height = icon.Height; } e.Graphics.DrawIcon(icon, bounds); } }
// Draws a representation of the property's value. public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { int normalX = (e.Bounds.Width / 2); int normalY = (e.Bounds.Height / 2); //// Fill background and ellipse and center point. e.Graphics.FillRectangle(new SolidBrush(Color.Transparent), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); //e.Graphics.FillEllipse(new SolidBrush(Color.White), e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 3, e.Bounds.Height - 3); //e.Graphics.FillEllipse(new SolidBrush(Color.SlateGray), normalX + e.Bounds.X - 1, normalY + e.Bounds.Y - 1, 3, 3); //// Draw line along the current angle. //double radians = ((double)e.Value * Math.PI) / (double)180; //e.Graphics.DrawLine(new Pen(new SolidBrush(Color.Red), 1), normalX + e.Bounds.X, normalY + e.Bounds.Y, // e.Bounds.X + (normalX + (int)((double)normalX * Math.Cos(radians))), // e.Bounds.Y + (normalY + (int)((double)normalY * Math.Sin(radians)))); //((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); //e.Graphics.DrawImage(global::Fwk.Bases.FrontEnd.Controls.Design.Properties.Resources.sitebuild_icon, new Point()); Image imgTools = global::Fwk.Bases.FrontEnd.Properties.Resources.tools_small; e.Graphics.DrawImageUnscaled(imgTools, new Point()); }