コード例 #1
0
ファイル: PointTest.cs プロジェクト: cwensley/xamarin-macios
        public void ToStringTest()
        {
            var point = new CGPoint((nfloat)1, (nfloat)2);

#if NET
            Assert.AreEqual("{1, 2}", point.ToString(), "ToString");
#else
            Assert.AreEqual("{X=1, Y=2}", point.ToString(), "ToString");
#endif
        }
コード例 #2
0
ファイル: View.cs プロジェクト: xinmeng1/monotouch-samples
        // Raised when a user raises their finger from the screen. Since we need to check to
        // see if the user touch started and ended within the path, we have to track to see
        // when the finger is raised, if it did.
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);

            // get a reference to any of the touches
            UITouch touch = touches.AnyObject as UITouch;

            // if there is a touch
            if (touch != null)
            {
                // the point of touch
                CGPoint pt = touch.LocationInView(this);

                // if the touch ended in the path AND it started in the path
                if (myRectangleButtonPath.ContainsPoint(pt, true) && touchStartedInPath)
                {
                    Console.WriteLine("touched at location: " + pt.ToString());
                    UIAlertView alert = new UIAlertView("Hit!", "You sunk my battleship!", null, "OK", null);
                    alert.Show();
                }
            }

            // reset
            touchStartedInPath = false;
        }
コード例 #3
0
        public UIViewController GetViewControllerForPreview(IUIViewControllerPreviewing previewingContext, CGPoint location)
        {
            // Obtain the index path and the cell that was pressed.
            var indexPath = CollectionView.IndexPathForItemAtPoint(location);

            Console.WriteLine("ForPreview " + location.ToString() + " " + indexPath);

            if (indexPath == null)
            {
                return(null);
            }

            var cell = CollectionView.CellForItem(indexPath);

            if (cell == null)
            {
                return(null);
            }


            // Create a detail view controller and set its properties.
            var peekViewController = (PeekViewController)Storyboard.InstantiateViewController("peekvc");

            if (peekViewController == null)
            {
                return(null);
            }

            var peekAt = todoItems [indexPath.Row];

            peekViewController.SetTodo(peekAt);
            peekViewController.PreferredContentSize = new CGSize(0, 160);

            previewingContext.SourceRect = cell.Frame;

            return(peekViewController);
        }
コード例 #4
0
        public UIViewController GetViewControllerForPreview(IUIViewControllerPreviewing previewingContext, CGPoint location)
        {
            // Obtain the index path and the cell that was pressed.
            var indexPath = CollectionView.IndexPathForItemAtPoint (location);

            Console.WriteLine ("ForPreview " + location.ToString() + " " + indexPath);

            if (indexPath == null)
                return null;

            var cell = CollectionView.CellForItem (indexPath);

            if (cell == null)
                return null;

            // Create a detail view controller and set its properties.
            var peekViewController = (PeekViewController)Storyboard.InstantiateViewController ("peekvc");
            if (peekViewController == null)
                return null;

            var peekAt = tasks [indexPath.Row];
            peekViewController.SetTodo (peekAt);
            peekViewController.PreferredContentSize = new CGSize (0, 160);

            previewingContext.SourceRect = cell.Frame;

            return peekViewController;
        }