private void DrawGradientItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0 && e.Index < Gradients.List.Count) { IGradient g = Gradients.List[e.Index]; GradientPainter.FillRectangle(e.Graphics, g, e.Bounds, GradientPainter.Direction.Right); } e.DrawFocusRectangle(); }
/// <summary> /// Draws a z-<see cref="Scale">Scale</see> for a <see cref="Plot2D">2D Plot</see>. /// </summary> /// <param name="g">The <see cref="Graphics"/> to paint to</param> /// <param name="Model">The <see cref="PlotModel"/> of the Plot</param> /// <param name="v">The orientation of the scale</param> /// <param name="draw">If false, the scale is not drawn only is extensions are measured</param> /// <param name="r">The rectangle where the z-gradient is drawn inside</param> /// <param name="norms">The extensions of the painting</param> public static void DrawZScale(Graphics g, PlotModel Model, ref PointF[] v, bool draw, Rectangle r, ref Norms norms) { Function2DItem f = Model.GetPaintableItem() as Function2DItem; if (Model.z.scale && f != null) { Model.z.oppositeRaster = Model.z.oppositeLine = false; Model.z.scaleOutside = Model.z.rasterOutside = false; if (draw) { GradientPainter.FillRectangle(g, f.Gradient, r, GradientPainter.Direction.Up); Pen pen = new Pen(Model.ScaleColor, Model.ScaleLineWidth); g.DrawRectangle(pen, r); } SizeF size = g.MeasureString("0.5", Model.ScaleFont); float s0 = Math.Max(1, size.Height); v[0] = new PointF(r.X + r.Width, r.Y + r.Height); v[1] = new PointF(r.X + r.Width, r.Y); v[2] = new PointF(r.X + r.Width + s0, r.Y + r.Height); DrawScale(g, v, Model, Model.z, draw, ref norms); } }