Exemplo n.º 1
0
        protected override void OnDraw(Xwt.Drawing.Context ctx, Rectangle dirtyRect)
        {
            ctx.Rectangle (0, 0, Bounds.Width, Bounds.Height);
            var g = new LinearGradient (0, 0, Bounds.Width, Bounds.Height);
            g.AddColorStop (0, new Color (1, 0, 0));
            g.AddColorStop (1, new Color (0, 1, 0));
            ctx.Pattern = g;
            ctx.Fill ();

            Rectangle r = rect.Inflate (5, 5);
            ctx.Rectangle (r);
            ctx.SetColor (new Color (0,0,1));
            ctx.SetLineWidth (1);
            ctx.Stroke ();
        }
Exemplo n.º 2
0
 public void LinearGradientReverse()
 {
     InitBlank ();
     var g = new LinearGradient (5, 45, 5, 5);
     g.AddColorStop (0, Colors.Red);
     g.AddColorStop (0.5, Colors.Green);
     g.AddColorStop (1, Colors.Blue);
     context.Rectangle (5, 5, 40, 40);
     context.Pattern = g;
     context.Fill ();
     CheckImage ("LinearGradientReverse.png");
 }
Exemplo n.º 3
0
		void DrawBookmark (Context cr, double x, double y)
		{
			var color1 = Style.BookmarkColor1;
			var color2 = Style.BookmarkColor2;
			
			DrawRoundRectangle (cr, x + 1, y + 1, 8, Width - 4, Editor.LineHeight - 4);
			using (var pat = new LinearGradient (x + Width / 4, y, x + Width / 2, y + Editor.LineHeight - 4)) {
				pat.AddColorStop (0, color1);
				pat.AddColorStop (1, color2);
				cr.Pattern = pat;
				cr.FillPreserve ();
			}
			
			using (var pat = new LinearGradient (x, y + Editor.LineHeight, x + Width, y)) {
				pat.AddColorStop (0, color2);
				//pat.AddColorStop (1, color1);
				cr.Pattern = pat;
				cr.Stroke ();
			}
		}
Exemplo n.º 4
0
		protected override void OnDraw (Context ctx, Rectangle dirtyRect)
		{
			double rwidth = Bounds.Width, rheight = Bounds.Height;
			
			if (autoStartY || autoEndY) {
				double nstartY = double.MaxValue;
				double nendY = double.MinValue;
				GetValueRange (AxisDimension.Y, out nstartY, out nendY);
				
				if (!autoStartY) nstartY = startY;
				if (!autoEndY) nendY = endY;
				if (nendY < nstartY) nendY = nstartY;
				
				if (nstartY != startY || nendY != endY) {
					yrangeChanged = true;
					startY = nstartY;
					endY = nendY;
				}
			}
			
			if (autoStartX || autoEndX) {
				double nstartX = double.MaxValue;
				double nendX = double.MinValue;
				GetValueRange (AxisDimension.X, out nstartX, out nendX);
				
				if (!autoStartX) nstartX = startX;
				if (!autoEndX) nendX = endX;
				if (nendX < nstartX) nendX = nstartX;
				
				if (nstartX != startX || nendX != endX) {
					xrangeChanged = true;
					startX = nstartX;
					endX = nendX;
				}
			}
			
			if (yrangeChanged) {
				FixOrigins ();
				double right = rwidth - 2 - AreaBorderWidth;
				left = AreaBorderWidth;
				left += MeasureAxisSize (ctx, AxisPosition.Left) + 1;
				right -= MeasureAxisSize (ctx, AxisPosition.Right) + 1;
				yrangeChanged = false;
				width = right - left + 1;
				if (width <= 0) width = 1;
			}
			
			if (xrangeChanged) {
				FixOrigins ();
				double bottom = rheight - 2 - AreaBorderWidth;
				top = AreaBorderWidth;
				bottom -= MeasureAxisSize (ctx, AxisPosition.Bottom);
				top += MeasureAxisSize (ctx, AxisPosition.Top);
				
				// Make room for cursor handles
				foreach (ChartCursor cursor in cursors) {
					if (cursor.Dimension == AxisDimension.X && top - AreaBorderWidth < cursor.HandleSize)
						top = cursor.HandleSize + AreaBorderWidth;
				}
				
				xrangeChanged = false;
				height = bottom - top + 1;
				if (height <= 0) height = 1;
			}
			
			if (AutoScaleMargin != 0 && height > 0) {
				double margin = (double)AutoScaleMargin * (endY - startY) / (double) height;
				if (autoStartY) startY -= margin;
				if (autoEndY) endY += margin;
			}

//			Console.WriteLine ("L:" + left + " T:" + top + " W:" + width + " H:" + height);
			
			// Draw the background

			if (backgroundDisplay == BackgroundDisplay.Gradient) {
				ctx.Rectangle (left - 1, top - 1, width + 2, height + 2);
				Gradient pat = new LinearGradient (left - 1, top - 1, left - 1, height + 2);
				pat.AddColorStop (0, backroundColor);
				Color endc = new Color (1,1,1);
				pat.AddColorStop (1, endc);
				ctx.Pattern = pat;
				ctx.Fill ();
			} else {
				ctx.Rectangle (left - 1, top - 1, width + 2, height + 2);
				ctx.SetColor (backroundColor);
				ctx.Fill ();
			}
//			win.DrawRectangle (Style.WhiteGC, true, left - 1, top - 1, width + 2, height + 2);
			ctx.SetColor (Colors.Black);
			ctx.Rectangle (left - AreaBorderWidth, top - AreaBorderWidth, width + AreaBorderWidth*2, height + AreaBorderWidth*2);
			ctx.Stroke ();
			
			// Draw selected area
			
			if (enableSelection) {
				int sx, sy, ex, ey;
				GetPoint (selectionStart.Value, selectionStart.Value, out sx, out sy);
				GetPoint (selectionEnd.Value, selectionEnd.Value, out ex, out ey);
				if (sx > ex) {
					int tmp = sx; sx = ex; ex = tmp;
				}
				ctx.SetColor (new Color (225d/255d, 225d/255d, 225d/255d));
				ctx.Rectangle (sx, top, ex - sx, height + 1);
				ctx.Fill ();
			}
			
			// Draw axes
			
			foreach (Axis ax in axis)
				DrawAxis (ctx, ax);
			
			// Draw values
			foreach (Serie serie in series)
				if (serie.Visible)
					DrawSerie (ctx, serie);

			// Draw cursors
			foreach (ChartCursor cursor in cursors)
				DrawCursor (ctx, cursor);
			
			// Draw cursor labels
			foreach (ChartCursor cursor in cursors)
				if (cursor.ShowValueLabel)
					DrawCursorLabel (ctx, cursor);
			
			((IDisposable)ctx).Dispose ();
		}
Exemplo n.º 5
0
 /// <summary>
 /// Draws a representation of this plot in the legend.
 /// </summary>
 /// <param name="ctx">The Drawing Context with which to draw.</param>
 /// <param name="r">
 /// A rectangle specifying the bounds of the area in the legend set aside for drawing
 /// </param>
 public void DrawInLegend(Context ctx, Rectangle r)
 {
     ctx.Save ();
     ctx.SetLineWidth (1);
     ctx.Rectangle (r);
     if (Filled) {
         if (FillGradient != null) {
             // Scale FillGradient to bar rectangle
             double sX = r.X + fillGradient.StartPoint.X * r.Width;
             double sY = r.Y + fillGradient.StartPoint.Y * r.Height;
             double eX = r.X + fillGradient.EndPoint.X * r.Width;
             double eY = r.Y + fillGradient.EndPoint.Y * r.Height;
             LinearGradient g = new LinearGradient (sX, sY, eX, eY);
             g.AddColorStop (0, FillGradient.StartColor);
             g.AddColorStop (1, FillGradient.EndColor);
             ctx.Pattern = g;
         } else {
             ctx.SetColor (FillColor);
         }
         ctx.FillPreserve ();
     }
     ctx.SetColor (BorderColor);
     ctx.Stroke ();
     ctx.Restore ();
 }
Exemplo n.º 6
0
        /// <summary>
        /// Draws the histogram.
        /// </summary>
        /// <param name="ctx">The Drawing Context with which to draw</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            double yoff;
            SequenceAdapter data = new SequenceAdapter (DataSource, DataMember, OrdinateData, AbscissaData);

            ctx.Save ();
            ctx.SetLineWidth (1);

            for (int i=0; i<data.Count; ++i ) {

                // (1) determine the top left hand point of the bar (assuming not centered)
                Point p1 = data[i];
                if (double.IsNaN(p1.X) || double.IsNaN(p1.Y)) {
                    continue;
                }

                // (2) determine the top right hand point of the bar (assuming not centered)
                Point p2 = Point.Zero;;
                if (i+1 != data.Count) {
                    p2 = data[i+1];
                    if (double.IsNaN(p2.X) || double.IsNaN(p2.Y)) {
                        continue;
                    }
                    p2.Y = p1.Y;
                }
                else if (i != 0) {
                    p2 = data[i-1];
                    if (double.IsNaN(p2.X) || double.IsNaN(p2.Y)) {
                        continue;
                    }
                    double offset = p1.X - p2.X;
                    p2.X = p1.X + offset;
                    p2.Y = p1.Y;
                }
                else {
                    double offset = 1.0;
                    p2.X = p1.X + offset;
                    p2.Y = p1.Y;
                }

                // (3) now account for plots this may be stacked on top of.
                HistogramPlot currentPlot = this;
                yoff = 0.0;
                double yval = 0.0;
                while (currentPlot.IsStacked) {
                    SequenceAdapter stackedToData = new SequenceAdapter (
                        currentPlot.stackedTo.DataSource,
                        currentPlot.stackedTo.DataMember,
                        currentPlot.stackedTo.OrdinateData,
                        currentPlot.stackedTo.AbscissaData );

                    yval += stackedToData[i].Y;
                    yoff = yAxis.WorldToPhysical (yval, false).Y;
                    p1.Y += stackedToData[i].Y;
                    p2.Y += stackedToData[i].Y;
                    currentPlot = currentPlot.stackedTo;
                }

                // (4) now account for centering
                if (Center) {
                    double offset = (p2.X - p1.X) / 2.0;
                    p1.X -= offset;
                    p2.X -= offset;
                }

                // (5) now account for BaseOffset (shift of bar sideways).
                p1.X += BaseOffset;
                p2.X += BaseOffset;

                // (6) now get physical coordinates of top two points.
                Point xPos1 = xAxis.WorldToPhysical (p1.X, false);
                Point yPos1 = yAxis.WorldToPhysical (p1.Y, false);
                Point xPos2 = xAxis.WorldToPhysical (p2.X, false);

                if (IsStacked) {
                    currentPlot = this;
                    while (currentPlot.IsStacked) {
                        currentPlot = currentPlot.stackedTo;
                    }
                    baseWidth = currentPlot.baseWidth;
                }

                double width = xPos2.X - xPos1.X;
                double height;
                if (IsStacked) {
                    height = -yPos1.Y+yoff;
                }
                else {
                    height = -yPos1.Y+yAxis.PhysicalMin.Y;
                }

                double xoff = (1.0 - baseWidth)/2.0*width;
                Rectangle bar = new Rectangle (xPos1.X+xoff, yPos1.Y, width-2*xoff, height);

                ctx.Rectangle (bar);
                if (Filled) {
                    if (bar.Height != 0 && bar.Width != 0) {
                        if (FillGradient != null) {
                            // Scale FillGradient to bar rectangle
                            double sX = bar.X + fillGradient.StartPoint.X * bar.Width;
                            double sY = bar.Y + fillGradient.StartPoint.Y * bar.Height;
                            double eX = bar.X + fillGradient.EndPoint.X * bar.Width;
                            double eY = bar.Y + fillGradient.EndPoint.Y * bar.Height;
                            LinearGradient g = new LinearGradient (sX, sY, eX, eY);
                            g.AddColorStop (0, FillGradient.StartColor);
                            g.AddColorStop (1, FillGradient.EndColor);
                            ctx.Pattern = g;
                        } else {
                            ctx.SetColor (FillColor);
                        }
                        ctx.FillPreserve ();
                    }
                }
                ctx.SetColor (BorderColor);
                ctx.Stroke ();
            }
            ctx.Restore ();
        }
Exemplo n.º 7
0
		protected override void OnDraw (Xwt.Drawing.Context ctx, Rectangle dirtyRect)
		{
			if (Bounds.IsEmpty)
				return;

			ctx.Rectangle (0, 0, Bounds.Width, Bounds.Height);
			Gradient g = null;
			if (Linear)
				g = new LinearGradient (xStart, 0, xEnd, Bounds.Height);
			else
				g = new RadialGradient (Bounds.Width / 2, Bounds.Height / 2, Bounds.Width / 2, Bounds.Width / 2, Bounds.Height / 2, xStart/4 + Bounds.Width / 8);

			g.AddColorStop (0, stop1);
			g.AddColorStop (1, stop2);
			ctx.Pattern = g;
			ctx.Fill ();
			
			Rectangle r = rect.Inflate (5, 5);
			ctx.Rectangle (r);
			ctx.SetColor (new Color (0,0,1));
			ctx.SetLineWidth (1);
			ctx.Stroke ();
		}
Exemplo n.º 8
0
        /// <summary>
        /// Draw the marker.
        /// </summary>
        /// <param name="ctx">Context.</param>
        public override void Draw(Context ctx)
        {
            ctx.SetColor(PipelineNode.NodeColorBorder);

            Rectangle bndTmp = Bounds;

            ctx.RoundRectangle(bndTmp.Inflate(-2, -2), 2);
            if (compatible.IsFinal()) {
                ctx.SetColor(Colors.LightGray);
            } else {
                ctx.RoundRectangle(bndTmp.Inflate(-1, -1), 3);
                using (LinearGradient g = new LinearGradient(bndTmp.Left, bndTmp.Top, bndTmp.Right, bndTmp.Bottom)) {
                    g.AddColorStop(0, Colors.Black.BlendWith(NodeColor, 0.7));
                    g.AddColorStop(1, NodeColor);
                    ctx.Pattern = g;
                    ctx.Fill();
                }

                ctx.SetColor(NodeColor);
            }
            ctx.Fill();

            if (IsInput) {
                int inputBufferSize = inputData.Count;
                List<Result> ihCopy;
                lock (inputHistoryLock) {
                    ihCopy = new List<Result>(inputHistory);
                }
                foreach (Result input in ihCopy) {
                    if (input.IsUsed(parent)) {
                        inputBufferSize++;
                    } else {
                        lock (inputHistoryLock) {
                            inputHistory.Remove(input);
                        }
                    }
                }
                if (inputBufferSize > 0) {
                    bool sourceNodeIsAbove = true;
                    if (edges.Count > 0 && edges[0] != null) {
                        if (edges[0].to.Bounds.Center.Y > Bounds.Center.Y - 4.0) {
                            sourceNodeIsAbove = false;
                        }
                    }

                    textLayout.Text = inputBufferSize.ToString();
                    double textWidth = textLayout.GetSize().Width;
                    double textHeight = textLayout.GetSize().Height;
                    Point inputbufferSizeLocation =
                        Bounds.Location.Offset(
                            -24 -(textWidth/2),
                            sourceNodeIsAbove ? textHeight + 6 : -6 - textHeight);

                    ctx.Arc(
                        inputbufferSizeLocation.X + textWidth / 2,
                        inputbufferSizeLocation.Y + textHeight / 2,
                        Math.Max(textHeight, textWidth) / 2 + 1,
                        0, 360
                    );
                    ctx.Fill();

                    ctx.SetColor(PipelineNode.NodeColor);
                    ctx.DrawTextLayout(textLayout, inputbufferSizeLocation);
                }
            } else {
                // if this is a final node
                if (parent.algorithm.Output[positionNo].IsFinal()) {
                    ctx.MoveTo(bndTmp.Right + 4, bndTmp.Top);
                    ctx.LineTo(bndTmp.Right + 4, bndTmp.Bottom);
                    ctx.Stroke();

                    // draw output size on end nodes (= number of features
                    if (parent.results != null &&
                        parent.results.Count > 0 &&
                        parent.results[0].Item1 != null &&
                        parent.results[0].Item1.Length - 1 >= Position) {

                        textLayout.Text = parent.results.Count.ToString();
                        double textWidth = textLayout.GetSize().Width;
                        double textHeight = textLayout.GetSize().Height;
                        Point outputbufferSizeLocation =
                            Bounds.Location.Offset(Bounds.Width * 1.8, 0);

                        ctx.Arc(
                            outputbufferSizeLocation.X + textWidth / 2,
                            outputbufferSizeLocation.Y + textHeight / 2,
                            Math.Max(textHeight, textWidth) / 2 + 1,
                            0, 360
                        );
                        ctx.Fill();

                        ctx.SetColor(PipelineNode.NodeColor);
                        ctx.DrawTextLayout(textLayout, outputbufferSizeLocation);
                    }
                }
            }
        }
Exemplo n.º 9
0
 LinearGradient GetTopEdgeGradient(double top, double thickness)
 {
     var gradient = new LinearGradient (0, top - thickness, 0, top + thickness);
     gradient.AddColorStop (0, GetColor (BackgroundColor, 0.75));
     gradient.AddColorStop (1, BackgroundColor);
     return gradient;
 }
Exemplo n.º 10
0
 LinearGradient GetRightEdgeGradient(double right, double thickness)
 {
     var gradient = new LinearGradient (right - thickness, 0, right + thickness, 0);
     gradient.AddColorStop (0, BackgroundColor);
     gradient.AddColorStop (1, GetColor (BackgroundColor, 0.75));
     return gradient;
 }
Exemplo n.º 11
0
 LinearGradient GetLeftEdgeGradient(double left, double thickness)
 {
     var gradient = new LinearGradient (left - thickness, 0, left + thickness, 0);
     gradient.AddColorStop (0, GetColor (BackgroundColor, 0.75));
     gradient.AddColorStop (1, BackgroundColor);
     return gradient;
 }
Exemplo n.º 12
0
 LinearGradient GetBottomEdgeGradient(double bottom, double thickness)
 {
     var gradient = new LinearGradient (0, bottom - thickness, 0, bottom + thickness);
     gradient.AddColorStop (0, BackgroundColor);
     gradient.AddColorStop (1, GetColor (BackgroundColor, 0.75));
     return gradient;
 }
Exemplo n.º 13
0
        static void Draw(Context ctx, LogLevel level, Color color)
        {
            using (TextLayout text = new TextLayout()) {
                text.Text = level.ToString();

                double height = text.GetSize().Height;

                ctx.SetColor(color);
                ctx.RoundRectangle(0, 1, height - 2, height - 2, 3);
                ctx.Fill();

                // inner shadow
                ctx.RoundRectangle(0, 1, height - 2, height - 2, 3);
                LinearGradient g = new LinearGradient(1, 2, height - 2, height - 2);
                g.AddColorStop(0, Colors.Black.BlendWith(color, 0.7));
                g.AddColorStop(1, color);
                ctx.Pattern = g;
                ctx.Fill();

                ctx.SetColor(Colors.Black);
                ctx.DrawTextLayout(text, new Point(height + 3, 0));
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Draw the the PlotSurface and contents (axes, drawables, and legend) using the
        /// Drawing Context supplied and the bounding rectangle for the PlotSurface to cover
        /// </summary>
        /// <param name="ctx">The Drawing Context with which to draw.</param>
        /// <param name="bounds">The rectangle within which to draw</param>
        public void Draw(Context ctx, Rectangle bounds)
        {
            Point titleOrigin = Point.Zero;

            ctx.Save ();

            // determine font sizes and tick scale factor.
            double scale = DetermineScaleFactor (bounds.Width, bounds.Height);

            // if there is nothing to plot, draw title and return.
            if (drawables.Count == 0) {
                // draw title
                //TODO: Title should be centred here - not its origin
                Point origin = Point.Zero;
                titleOrigin.X = bounds.Width/2;
                titleOrigin.Y = bounds.Height/2;
                DrawTitle (ctx, titleOrigin, scale);
                ctx.Restore ();
                return;
            }

            // determine the [non physical] axes to draw based on the axis properties set.
            Axis XAxis1 = null;
            Axis XAxis2 = null;
            Axis YAxis1 = null;
            Axis YAxis2 = null;
            DetermineAxesToDraw (out XAxis1, out XAxis2, out YAxis1, out YAxis2);

            // apply scale factor to axes as desired.

            if (XAxis1.AutoScaleTicks) {
                XAxis1.TickScale = scale;
            }
            if (XAxis1.AutoScaleText) {
                XAxis1.FontScale = scale;
            }
            if (YAxis1.AutoScaleTicks) {
                YAxis1.TickScale = scale;
            }
            if (YAxis1.AutoScaleText) {
                YAxis1.FontScale = scale;
            }
            if (XAxis2.AutoScaleTicks) {
                XAxis2.TickScale = scale;
            }
            if (XAxis2.AutoScaleText) {
                XAxis2.FontScale = scale;
            }
            if (YAxis2.AutoScaleTicks) {
                YAxis2.TickScale = scale;
            }
            if (YAxis2.AutoScaleText) {
                YAxis2.FontScale = scale;
            }

            // determine the default physical positioning of those axes.
            PhysicalAxis pXAxis1 = null;
            PhysicalAxis pYAxis1 = null;
            PhysicalAxis pXAxis2 = null;
            PhysicalAxis pYAxis2 = null;
            DeterminePhysicalAxesToDraw (
                bounds, XAxis1, XAxis2, YAxis1, YAxis2,
                out pXAxis1, out pXAxis2, out pYAxis1, out pYAxis2 );

            double oldXAxis2Height = pXAxis2.PhysicalMin.Y;

            // Apply axes constraints
            for (int i=0; i<axesConstraints.Count; ++i) {
                ((AxesConstraint)axesConstraints[i]).ApplyConstraint(
                    pXAxis1, pYAxis1, pXAxis2, pYAxis2 );
            }

            // draw legend if have one.
            // Note: this will update axes if necessary.
            Point legendPosition = new Point(0,0);
            if (legend != null) {
                legend.UpdateAxesPositions (
                    pXAxis1, pYAxis1, pXAxis2, pYAxis2,
                    drawables, scale, Padding, bounds,
                    out legendPosition );
            }

            double newXAxis2Height = pXAxis2.PhysicalMin.Y;
            double titleExtraOffset = oldXAxis2Height - newXAxis2Height;

            // now we are ready to define the clipping region
            plotAreaBoundingBoxCache = new Rectangle (
                Math.Min (pXAxis1.PhysicalMin.X, pXAxis1.PhysicalMax.X),
                Math.Min (pYAxis1.PhysicalMax.Y, pYAxis1.PhysicalMin.Y),
                Math.Abs (pXAxis1.PhysicalMax.X - pXAxis1.PhysicalMin.X + 1),
                Math.Abs (pYAxis1.PhysicalMin.Y - pYAxis1.PhysicalMax.Y + 1)
            );
            bbXAxis1Cache = pXAxis1.GetBoundingBox ();
            bbXAxis2Cache = pXAxis2.GetBoundingBox ();
            bbYAxis1Cache = pYAxis1.GetBoundingBox ();
            bbYAxis2Cache = pYAxis2.GetBoundingBox ();

            Rectangle plotBounds = (Rectangle)plotAreaBoundingBoxCache;

            // set the clipping region.. (necessary for zoom)
            // Note: although clipping is enforced by the clip region, it is probably more efficient
            // for each Drawable to check against the plotBounds and not draw if points are outside.
            // This hasn't yet been implemented
            ctx.Save ();
            ctx.Rectangle (plotBounds);
            ctx.Clip ();

            // Fill in the plot background.
            if (plotBackImage != null) {
                // Ensure plotBounds has integer size for correct tiling/drawing
                plotBounds.Width = Math.Truncate (plotBounds.Width);
                plotBounds.Height = Math.Truncate (plotBounds.Height);
                ctx.DrawImage (Utils.TiledImage (plotBackImage , plotBounds.Size), plotBounds);
            }
            else if (plotBackGradient != null) {
                // Scale plotBackGradient to plotBounds
                double startX = plotBounds.X + (plotBackGradient.StartPoint.X * plotBounds.Width);
                double startY = plotBounds.Y + (plotBackGradient.StartPoint.Y * plotBounds.Height);
                double endX = plotBounds.X + (plotBackGradient.EndPoint.X * plotBounds.Width);
                double endY = plotBounds.Y + (plotBackGradient.EndPoint.Y * plotBounds.Height);
                LinearGradient g = new LinearGradient (startX, startY, endX, endY);
                g.AddColorStop (0, plotBackGradient.StartColor);
                g.AddColorStop (1, plotBackGradient.EndColor);
                ctx.Rectangle (plotBounds);
                ctx.Pattern = g;
                ctx.Fill ();
            }
            else {
                ctx.Rectangle (plotBounds);
                ctx.SetColor (plotBackColor);
                ctx.Fill ();
            }

            // draw title at centre of Physical X-axis and at top of plot

            titleOrigin.X = (pXAxis2.PhysicalMax.X + pXAxis2.PhysicalMin.X)/2.0;
            titleOrigin.Y = bounds.Top + Padding - titleExtraOffset;
            Size s = DrawTitle (ctx, titleOrigin, scale);

            bbTitleCache = new Rectangle (titleOrigin.X-s.Width/2, titleOrigin.Y, s.Width, s.Height);

            // draw drawables..
            bool legendDrawn = false;

            for (int i_o = 0; i_o < ordering.Count; ++i_o) {

                int i = (int)ordering.GetByIndex (i_o);
                double zOrder = (double)ordering.GetKey (i_o);
                if (zOrder > legendZOrder) {
                    // draw legend.
                    if (!legendDrawn && legend != null) {
                        legend.Draw (ctx, legendPosition, drawables, scale);
                        legendDrawn = true;
                    }
                }

                IDrawable drawable = (IDrawable)drawables[i];
                XAxisPosition xap = (XAxisPosition)xAxisPositions[i];
                YAxisPosition yap = (YAxisPosition)yAxisPositions[i];

                PhysicalAxis drawXAxis;
                PhysicalAxis drawYAxis;

                if (xap == XAxisPosition.Bottom) {
                    drawXAxis = pXAxis1;
                }
                else {
                    drawXAxis = pXAxis2;
                }

                if (yap == YAxisPosition.Left) {
                    drawYAxis = pYAxis1;
                }
                else {
                    drawYAxis = pYAxis2;
                }

                drawable.Draw (ctx, drawXAxis, drawYAxis);

            }

            if (!legendDrawn && legend != null) {
                legend.Draw (ctx, legendPosition, drawables, scale);
            }

            ctx.Restore ();		// end of clipping region

            // cache the physical axes we used on this draw;
            pXAxis1Cache = pXAxis1;
            pYAxis1Cache = pYAxis1;
            pXAxis2Cache = pXAxis2;
            pYAxis2Cache = pYAxis2;

            // now draw axes.
            Rectangle axisBounds;
            pXAxis1.Draw (ctx, out axisBounds);
            pXAxis2.Draw (ctx, out axisBounds);
            pYAxis1.Draw (ctx, out axisBounds);
            pYAxis2.Draw (ctx, out axisBounds);

            #if DEBUG_BOUNDING_BOXES
            ctx.SetColor (Colors.Orange);
            ctx.Rectangle ((Rectangle)bbXAxis1Cache);
            ctx.Rectangle ((Rectangle)bbXAxis2Cache);
            ctx.Rectangle ((Rectangle)bbYAxis1Cache);
            ctx.Rectangle ((Rectangle)bbYAxis2Cache);
            ctx.Stroke ();
            ctx.SetColor (Colors.Red);
            ctx.Rectangle ((Rectangle)plotAreaBoundingBoxCache);
            ctx.Rectangle ((Rectangle)bbTitleCache);
            ctx.Stroke ();
            #endif
            ctx.Restore ();
        }
Exemplo n.º 15
0
 public void SaveRestoreLinearGradient()
 {
     // Pattern is saved
     InitBlank ();
     var g = new LinearGradient (5, 5, 5, 45);
     g.AddColorStop (0, Colors.Red);
     g.AddColorStop (0.5, Colors.Green);
     g.AddColorStop (1, Colors.Blue);
     context.Save ();
     context.Pattern = g;
     context.Restore ();
     context.Rectangle (5, 5, 40, 40);
     context.Fill ();
     CheckImage ("SaveRestoreLinearGradient.png");
 }
Exemplo n.º 16
0
 void DrawGradientButton(Xwt.Drawing.Context G, GradientButton B)
 {
     DrawingPath P = new DrawingPath();
     P.Rectangle(new Xwt.Rectangle(B.Position, B.Size));
     LinearGradient gr;
     G.AppendPath(P);
     Pattern pat = gr = new LinearGradient(B.Position.X, B.Position.Y, B.Position.X + B.Size.Width, B.Position.Y + B.Size.Height);
     gr.AddColorStop(0, B.Color.BlendWith(Colors.White, 0.8));
     gr.AddColorStop(0.5, B.Color);
     gr.AddColorStop(1, B.Color.BlendWith(Colors.White, 0.8));
     G.Pattern = pat;
     G.Fill();
     G.AppendPath(P);
     G.SetColor(Xwt.Drawing.Colors.Black);
     G.SetLineWidth(1);
     G.Stroke();
     TextLayout L = new TextLayout()
     {
         Font = B.Font,
         Text = B.Text
     };
     Size TextSize = new Size(0.6 * L.Font.Size * L.Text.Count(), L.Font.Size);
     G.DrawTextLayout(L, new Xwt.Point(B.Position.X + B.Size.Width / 2 - TextSize.Width / 2, B.Position.Y + B.Size.Height / 2 - TextSize.Height / 2));
 }
Exemplo n.º 17
0
 void DrawCache(Context ctx)
 {
     ctx.Save ();
     // Test 'background' is a vertical colour gradient
     ctx.Rectangle (0, 0, Bounds.Width, Bounds.Height);
     Gradient g = new Xwt.Drawing.LinearGradient (0, 0, 0, Bounds.Height);
     g.AddColorStop (0, new Color (0.5, 0.5, 1));
     g.AddColorStop (1, new Color (0.5, 1, 0.5));
     ctx.Pattern = g;
     ctx.Fill ();
     ctx.Restore ();
 }