当前位置: 首页>>代码示例>>C#>>正文


C# Context.FillPreserve方法代码示例

本文整理汇总了C#中Xwt.Drawing.Context.FillPreserve方法的典型用法代码示例。如果您正苦于以下问题:C# Context.FillPreserve方法的具体用法?C# Context.FillPreserve怎么用?C# Context.FillPreserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xwt.Drawing.Context的用法示例。


在下文中一共展示了Context.FillPreserve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDraw

 protected override void OnDraw(Context ctx)
 {
     ctx.SetLineWidth (5);
     ctx.SetColor (new Color (1.0f, 0f, 0.5f));
     ctx.Rectangle (5, 5, 200, 100);
     ctx.FillPreserve ();
     ctx.SetColor (new Color (0f, 0f, 1f));
     ctx.Stroke ();
 }
开发者ID:sandeep-datta,项目名称:xwt,代码行数:9,代码来源:NotebookSample.cs

示例2: OnDraw

        protected override void OnDraw(Context ctx, Rectangle cellArea)
        {
            var pct = GetValue (ValueField);
            var size = (cellArea.Width * pct) / 100f;
            cellArea.Width = (int) size;

            ctx.SetLineWidth (1);
            ctx.Rectangle (cellArea.Inflate (-0.5, -0.5));
            ctx.SetColor (Colors.LightBlue);
            ctx.FillPreserve ();
            ctx.SetColor (Colors.Gray);
            ctx.Stroke ();
        }
开发者ID:nbros,项目名称:xwt,代码行数:13,代码来源:ListView1.cs

示例3: Draw


//.........这里部分代码省略.........
            else {
                throw new NPlotException( "logic error in legend base" );
            }

            // determine height of legend in items count units.
            int heightInItemCount = 0;
            if (extendingHorizontally) {
                if (labelCount >= numberItemsVertically_) {
                    heightInItemCount = numberItemsVertically_;
                }
                else {
                    heightInItemCount = labelCount;
                }
            }
            else {		// extendingVertically
                heightInItemCount = labelCount / numberItemsHorizontally_;
                if (labelCount % numberItemsHorizontally_ != 0)
                    heightInItemCount += 1;
            }

            double lineLength = 20;
            double hSpacing = (int)(5.0f * scale);
            double vSpacing = (int)(3.0f * scale);
            double boxWidth = (int) ((float)widthInItemCount * (lineLength + maxWd + hSpacing * 2.0f ) + hSpacing);
            double boxHeight = (int)((float)heightInItemCount * (maxHt + vSpacing) + vSpacing);

            double totalWidth = boxWidth;
            double totalHeight = boxHeight;

            // draw box around the legend.
            if (BorderStyle == BorderType.Line) {
                ctx.SetColor (bgColor_);
                ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight);
                ctx.FillPreserve ();
                ctx.SetColor (borderColor_);
                ctx.Stroke ();
            }
            else if (BorderStyle == BorderType.Shadow) {
                double offset = (4.0 * scale);
                Color shade = Colors.Gray;
                shade.Alpha = 0.5;
                ctx.SetColor (Colors.Gray);
                ctx.Rectangle (position.X+offset, position.Y+offset, boxWidth, boxHeight);
                ctx.Fill ();
                ctx.SetColor (bgColor_);
                ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight);
                ctx.FillPreserve ();
                ctx.SetColor (borderColor_);
                ctx.Stroke ();

                totalWidth += offset;
                totalHeight += offset;
            }

            /*
               else if ( this.BorderStyle == BorderType.Curved )
               {
                   // TODO. make this nice.
               }
            */
            else {
                // do nothing.
            }

            // now draw entries in box..
            labelCount = 0;
开发者ID:parnham,项目名称:NPlot,代码行数:67,代码来源:LegendBase.cs

示例4: Draw

        /// <summary>
        /// Draws the candle plot with the specified Drawing Context and X,Y axes
        /// </summary>
        /// <param name="ctx">The Drawing Context with which to draw</param>
        /// <param name="xAxis">The physical X-Axis to draw against</param>
        /// <param name="yAxis">The physical Y-Axis to draw against</param>
        public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            CandleDataAdapter cd = new CandleDataAdapter (DataSource, DataMember,
                AbscissaData, OpenData, LowData, HighData, CloseData);

            double offset = 0;
            if (Centered) {
                offset = CalculatePhysicalSeparation (cd,xAxis)/2;
            }

            double addAmount = StickWidth/2;
            double stickWidth = StickWidth;

            if (StickWidth == AutoScaleStickWidth) {
                // default
                addAmount = 2;
                stickWidth = 4;

                double minDist = CalculatePhysicalSeparation (cd, xAxis);

                addAmount = minDist / 3;
                stickWidth = addAmount * 2;
            }

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

            /*
            // brant hyatt proposed.
            if (Style == Styles.Stick)
            {
                p.Width = stickWidth;
                addAmount = stickWidth + 2;
            }
            */

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

                PointOLHC point = (PointOLHC)cd [i];
                if ((!double.IsNaN (point.Open)) && (!double.IsNaN(point.High))
                 && (!double.IsNaN (point.Low)) && (!double.IsNaN(point.Close))) {
                    double xPos = (xAxis.WorldToPhysical (point.X, false)).X;

                    if (xPos + offset + addAmount < xAxis.PhysicalMin.X || xAxis.PhysicalMax.X < xPos + offset - addAmount) {
                        continue;
                    }

                    double yLo  = (yAxis.WorldToPhysical (point.Low,  false)).Y;
                    double yHi  = (yAxis.WorldToPhysical (point.High, false)).Y;
                    double yOpn = (yAxis.WorldToPhysical (point.Open, false)).Y;
                    double yCls = (yAxis.WorldToPhysical (point.Close,false)).Y;

                    if (Style == Styles.Stick) {
                        /*
                        // brant hyatt proposed.
                        if (i > 0)
                        {
                            if ( ((PointOLHC)cd[i]).Close > ((PointOLHC)cd[i-1]).Close)
                            {
                                p.Color = BullishColor;
                            }
                            else
                            {
                                p.Color = BearishColor;
                            }
                        }
                        */
                        ctx.SetColor (Color);
                        ctx.MoveTo (xPos+offset, yLo);
                        ctx.LineTo (xPos+offset, yHi);		// Low to High line

                        ctx.MoveTo (xPos-addAmount+offset, yOpn);
                        ctx.LineTo (xPos+offset, yOpn);		// Open line

                        ctx.MoveTo (xPos+addAmount+offset, yCls);
                        ctx.LineTo (xPos+offset, yCls);		// Close line
                        ctx.Stroke ();
                    }
                    else if (Style == Styles.Filled) {
                        ctx.MoveTo (xPos+offset, yLo);
                        ctx.LineTo (xPos+offset, yHi);
                        ctx.Stroke ();
                        if (yOpn > yCls) {
                            ctx.SetColor (BullishColor);
                            ctx.Rectangle (xPos-addAmount+offset, yCls, stickWidth, yOpn - yCls);
                            ctx.FillPreserve ();
                            ctx.SetColor (Color);
                            ctx.Stroke ();
                        }
                        else if (yOpn < yCls) {
                            ctx.SetColor (BearishColor);
                            ctx.Rectangle (xPos-addAmount+offset, yOpn, stickWidth, yCls - yOpn);
                            ctx.FillPreserve ();
                            ctx.SetColor (Color);
//.........这里部分代码省略.........
开发者ID:hwthomas,项目名称:XwPlot,代码行数:101,代码来源:CandlePlot.cs

示例5: DrawBookmark

		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 ();
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:20,代码来源:IconMargin.cs

示例6: Scale

        public virtual void Scale(Context ctx, double ax, double ay)
        {
            ctx.Save ();
            ctx.Translate (ax, ay);
            ctx.SetColor (Colors.Black);
            ctx.SetLineWidth (1);

            var x = 0d;
            var y = 0d;
            var w = 10d;
            var inc = .1d;
            for (var i = inc; i < 3.5d; i +=inc) {
                ctx.Save ();
                ctx.Scale (i, i);
                ctx.Rectangle (x, y, w, w);
                ctx.SetColor (Colors.Yellow.WithAlpha (1 / i));
                ctx.FillPreserve ();
                ctx.SetColor (Colors.Red.WithAlpha (1 / i));
                ctx.Stroke ();
                ctx.MoveTo (x += w * inc, y += w * inc / 3);
                ctx.Restore ();

            }

            ctx.Restore ();
        }
开发者ID:RevolutionSmythe,项目名称:xwt,代码行数:26,代码来源:DrawingTransforms.cs

示例7: DrawCursor

		void DrawCursor (Context ctx, ChartCursor cursor)
		{
			ctx.SetColor (cursor.Color);
			
			double x, y;
			GetPoint (cursor.Value, cursor.Value, out x, out y);
				
			if (cursor.Dimension == AxisDimension.X) {
				double cy = top - AreaBorderWidth - 1;
				ctx.MoveTo (x, cy);
				ctx.LineTo (x + (cursor.HandleSize/2), cy - cursor.HandleSize + 1);
				ctx.LineTo (x - (cursor.HandleSize/2), cy - cursor.HandleSize + 1);
				ctx.ClosePath ();
				if (activeCursor == cursor)
					ctx.FillPreserve ();
				ctx.Stroke ();
				ctx.MoveTo (x, top);
				ctx.RelLineTo (0, height);
				ctx.Stroke ();
			} else {
				throw new NotSupportedException ();
			}
		}
开发者ID:m13253,项目名称:xwt,代码行数:23,代码来源:BasicChart.cs

示例8: DrawInLegend

 /// <summary>
 /// Draws a representation of this plot in the legend.
 /// </summary>
 /// <param name="g">The graphics surface on which to draw.</param>
 /// <param name="startEnd">A rectangle specifying the bounds of the area in the legend set aside for drawing.</param>
 public virtual void DrawInLegend(Context ctx, Rectangle startEnd)
 {
     double smallerHeight = (startEnd.Height * 0.5);
     //double heightToRemove = (startEnd.Height * 0.5f);
     ctx.Save ();
     ctx.SetColor (fillColor);
     Rectangle newRectangle = new Rectangle (startEnd.Left, startEnd.Top + smallerHeight/2, startEnd.Width, smallerHeight);
     ctx.Rectangle (newRectangle);
     ctx.FillPreserve ();
     ctx.SetColor (borderColor);
     ctx.Stroke ();
     ctx.Restore ();
 }
开发者ID:hwthomas,项目名称:XwPlot,代码行数:18,代码来源:BarPlot.cs

示例9: Draw


//.........这里部分代码省略.........
                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 ();
        }
开发者ID:hwthomas,项目名称:XwPlot,代码行数:101,代码来源:HistogramPlot.cs

示例10: Draw

        /// <summary>
        /// Draws the marker at the given position
        /// </summary>
        /// <param name="ctx">The Drawing Context with which to draw.</param>
        /// <param name="x">The [physical] x position to draw the marker.</param>
        /// <param name="y">The [physical] y position to draw the marker.</param>
        public void Draw(Context ctx, double x, double y )
        {
            ctx.Save ();
            ctx.SetLineWidth (lineWidth);
            ctx.SetColor (lineColor);

            switch (markerType) {
            case MarkerType.Cross1:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x+h, y-h);
                ctx.MoveTo (x+h, y+h);
                ctx.LineTo (x-h, y-h);
                ctx.Stroke ();
                break;

            case MarkerType.Cross2:
                ctx.MoveTo (x, y-h);
                ctx.LineTo (x, y+h);
                ctx.MoveTo (x-h, y);
                ctx.LineTo (x+h, y);
                ctx.Stroke ();
                break;

            case MarkerType.Circle:
                ctx.MoveTo (x+h,y);
                ctx.Arc (x, y, h, 0, 360);
                ctx.ClosePath ();
                if (filled ) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Square:
                ctx.Rectangle (x-h, y-h, size, size);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.Triangle:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x, y-h);
                ctx.LineTo (x+h, y+h);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.TriangleDown:
                ctx.MoveTo (x-h, y-h);
                ctx.LineTo (x, y+h);
                ctx.LineTo (x+h, y-h);
                ctx.ClosePath ();
                if (filled) {
                    ctx.SetColor (fillColor);
                    ctx.FillPreserve ();
                }
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledCircle:
                ctx.MoveTo (x+h,y);
                ctx.Arc (x, y, h, 0, 360);
                ctx.ClosePath ();
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledSquare:
                ctx.Rectangle (x-h, y-h, size, size);
                ctx.ClosePath ();
                ctx.SetColor (fillColor);
                ctx.FillPreserve ();
                ctx.SetColor (lineColor);
                ctx.Stroke ();
                break;

            case MarkerType.FilledTriangle:
                ctx.MoveTo (x-h, y+h);
                ctx.LineTo (x, y-h);
//.........这里部分代码省略.........
开发者ID:hwthomas,项目名称:XwPlot,代码行数:101,代码来源:Marker.cs

示例11: OnDraw

        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw (ctx, dirtyRect);

            if (!pset) {
                ParentWindow.BoundsChanged += delegate {
                    QueueDraw ();
                };
                pset = true;
            }

            ctx.Rectangle (Bounds);
            ctx.SetColor (Colors.LightGray);
            ctx.Fill ();

            var size = Size;
            size.Width--;
            size.Height--;
            var fx = size.Width / Desktop.Bounds.Width;

            if (Desktop.Bounds.Height * fx > size.Height)
                fx = size.Height / Desktop.Bounds.Height;

            if (Desktop.Bounds.X < 0)
                ctx.Translate (-Desktop.Bounds.X * fx, 0);
            if (Desktop.Bounds.Y < 0)
                ctx.Translate (0, -Desktop.Bounds.Y * fx);

            ctx.SetLineWidth (1);
            foreach (var s in Desktop.Screens) {
                if (s.Bounds != s.VisibleBounds) {
                    var vr = new Rectangle ((int)(s.Bounds.X * fx), (int)(s.Bounds.Y * fx), (int)(s.Bounds.Width * fx), (int)(s.Bounds.Height * fx));
                    vr = vr.Offset (0.5, 0.5);
                    ctx.Rectangle (vr);
                    ctx.SetColor (Colors.White);
                    ctx.FillPreserve ();
                    ctx.SetColor (Colors.Black);
                    ctx.Stroke ();
                }
                var r = new Rectangle ((int)(s.VisibleBounds.X * fx), (int)(s.VisibleBounds.Y * fx), (int)(s.VisibleBounds.Width * fx), (int)(s.VisibleBounds.Height * fx));
                r = r.Offset (0.5, 0.5);
                ctx.Rectangle (r);
                ctx.SetColor (new Color (0.4, 0.62, 0.83));
                ctx.FillPreserve ();
                ctx.SetColor (Colors.Black);
                ctx.Stroke ();

                TextLayout tl = new TextLayout (ctx);
                tl.Text = s.DeviceName;
                tl.Font = Font;
                ctx.DrawTextLayout (tl, r.Center.X - tl.Width / 2, r.Center.Y - tl.Height / 2);
            }

            var wr = ParentWindow.ScreenBounds;
            wr = new Rectangle ((int)(wr.X * fx), (int)(wr.Y * fx), (int)(wr.Width * fx), (int)(wr.Height * fx));
            ctx.Rectangle (wr);
            ctx.SetColor (Colors.Azure.WithAlpha (0.5));
            ctx.FillPreserve ();
            ctx.SetColor (Colors.Azure);
            ctx.Stroke ();
        }
开发者ID:garuma,项目名称:xwt,代码行数:61,代码来源:ScreensSample.cs

示例12: DrawInLegend

 /// <summary>
 /// Draws a representation of this plot in the legend.
 /// </summary>
 /// <param name="ctx">The Drawing Context with which to draw.</param>
 /// <param name="startEnd">A rectangle specifying the bounds of the area in the legend set aside for drawing.</param>
 public void DrawInLegend(Context ctx, Rectangle startEnd )
 {
     ctx.Save ();
     ctx.Rectangle (startEnd);
     if (Filled) {
         ctx.SetColor (fillColor);
         ctx.FillPreserve ();
     }
     ctx.Stroke ();
     ctx.Restore ();
 }
开发者ID:parnham,项目名称:NPlot,代码行数:16,代码来源:HistogramPlot.cs

示例13: Draw


//.........这里部分代码省略.........

            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 r = new Rectangle (xPos1.X+xoff, yPos1.Y, width-2*xoff, height);

                ctx.Rectangle (r);
                if (Filled) {
                    if (r.Height != 0 && r.Width != 0) {
                        // room for optimization maybe.
                        ctx.SetColor (fillColor);
                        ctx.FillPreserve ();
                    }
                }
                ctx.SetColor (borderColor);
                ctx.Stroke ();
            }
            ctx.Restore ();
        }
开发者ID:parnham,项目名称:NPlot,代码行数:101,代码来源:HistogramPlot.cs

示例14: OnDraw

        /// <summary>
        /// Raises the draw event.
        /// </summary>
        /// <param name="ctx">Context.</param>
        /// <param name="dirtyRect">Dirty rect.</param>
        protected override void OnDraw(Context ctx, Rectangle dirtyRect)
        {
            base.OnDraw(ctx, dirtyRect);

            ctx.SetLineWidth(1.0);

            if (previous != null && !previous.Active) {
                ctx.SetColor(deactiveColor);
                if (Multiple) {
                    ctx.Rectangle(0, 0, Lean.Dx * 2, Size.Height);
                    ctx.Fill();

                    ctx.SetColor(borderColor);
                    ctx.MoveTo(0, 0);
                    ctx.LineTo(Lean.Dx * 2, 0);
                    ctx.Stroke();
                } else {
                    ctx.MoveTo(0, 0);
                    ctx.CurveTo(
                        0, 0,
                        Lean.Dx, 0,
                        Lean.Dx, Lean.Dy);
                    ctx.LineTo(Lean.Dx, Size.Height - Lean.Dy);
                    ctx.CurveTo(
                        Lean.Dx, Size.Height - Lean.Dy,
                        Lean.Dx, Size.Height + 0.5,
                        Lean.Dx * 2, Size.Height + 0.5);
                    ctx.LineTo(0, Size.Height);

                    ctx.FillPreserve();

                    ctx.SetColor(borderColor);
                    ctx.Stroke();
                }
            }

            if (previous == null || Multiple || !previous.Active) {
                ctx.MoveTo(0, Size.Height + 0.5);
                ctx.CurveTo(
                    0, Size.Height + 0.5,
                    Lean.Dx, Size.Height + 0.5,
                    Lean.Dx, Size.Height - Lean.Dy);
            } else {
                ctx.MoveTo(Lean.Dx, Size.Height);
            }
            ctx.LineTo(Lean.Dx, Lean.Dy);
            ctx.CurveTo(
                Lean.Dx, Lean.Dy,
                Lean.Dx, 0,
                Lean.Dx * 2, 0);

            if (next == null) {
                ctx.LineTo(Size.Width - (Lean.Dx * 2), 0);
                ctx.CurveTo(
                    Size.Width - (Lean.Dx * 2), 0,
                    Size.Width - Lean.Dx, 0,
                    Size.Width - Lean.Dx, Lean.Dy);
                ctx.LineTo(Size.Width - Lean.Dx, Size.Height - Lean.Dy);
                ctx.CurveTo(
                    Size.Width - Lean.Dx, Size.Height - Lean.Dy,
                    Size.Width - Lean.Dx, Size.Height,
                    Size.Width, Size.Height);
            } else {
                ctx.LineTo(Size.Width, 0);
                ctx.LineTo(Size.Width, Size.Height);
            }

            ctx.SetColor(Active ? activeColor : deactiveColor);
            ctx.Fill();

            // border
            if (previous == null || Multiple || !previous.Active) {
                ctx.MoveTo(0, Size.Height + 0.5);
                ctx.CurveTo(
                    0, Size.Height + 0.5,
                    Lean.Dx, Size.Height + 0.5,
                    Lean.Dx, Size.Height - Lean.Dy);
            } else {
                ctx.MoveTo(Lean.Dx, Size.Height + 0.5 - Lean.Dy);
            }

            ctx.LineTo(Lean.Dx, Lean.Dy);
            ctx.CurveTo(
                Lean.Dx, Lean.Dy,
                Lean.Dx, 0,
                Lean.Dx * 2, 0);

            if (next == null) {
                ctx.LineTo(Size.Width - (Lean.Dx * 2), 0);
                ctx.CurveTo(
                    Size.Width - (Lean.Dx * 2), 0,
                    Size.Width - Lean.Dx, 0,
                    Size.Width - Lean.Dx, Lean.Dy);
                ctx.LineTo(Size.Width - Lean.Dx, Size.Height - Lean.Dy);
                ctx.CurveTo(
//.........这里部分代码省略.........
开发者ID:jfreax,项目名称:BAIMP,代码行数:101,代码来源:TabButton.cs

示例15: DrawInLegend

 /// <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 ();
 }
开发者ID:hwthomas,项目名称:XwPlot,代码行数:32,代码来源:HistogramPlot.cs


注:本文中的Xwt.Drawing.Context.FillPreserve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。