SetDash() публичный Метод

public SetDash ( double dashes, double offset ) : void
dashes double
offset double
Результат void
Пример #1
0
        public void Draw(Cairo.Context g, double scale, bool fillSelection)
        {
            g.Save();
            g.Translate(0.5, 0.5);
            g.Scale(scale, scale);

            g.AppendPath(selection_path);

            if (fillSelection)
            {
                g.Color    = new Cairo.Color(0.7, 0.8, 0.9, 0.2);
                g.FillRule = Cairo.FillRule.EvenOdd;
                g.FillPreserve();
            }

            g.LineWidth = 1 / scale;

            // Draw a white line first so it shows up on dark backgrounds
            g.Color = new Cairo.Color(1, 1, 1);
            g.StrokePreserve();

            // Draw a black dashed line over the white line
            g.SetDash(new double[] { 2 / scale, 4 / scale }, 0);
            g.Color = new Cairo.Color(0, 0, 0);

            g.Stroke();
            g.Restore();
        }
Пример #2
0
 public static void PaintFocus(Cairo.Context cr, Style style, StateType state)
 {
     cr.SetSourceRGBA(GetCairoColorWithAlpha(style.Foreground(state), 0.7f).R, GetCairoColorWithAlpha(style.Foreground(state), 0.7f).G, GetCairoColorWithAlpha(style.Foreground(state), 0.7f).B, GetCairoColorWithAlpha(style.Foreground(state), 0.7f).A);
     //cr.Color = GetCairoColorWithAlpha (style.Foreground (state), 0.7f);
     cr.LineCap  = LineCap.Butt;
     cr.LineJoin = LineJoin.Miter;
     cr.SetDash(FocusDash, 1.5f);
     cr.Antialias = Antialias.None;
     cr.LineWidth = 1.0f;
     cr.Stroke();
 }
Пример #3
0
        protected override void DrawFrame (Cairo.Context context, double lineWidth, Cairo.Color lineColor, Cairo.Color fillColor)
        {          
            rect = DisplayBox;
            rect.OffsetDot5();
            CairoFigures.AngleFrame(context, rect, 0, 0, 0, 0);

            Cairo.Color fillColorOrigin;
            fillColorOrigin = fillColor;

            lineWidth = 1;
            fillColor = new Cairo.Color (1.0, 1.0, 1.0, 1.0);

            context.Color = fillColor;  
            context.FillPreserve();
            context.Color = lineColor;
            context.LineWidth = lineWidth;

            double[] dash = {2, 0, 2};
            context.SetDash (dash, 0);

            context.Stroke();

            rect2 = DisplayBox;
            rect2.Width = DisplayBox.Width;
            rect2.Height = 30;
            rect2.OffsetDot5();
            CairoFigures.AngleFrame(context, rect2, 0, 0, 0, 0);
            fillColor = fillColorOrigin;
            context.Color = fillColor;  
            context.FillPreserve();
            context.Color = lineColor;
            context.LineWidth = lineWidth;

            context.Stroke();

            // HERZUM SPRINT 1.1 LOOP 
            DrawScope ();
            // END HERZUM SPRINT 1.1 LOOP

        }
Пример #4
0
        void Draw(Cairo.Context ctx, List <TableRow> rowList, int dividerX, int x, ref int y)
        {
            if (!heightMeasured)
            {
                return;
            }

            Pango.Layout layout       = new Pango.Layout(PangoContext);
            TableRow     lastCategory = null;

            foreach (var r in rowList)
            {
                int w, h;
                layout.SetText(r.Label);
                layout.GetPixelSize(out w, out h);
                int indent = 0;

                if (r.IsCategory)
                {
                    var rh = h + CategoryTopBottomPadding * 2;
                    ctx.Rectangle(0, y, Allocation.Width, rh);
                    ctx.SetSourceColor(Styles.PadCategoryBackgroundColor.ToCairoColor());
                    ctx.Fill();

                    if (IsFocus && r.Focused)
                    {
                        ctx.Rectangle(1, y + 1, Allocation.Width - 2, rh - 3);
                        ctx.SetDash(new double[] { 1, 1 }, 0.5);
                        ctx.LineWidth = 1.0;
                        ctx.SetSourceColor(Styles.BaseForegroundColor.ToCairoColor());
                        ctx.Stroke();
                    }

                    if (lastCategory == null || lastCategory.Expanded || lastCategory.AnimatingExpand)
                    {
                        ctx.MoveTo(0, y + 0.5);
                        ctx.LineTo(Allocation.Width, y + 0.5);
                    }
                    ctx.MoveTo(0, y + rh - 0.5);
                    ctx.LineTo(Allocation.Width, y + rh - 0.5);
                    ctx.SetSourceColor(Styles.PadCategoryBorderColor.ToCairoColor());
                    ctx.Stroke();

                    ctx.MoveTo(x, y + CategoryTopBottomPadding);
                    ctx.SetSourceColor(Styles.PadCategoryLabelColor.ToCairoColor());
                    Pango.CairoHelper.ShowLayout(ctx, layout);

                    var img = r.Expanded ? discloseUp : discloseDown;
                    ctx.DrawImage(this, img, Allocation.Width - img.Width - CategoryTopBottomPadding, y + Math.Round((rh - img.Height) / 2));

                    y           += rh;
                    lastCategory = r;
                }
                else
                {
                    var cell = GetCell(r);
                    r.Enabled = !r.Property.IsReadOnly || cell.EditsReadOnlyObject;
                    var state = r.Enabled ? State : Gtk.StateType.Insensitive;
                    ctx.Save();
                    ctx.Rectangle(0, y, dividerX, h + PropertyTopBottomPadding * 2);
                    ctx.Clip();
                    ctx.MoveTo(x, y + PropertyTopBottomPadding);
                    ctx.SetSourceColor(Style.Text(state).ToCairoColor());
                    Pango.CairoHelper.ShowLayout(ctx, layout);
                    ctx.Restore();

                    if (r != currentEditorRow)
                    {
                        var bounds = GetInactiveEditorBounds(r);

                        cell.Render(GdkWindow, ctx, bounds, state);

                        if (r.IsExpandable)
                        {
                            var img = r.Expanded ? discloseUp : discloseDown;
                            ctx.DrawImage(
                                this, img,
                                Allocation.Width - img.Width - PropertyTopBottomPadding,
                                y + Math.Round((h + PropertyTopBottomPadding * 2 - img.Height) / 2)
                                );
                        }
                    }

                    y     += r.EditorBounds.Height;
                    indent = PropertyIndent;
                }

                if (r.ChildRows != null && r.ChildRows.Count > 0 && (r.Expanded || r.AnimatingExpand))
                {
                    int py = y;

                    ctx.Save();
                    if (r.AnimatingExpand)
                    {
                        ctx.Rectangle(0, y, Allocation.Width, r.AnimationHeight);
                    }
                    else
                    {
                        ctx.Rectangle(0, 0, Allocation.Width, Allocation.Height);
                    }

                    ctx.Clip();
                    Draw(ctx, r.ChildRows, dividerX, x + indent, ref y);
                    ctx.Restore();

                    if (r.AnimatingExpand)
                    {
                        y = py + r.AnimationHeight;
                        // Repaing the background because the cairo clip doesn't work for gdk primitives
                        int dx = (int)((double)Allocation.Width * dividerPosition);
                        ctx.Rectangle(0, y, dx, Allocation.Height - y);
                        ctx.SetSourceColor(Styles.PropertyPadLabelBackgroundColor.ToCairoColor());
                        ctx.Fill();
                        ctx.Rectangle(dx + 1, y, Allocation.Width - dx - 1, Allocation.Height - y);
                        ctx.SetSourceColor(Styles.BrowserPadBackground.ToCairoColor());
                        ctx.Fill();
                    }
                }
            }
            layout.Dispose();
        }
Пример #5
0
		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();
		}
Пример #6
0
 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;
     }
 }
        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 ();
        }
Пример #8
0
 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 ();
     }
 }
Пример #9
0
        public void Draw(Cairo.Context cr, Cairo.Rectangle rectangle)
        {
            if (IsSeparator)
            {
                cr.NewPath();
                double x = Math.Ceiling(rectangle.X + rectangle.Width / 2) + 0.5;
                cr.MoveTo(x, rectangle.Y + 0.5 + 2);
                cr.RelLineTo(0, rectangle.Height - 1 - 4);
                cr.ClosePath();
                cr.SetSourceColor(Styles.SubTabBarSeparatorColor.ToCairoColor());
                cr.LineWidth = 1;
                cr.Stroke();
                return;
            }

            if (Active || HoverPosition.X >= 0)
            {
                if (Active)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarActiveBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
                else if (HoverPosition.X >= 0)
                {
                    cr.Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
                    cr.SetSourceColor(Styles.SubTabBarHoverBackgroundColor.ToCairoColor());
                    cr.Fill();
                }
            }

            if (Active)
            {
                cr.SetSourceColor(Styles.SubTabBarActiveTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11, Pango.Weight.Bold);
            }
            else
            {
                cr.SetSourceColor(Styles.SubTabBarTextColor.ToCairoColor());
                layout.FontDescription = FontService.SansFont.CopyModified(Styles.FontScale11);
            }

            layout.Width = (int)rectangle.Width;

            cr.MoveTo(rectangle.X + (int)(rectangle.Width / 2), (rectangle.Height - h) / 2 - 1);
            Pango.CairoHelper.ShowLayout(cr, layout);

            if (parent.HasFocus && Focused)
            {
                cr.LineWidth = 1.0;
                cr.SetDash(new double[] { 1, 1 }, 0.5);
                if (Active)
                {
                    cr.SetSourceColor(Styles.SubTabBarActiveTextColor.ToCairoColor());
                }
                else
                {
                    cr.SetSourceColor(Styles.FocusColor.ToCairoColor());
                }
                cr.Rectangle(rectangle.X + 2, rectangle.Y + 2, rectangle.Width - 4, rectangle.Height - 4);
                cr.Stroke();
            }
        }
Пример #10
0
 private void ResetDash(Context c)
 {
     c.SetDash(new Double[] {10,0}, 0);
 }
 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();
 }
Пример #12
0
		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);
		}
Пример #13
0
        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 ();
            }
        }
Пример #14
0
        void InternalDraw(int markerStart, int markerEnd, MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
        {
            if (markerStart >= markerEnd)
            {
                return;
            }
            var    layout = metrics.Layout.Layout;
            double @from;
            double to;

            if (markerStart < startOffset && endOffset < markerEnd)
            {
                @from = startXPos;
                to    = endXPos;
            }
            else
            {
                int             start = Math.Max(startOffset, markerStart);
                int             end   = Math.Min(endOffset, markerEnd);
                int /*lineNr,*/ x_pos;
                uint            curIndex  = 0;
                uint            byteIndex = 0;

                var textLength = metrics.Layout.Text.Length;
                if (textLength > 0)
                {
                    uint idx = (uint)Math.Min(Math.Max(0, start - startOffset), textLength - 1);
                    metrics.Layout.TranslateToUTF8Index(idx, ref curIndex, ref byteIndex);

                    x_pos = layout.IndexToPos(System.Math.Max(0, (int)byteIndex)).X;
                    @from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);

                    idx = (uint)Math.Min(Math.Max(0, end - startOffset), textLength - 1);
                    metrics.Layout.TranslateToUTF8Index(idx, ref curIndex, ref byteIndex);

                    x_pos = layout.IndexToPos(System.Math.Max(0, (int)byteIndex)).X;

                    to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
                }
                else
                {
                    @from = startXPos;
                    to    = startXPos + editor.TextViewMargin.CharWidth;
                }

                var line = editor.GetLineByOffset(endOffset);
                if (markerEnd > endOffset || @from == to)
                {
                    to += editor.TextViewMargin.CharWidth;
                    if (@from >= to)
                    {
                        @from = to - editor.TextViewMargin.CharWidth;
                    }
                }
            }
            @from = System.Math.Max(@from, editor.TextViewMargin.XOffset);
            to    = System.Math.Max(to, editor.TextViewMargin.XOffset);
            if (Length == 0)
            {
                to += editor.TextViewMargin.charWidth;
            }

            if (@from >= to)
            {
                return;
            }
            double height = editor.LineHeight / 5;

            if (string.IsNullOrEmpty(ColorName))
            {
                cr.SetSourceColor(Color);
            }
            else
            {
                HslColor color;
                editor.EditorTheme.TryGetColor(ColorName, out color);
                cr.SetSourceColor(color);
            }
            cr.LineWidth = editor.Options.Zoom;

            switch (Effect)
            {
            case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine:
                cr.Rectangle(@from, 0, to - @from, editor.Allocation.Height);
                cr.Clip();
                Pango.CairoHelper.ShowErrorUnderline(cr, metrics.TextRenderStartPosition, y + editor.LineHeight - height, editor.Allocation.Width, height);
                cr.ResetClip();
                break;

            case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine:
                cr.Save();
                cr.MoveTo(@from, y + editor.LineHeight - editor.Options.Zoom - 0.5);
                cr.LineTo(to, y + editor.LineHeight - editor.Options.Zoom - 0.5);
                cr.SetDash(new double [] { 2 * editor.Options.Zoom, 2 * editor.Options.Zoom }, 0);
                cr.Stroke();
                cr.Restore();
                break;

            case MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.Underline:
                cr.MoveTo(@from, y + editor.LineHeight - editor.Options.Zoom - 0.5);
                cr.LineTo(to, y + editor.LineHeight - editor.Options.Zoom - 0.5);
                cr.Stroke();
                break;

            default:
                throw new InvalidOperationException("Invalid text segment marker effect " + Effect + " not supported by this marker.");
            }
        }
Пример #15
0
        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();
        }
Пример #16
0
 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 ();
 }
Пример #17
0
		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);
		}
Пример #18
0
 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;
     }
 }
Пример #19
0
		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 ();
		}
Пример #20
0
        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);
        }
        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];
        }