public override void InternalRender(RenderContext context) { base.InternalRender(context); if (_filler == null) { return; } var v = _value; if (v < Minimum) { v = Minimum; } if (v > Maximum) { v = Maximum; } var delta = Maximum - Minimum; if (delta.IsZero()) { return; } var filledPart = (v - Minimum) / delta; if (filledPart.EpsilonEquals(0.0f)) { return; } var bounds = ActualBounds; if (Orientation == Orientation.Horizontal) { _filler.Draw(context, new Rectangle(bounds.X, bounds.Y, (int)(filledPart * bounds.Width), bounds.Height), Color.White); } else { _filler.Draw(context, new Rectangle(bounds.X, bounds.Y, bounds.Width, (int)(filledPart * bounds.Height)), Color.White); } }
void BlockChange(Player sender, BlockChangeEventArgs e) { e.Cancel(); var raw = (BrushData)sender.ExtraData.GetIfExist <object, object> ("BrushData"); if (raw == null) { sender.SendMessage("An error occurred while trying to brush"); sender.OnPlayerBlockChange.Normal -= BlockChange; return; } byte block = raw.Block != 255 ? raw.Block : e.Holding; Vector3S loc = new Vector3S(e.X, e.Z, e.Y); IBrush b = (IBrush)Activator.CreateInstance(raw.BrushType); var qq = b.Draw(loc, raw.Block, raw.Size); if (sender.Group.MaxBlockChange < qq.Count()) { sender.SendMessage("You cannot set that many blocks"); return; } foreach (var fml in qq) { sender.SendBlockChange((ushort)fml.x, (ushort)fml.z, (ushort)fml.y, block); } #if DEBUG sender.SendMessage(string.Format("Brushed {0} blocks", qq.Count())); #endif }
private void pictureBoxPicture_Paint(object sender, PaintEventArgs e) { Pen pen = new Pen(Color.Black); pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; pen.Width = 5; brush.Draw(e, pen); if (radioButtonPolygonBrush.Checked && !(brush is PolygonBrush)) { if (vertices.Count > 0) { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(vertices[0].X - 5, vertices[0].Y - 5, 10, 10); e.Graphics.DrawEllipse(pen, rect); e.Graphics.FillEllipse(Brushes.Black, rect); } for (int i = 1; i < vertices.Count; i++) { e.Graphics.DrawLine(pen, vertices[i - 1].ToPoint(), vertices[i].ToPoint()); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(vertices[i].X - 5, vertices[i].Y - 5, 10, 10); e.Graphics.DrawEllipse(pen, rect); e.Graphics.FillEllipse(Brushes.Black, rect); } } }
public static void Draw(this IBrush brush, RenderContext context, Rectangle dest) { brush.Draw(context, dest, Color.White); }
/// <summary> /// Draws texture region taking into account the context transformations /// </summary> /// <param name="brush"></param> /// <param name="rectangle"></param> /// <param name="color"></param> public void Draw(IBrush brush, Rectangle rectangle, Color?color = null) { var c = color != null ? color.Value : Color.White; brush.Draw(Batch, rectangle, c * Opacity); }