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


C# Context.StrokePreserve方法代码示例

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


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

示例1: OnMouseMove

		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			// Cairo does not support a single-pixel-long single-pixel-wide line
			if (x == lastX && y == lastY && g.LineWidth == 1 &&
			    PintaCore.Workspace.ActiveWorkspace.PointInCanvas (new PointD(x,y))) {
				surface.Flush ();

				ColorBgra source = surface.GetColorBgraUnchecked (x, y);
				source = UserBlendOps.NormalBlendOp.ApplyStatic (source, strokeColor.ToColorBgra ());
				surface.SetColorBgra (source, x, y);
				surface.MarkDirty ();

				return new Gdk.Rectangle (x - 1, y - 1, 3, 3);
			}

			g.MoveTo (lastX + 0.5, lastY + 0.5);
			g.LineTo (x + 0.5, y + 0.5);
			g.StrokePreserve ();

			Gdk.Rectangle dirty = g.FixedStrokeExtents ().ToGdkRectangle ();

			// For some reason (?!) we need to inflate the dirty
			// rectangle for small brush widths in zoomed images
			dirty.Inflate (1, 1);

			return dirty;
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:28,代码来源:PlainBrush.cs

示例2: DrawBackground

		protected override void DrawBackground (Context context, Gdk.Rectangle region)
		{
			LayoutRoundedRectangle (context, region);
			context.Clip ();

			context.SetSourceColor (CairoExtensions.ParseColor ("D3E6FF"));
			context.Paint ();

			context.Save ();
			context.Translate (region.X + region.Width / 2.0, region.Y + region.Height);

			using (var rg = new RadialGradient (0, 0, 0, 0, 0, region.Height * 1.2)) {
				var color = CairoExtensions.ParseColor ("E5F0FF");
				rg.AddColorStop (0, color);
				color.A = 0;
				rg.AddColorStop (1, color);

				context.Scale (region.Width / (double)region.Height, 1.0);
				context.SetSource (rg);
				context.Paint ();
			}

			context.Restore ();

			LayoutRoundedRectangle (context, region, -3, -3, 2);
			context.SetSourceRGBA (1, 1, 1, 0.4);
			context.LineWidth = 1;
			context.StrokePreserve ();

			context.Clip ();

			int boxSize = 11;
			int x = region.Left + (region.Width % boxSize) / 2;
			for (; x < region.Right; x += boxSize) {
				context.MoveTo (x + 0.5, region.Top);
				context.LineTo (x + 0.5, region.Bottom);
			}

			int y = region.Top + (region.Height % boxSize) / 2;
			y += boxSize / 2;
			for (; y < region.Bottom; y += boxSize) {
				context.MoveTo (region.Left, y + 0.5);
				context.LineTo (region.Right, y + 0.5);
			}

			context.SetSourceRGBA (1, 1, 1, 0.2);
			context.Stroke ();

			context.ResetClip ();
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:50,代码来源:StatusAreaBuildTheme.cs

示例3: OnMouseMove

		protected override Gdk.Rectangle OnMouseMove (Context g, Color strokeColor, ImageSurface surface,
		                                              int x, int y, int lastX, int lastY)
		{
			int dx = x - lastX;
			int dy = y - lastY;
			double px = Math.Cos (theta) * dx - Math.Sin (theta) * dy;
			double py = Math.Sin (theta) * dx + Math.Cos (theta) * dy;

			g.MoveTo (lastX - px, lastY - py);
			g.LineTo (lastX + px, lastY + py);
			g.LineTo (x + px, y + py);
			g.LineTo (x - px, y - py);
			g.LineTo (lastX - px, lastY - py);

			g.StrokePreserve ();

			return g.FixedStrokeExtents ().ToGdkRectangle ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:18,代码来源:SquaresBrush.cs

示例4: Draw

		public static void Draw(Context grw, RectangleElement rect)
		{
			if (rect.Foregraund != null) {
				grw.SetSourceRGBA (
					rect.Foregraund.Red, 
					rect.Foregraund.Green, 
					rect.Foregraund.Blue, 
					rect.Alpha);
			}

			grw.Rectangle (
				new Rectangle (
					rect.LeftBottom.GeometryX, 
					rect.LeftBottom.GeometryY, 
					rect.GeometryWidth, 
					rect.GeometryHeight));

			grw.StrokePreserve();
			grw.Fill();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:20,代码来源:RectangleBrush.cs

示例5: Draw

		public static void Draw(Context grw, Connector con)
		{
			var c = con.Selected ? AppController.Instance.Config.SelectedConnectorColor : 
				!con.ConnectedTo.Any() ? 
				con.Foregraund : 
				AppController.Instance.Config.ConnectedColor;

			if ( c != null) {
				grw.SetSourceRGB (
					c.Red, 
					c.Green, 
					c.Blue);
			}

			grw.Arc (
				con.Center.GeometryX, 
				con.Center.GeometryY, 
				con.GeometryRadius, 
				0, 2 * Math.PI);

			grw.StrokePreserve ();
			grw.Fill ();
		}
开发者ID:jdpillon,项目名称:ArduinoLadder,代码行数:23,代码来源:ConnectorBrush.cs

示例6: OnDrawn

			protected override bool OnDrawn (Context cr)
			{
				int w, h;
				this.GdkWindow.GetSize (out w, out h);
				var bounds = new Xwt.Rectangle (0.5, 0.5, w - 1, h - 1);
				var black = Xwt.Drawing.Color.FromBytes (0xee, 0xee, 0xee);
				
				// We clear the surface with a transparent color if possible
				if (supportAlpha)
					cr.SetSourceRGBA (1.0, 1.0, 1.0, 0.0);
				else
					cr.SetSourceRGB (1.0, 1.0, 1.0);
				cr.Operator = Operator.Source;
				cr.Paint ();
				
				var calibratedRect = RecalibrateChildRectangle (bounds);
				// Fill it with one round rectangle
				RoundRectangle (cr, calibratedRect, radius);
				cr.LineWidth = 1;
				
				// Triangle
				// We first begin by positionning ourselves at the top-center or bottom center of the previous rectangle
				var arrowX = bounds.Center.X + arrowDelta;
				var arrowY = arrowPosition == Xwt.Popover.Position.Top ? calibratedRect.Top + cr.LineWidth : calibratedRect.Bottom;
				cr.MoveTo (arrowX, arrowY);
				// We draw the rectangle path
				DrawTriangle (cr);

				// We use it
				cr.SetSourceRGBA (black.Red, black.Green, black.Blue, black.Alpha);
				cr.StrokePreserve ();
				cr.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
				cr.Fill ();

				return base.OnDrawn (cr);
			}
开发者ID:silasary,项目名称:xwt,代码行数:36,代码来源:PopoverBackend.cs

示例7: DrawTab

		void DrawTab (Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la)
		{
			// This logic is stupid to have here, should be in the caller!
			if (dragging) {
				tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress);
				tabBounds.X = Clamp (tabBounds.X, tabStartX, tabEndX - tabBounds.Width);
			}
			int padding = LeftRightPadding;
			padding = (int)(padding * Math.Min (1.0, Math.Max (0.5, (tabBounds.Width - 30) / 70.0)));

			ctx.LineWidth = 1;
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.ClosePath ();
			using (var gr = new LinearGradient (tabBounds.X, TopBarPadding, tabBounds.X, allocation.Bottom)) {
				if (active) {
					gr.AddColorStop (0, Styles.BreadcrumbGradientStartColor.MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, Styles.BreadcrumbBackgroundColor.MultiplyAlpha (tab.Opacity));
				} else {
					gr.AddColorStop (0, CairoExtensions.ParseColor ("f4f4f4").MultiplyAlpha (tab.Opacity));
					gr.AddColorStop (1, CairoExtensions.ParseColor ("cecece").MultiplyAlpha (tab.Opacity));
				}
				ctx.SetSource (gr);
			}
			ctx.Fill ();

			ctx.SetSourceColor (new Cairo.Color (1, 1, 1, .5).MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 1, active);
			ctx.Stroke ();

			ctx.SetSourceColor (Styles.BreadcrumbBorderColor.MultiplyAlpha (tab.Opacity));
			LayoutTabBorder (ctx, allocation, tabBounds.Width, tabBounds.X, 0, active);
			ctx.StrokePreserve ();

			if (tab.GlowStrength > 0) {
				Gdk.Point mouse = tracker.MousePosition;
				using (var rg = new RadialGradient (mouse.X, tabBounds.Bottom, 0, mouse.X, tabBounds.Bottom, 100)) {
					rg.AddColorStop (0, new Cairo.Color (1, 1, 1, 0.4 * tab.Opacity * tab.GlowStrength));
					rg.AddColorStop (1, new Cairo.Color (1, 1, 1, 0));

					ctx.SetSource (rg);
					ctx.Fill ();
				}
			} else {
				ctx.NewPath ();
			}

			// Render Close Button (do this first so we can tell how much text to render)

			var ch = allocation.Height - TopBarPadding - BottomBarPadding + CloseImageTopOffset;
			var crect = new Gdk.Rectangle (tabBounds.Right - padding - CloseButtonSize + 3,
				            tabBounds.Y + TopBarPadding + (ch - CloseButtonSize) / 2,
				            CloseButtonSize, CloseButtonSize);
			tab.CloseButtonAllocation = crect;
			tab.CloseButtonAllocation.Inflate (2, 2);

			bool closeButtonHovered = tracker.Hovered && tab.CloseButtonAllocation.Contains (tracker.MousePosition) && tab.WidthModifier >= 1.0f;
			bool drawCloseButton = tabBounds.Width > 60 || highlight || closeButtonHovered;
			if (drawCloseButton) {
				DrawCloseButton (ctx, new Gdk.Point (crect.X + crect.Width / 2, crect.Y + crect.Height / 2), closeButtonHovered, tab.Opacity, tab.DirtyStrength);
			}

			// Render Text
			int w = tabBounds.Width - (padding * 2 + CloseButtonSize);
			if (!drawCloseButton)
				w += CloseButtonSize;

			int textStart = tabBounds.X + padding;

			ctx.MoveTo (textStart, tabBounds.Y + TopPadding + TextOffset + VerticalTextSize);
			if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) {
				// This is a work around for a linux specific problem.
				// A bug in the proprietary ATI driver caused TAB text not to draw.
				// If that bug get's fixed remove this HACK asap.
				la.Ellipsize = Pango.EllipsizeMode.End;
				la.Width = (int)(w * Pango.Scale.PangoScale);
				ctx.SetSourceColor (tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor);
				Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
			} else {
				// ellipses are for space wasting ..., we cant afford that
				using (var lg = new LinearGradient (textStart + w - 5, 0, textStart + w + 3, 0)) {
					var color = tab.Notify ? new Cairo.Color (0, 0, 1) : Styles.TabBarActiveTextColor;
					color = color.MultiplyAlpha (tab.Opacity);
					lg.AddColorStop (0, color);
					color.A = 0;
					lg.AddColorStop (1, color);
					ctx.SetSource (lg);
					Pango.CairoHelper.ShowLayoutLine (ctx, la.GetLine (0));
				}
			}
			la.Dispose ();
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:91,代码来源:TabStrip.cs

示例8: Paint

 public virtual void Paint(Context ctx)
 {
     PointD size = this.MeasureSize (ctx);
     PaintContour (ctx,size);
     KnownColors.SetFontFacePieceName(ctx);
     TextExtents te = ctx.TextExtents(this.Name), ten;
     double y0 = 0.5d*(size.Y-te.Width);
     ctx.MoveTo(0.5d*Margin,y0);
     ctx.Save();
     ctx.Rotate(0.5d*Math.PI);
     ctx.ShowText(this.Name);
     ctx.Restore();
     double x0 = Margin+te.Height;
     KnownColors.SetFontFaceNormal(ctx);
     te = ctx.TextExtents(OptionalString);
     y0 = 2.0d*Margin;
     int index = 0x00;
     PointD siz;
     foreach(IPuzzlePiece ipp in this.arguments) {
         ctx.Save();
         ctx.Translate(x0,Margin);
         if(ipp == null) {
             siz = new PointD(MinimumWidth,size.Y-4.0d*Margin);
             ctx.Rectangle(Margin,Margin,siz.X,siz.Y);
             ctx.Pattern = KnownColors.ConstructionPattern;
             ctx.FillPreserve();
         }
         else {
             siz = ipp.MeasureSize(ctx);
         }
         ctx.Rectangle(0.0d,0.0d,siz.X+2.0d*Margin,siz.Y+2.0d*Margin);
         ctx.Color = KnownColors.Black;
         ctx.StrokePreserve();
         if(ipp == null) {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Translate(Margin,Margin);
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(MinimumWidth,0.0d);
             ctx.RelLineTo(0.0d,5.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowDownPattern;
             ctx.Fill();
             ctx.MoveTo(0.0d,0.0d);
             ctx.LineTo(0.0d,siz.Y);
             ctx.RelLineTo(5.0d,0.0d);
             ctx.LineTo(5.0d,5.0d);
             ctx.ClosePath();
             ctx.Pattern = KnownColors.ShadowRightPattern;
             ctx.Fill();
         }
         else {
             ctx.Pattern = ExtensionMethods.GenerateColorSequencePattern(siz.X+2.0d*Margin,TypeColorArguments[index]);
             ctx.Fill();
             ctx.Color = KnownColors.Black;
             ctx.Translate(Margin,Margin);
             ipp.Paint(ctx);
         }
         ctx.Restore();
         subpieces[index] = new Rectangle(x0+Margin,2.0d*Margin,siz.X,siz.Y);
         x0 += siz.X+3.0d*Margin;
         if(index >= NumberOfArguments-NumberOfOptionalArguments) {
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+te.Width),siz.Y+3.0d*Margin-2.0d);
             ctx.ShowText(OptionalString);
         }
         if(this.ArgumentNames != null && index < arguments.Length) {
             ten = ctx.TextExtents(this.ArgumentNames[index]);
             ctx.MoveTo(x0-2.0d*Margin-0.5d*(siz.X+ten.Width),-te.YBearing+Margin+2.0d);
             ctx.ShowText(this.ArgumentNames[index]);
         }
         index++;
     }
 }
开发者ID:KommuSoft,项目名称:CplKul2012,代码行数:74,代码来源:PuzzlePieceBase.cs

示例9: DrawPoint

 private void DrawPoint(Context context, int j, double val)
 {
     double xl = 0.5 * (double)(Width - 60) / N;
     int x = (int)((Width - 60) * ((double)j / N) + 50 + xl);
     int y = ValueToY (val);
     context.MoveTo (x, y);
     context.Arc(x, y, 2, 0, 2 * Math.PI);
     context.StrokePreserve();
     context.Fill();
 }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:10,代码来源:ValueSurfaceItem.cs

示例10: DrawHistArea

 private void DrawHistArea(Context context, double xl, double yl, int i, int j, double value)
 {
     Color c = HistColor (value);
     context.SetSourceRGB (c.R, c.G, c.B);
     context.MoveTo ((int)(j * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)(i * yl));
     context.LineTo ((int)((j + 1) * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)((i + 1) * yl));
     context.LineTo ((int)(j * xl + 50), (int)(i * yl));
     context.StrokePreserve ();
     context.MoveTo ((int)((j + .5) * xl + 50), (int)((i + .5) * yl));
     context.Fill ();
 }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:13,代码来源:ValueSurfaceItem.cs

示例11: DrawAxes

        private void DrawAxes(Context context, double min, double max)
        {
            context.Rectangle(0, 0, Width, Height);
            context.SetSourceRGB(Background.R, Background.G, Background.B);
            context.Fill();

            int y = ValueToY (0);
            context.LineWidth = 1;
            context.SetSourceRGB(0.0, 0.0, 0.0);

            context.MoveTo (44, y);
            context.LineTo (Width, y);
            context.StrokePreserve();

            context.MoveTo (50, 0);
            context.LineTo (50, Height);
            context.StrokePreserve();

            KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max);

            foreach (var a in ax) {
                y = ValueToY (a.Key);
                context.MoveTo (44, y);
                context.LineTo (56, y);
                context.StrokePreserve();
                context.MoveTo (40, y - 1);
                _axis.Text (context, a.Value, HorizontalTextAlignment.Right);
            }
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:29,代码来源:ValueSurfaceItem.cs

示例12: StrokeAndFill

        private void StrokeAndFill(Context context)
        {
            context.LineWidth = 4.0;
            context.Color = TangoColors.Chameleon3;
            context.StrokePreserve ();

            context.Color = TangoColors.Chameleon1;
            context.Fill ();
        }
开发者ID:manicolosi,项目名称:questar,代码行数:9,代码来源:HitPointsChart.cs

示例13: OnExpose

        void OnExpose(object sender, ExposeEventArgs args)
        {
            area = (DrawingArea) sender;
            cr =  Gdk.CairoHelper.Create(area.GdkWindow);

            cr.LineWidth = 2;
            cr.SetSourceRGB(0.7, 0.2, 0.0);

            cr.Translate(width/2, height/2);
            cr.Rectangle(pX , pY, width, height);
            //cr.Arc(pX, pY, (width < height ? width : height) / 2 - 10, 0, 2*Math.PI);
            cr.StrokePreserve();
            cr.SetSourceRGB(0.3, 0.4, 0.6);
            cr.Fill();

            pX=pY=4;

            //drawInterfaceEth();

            drawInterfaceUps();

            ((IDisposable) cr.Target).Dispose();
            ((IDisposable) cr).Dispose();
        }
开发者ID:odnanref,项目名称:snrviewer,代码行数:24,代码来源:guiEquipment.cs

示例14: DrawAxes

        private void DrawAxes(Context context, double min, double max)
        {
            context.Rectangle(0, 0, Width, Height);
            context.Color = Background;
            context.Fill();

            context.LineWidth = 1;
            context.SetSourceRGB(0.0, 0.0, 0.0);

            context.MoveTo (0, Height / 2);
            context.LineTo (Width, Height / 2);
            context.StrokePreserve();

            context.MoveTo (Width / 2, 0);
            context.LineTo (Width / 2, Height);
            context.StrokePreserve();

            KeyValuePair<double, string>[] ax = _axis.AxisSteps (min, max);
            double y;

            foreach (var a in ax) {
                y = a.Key / _axis.YLimUp * Height / 2 + Height / 2;
                context.MoveTo (Width / 2 - 6, y);
                context.LineTo (Width / 2 + 6, y);
                context.StrokePreserve();

                context.MoveTo (y, Height / 2 - 6);
                context.LineTo (y, Height / 2 + 6);
                context.StrokePreserve();

                if (a.Key != 0) {
                    context.MoveTo (Width / 2 - 10, Height - (y - 1));
                    _axis.Text (context, a.Value, HorizontalTextAlignment.Right);

                    context.MoveTo (y - 1, Height / 2 + 10);
                    _axis.Text (context, a.Value, HorizontalTextAlignment.Center, VerticalTextAlignment.Top);
                } else {
                    //context.MoveTo (Width / 2 + 5, Height / 2 + 5);
                    //_axis.Text (context, a.Value, HorizontalTextAlignment.Left, VerticalTextAlignment.Top);
                }
            }
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:42,代码来源:PhasePortraitSurfaceItem.cs

示例15: DrawPoint

        private void DrawPoint(Context context, Color c, Complex z)
        {
            context.SetSourceRGB (c.R, c.G, c.B);

            int x = (int)(0.5 * (Width - 10) * z.Real / _axis.YLimUp + 0.5 * Width);
            int y = (int)(0.5 * (Height - 10) * z.Imaginary / _axis.YLimUp + 0.5 * Height);

            context.MoveTo (x, y);
            context.Arc(x, y, 2, 0, 2 * Math.PI);
            context.StrokePreserve();
            context.Fill();
        }
开发者ID:codingcave,项目名称:CoupledOdeViewer,代码行数:12,代码来源:PhasePortraitSurfaceItem.cs


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