MoveToPoint() public method

public MoveToPoint ( CGAffineTransform transform, float x, float y ) : void
transform CGAffineTransform
x float
y float
return void
コード例 #1
0
ファイル: Extensions.cs プロジェクト: nagyist/AppStoreWindow
        internal static CGPath CreateClippingPath(RectangleF rect, float radius)
        {
            var path = new CGPath();
            path.MoveToPoint(rect.GetMinX(), rect.GetMinY());
            path.AddLineToPoint(rect.GetMinX(), rect.GetMaxY() - radius);
            path.AddArcToPoint(rect.GetMinX(), rect.GetMaxY(), rect.GetMinX() + radius, rect.GetMaxY(), radius);
            path.AddLineToPoint(rect.GetMaxX() - radius, rect.GetMaxY());
            path.AddArcToPoint(rect.GetMaxX(), rect.GetMaxY(), rect.GetMaxX(), rect.GetMaxY() - radius, radius);
            path.AddLineToPoint(rect.GetMaxX(), rect.GetMinY());
            path.CloseSubpath();

            return path;
        }
コード例 #2
0
        private static float scale = 10000; //or 1 or 10 or 10000 etc for lesser or greater precision.

        #endregion Fields

        #region Constructors

        // An infinite region would cover the entire device region which is the same as
        // not having a clipping region. Note that this is not the same as having an
        // empty region, which when clipping to it has the effect of excluding the entire
        // device region.
        public Region()
        {
            // We set the default region to a very large
            regionObject = infinite;

            var path = RectangleToPath (infinite);
            solution.Add (path);

            regionList.Add (new RegionEntry (RegionType.Infinity, infinite, path));

            regionPath = new CGPath ();
            regionPath.MoveToPoint (infinite.Left, infinite.Top);
            regionPath.AddLineToPoint (infinite.Right, infinite.Top);
            regionPath.AddLineToPoint (infinite.Right, infinite.Bottom);
            regionPath.AddLineToPoint (infinite.Left, infinite.Bottom);

            regionBounds = infinite;
        }
コード例 #3
0
        void PathsToInternalPath(Paths paths)
        {
            regionPath = new CGPath ();

            foreach (var poly in solution)
            {
                regionPath.MoveToPoint(IntPointToPointF(poly[0]));

                for (var p =1; p < poly.Count; p++)
                {
                    regionPath.AddLineToPoint (IntPointToPointF (poly [p]));
                }
            }
        }
コード例 #4
0
        //        public bool IsInfinite(Graphics g)
        //        {
        //        }
        public void MakeInfinite()
        {
            regionObject = infinite;

            var path = RectangleToPath (infinite);

            // clear out our containers.
            regionList.Clear ();
            solution.Clear ();

            solution.Add (path);
            regionList.Add (new RegionEntry (RegionType.Infinity, infinite, path));

            regionPath = new CGPath ();
            regionPath.MoveToPoint (infinite.Left, infinite.Top);
            regionPath.AddLineToPoint (infinite.Right, infinite.Top);
            regionPath.AddLineToPoint (infinite.Right, infinite.Bottom);
            regionPath.AddLineToPoint (infinite.Left, infinite.Bottom);

            regionBounds = regionPath.BoundingBox;
        }
コード例 #5
0
        public Region(RectangleF rect)
        {
            regionObject = rect;
            var path = RectangleToPath (rect);
            solution.Add (path);
            regionList.Add (new RegionEntry (RegionType.Rectangle, rect, path));
            regionPath = new CGPath ();
            regionPath.MoveToPoint (rect.Left, rect.Top);
            regionPath.AddLineToPoint (rect.Right, rect.Top);
            regionPath.AddLineToPoint (rect.Right, rect.Bottom);
            regionPath.AddLineToPoint (rect.Left, rect.Bottom);

            regionBounds = rect;
        }
コード例 #6
0
		private void FlyTheShirt(PointF startPoint)
		{
			// Reset starting point of the ImageView
			ivFlyingShirt.Frame = new RectangleF(startPoint.X, startPoint.Y, ivFlyingShirt.Frame.Width, ivFlyingShirt.Frame.Height);

			NSMatrix matrix = (NSMatrix)btnNavigationProducts.ControlView;
			int lastRowIndex = matrix.Rows - 1;
			// Assuming the shopping basket button is always the last in the list...
			var btnFrame = matrix.CellFrameAtRowColumn (lastRowIndex, 0);
			var btnCenter = new PointF (btnFrame.Left + (btnFrame.Width / 2), btnFrame.Top + (btnFrame.Height / 2));
			var btnCenterCompensated = new PointF (btnCenter.X - (ivFlyingShirt.Frame.Width / 2), btnCenter.Y + (ivFlyingShirt.Frame.Height / 2));
			var endPoint = matrix.ConvertPointToView (btnCenterCompensated, matrix.Superview);

			// Create quadratic curve path
			var path = new CGPath ();
			path.MoveToPoint (startPoint);
			// Use the view title label as the control point for the curve
			var controlPoint = lblViewTitle.Superview.ConvertPointToView(new PointF(lblViewTitle.Frame.Left + (lblViewTitle.Frame.Width/3), lblViewTitle.Frame.Bottom), null);
			path.AddQuadCurveToPoint (controlPoint.X, controlPoint.Y, endPoint.X, endPoint.Y);

			// Create animation based on the path and add it to the image view
			var pathAnimation = CAKeyFrameAnimation.GetFromKeyPath ("frameOrigin");
			pathAnimation.Path = path;
			pathAnimation.RepeatCount = 0f;
			pathAnimation.Duration = 0.7f;
			pathAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseInEaseOut);
			pathAnimation.AnimationStarted += delegate {
				// Show the ImageView
				ivFlyingShirt.Hidden = false;
			};
			pathAnimation.AnimationStopped += delegate {
				// Hide the ImageView
				ivFlyingShirt.Hidden = true;
				badgeView.BadgeNumber = WebService.Shared.CurrentOrder.Products.Count;
			};

			ivFlyingShirt.Animations = NSDictionary.FromObjectAndKey (pathAnimation, (NSString)"frameOrigin");

			// Change the frame location via animation
			((NSImageView) ivFlyingShirt.Animator).Frame = new RectangleF(endPoint, ivFlyingShirt.Frame.Size);
		}
コード例 #7
0
ファイル: SessionsPopUpButton.cs プロジェクト: pascalfr/MPfm
        public override void DrawRect(RectangleF dirtyRect)
        {
            float padding = 4;
            CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort;

            if (RoundedRadius == 0)
            {
                if (!Enabled)
                    CoreGraphicsHelper.FillRect(context, Bounds, DisabledBackgroundColor);
                else if (_isMouseDown)
                    CoreGraphicsHelper.FillRect(context, Bounds, BackgroundMouseDownColor);
                else if (_isMouseOver)
                    CoreGraphicsHelper.FillRect(context, Bounds, BackgroundMouseOverColor);
                else
                    CoreGraphicsHelper.FillRect(context, Bounds, BackgroundColor);

                CoreGraphicsHelper.DrawRect(context, Bounds, BorderColor, 2);
            } 
            else
            {
                var roundedPath = NSBezierPath.FromRoundedRect(Bounds, RoundedRadius, RoundedRadius);
                NSColor nsColor = null;
                if(!Enabled)
                    nsColor = NSColor.FromCIColor(CIColor.FromCGColor(DisabledBackgroundColor));
                else if (_isMouseDown)
                    nsColor = NSColor.FromCIColor(CIColor.FromCGColor(BackgroundMouseDownColor));
                else if (_isMouseOver)
                    nsColor = NSColor.FromCIColor(CIColor.FromCGColor(BackgroundMouseOverColor));
                else
                    nsColor = NSColor.FromCIColor(CIColor.FromCGColor(BackgroundColor));
                nsColor.SetFill();
                roundedPath.Fill();
            }

            //CoreGraphicsHelper.DrawRect(context, Bounds, BorderColor, 2);
            RectangleF rectTextSize = CoreGraphicsHelper.MeasureString(Bounds.Size, Title, "Roboto", 11);
            RectangleF rectText;
            if (Image != null)
            {
                float xImage = ((Bounds.Width - rectTextSize.Width - (padding * 2) - Image.Size.Width) / 2);
                RectangleF rectImage = new RectangleF(xImage, (Bounds.Height - Image.Size.Height) / 2, Image.Size.Width, Image.Size.Height);
                Image.DrawInRect(rectImage, new RectangleF(0, 0, Image.Size.Width, Image.Size.Height), NSCompositingOperation.SourceOver, 1.0f);

                float xText = xImage + padding + Image.Size.Width + padding;
                rectText = new RectangleF(xText, (Bounds.Height - rectTextSize.Height) / 2, rectTextSize.Width, rectTextSize.Height);
            } 
            else
            {
                rectText = new RectangleF(padding * 2, ((Bounds.Height - rectTextSize.Height) / 2) - 2, rectTextSize.Width, rectTextSize.Height);
            }

            CoreGraphicsHelper.DrawText(rectText, 0, 0, Title, "Roboto", 11, NSColor.White);

            var triangleColor = new CGColor(0.8f, 0.8f, 0.8f);
            float trianglePadding = 8;
            float triangleWidth = 8;
            var path = new CGPath();
            path.MoveToPoint(new PointF(Bounds.Width - trianglePadding, trianglePadding));
            path.AddLineToPoint(new PointF(Bounds.Width - trianglePadding - (triangleWidth / 2), Bounds.Height - trianglePadding));
            path.AddLineToPoint(new PointF(Bounds.Width - trianglePadding - triangleWidth, trianglePadding));
            path.AddLineToPoint(new PointF(Bounds.Width - trianglePadding, trianglePadding));

            CoreGraphicsHelper.StrokePath(context, path, 1, triangleColor);
            if(_isMouseOver)
                CoreGraphicsHelper.FillPath(context, path, triangleColor);
        }