private int doubleTapCountdown = 0; // number of ticks remaining to tap again for a "double-tap".

        #endregion Fields

        #region Constructors

        // default constructor.
        public ComponentManager(int screenWidth, int screenHeight)
        {
            // these are flipped because screen is in landscape.
            _screenWidth = screenHeight;
            _screenHeight = screenWidth;

            // set initial state
            this.currentState = ComponentManagerState.noMenu;

            // create component list
            componentList = new LinkedList<Component>();

            Component copperCoin = new Component(new Vector2(XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.X), XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.Y)));
            copperCoin.Texture = "coppercoin";
            copperCoin.RotateAngle = XNACS1Base.RandomFloat(0, 360);
            componentList.AddLast(copperCoin);

            Component goldCoin = new Component(new Vector2(XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.X), XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.Y)));
            goldCoin.Texture = "goldCoin";
            goldCoin.RotateAngle = XNACS1Base.RandomFloat(0, 360);
            componentList.AddLast(goldCoin);

            Component piggybank = new Component(new Vector2(XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.X), XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.Y)));
            piggybank.Texture = "piggybank";
            piggybank.RotateAngle = XNACS1Base.RandomFloat(0, 360);
            componentList.AddLast(piggybank);

            Component silvercoin = new Component(new Vector2(XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.X), XNACS1Base.RandomFloat(0, XNACS1Base.World.WorldDimension.Y)));
            silvercoin.Texture = "silvercoin";
            silvercoin.RotateAngle = XNACS1Base.RandomFloat(0, 360);
            componentList.AddLast(silvercoin);

            // create a RemoveComponentMenu
            // removeMenu = new RemoveComponentMenu();
        }
        private void updateNoMenuState()
        {
            // decrement count since last tap.
            doubleTapCountdown--;

            //obtain all of the devices TouchLocations
            TouchCollection touchCollection = TouchPanel.GetState();
            //check each of the devices TouchLocations;
            foreach (TouchLocation touchLocation in touchCollection)
            {
                /*
                    * Utilize the touch location state.
                    *   -TouchLocationState.Invalid is when the location's position is invalid. Could be when a new
                    *   touch location attempts to get the previous location of itself.
                    *   -TouchLocationState.Moved is when the touch location position was updated or pressed in the same position.
                    *   -TouchLocationState.Pressed is when the touch location position is new.
                    *   -TouchLocationState.Released is when the location position was released.
                */
                switch (touchLocation.State)
                {
                    case TouchLocationState.Pressed:

                        this.currentSelected = null;

                        // see if user touched a component.
                        foreach (Component current in componentList)
                        {
                            if (current.selected(screenToWorld(touchLocation.Position)))
                            {
                                this.currentSelected = current;

                                if (this.doubleTapCountdown > 0)
                                {
                                    // double tapped.
                                    // this.showRemoveComponentMenu(this.currentSelected);
                                }
                                else
                                {
                                    doubleTapCountdown = DOUBLE_TAP_TICKS;    // reset countdown for double-tap to 20 ticks.
                                }
                            }
                        }

                        // did user tap on empty space?
                        if (this.currentSelected == null)
                        {
                            if (this.doubleTapCountdown > 0)
                            {
                                // double tapped.
                                //this.componentList.AddFirst(new Component(screenToWorld(touchLocation.Position)));
                            }
                            else
                            {
                                doubleTapCountdown = DOUBLE_TAP_TICKS;    // reset countdown for double-tap to 20 ticks.
                            }
                        }

                        XNACS1Base.EchoToBottomStatus("touched " + touchLocation.Position + " (worldspace: + " + screenToWorld(touchLocation.Position) + ")");
                        break;

                    case TouchLocationState.Released:
                        // release current selected.
                        if (this.currentSelected != null)
                            this.currentSelected.released();
                        this.currentSelected = null;

                        XNACS1Base.EchoToBottomStatus("released");
                        break;
                }
            }

            while (TouchPanel.IsGestureAvailable)
            {
                //detect any gestures that were performed
                GestureSample gesture = TouchPanel.ReadGesture();

                //do code depending on which gesture was detected
                switch (gesture.GestureType)
                {
                    case GestureType.FreeDrag:
                        // drags which the selected image
                        if (null != currentSelected)
                        {
                            currentSelected.dragTo(screenToWorld(gesture.Position));

                            // move current selected to front of linked list since it is now on "top"
                            componentList.Remove(currentSelected);
                            componentList.AddLast(currentSelected);
                        }
                        break;
                }
            }

            // update the components.
            foreach (Component current in componentList)
            {
                current.Update();
            }
        }
 private void showRemoveComponentMenu(Component current)
 {
     //this.currentSelected = null;
     this.doubleTapCountdown = 0;
     this.currentState = ComponentManagerState.removeComponentMenu;
     //this.removeMenu.Show();
 }