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


C# Context.SetDash方法代码示例

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


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

示例1: SetContextProperties

 private void SetContextProperties(Context c, bool dashed)
 {
     c.LineCap = LineCap.Round;
     c.LineJoin = LineJoin.Round;
     if(selectedTool != DrawTool.ERASER) {
         c.Color = lineColor;
         c.LineWidth = lineWidth;
         c.Operator = Operator.Over;
         if(dashed)
             c.SetDash(new double[] {10, 10}, 10);
     } else {
         c.Color = new Cairo.Color(0,0,0,0);
         c.LineWidth = 20;
         c.Operator = Operator.Source;
     }
 }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:16,代码来源:DrawingWidget.cs

示例2: DrawGrid

        private void DrawGrid(Context g)
        {
            g.Color = new Color (0.05, 0.05, 0.05);
            g.SetDash (new double[] {4, 4}, 2);
            g.LineWidth = 1;

            for (int i = 1; i < 4; i++) {
                g.MoveTo (i * size / 4, 0);
                g.LineTo (i * size / 4, size);
                g.MoveTo (0, i * size / 4);
                g.LineTo (size, i * size / 4);
            }

            g.MoveTo (0, size - 1);
            g.LineTo (size - 1, 0);
            g.Stroke ();

            g.SetDash (new double[] {}, 0);
        }
开发者ID:sandyarmstrong,项目名称:Pinta,代码行数:19,代码来源:CurvesDialog.cs

示例3: DrawCropMarks

 private void DrawCropMarks(Context cr, double x, double y, double length)
 {
     cr.Save ();
     cr.Color = new Color (0, 0, 0);
     cr.MoveTo (x - length/2, y);
     cr.LineTo (x + length/2, y);
     cr.MoveTo (x, y - length/2);
     cr.LineTo (x, y + length/2);
     cr.LineWidth = .2;
     cr.SetDash (new double[] {length*.4, length*.2}, 0);
     cr.Stroke ();
     cr.Restore ();
 }
开发者ID:GNOME,项目名称:f-spot,代码行数:13,代码来源:PrintOperation.cs

示例4: ResetDash

 private void ResetDash(Context c)
 {
     c.SetDash(new Double[] {10,0}, 0);
 }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:4,代码来源:DrawingWidget.cs

示例5: CairoStrokeStyle

 void CairoStrokeStyle(Context cr, DStrokeStyle strokeStyle, double strokeWidth)
 {
     double dot = strokeWidth;
     double space = 2 * strokeWidth;
     double dash = 3 * strokeWidth;
     switch (strokeStyle)
     {
         case DStrokeStyle.Solid:
             cr.SetDash(new double[] { }, 0);
             break;
         case DStrokeStyle.Dash:
             cr.SetDash(new double[] { dash, space }, 0);
             break;
         case DStrokeStyle.Dot:
             cr.SetDash(new double[] { dot, space }, 0);
             break;
         case DStrokeStyle.DashDot:
             cr.SetDash(new double[] { dash, space, dot, space }, 0);
             break;
         case DStrokeStyle.DashDotDot:
             cr.SetDash(new double[] { dash, space, dot, space, dot, space }, 0);
             break;
     }
 }
开发者ID:djpnewton,项目名称:ddraw,代码行数:24,代码来源:CairoGraphics.cs

示例6: xxx_dash

		public void xxx_dash(Context cr, int width, int height)
		{
			double[] dashes = new double[] {
				0.20,  // ink
				0.05,  // skip
				0.05,  // ink
				0.05   // skip 
			};
			double offset = -0.2; 

			Normalize(cr, width, height);

			cr.SetDash(dashes, offset);

			cr.MoveTo(0.5, 0.1);
			cr.LineTo(0.9, 0.9);
			cr.RelLineTo(-0.4, 0.0);
			cr.CurveTo(0.2, 0.9, 0.2, 0.5, 0.5, 0.5);
			cr.Stroke();
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:20,代码来源:Snippets.cs

示例7: OnMouseUp

		protected override void OnMouseUp (Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;
            doc.ToolLayer.Clear ();
			doc.ToolLayer.Hidden = true;

			ImageSurface surf = doc.CurrentUserLayer.Surface;
			using (Context g = new Context (surf)) {
				g.AppendPath (doc.Selection.SelectionPath);
				g.FillRule = FillRule.EvenOdd;
				g.Clip ();

				g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

				g.SetDash(DashPatternBox.GenerateDashArray(dashPattern, BrushWidth), 0.0);

				if (path != null) {
					g.AppendPath (path);
					(path as IDisposable).Dispose ();
					path = null;
				}

				g.ClosePath ();
				g.LineWidth = BrushWidth;
				g.FillRule = FillRule.EvenOdd;

				if (FillShape && StrokeShape) {
					g.SetSourceColor (fill_color);
					g.FillPreserve ();
					g.SetSourceColor (outline_color);
					g.Stroke ();
				} else if (FillShape) {
					g.SetSourceColor (outline_color);
					g.FillPreserve();
					g.SetSourceColor (outline_color);
					g.Stroke();
				} else {
					g.SetSourceColor (outline_color);
					g.Stroke ();
				}
			}

			if (surface_modified)
				PintaCore.History.PushNewItem (new SimpleHistoryItem (Icon, Name, undo_surface, doc.CurrentUserLayerIndex));
			else if (undo_surface != null)
				(undo_surface as IDisposable).Dispose ();

			surface_modified = false;

			doc.Workspace.Invalidate ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:51,代码来源:FreeformShapeTool.cs

示例8: BasicDraw

        protected override void BasicDraw(Context context)
        {
            if (_points.Count < 2)
                return;

            context.LineWidth = LineWidth;
            context.LineJoin  = LineJoin.Round;
            context.Color = LineColor;

            if (Dashes != null)
                context.SetDash (Dashes, 0);

            PointD start, end;

            if (StartTerminal != null)
                start = StartTerminal.Draw (context, StartPoint, _points [1]);
            else
                start = StartPoint;

            if (EndTerminal != null)
                end = EndTerminal.Draw (context, EndPoint, _points [PointCount-2]);
            else
                end = EndPoint;

            context.MoveTo (start);

            for (int i = 1; i < _points.Count-1; i++)
                context.LineTo (_points [i]);

            context.LineTo (end);
            context.Stroke ();
        }
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:32,代码来源:PolyLineFigure.cs

示例9: DrawGrid

 void DrawGrid(Context cr, int CubePxSize)
 {
     cr.SetSourceRGB(0.321568627, 0.235294118, 0.235294118);
     cr.SetDash(new double[]{2.0, 3.0}, 0.0);
     for (int x = 0; x <= CubesH; x++)
     {
         cr.MoveTo(x * CubePxSize, 0);
         cr.LineTo(x * CubePxSize, CubePxSize * CubesV);
     }
     for (int y = 0; y <= CubesV; y++)
     {
         cr.MoveTo(0, y * CubePxSize);
         cr.LineTo(CubesH * CubePxSize, CubePxSize * y);
     }
     cr.Stroke();
 }
开发者ID:QualitySolution,项目名称:CupboardDesigner,代码行数:16,代码来源:ConstructionClasses.cs

示例10: OnMouseMove

		protected override void OnMouseMove (object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			if ((args.Event.State & Gdk.ModifierType.Button1Mask) == Gdk.ModifierType.Button1Mask) {
				outline_color = PintaCore.Palette.PrimaryColor;
				fill_color = PintaCore.Palette.SecondaryColor;
			} else if ((args.Event.State & Gdk.ModifierType.Button3Mask) == Gdk.ModifierType.Button3Mask) {
				outline_color = PintaCore.Palette.SecondaryColor;
				fill_color = PintaCore.Palette.PrimaryColor;
			} else {
				last_point = point_empty;
				return;
			}

			int x = (int)point.X;
			int y = (int)point.Y;

			if (last_point.Equals (point_empty)) {
				last_point = new Point (x, y);
				return;
			}

			if (doc.Workspace.PointInCanvas (point))
				surface_modified = true;

			doc.ToolLayer.Clear ();
			ImageSurface surf = doc.ToolLayer.Surface;

			using (Context g = new Context (surf)) {
				doc.Selection.Clip(g);

				g.Antialias = UseAntialiasing ? Antialias.Subpixel : Antialias.None;

				g.SetDash(DashPatternBox.GenerateDashArray(dashPattern, BrushWidth), 0.0);

				if (path != null) {
					g.AppendPath (path);
					(path as IDisposable).Dispose ();
				} else {
					g.MoveTo (x, y);
				}
					
				g.LineTo (x, y);

				path = g.CopyPath ();
				
				g.ClosePath ();
				g.LineWidth = BrushWidth;
				g.FillRule = FillRule.EvenOdd;

				if (FillShape && StrokeShape) {
					g.SetSourceColor (fill_color);
					g.FillPreserve ();
					g.SetSourceColor (outline_color);
					g.Stroke ();
				} else if (FillShape) {
					g.SetSourceColor (outline_color);
					g.FillPreserve();
					g.SetSourceColor (outline_color);
					g.Stroke();
				} else {
					g.SetSourceColor (outline_color);
					g.Stroke ();
				}
			}

			doc.Workspace.Invalidate ();

			last_point = new Point (x, y);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:71,代码来源:FreeformShapeTool.cs

示例11: DrawShape

		protected Rectangle DrawShape(ShapeEngine engine, Layer l, bool drawCP, bool drawHoverSelection)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			Rectangle? dirty = null;

			ShapeEngine activeEngine = ActiveShapeEngine;

			if (activeEngine != null)
			{
				using (Context g = new Context(l.Surface))
				{
					g.AppendPath(doc.Selection.SelectionPath);
					g.FillRule = FillRule.EvenOdd;
					g.Clip();

					g.Antialias = activeEngine.AntiAliasing ? Antialias.Subpixel : Antialias.None;

					g.SetDash(DashPatternBox.GenerateDashArray(activeEngine.DashPattern, activeEngine.BrushWidth), 0.0);

					g.LineWidth = activeEngine.BrushWidth;

					//Draw the shape.
					if (activeEngine.ControlPoints.Count > 0)
					{
						//Generate the points that make up the shape.
						activeEngine.GeneratePoints(activeEngine.BrushWidth);

                        PointD[] points = activeEngine.GetActualPoints ();

						//Expand the invalidation rectangle as necessary.

						if (FillShape)
						{
                            Color fill_color = StrokeShape ? activeEngine.FillColor : activeEngine.OutlineColor;
                            dirty = dirty.UnionRectangles (g.FillPolygonal (points, fill_color));
						}

						if (StrokeShape)
						{
							dirty = dirty.UnionRectangles(g.DrawPolygonal(points, activeEngine.OutlineColor));
						}
					}

					g.SetDash(new double[] { }, 0.0);

					//Draw anything extra (that not every shape has), like arrows.
					DrawExtras(ref dirty, g, engine);

					if (drawCP)
					{
						DrawControlPoints(g, drawHoverSelection);
					}
				}
			}


			return dirty ?? new Rectangle(0d, 0d, 0d, 0d);
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:59,代码来源:BaseEditEngine.cs

示例12: DrawAttribute

        private void DrawAttribute(Context context, bool selected)
        {
            double midwidth  = 0;
            double midheight = 0;

            RectangleD displayBox = BasicDisplayBox;
            displayBox.OffsetDot5 ();

            midwidth  = displayBox.Width / 2.0;
            midheight = displayBox.Height / 2.0;

            context.LineWidth = LineWidth + (selected == true ? 2 : 0);

            context.Save ();
            context.Translate (displayBox.X + midwidth, displayBox.Y + midheight);
            context.Scale (midwidth - 1.0, midheight - 1.0);
            context.Arc (0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI);
            context.Restore ();
            if (Multivalued) {
                context.SetDash (Dash.MediumDash, 0);
            }
            if (selected) {
                context.Color = new Color (0, 0, 0, 1);
            } else {
                context.Color = FillColor;
                context.FillPreserve ();
                context.Color = LineColor;
            }
            context.Stroke ();
            if (IsPrimaryKey) {
                context.Restore ();
                PointD bottomLeft  = DisplayBox.BottomLeft;
                PointD bottomRight = DisplayBox.BottomRight;

                bottomLeft.X += Padding;
                bottomLeft.Y -= Padding + 0.5;

                bottomRight.X -= Padding;
                bottomRight.Y -= Padding + 0.5;

                context.LineWidth = LineWidth;
                context.MoveTo (bottomLeft);
                context.LineTo (bottomRight);
                context.Stroke ();
            }
        }
开发者ID:mono,项目名称:monohotdraw,代码行数:46,代码来源:Attribute.cs

示例13: BasicDrawSelected

        public void BasicDrawSelected(Context context, PointD anchor)
        {
            BasicDrawSelected(context);

            context.Save();
            context.Color = new Color(1.0, 0.2, 0.2);
            context.SetDash(Dash.DotDash, 0.0);
            context.MoveTo(anchor);
            context.LineTo(HandlePosition());
            context.Stroke();
            context.Restore();
        }
开发者ID:mono,项目名称:monohotdraw,代码行数:12,代码来源:LabelFigure.cs

示例14: OnAfterDraw

 public override void OnAfterDraw(Context c)
 {
     if (designService.SelectedControl != null && designService.IsDesign) {
         c.Save ();
         c.SetDash (new double[] { 1.0 ,1,1}, 2);
         c.DrawInsideBorderInUnit (designService.SelectedControl.AbsoluteBound, selectBorder, true);
         double gripperSize = 4 / (designService.Zoom > 1.5 ? (designService.Zoom / 2) : 1);
         c.DrawSelectBoxInUnits (designService.SelectedControl.AbsoluteBound,gripperSize);
         c.Restore ();
     }
 }
开发者ID:elsupergomez,项目名称:monoreports,代码行数:11,代码来源:RectTool.cs

示例15: Draw

        public override PointD Draw(Context context, PointD a, PointD b)
        {
            context.Save ();
            double[] Dashes = new double[] {

            };
            context.SetDash (Dashes, 0);
            PointD[] points = new PointD[8]; //a,b,leftPoint1,rightPoint1,middlePoint1,leftPoint2,rightPoint2,middlePoint2
            //get parallel lines points
            points[0] = a;
            points[1] = b;
            Geometry.GetArrowPoints (points[0], points[1], lineDistance, pointDistance, out points[2], out points[3], out points[4]);
            Geometry.GetArrowPoints (points[0], points[1], lineDistance, pointDistance + 3, out points[5], out points[6], out points[7]);

            switch (kind) {
            case kindRelationshipTerminal.OneMore:
                if (notation == kindNotation.CrowsFoot)
                    DrawCrowFootOneMore (context, points); else
                    DrawBarkerMany (context, points);
                break;
            case kindRelationshipTerminal.ZeroMore:
                if (notation == kindNotation.CrowsFoot)
                    DrawCrowFootZeroMore (context, points); else
                    DrawBarkerMany (context, points);
                break;
            case kindRelationshipTerminal.OneOne:
                if (notation == kindNotation.CrowsFoot)
                    DrawCrowFootOneOne (context, points); else
                    DrawBarkerOne (context, points);
                break;
            case kindRelationshipTerminal.ZeroOne:
                if (notation == kindNotation.CrowsFoot)
                    DrawCrowFootZeroOne (context, points); else
                    DrawBarkerOne (context, points);
                break;
            }
            context.Restore ();
            return points[4];
        }
开发者ID:xiul,项目名称:Monodevelop-Database-Modeler-Addin,代码行数:39,代码来源:RelationshipLineTerminal.cs


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