示例#1
0
		protected override bool OnExposeEvent (Gdk.EventExpose evt)
		{
			var build = "";
			var version = "v" + BuildInfo.VersionLabel;

			var index = version.IndexOf (' ');
			if (index != -1) {
				build = version.Substring (index + 1);
				version = version.Substring (0, index);
			}

			if (bitmap != null) {
				using (var context = Gdk.CairoHelper.Create (GdkWindow)) {
					context.Antialias = Cairo.Antialias.Subpixel;

					// Render the image first.
					context.DrawImage (this, bitmap, 0, 0);

					if (showVersionInfo) {
						var bottomRight = new Cairo.PointD (bitmap.Width - 10, bitmap.Height - 12);

						// Render the alpha/beta text if we're an alpha or beta. If this
						// is rendered, the bottomRight point will be shifted upwards to
						// allow the MonoDevelop version to be rendered above the alpha marker
						if (!string.IsNullOrEmpty (build)) {
							DrawAlphaBetaMarker (context, ref bottomRight, build);
						}
						// Render the MonoDevelop version
						DrawVersionNumber (context, ref bottomRight, version);
					}
				}
			}

			return true;
		}
示例#2
0
        public void UpdateRulerRange()
        {
            Gtk.Main.Iteration();              //Force update of scrollbar upper before recenter

            Cairo.PointD lower = new Cairo.PointD(0, 0);
            Cairo.PointD upper = new Cairo.PointD(0, 0);

            if (PintaCore.Workspace.HasOpenDocuments)
            {
                if (PintaCore.Workspace.Offset.X > 0)
                {
                    lower.X = -PintaCore.Workspace.Offset.X / PintaCore.Workspace.Scale;
                    upper.X = PintaCore.Workspace.ImageSize.Width - lower.X;
                }
                else
                {
                    lower.X = sw.Hadjustment.Value / PintaCore.Workspace.Scale;
                    upper.X = (sw.Hadjustment.Value + sw.Hadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
                if (PintaCore.Workspace.Offset.Y > 0)
                {
                    lower.Y = -PintaCore.Workspace.Offset.Y / PintaCore.Workspace.Scale;
                    upper.Y = PintaCore.Workspace.ImageSize.Height - lower.Y;
                }
                else
                {
                    lower.Y = sw.Vadjustment.Value / PintaCore.Workspace.Scale;
                    upper.Y = (sw.Vadjustment.Value + sw.Vadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
            }

            hruler.SetRange(lower.X, upper.X, 0, upper.X);
            vruler.SetRange(lower.Y, upper.Y, 0, upper.Y);
        }
        void DrawAlphaBetaMarker(Cairo.Context c, ref Cairo.PointD bottomRight, string text)
        {
            c.SelectFontFace(SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
            c.SetFontSize(SplashFontSize);

            // Create a rectangle larger than the text so we can have a nice border
            var extents   = c.TextExtents(text);
            var x         = bottomRight.X - extents.Width * 1.3;
            var y         = bottomRight.Y - extents.Height * 1.5;
            var rectangle = new Cairo.Rectangle(x, y, bottomRight.X - x, bottomRight.Y - y);

            // Draw the background color the text will be overlaid on
            DrawRoundedRectangle(c, rectangle);

            // Calculate the offset the text will need to be at to be centralised
            // in the border
            x = x + extents.XBearing + (rectangle.Width - extents.Width) / 2;
            y = y - extents.YBearing + (rectangle.Height - extents.Height) / 2;
            c.MoveTo(x, y);

            // Draw the text
            c.Color = new Cairo.Color(1, 1, 1);
            c.ShowText(text);

            bottomRight.Y -= rectangle.Height - 2;
        }
示例#4
0
 public static Point GetNormalizedDirectionVector(Point fromPoint, Point toPoint)
 {
     double dx = toPoint.X - fromPoint.X;
     double dy = toPoint.Y - fromPoint.Y;
     double length = Math.Sqrt (dx * dx + dy * dy);
     return new Point (dx/length,dy/length);
 }
示例#5
0
        /// <summary>
        /// Converts a point from canvas coordinates to window coordinates
        /// </summary>
        /// <param name='x'>
        /// The X coordinate of the canvas point
        /// </param>
        /// <param name='y'>
        /// The Y coordinate of the canvas point
        /// </param>
        public Cairo.PointD CanvasPointToWindow(double x, double y)
        {
            ScaleFactor sf = new ScaleFactor(PintaCore.Workspace.ImageSize.Width, PintaCore.Workspace.CanvasSize.Width);

            Cairo.PointD pt = sf.UnscalePoint(new Cairo.PointD(x, y));
            return(new Cairo.PointD((int)(pt.X + Offset.X), (int)(pt.Y + Offset.Y)));
        }
示例#6
0
        /// <summary>
        /// Converts a point from window coordinates to canvas coordinates
        /// </summary>
        /// <param name='x'>
        /// The X coordinate of the window point
        /// </param>
        /// <param name='y'>
        /// The Y coordinate of the window point
        /// </param>
        public Cairo.PointD WindowPointToCanvas(double x, double y)
        {
            ScaleFactor sf = new ScaleFactor(PintaCore.Workspace.ImageSize.Width, PintaCore.Workspace.CanvasSize.Width);

            Cairo.PointD pt = sf.ScalePoint(new Cairo.PointD(x - Offset.X, y - Offset.Y));
            return(new Cairo.PointD((int)pt.X, (int)pt.Y));
        }
示例#7
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            Point pt = point.ToGdkPoint();

            // Grab focus so we can get keystrokes
            PintaCore.Chrome.Canvas.GrabFocus();

            // If we're in editing mode, a right click
            // allows you to move the text around
            if (is_editing && (args.Event.Button == 3))
            {
                tracking        = true;
                startMouseXY    = point;
                startClickPoint = clickPoint;

                SetCursor(cursor_hand);
                return;
            }

            // The user clicked the left mouse button
            if (args.Event.Button == 1)
            {
                // If we're editing and the user clicked within the text,
                // move the cursor to the click location
                if (is_editing && old_bounds.ContainsCorrect(pt))
                {
                    Position p = engine.PointToTextPosition(pt);
                    engine.SetCursorPosition(p);
                    RedrawText(true, true);
                    return;
                }

                // We're already editing and the user clicked outside the text,
                // commit the user's work, and start a new edit
                if (is_editing)
                {
                    switch (engine.EditMode)
                    {
                    // We were editing, save and stop
                    case EditingMode.Editing:
                        StopEditing();
                        break;

                    // We were editing, but nothing had been
                    // keyed. Stop editing.
                    case EditingMode.EmptyEdit:
                        StopEditing();
                        break;
                    }
                }

                // Start editing at the cursor location
                clickPoint = pt;
                StartEditing();
                engine.Origin = clickPoint;
                RedrawText(true, true);
                PintaCore.Workspace.Invalidate();
            }
        }
示例#8
0
        public static Cairo.PointD GetNormalized(this Cairo.PointD p)
        {
            double length = p.GetLength();

            p.X /= length;
            p.Y /= length;
            return(p);
        }
示例#9
0
 protected override void OnSizeAllocated(Rectangle allocation)
 {
     base.OnSizeAllocated(allocation);
     radius       = allocation.Height / 2;
     center       = new Cairo.PointD(allocation.Width / 2, allocation.Height / 2);
     hourLength   = allocation.Height / 3 / 1.65F;
     minuteLength = allocation.Height / 3 / 1.20F;
     secondLength = allocation.Height / 3 / 1.15F;
 }
示例#10
0
        /// <summary>
        /// Transform an n-dimensional vector (ignoring translational offset).
        /// </summary>
        public void TransformVector(IVector v, ref Cairo.PointD p)
        {
            double vx = v[_projection.First];
            double vy = v[_projection.Second];

            _world_to_surface.TransformDistance(ref vx, ref vy);
            p.X = vx;
            p.Y = vy;
        }
示例#11
0
        public PintaCanvas()
        {
            cr = new CanvasRenderer(true);

            // Keep the widget the same size as the canvas
            PintaCore.Workspace.CanvasSizeChanged += delegate(object sender, EventArgs e) {
                SetRequisition(PintaCore.Workspace.CanvasSize);
            };

            // Update the canvas when the image changes
            PintaCore.Workspace.CanvasInvalidated += delegate(object sender, CanvasInvalidatedEventArgs e) {
                if (e.EntireSurface)
                {
                    GdkWindow.Invalidate();
                }
                else
                {
                    GdkWindow.InvalidateRect(e.Rectangle, false);
                }
            };

            // Give mouse press events to the current tool
            ButtonPressEvent += delegate(object sender, ButtonPressEventArgs e) {
                if (PintaCore.Workspace.HasOpenDocuments)
                {
                    PintaCore.Tools.CurrentTool.DoMouseDown(this, e, PintaCore.Workspace.WindowPointToCanvas(e.Event.X, e.Event.Y));
                }
            };

            // Give mouse release events to the current tool
            ButtonReleaseEvent += delegate(object sender, ButtonReleaseEventArgs e) {
                if (PintaCore.Workspace.HasOpenDocuments)
                {
                    PintaCore.Tools.CurrentTool.DoMouseUp(this, e, PintaCore.Workspace.WindowPointToCanvas(e.Event.X, e.Event.Y));
                }
            };

            // Give mouse move events to the current tool
            MotionNotifyEvent += delegate(object sender, MotionNotifyEventArgs e) {
                if (!PintaCore.Workspace.HasOpenDocuments)
                {
                    return;
                }

                Cairo.PointD point = PintaCore.Workspace.ActiveWorkspace.WindowPointToCanvas(e.Event.X, e.Event.Y);

                if (PintaCore.Workspace.ActiveWorkspace.PointInCanvas(point))
                {
                    PintaCore.Chrome.LastCanvasCursorPoint = point.ToGdkPoint();
                }

                if (PintaCore.Tools.CurrentTool != null)
                {
                    PintaCore.Tools.CurrentTool.DoMouseMove(sender, e, point);
                }
            };
        }
示例#12
0
		protected override void OnSizeAllocated (Rectangle allocation)
		{
			base.OnSizeAllocated (allocation);
			radius = allocation.Height / 2;
			center = new Cairo.PointD(allocation.Width / 2, allocation.Height / 2);
			hourLength = allocation.Height / 3 / 1.65F;
			minuteLength = allocation.Height / 3 / 1.20F;
			secondLength = allocation.Height / 3 / 1.15F;
		}
		void Normalize ()
		{
			var max = verticies.Aggregate ((agg, next) => agg = new Cairo.PointD (Math.Max (agg.X, next.X), Math.Max (agg.Y, next.Y)));
			var min = verticies.Aggregate ((agg, next) => agg = new Cairo.PointD (Math.Min (agg.X, next.X), Math.Min (agg.Y, next.Y)));

			verticies.ForEach (vert => {
				vert.X = (vert.X + min.Y) / max.Y;
				vert.Y = (vert.Y + min.Y) / max.Y;
			});
		}
示例#14
0
 static void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, Eto.Drawing.Color.FromArgb(240, 240, 230, 75).ToCairo());
     pat.AddColorStop(1, Eto.Drawing.Color.FromArgb(0, 0, 0, 50).ToCairo());
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
示例#15
0
 void DrawFace(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, Generator.ConvertC(new Eto.Drawing.Color(240, 240, 230, 75)));
     pat.AddColorStop(1, Generator.ConvertC(new Eto.Drawing.Color(0, 0, 0, 50)));
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
示例#16
0
 private void DrawCenterFilledCircle(Cairo.PointD center, double radius, Cairo.Context e)
 {
     e.Arc(center.X, center.Y, radius, 0, 360);
     Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);
     pat.AddColorStop(0, CairoUtil.ColorFromRgb(240, 235, 229, 0.3));
     pat.AddColorStop(1, CairoUtil.ColorFromRgb(0, 0, 0, 0.2));
     e.LineWidth = 0.1;
     e.Pattern   = pat;
     e.FillPreserve();
     e.Stroke();
 }
示例#17
0
        public static Cairo.PointD[] ToPointDArray(this Vector2[] ps)
        {
            int len = ps.Length;

            Cairo.PointD[] ret = new Cairo.PointD[len];
            for (int i = 0; i < len; i++)
            {
                ret [i] = ps [i].ToPointD();
            }
            return(ret);
        }
示例#18
0
 public static void rotatePointIP(ref Point rotated, Point anchor, double radians)
 {
     double remapX = rotated.X - anchor.X;
     double remapY = rotated.Y - anchor.Y;
     double newX = Math.Cos (radians) * remapX - Math.Sin (radians) * remapY;
     double newY = Math.Sin (radians) * remapX + Math.Cos (radians) * remapY;
     double dx = newX - remapX;
     double dy = newY - remapY;
     rotated.X = rotated.X + dx;
     rotated.Y = rotated.Y + dy;
 }
示例#19
0
        /// <summary>
        /// Repaints a rectangle region on the canvas.
        /// </summary>
        /// <param name='canvasRect'>
        /// The rectangle region of the canvas requiring repainting
        /// </param>
        public void Invalidate(Gdk.Rectangle canvasRect)
        {
            Cairo.PointD canvasTopLeft  = new Cairo.PointD(canvasRect.Left, canvasRect.Top);
            Cairo.PointD canvasBtmRight = new Cairo.PointD(canvasRect.Right + 1, canvasRect.Bottom + 1);

            Cairo.PointD winTopLeft  = CanvasPointToWindow(canvasTopLeft.X, canvasTopLeft.Y);
            Cairo.PointD winBtmRight = CanvasPointToWindow(canvasBtmRight.X, canvasBtmRight.Y);

            Gdk.Rectangle winRect = Utility.PointsToRectangle(winTopLeft, winBtmRight, false).ToGdkRectangle();

            PintaCore.Workspace.OnCanvasInvalidated(new CanvasInvalidatedEventArgs(winRect));
        }
示例#20
0
        void DrawVersionNumber(Cairo.Context c, ref Cairo.PointD bottomRight, string text)
        {
            c.SelectFontFace(SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
            c.SetFontSize(SplashFontSize);

            var extents = c.TextExtents(text);

            c.MoveTo(bottomRight.X - extents.Width - 1, bottomRight.Y - extents.Height);

            c.SetSourceRGB(1, 1, 1);
            c.ShowText(text);
        }
示例#21
0
        protected override void OnMouseMove(object o, MotionNotifyEventArgs args, Cairo.PointD point)
        {
            // If we're dragging the text around, do that
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint    = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                engine.Origin = clickPoint;

                RedrawText(true, true);
            }
        }
示例#22
0
        public bool PointInCanvas(Cairo.PointD point)
        {
            if (point.X < 0 || point.Y < 0)
            {
                return(false);
            }

            if (point.X >= document.ImageSize.Width || point.Y >= document.ImageSize.Height)
            {
                return(false);
            }

            return(true);
        }
        public static bool Between(Point a, Point b, Point c)
        {
            if ( !Collinear(a, b, c)){
                return false;
            }

            if (a.X != b.X){
                return ((a.X <= c.X && c.X <= b.X) ||
                        (b.X <= c.X && c.X <= a.X) );
            }
            else{
                return ((a.Y <= c.Y && c.Y <= b.Y) ||
                        (b.Y <= c.Y && c.Y <= a.Y));
            }
        }
示例#24
0
        protected override void OnMouseUp(Document document, ToolMouseEventArgs e)
        {
            // If we were dragging the text around, finish that up
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(e.PointDouble.X - startMouseXY.X, e.PointDouble.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(false, true);
                tracking = false;
                SetCursor(null);
            }
        }
示例#25
0
 private void DrawLine(double fThickness, float fLength, Cairo.Color color,
                       float fRadians, Cairo.Context e)
 {
     Cairo.PointD p1, p2;
     p1 = new Cairo.PointD(_fCenterX - (double)(fLength / 9 * Math.Sin(fRadians)), _fCenterY + (double)(fLength / 9 * System.Math.Cos(fRadians)));
     p2 = new Cairo.PointD(_fCenterX + (double)(fLength * Math.Sin(fRadians)), _fCenterY - (double)(fLength * System.Math.Cos(fRadians)));
     e.MoveTo(p1);
     e.LineTo(p2);
     e.ClosePath();
     e.LineCap   = Cairo.LineCap.Round;
     e.LineJoin  = Cairo.LineJoin.Round;
     e.Color     = color;
     e.LineWidth = fThickness;
     e.Stroke();
 }
示例#26
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            // If we were dragging the text around, finish that up
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(false, true);
                tracking = false;
                SetCursor(null);
            }
        }
示例#27
0
        public static void DrawCote(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
                                    double stroke = 1.0, bool fill = false, double arrowWidth = 3.0, double arrowLength = 7.0)
        {
            Cairo.PointD vDir = p2.Substract(p1);
            vDir = vDir.GetNormalized();
            Cairo.PointD vPerp = vDir.GetPerp();

            Cairo.PointD pA0 = p1.Add(vDir.Multiply(arrowLength));
            Cairo.PointD pA1 = p2.Substract(vDir.Multiply(arrowLength));

            Cairo.PointD vA = vPerp.Multiply(arrowWidth);

            ctx.MoveTo(p1);
            ctx.LineTo(pA0.Add(vA));
            if (fill)
            {
                ctx.LineTo(pA0.Substract(vA));
            }
            else
            {
                ctx.MoveTo(pA0.Substract(vA));
            }

            ctx.LineTo(p1);

            ctx.MoveTo(p2);
            ctx.LineTo(pA1.Add(vA));
            if (fill)
            {
                ctx.LineTo(pA1.Substract(vA));
            }
            else
            {
                ctx.MoveTo(pA1.Substract(vA));
            }
            ctx.LineTo(p2);

            if (fill)
            {
                ctx.Fill();
            }

            ctx.MoveTo(p1);
            ctx.LineTo(p2);
            ctx.LineWidth = stroke;
            ctx.Stroke();
        }
示例#28
0
        public static Cairo.Rectangle PointsToRectangle(Cairo.PointD p1, Cairo.PointD p2, bool constrain)
        {
            // We want to create a rectangle that always has positive width/height
            double x, y, w, h;

            if (p1.Y <= p2.Y)
            {
                y = p1.Y;
                h = p2.Y - y + 1;
            }
            else
            {
                y = p2.Y;
                h = p1.Y - y + 1;
            }

            if (p1.X <= p2.X)
            {
                x = p1.X;

                if (constrain)
                {
                    w = h;
                }
                else
                {
                    w = p2.X - x + 1;
                }
            }
            else
            {
                x = p2.X;

                if (constrain)
                {
                    w = h;
                    x = p1.X - w;
                }
                else
                {
                    w = p1.X - x + 1;
                }
            }

            return(new Cairo.Rectangle(x, y, w, h));
        }
示例#29
0
        public static void DrawCoteFixed(this Cairo.Context ctx, Cairo.PointD p1, Cairo.PointD p2,
                                         double stroke = 1.0, double coteWidth = 3.0)
        {
            Cairo.PointD vDir = p2.Substract(p1);
            vDir = vDir.GetNormalized();
            Cairo.PointD vPerp = vDir.GetPerp();
            Cairo.PointD vA    = vPerp.Multiply(coteWidth);

            ctx.MoveTo(p1.Add(vA));
            ctx.LineTo(p1.Substract(vA));
            ctx.MoveTo(p2.Add(vA));
            ctx.LineTo(p2.Substract(vA));
            ctx.MoveTo(p1);
            ctx.LineTo(p2);
            ctx.LineWidth = stroke;
            ctx.Stroke();
        }
示例#30
0
        /// <summary>
        /// Handles the drag data received.
        /// See the EnableDrag and HandleDragDataGet in the ComponentLibraryPad where the drag
        /// has started and drag source is set
        /// </summary>
        /// <param name='o'>
        /// O.
        /// </param>
        /// <param name='args'>
        /// Arguments.
        /// </param>
        private void HandleDragDataReceived(object o, DragDataReceivedArgs args)
        {
            Widget   source   = Drag.GetSourceWidget(args.Context);
            TreeView treeView = source as TreeView;
            TreeIter selectedItem;

            if (treeView != null && treeView.Selection.GetSelected(out selectedItem))
            {
                ComponentsLibraryNode selectedNode = treeView.Model.GetValue(selectedItem, 0) as ComponentsLibraryNode;

                Cairo.PointD   translation = m_experimentCanvasWidget.ExperimentCanvas.View.ViewToDrawing(args.X, args.Y);
                ExperimentNode node        = m_applicationViewModel.Experiment.AddComponentFromDefinition(selectedNode.Data,
                                                                                                          translation.X, translation.Y);
                m_experimentDrawer.DrawComponent(node, true);
            }

            Drag.Finish(args.Context, true, false, args.Time);
        }
示例#31
0
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            base.OnExposeEvent(evnt);
            using (var e = CairoHelper.Create(evnt.Window))
            {
                var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180;
                DrawHand(3, hourLength, hourColor, hourRadians, e);

                var minuteRadians = (time.Minute) * 6 * Math.PI / 180;
                DrawHand(2, minuteLength, minuteColor, minuteRadians, e);

                var secondRadians = (time.Second) * 6 * Math.PI / 180;
                DrawHand(1, secondLength, secondColor, secondRadians, e);

                for (int i = 0; i < 60; i++)
                {
                    if (i % 5 == 0)
                    {
                        var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                        var p2 = new Cairo.PointD(center.X + (radius / 1.65 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos(i * 6 * Math.PI / 180)));
                        e.LineWidth = 1;
                        e.Color     = ticksColor;
                        e.MoveTo(p1);
                        e.LineTo(p2);
                        e.ClosePath();
                        e.Stroke();
                    }
                    else
                    {
                        var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                        var p2 = new Cairo.PointD(center.X + (radius / 1.55 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos(i * 6 * Math.PI / 180)));
                        e.LineWidth = 1;
                        e.Color     = ticksColor;
                        e.MoveTo(p1);
                        e.LineTo(p2);
                        e.ClosePath();
                        e.Stroke();
                    }
                }
                DrawFace(center, (radius / 2) + 17, e);
                DrawFace(center, 8, e);
            }
            return(true);
        }
示例#32
0
        protected void SelectionToolButtonToggled(object sender, EventArgs e)
        {
            if (selectionToolButton.Active == true)
            {
                ExperimentCanvas.SetSelectionTool();
            }

            //toggle the other button
            if (selectionToolButton.Active == panToolButton.Active)
            {
                panToolButton.Active = !panToolButton.Active;
            }

            // HERZUM SPRINT 2.4: TLAB-156
            Cairo.PointD pointTranslation = ExperimentCanvas.View.DrawingToView(0, 0);
            offsetPanX = pointTranslation.X;
            offsetPanY = pointTranslation.Y;
            // END HERZUM SPRINT 2.4: TLAB-156
        }
示例#33
0
		protected override bool OnExposeEvent (EventExpose evnt)
		{
			base.OnExposeEvent (evnt);
			using (var e = CairoHelper.Create (evnt.Window))
			{
				var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180;
				DrawHand (3, hourLength, hourColor, hourRadians, e);

				var minuteRadians = (time.Minute) * 6 * Math.PI / 180;
				DrawHand (2, minuteLength, minuteColor, minuteRadians, e);

				var secondRadians = (time.Second) * 6 * Math.PI / 180;
				DrawHand (1, secondLength, secondColor, secondRadians, e);
				
				for (int i = 0; i < 60; i++) {
					if (i % 5 == 0) {
						var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180)));
						var p2 = new Cairo.PointD (center.X + (radius / 1.65 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos (i * 6 * Math.PI / 180)));
						e.LineWidth = 1;
						e.Color = ticksColor;
						e.MoveTo (p1);
						e.LineTo (p2);
						e.ClosePath ();
						e.Stroke ();
					} else {
						
						var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180)));
						var p2 = new Cairo.PointD ( center.X + (radius / 1.55 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos (i * 6 * Math.PI / 180)));
						e.LineWidth = 1;
						e.Color = ticksColor;
						e.MoveTo (p1);
						e.LineTo (p2);
						e.ClosePath ();
						e.Stroke ();
						
					}
				}
				DrawFace (center, (radius / 2) + 17, e);
				DrawFace (center, 8, e);
				
			}
			return true;			
		}
示例#34
0
        void Render(Cairo.Context context)
        {
            var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180;

            DrawHand(3, hourLength, hourColor, hourRadians, context);

            var minuteRadians = (time.Minute) * 6 * Math.PI / 180;

            DrawHand(2, minuteLength, minuteColor, minuteRadians, context);

            var secondRadians = (time.Second) * 6 * Math.PI / 180;

            DrawHand(1, secondLength, secondColor, secondRadians, context);

            for (int i = 0; i < 60; i++)
            {
                if (i % 5 == 0)
                {
                    var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                    var p2 = new Cairo.PointD(center.X + (radius / 1.65 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos(i * 6 * Math.PI / 180)));
                    context.LineWidth = 1;
                    context.Color     = ticksColor;
                    context.MoveTo(p1);
                    context.LineTo(p2);
                    context.ClosePath();
                    context.Stroke();
                }
                else
                {
                    var p1 = new Cairo.PointD(center.X + (radius / 1.50 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos(i * 6 * Math.PI / 180)));
                    var p2 = new Cairo.PointD(center.X + (radius / 1.55 * Math.Sin(i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos(i * 6 * Math.PI / 180)));
                    context.LineWidth = 1;
                    context.Color     = ticksColor;
                    context.MoveTo(p1);
                    context.LineTo(p2);
                    context.ClosePath();
                    context.Stroke();
                }
            }
            //DrawFace (center, (radius / 2) + 17, e);
            //DrawFace (center, 8, e);
        }
示例#35
0
        protected override void OnMouseMove(object o, MotionNotifyEventArgs args, Cairo.PointD point)
        {
            ctrlKey = (args.Event.State & ModifierType.ControlMask) != 0;

            lastMousePosition = point.ToGdkPoint();

            // If we're dragging the text around, do that
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(true, true);
            }
            else
            {
                UpdateMouseCursor();
            }
        }
示例#36
0
        protected override void OnMouseMove(Document document, ToolMouseEventArgs e)
        {
            ctrlKey = e.IsControlPressed;

            lastMousePosition = e.PointDouble.ToGdkPoint();

            // If we're dragging the text around, do that
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(e.PointDouble.X - startMouseXY.X, e.PointDouble.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(true, true);
            }
            else
            {
                UpdateMouseCursor(document);
            }
        }
示例#37
0
        protected override bool OnExposeEvent(Gdk.EventExpose evt)
        {
            var build   = "";
            var version = "v" + BuildInfo.VersionLabel;

            var index = version.IndexOf(' ');

            if (index != -1)
            {
                build   = version.Substring(index + 1);
                version = version.Substring(0, index);
            }

            if (bitmap != null)
            {
                using (var context = Gdk.CairoHelper.Create(GdkWindow)) {
                    context.Antialias = Cairo.Antialias.Subpixel;

                    // Render the image first.
                    context.DrawImage(this, bitmap, 0, 0);

                    if (showVersionInfo)
                    {
                        var bottomRight = new Cairo.PointD(bitmap.Width - 10, bitmap.Height - 12);

                        // Render the alpha/beta text if we're an alpha or beta. If this
                        // is rendered, the bottomRight point will be shifted upwards to
                        // allow the MonoDevelop version to be rendered above the alpha marker
                        if (!string.IsNullOrEmpty(build))
                        {
                            DrawAlphaBetaMarker(context, ref bottomRight, build);
                        }
                        // Render the MonoDevelop version
                        DrawVersionNumber(context, ref bottomRight, version);
                    }
                }
            }

            return(true);
        }
示例#38
0
		void Render (Cairo.Context context)
		{
			var hourRadians = (time.Hour % 12 + time.Minute / 60F) * 30 * Math.PI / 180;
			DrawHand (3, hourLength, hourColor, hourRadians, context);

			var minuteRadians = (time.Minute) * 6 * Math.PI / 180;
			DrawHand (2, minuteLength, minuteColor, minuteRadians, context);

			var secondRadians = (time.Second) * 6 * Math.PI / 180;
			DrawHand (1, secondLength, secondColor, secondRadians, context);
				
			for (int i = 0; i < 60; i++) {
				if (i % 5 == 0) {
					var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180)));
					var p2 = new Cairo.PointD (center.X + (radius / 1.65 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.65 * Math.Cos (i * 6 * Math.PI / 180)));
					context.LineWidth = 1;
					context.Color = ticksColor;
					context.MoveTo (p1);
					context.LineTo (p2);
					context.ClosePath ();
					context.Stroke ();
				} else {
						
					var p1 = new Cairo.PointD (center.X + (radius / 1.50 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.50 * Math.Cos (i * 6 * Math.PI / 180)));
					var p2 = new Cairo.PointD (center.X + (radius / 1.55 * Math.Sin (i * 6 * Math.PI / 180)), center.Y - (radius / 1.55 * Math.Cos (i * 6 * Math.PI / 180)));
					context.LineWidth = 1;
					context.Color = ticksColor;
					context.MoveTo (p1);
					context.LineTo (p2);
					context.ClosePath ();
					context.Stroke ();
						
				}
			}
			//DrawFace (center, (radius / 2) + 17, e);
			//DrawFace (center, 8, e);
		}
 public static bool IntersectProp(Point a, Point b, Point c, Point d)
 {
     if (Collinear (a, b, c) ||
             Collinear (a, b, d) ||
             Collinear (c, d, a) ||
             Collinear (c, d, b)) {
             return false;
         }
         return ((Left (a, b, c) ^ Left (a, b, d)) &&
             (Left (c , d, a) ^ Left (c, d, b)));
 }
示例#40
0
文件: Utility.cs 项目: msiyer/Pinta
		public static unsafe void GetRgssOffsets (Cairo.PointD* samplesArray, int sampleCount, int quality)
        {
            if (sampleCount < 1)
            {
                throw new ArgumentOutOfRangeException("sampleCount", "sampleCount must be [0, int.MaxValue]");
            }

            if (sampleCount != quality * quality)
            {
                throw new ArgumentOutOfRangeException("sampleCount != (quality * quality)");
            }

            if (sampleCount == 1)
            {
                samplesArray[0] = new Cairo.PointD (0.0, 0.0);
            }
            else
            {
                for (int i = 0; i < sampleCount; ++i)
                {
                    double y = (i + 1d) / (sampleCount + 1d);
                    double x = y * quality;

                    x -= (int)x;

                    samplesArray[i] = new Cairo.PointD (x - 0.5d, y - 0.5d);
                }
            }
        }
示例#41
0
文件: TextTool.cs 项目: xxgreg/Pinta
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            if (tracking) {
                Cairo.PointD delta = new Cairo.PointD (point.X - startMouseXY.X, point.Y - startMouseXY.Y);
                this.clickPoint = new Point ((int)(this.startClickPoint.X + delta.X), (int)(this.startClickPoint.Y + delta.Y));
                RedrawText (false);
                tracking = false;
                //UpdateStatusText();
            }

            //base.OnMouseUp (e);
        }
示例#42
0
        protected override void OnMouseUp(Gtk.DrawingArea canvas, Gtk.ButtonReleaseEventArgs args, Cairo.PointD point)
        {
            // If we were dragging the text around, finish that up
            if (tracking) {
                Cairo.PointD delta = new Cairo.PointD (point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point ((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText (false, true);
                tracking = false;
                SetCursor (null);
            }
        }
 public static void Add(ref VertexStructure head, Point p)
 {
     VertexStructure vs = new VertexStructure (p);
     VertexStructure.Add (ref head,vs);
 }
示例#44
0
文件: TextTool.cs 项目: rini18/Pinta
        protected override void OnMouseMove(object o, MotionNotifyEventArgs args, Cairo.PointD point)
        {
            // If we're dragging the text around, do that
            if (tracking) {
                Cairo.PointD delta = new Cairo.PointD (point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point ((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                engine.Origin = clickPoint;

                RedrawText (true, true);
            }
        }
示例#45
0
文件: TextTool.cs 项目: rini18/Pinta
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            Point pt = point.ToGdkPoint ();

            // Grab focus so we can get keystrokes
            PintaCore.Chrome.Canvas.GrabFocus ();

            // If we're in editing mode, a right click
            // allows you to move the text around
            if (is_editing && (args.Event.Button == 3)) {
                tracking = true;
                startMouseXY = point;
                startClickPoint = clickPoint;

                SetCursor (cursor_hand);
                return;
            }

            // The user clicked the left mouse button
            if (args.Event.Button == 1) {
                // If we're editing and the user clicked within the text,
                // move the cursor to the click location
                if (is_editing && old_bounds.ContainsCorrect (pt)) {
                    Position p = engine.PointToTextPosition (pt);
                    engine.SetCursorPosition (p);
                    RedrawText (true, true);
                    return;
                }

                // We're already editing and the user clicked outside the text,
                // commit the user's work, and start a new edit
                if (is_editing) {
                    switch (engine.EditMode) {
                        // We were editing, save and stop
                        case EditingMode.Editing:
                            StopEditing ();
                            break;

                        // We were editing, but nothing had been
                        // keyed. Stop editing.
                        case EditingMode.EmptyEdit:
                            StopEditing ();
                            break;
                    }
                }

                // Start editing at the cursor location
                clickPoint = pt;
                StartEditing ();
                engine.Origin = clickPoint;
                RedrawText (true, true);
                PintaCore.Workspace.Invalidate ();
            }
        }
        public static int Count(VertexStructure vertices)
        {
            int n = 0;
            VertexStructure v = vertices;
            do{
                v = v.next;
                n++;
            }
            while(!ReferenceEquals (v, vertices));

            return n;
        }
 public static bool Collinear(Point a, Point b, Point c)
 {
     return Area2(a, b, c) == 0;
 }
示例#48
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            ctrlKey = (args.Event.State & ModifierType.ControlMask) != 0;

            //Store the mouse position.
            Point pt = point.ToGdkPoint();

            // Grab focus so we can get keystrokes
            PintaCore.Chrome.Canvas.GrabFocus();

            // A right click allows you to move the text around
            if (args.Event.Button == 3)
            {
                //The user is dragging text with the right mouse button held down, so track the mouse as it moves.
                tracking = true;

                //Remember the position of the mouse before the text is dragged.
                startMouseXY = point;
                startClickPoint = clickPoint;

                //Change the cursor to indicate that the text is being dragged.
                SetCursor(cursor_hand);

                return;
            }

            // The user clicked the left mouse button
            if (args.Event.Button == 1)
            {
                // If the user is [editing or holding down Ctrl] and clicked
                //within the text, move the cursor to the click location
                if ((is_editing || ctrlKey) && CurrentTextBounds.ContainsCorrect(pt))
                {
                    StartEditing();

                    //Change the position of the cursor to where the mouse clicked.
                    Position p = CurrentTextEngine.PointToTextPosition(pt);
                    CurrentTextEngine.SetCursorPosition(p);

                    //Redraw the text with the new cursor position.
                    RedrawText(true, true);

                    return;
                }

                // We're already editing and the user clicked outside the text,
                // commit the user's work, and start a new edit
                switch (CurrentTextEngine.EditMode)
                {
                    // We were editing, save and stop
                    case EditingMode.Editing:
                        StopEditing(true);
                        break;

                    // We were editing, but nothing had been
                    // keyed. Stop editing.
                    case EditingMode.EmptyEdit:
                        StopEditing(false);
                        break;
                }

                if (ctrlKey)
                {
                    //Go through every UserLayer.
                    foreach (UserLayer ul in PintaCore.Workspace.ActiveDocument.UserLayers)
                    {
                        //Check each UserLayer's editable text boundaries to see if they contain the mouse position.
                        if (ul.textBounds.ContainsCorrect(pt))
                        {
                            //The mouse clicked on editable text.

                            //Change the current UserLayer to the Layer that contains the text that was clicked on.
                            PintaCore.Workspace.ActiveDocument.SetCurrentUserLayer(ul);

                            //The user is editing text now.
                            is_editing = true;

                            //Set the cursor in the editable text where the mouse was clicked.
                            Position p = CurrentTextEngine.PointToTextPosition(pt);
                            CurrentTextEngine.SetCursorPosition(p);

                            //Redraw the editable text with the cursor.
                            RedrawText(true, true);

                            //Don't check any more UserLayers - stop at the first UserLayer that has editable text containing the mouse position.
                            return;
                        }
                    }
                }
                else
                {
                    if (CurrentTextEngine.textMode == TextMode.NotFinalized)
                    {
                        //The user is making a new text and the old text hasn't been finalized yet.
                        FinalizeText();
                    }

                    if (!is_editing)
                    {
                        // Start editing at the cursor location
                        clickPoint = pt;
                        CurrentTextEngine.Clear();
                        clickPoint.Offset (0, -CurrentTextEngine.FontHeight/2);
                        CurrentTextEngine.Origin = clickPoint;
                        StartEditing();
                        RedrawText(true, true);
                    }
                }
            }
        }
示例#49
0
        protected override void OnMouseMove(object o, MotionNotifyEventArgs args, Cairo.PointD point)
        {
            ctrlKey = (args.Event.State & ModifierType.ControlMask) != 0;

            lastMousePosition = point.ToGdkPoint();

            // If we're dragging the text around, do that
            if (tracking)
            {
                Cairo.PointD delta = new Cairo.PointD(point.X - startMouseXY.X, point.Y - startMouseXY.Y);

                clickPoint = new Point((int)(startClickPoint.X + delta.X), (int)(startClickPoint.Y + delta.Y));
                CurrentTextEngine.Origin = clickPoint;

                RedrawText(true, true);
            }
            else
            {
                UpdateMouseCursor();
            }
        }
示例#50
0
        void UpdateRulerRange()
        {
            Cairo.PointD p = new Cairo.PointD (0, 0);
            if (PintaCore.Workspace.Offset.X > 0)
                p.X = PintaCore.Workspace.Offset.X /PintaCore.Workspace.Scale;

            if (PintaCore.Workspace.Offset.Y > 0)
                p.Y = PintaCore.Workspace.Offset.Y;

            hruler.SetRange (-p.X, PintaCore.Workspace.ImageSize.Width + p.X, 0, PintaCore.Workspace.ImageSize.Width + p.X);
            vruler.SetRange (-p.Y, PintaCore.Workspace.ImageSize.Height + p.Y, 0, PintaCore.Workspace.ImageSize.Height + p.Y);
        }
示例#51
0
        public void UpdateRulerRange()
        {
            Gtk.Main.Iteration (); //Force update of scrollbar upper before recenter

            Cairo.PointD lower = new Cairo.PointD (0, 0);
            Cairo.PointD upper = new Cairo.PointD (0, 0);

            if (PintaCore.Workspace.HasOpenDocuments) {
                if (PintaCore.Workspace.Offset.X > 0) {
                    lower.X = - PintaCore.Workspace.Offset.X / PintaCore.Workspace.Scale;
                    upper.X = PintaCore.Workspace.ImageSize.Width - lower.X;
                }
                else {
                    lower.X = sw.Hadjustment.Value / PintaCore.Workspace.Scale;
                    upper.X = (sw.Hadjustment.Value + sw.Hadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
                if (PintaCore.Workspace.Offset.Y > 0) {
                    lower.Y = - PintaCore.Workspace.Offset.Y / PintaCore.Workspace.Scale;
                    upper.Y = PintaCore.Workspace.ImageSize.Height - lower.Y;
                }
                else {
                    lower.Y = sw.Vadjustment.Value / PintaCore.Workspace.Scale;
                    upper.Y = (sw.Vadjustment.Value + sw.Vadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
            }

            hruler.SetRange (lower.X, upper.X, 0, upper.X);
            vruler.SetRange (lower.Y, upper.Y, 0, upper.Y);
        }
        private void DrawLine(double fThickness, float fLength, Cairo.Color color,
		                      float fRadians, Cairo.Context e)
        {
            Cairo.PointD p1, p2;
            p1 = new Cairo.PointD( fCenterX - (double)(fLength/9*System.Math.Sin(fRadians)), fCenterY + (double)(fLength/9*System.Math.Cos(fRadians)) );
            p2 = new Cairo.PointD( fCenterX + (double)(fLength*System.Math.Sin(fRadians) )  , fCenterY - (double)(fLength*System.Math.Cos(fRadians)) );
            e.MoveTo(p1);
            e.LineTo(p2);
            e.ClosePath();
            e.LineCap   = Cairo.LineCap.Round;
            e.LineJoin  = Cairo.LineJoin.Round;
            e.Color     = color;
            e.LineWidth = fThickness;
            e.Stroke();
        }
示例#53
0
        public void UpdateRulerRange ()
        {
            Gtk.Main.Iteration (); //Force update of scrollbar upper before recenter

            var lower = new Cairo.PointD (0, 0);
            var upper = new Cairo.PointD (0, 0);

            if (scrolled_window.Hadjustment == null || scrolled_window.Vadjustment == null)
                return;

            if (PintaCore.Workspace.HasOpenDocuments) {
                if (PintaCore.Workspace.Offset.X > 0) {
                    lower.X = -PintaCore.Workspace.Offset.X / PintaCore.Workspace.Scale;
                    upper.X = PintaCore.Workspace.ImageSize.Width - lower.X;
                } else {
                    lower.X = scrolled_window.Hadjustment.Value / PintaCore.Workspace.Scale;
                    upper.X = (scrolled_window.Hadjustment.Value + scrolled_window.Hadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
                if (PintaCore.Workspace.Offset.Y > 0) {
                    lower.Y = -PintaCore.Workspace.Offset.Y / PintaCore.Workspace.Scale;
                    upper.Y = PintaCore.Workspace.ImageSize.Height - lower.Y;
                } else {
                    lower.Y = scrolled_window.Vadjustment.Value / PintaCore.Workspace.Scale;
                    upper.Y = (scrolled_window.Vadjustment.Value + scrolled_window.Vadjustment.PageSize) / PintaCore.Workspace.Scale;
                }
            }

            horizontal_ruler.SetRange (lower.X, upper.X, 0, upper.X);
            vertical_ruler.SetRange (lower.Y, upper.Y, 0, upper.Y);
        }
        protected override bool OnExposeEvent(EventExpose evnt)
        {
            base.OnExposeEvent (evnt);
            Cairo.Context e = CairoHelper.Create( evnt.Window);

            //
            DateTime dateTime = this.datetime;
            float fRadHr      = (dateTime.Hour%12+dateTime.Minute/60F) *30*PI/180;
            float fRadMin     = (dateTime.Minute)*6*PI / 180;
            float fRadSec     = (dateTime.Second)*6*PI / 180;

            Cairo.PointD center = new Cairo.PointD( fCenterX, fCenterY );

            DrawLine( this.fHourTickness, this.fHourLength, hrColor , fRadHr , e );
            DrawLine( this.fMinTickness , this.fMinLength , minColor, fRadMin, e );
            DrawLine( this.fSecTickness , this.fSecLength , secColor, fRadSec, e );

            for( int i = 0; i < 60; i++ )
            {
                if ( this.bDraw5MinuteTicks==true && i%5==0 )
                // Draw 5 minute ticks
                {
                    e.LineWidth = fTicksThickness;
                    e.Color     = ticksColor;
                    Cairo.PointD p1 = new Cairo.PointD(
                                      fCenterX + (double)( this.fRadius/1.50F*System.Math.Sin(i*6*PI/180) ) ,
                                      fCenterY - (double)( this.fRadius/1.50F*System.Math.Cos(i*6*PI/180) ) );
                    Cairo.PointD p2 = new Cairo.PointD(
                                      fCenterX + (double)( this.fRadius/1.65F*System.Math.Sin(i*6*PI/180) ),
                                      fCenterY - (double)( this.fRadius/1.65F*System.Math.Cos(i*6*PI/180) ) );

                    e.MoveTo(p1);
                    e.LineTo(p2);
                    e.ClosePath();
                    e.Stroke();
                }
                else if ( this.bDraw1MinuteTicks==true ) // draw 1 minute ticks
                {

                    e.LineWidth = fTicksThickness;
                    e.Color     = ticksColor;
                    Cairo.PointD p1 = new Cairo.PointD
                    (
                        fCenterX + (double) ( this.fRadius/1.50F*System.Math.Sin(i*6*PI/180) ),
                        fCenterY - (double) ( this.fRadius/1.50F*System.Math.Cos(i*6*PI/180) )
                    );
                    Cairo.PointD p2 = new Cairo.PointD
                    (
                         fCenterX + (double) ( this.fRadius/1.55F*System.Math.Sin(i*6*PI/180) ),
                         fCenterY - (double) ( this.fRadius/1.55F*System.Math.Cos(i*6*PI/180) )
                    );
                    e.MoveTo( p1 );
                    e.LineTo( p2 );
                    e.ClosePath();
                    e.Stroke();

                }
            }
            DrawCenterFilledCircle( center, ( fRadius / 2 ) + 17 , e );
            DrawCenterFilledCircle( center, 8 , e );

            ((IDisposable) e.Target).Dispose ();
            ((IDisposable) e).Dispose ();

            //
            return true;
        }
 public VertexStructure(Point v)
 {
     this.v = v;
 }
示例#56
0
		protected override bool OnExposeEvent (Gdk.EventExpose ev)
		{
			base.OnExposeEvent (ev);

			using (Cairo.Context g = CairoHelper.Create (GdkWindow)) {
				Cairo.Rectangle ourRect = Rectangle.Inflate (GdkWindow.GetBounds (), -1, -1).ToCairoRectangle ();
				double diameter = Math.Min (ourRect.Width, ourRect.Height);

				double radius = (diameter / 2.0);

				Cairo.PointD center = new Cairo.PointD (
				    (float)(ourRect.X + radius),
				    (float)(ourRect.Y + radius));

				double theta = (this.angleValue * 2.0 * Math.PI) / 360.0;

				Cairo.Rectangle ellipseRect = new Cairo.Rectangle (ourRect.Location (), diameter, diameter);
				Cairo.Rectangle ellipseOutlineRect = ellipseRect;

				g.DrawEllipse (ellipseOutlineRect, new Cairo.Color (.1, .1, .1), 1);

				double endPointRadius = radius - 2;
				
				Cairo.PointD endPoint = new Cairo.PointD (
				    (float)(center.X + (endPointRadius * Math.Cos (theta))),
				    (float)(center.Y - (endPointRadius * Math.Sin (theta))));

				float gripSize = 2.5f;
				Cairo.Rectangle gripEllipseRect = new Cairo.Rectangle (center.X - gripSize, center.Y - gripSize, gripSize * 2, gripSize * 2);
				
				g.FillEllipse (gripEllipseRect, new Cairo.Color (.1, .1, .1));
				g.DrawLine (center, endPoint, new Cairo.Color (.1, .1, .1), 1);
			}
			
			return true;
		}
示例#57
0
文件: TextTool.cs 项目: xxgreg/Pinta
        protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
        {
            base.OnMouseDown (canvas, args, point);

            //bool touchingMoveNub = this.moveNub.IsPointTouching(new Point(e.X, e.Y), false);

            //|| touchingMoveNub)) // = right click
            if (this.mode != EditingMode.NotEditing && (args.Event.Button == 3)) {
                this.tracking = true;
                this.startMouseXY = point;
                this.startClickPoint = this.clickPoint;
                //this.Cursor = this.handCursorMouseDown;
                //UpdateStatusText();
            } else if (args.Event.Button == 1) {
                if (saved != null) {
                    Rectangle[] rects = saved.Region.GetRectangles ();
                    Rectangle bounds = Utility.GetRegionBounds (rects, 0, rects.Length);
                    bounds.Inflate (FontHeight, FontHeight);

                    if (lines != null && bounds.Contains ((int)point.X, (int)point.Y)) {
                        Position p = PointToTextPosition (new Point ((int)point.X, (int)(point.Y + (FontHeight / 2))));
                        linePos = p.Line;
                        textPos = p.Offset;
                        RedrawText (true);
                        return;
                    }
                }

                switch (mode) {
                case EditingMode.Editing:
                    SaveHistoryMemento ();
                    StopEditing ();
                    break;

                case EditingMode.EmptyEdit:
                    RedrawText (false);
                    StopEditing ();
                    break;
                }

                clickPoint = new Point ((int)point.X, (int)point.Y);
                StartEditing ();
                RedrawText (true);
            }
        }
 public static bool LeftOn(Point a, Point b, Point c)
 {
     return Area2(a, b, c) >= 0;
 }
示例#59
0
        /// <summary>
        /// Repaints a rectangle region on the canvas.
        /// </summary>
        /// <param name='canvasRect'>
        /// The rectangle region of the canvas requiring repainting
        /// </param>
        public void Invalidate(Gdk.Rectangle canvasRect)
        {
            Cairo.PointD canvasTopLeft = new Cairo.PointD(canvasRect.Left, canvasRect.Top);
            Cairo.PointD canvasBtmRight = new Cairo.PointD(canvasRect.Right, canvasRect.Bottom);

            Cairo.PointD winTopLeft = CanvasPointToWindow(canvasTopLeft.X, canvasTopLeft.Y);
            Cairo.PointD winBtmRight = CanvasPointToWindow(canvasBtmRight.X, canvasBtmRight.Y);

            Gdk.Rectangle winRect = Utility.PointsToRectangle(winTopLeft, winBtmRight, false).ToGdkRectangle();

            PintaCore.Workspace.OnCanvasInvalidated (new CanvasInvalidatedEventArgs (winRect));
        }
示例#60
0
文件: TextTool.cs 项目: xxgreg/Pinta
        protected override void OnMouseMove(object o, Gtk.MotionNotifyEventArgs args, Cairo.PointD point)
        {
            if (tracking) {
                Cairo.PointD delta = new Cairo.PointD (point.X - startMouseXY.X, point.Y - startMouseXY.Y);
                this.clickPoint = new Point ((int)(this.startClickPoint.X + delta.X), (int)(this.startClickPoint.Y + delta.Y));
                RedrawText (false);
                //UpdateStatusText();
            } else {
                /*bool touchingNub = this.moveNub.IsPointTouching(new Point(e.X, e.Y), false);

                if (touchingNub && this.moveNub.Visible)
                {
                    this.Cursor = this.handCursor;
                }
                else
                {
                    this.Cursor = this.textToolCursor;
                }*/
            }

            base.OnMouseMove (o, args, point);
        }