public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);
            var touch = touches.AnyObject as UITouch;

            if (touch == null || nodeIsMoving == false || currentMovingNode == null)
            {
                return;
            }

            if (DropableCanvas.Frame.Contains(currentMovingNode.Center) == true)
            {
                //Remove this view from superview
                currentMovingNode.RemoveFromSuperview();

                binarySearchTreeView.InsertNode(int.Parse(currentMovingNode.Text));
            }
            else
            {
                currentMovingNode.Frame = currentMovingNodeOriginalPosition;
            }

            currentMovingNode = null;
            currentMovingNodeOriginalPosition = CGRect.Empty;
            nodeIsMoving = false;
        }
Пример #2
0
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesBegan (touches, evt);
            var touch = touches.AnyObject as UITouch;

            if (touch == null)
                return;

            var locationinContainerView = touch.LocationInView (NodesContainerView);

            //check which subview falls under this
            currentMovingNode = NodesContainerView.Subviews.FirstOrDefault(node=>node.Frame.Contains(locationinContainerView)) as CircleView;
            if (currentMovingNode != null) {
                nodeIsMoving = true;
                currentMovingNodeOriginalPosition = currentMovingNode.Frame;
            }
        }
        public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesBegan(touches, evt);
            var touch = touches.AnyObject as UITouch;

            if (touch == null)
            {
                return;
            }

            var locationinContainerView = touch.LocationInView(NodesContainerView);

            //check which subview falls under this
            currentMovingNode = NodesContainerView.Subviews.FirstOrDefault(node => node.Frame.Contains(locationinContainerView)) as CircleView;
            if (currentMovingNode != null)
            {
                nodeIsMoving = true;
                currentMovingNodeOriginalPosition = currentMovingNode.Frame;
            }
        }
        partial void GenerateNodesBtn_TouchUpInside(UIButton sender)
        {
            //Generate a random 5 numbers which are not in the tree

            var fiveRandomValues = new RandomValueGenerator().GetRandomNumbers(5);

            //Clear the existing subviews of the container
            foreach (var subview in NodesContainerView.Subviews)
            {
                subview.RemoveFromSuperview();
            }
            // Add new subviews to the container

            var frameToSet = new CGRect(10, 15, 50, 50);

            foreach (var randomValue in fiveRandomValues)
            {
                CircleView circleView = new CircleView();
                circleView.Frame = frameToSet;
                circleView.Text  = Convert.ToString(randomValue);
                NodesContainerView.Add(circleView);
                frameToSet.X = frameToSet.X + 70;
            }
        }
Пример #5
0
        public override void TouchesEnded(Foundation.NSSet touches, UIEvent evt)
        {
            base.TouchesEnded (touches, evt);
            var touch = touches.AnyObject as UITouch;

            if (touch == null || nodeIsMoving == false || currentMovingNode == null)
                return;

            if (DropableCanvas.Frame.Contains (currentMovingNode.Center) == true)
            {
                //Remove this view from superview
                currentMovingNode.RemoveFromSuperview();

                binarySearchTreeView.InsertNode (int.Parse (currentMovingNode.Text));
            }
            else
            {
                currentMovingNode.Frame = currentMovingNodeOriginalPosition;
            }

            currentMovingNode = null;
            currentMovingNodeOriginalPosition = CGRect.Empty;
            nodeIsMoving = false;
        }
Пример #6
0
partial         void GenerateNodesBtn_TouchUpInside(UIButton sender)
        {
            //Generate a random 5 numbers which are not in the tree

            var fiveRandomValues = new RandomValueGenerator().GetRandomNumbers(5);

            //Clear the existing subviews of the container
            foreach(var subview in NodesContainerView.Subviews)
            {
                subview.RemoveFromSuperview();
            }
            // Add new subviews to the container

            var frameToSet = new CGRect(10,15,50,50);

            foreach(var randomValue in fiveRandomValues)
            {
                CircleView circleView = new CircleView();
                circleView.Frame = frameToSet;
                circleView.Text = Convert.ToString(randomValue);
                NodesContainerView.Add(circleView);
                frameToSet.X = frameToSet.X + 70;
            }
        }