private void updateRemoveComponentMenu()
        {
            bool finished = removeMenu.Update();

            if (finished)
            {
                // did user click remove button?
                if (this.removeMenu.RemoveButtonState())
                {
                    // remove component from draw-set and list.
                    this.addMenu.ComponentRemovedFromStage(this.currentSelected.myComponentType());
                    this.currentSelected.RemoveFromAutoDrawSet();
                    componentList.Remove(this.currentSelected);
                }

                this.hideRemoveComponentMenu();

                this.currentSelected = null;
            }
        }
        private void updateAddComponentMenu()
        {
            bool finished = addMenu.Update();

            if (finished)
            {
                // do we need to add a component?
                Component newComponent = this.addMenu.getNewComponent();
                if (newComponent != null)
                {
                    this.componentList.AddLast(newComponent);
                }

                this.hideAddComponentMenu();
                this.currentSelected = null;
            }
        }
        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;

                                // is this a double tap?
                                float tapDist = Math.Abs(Vector2.Distance(lastTapLocation, touchLocation.Position));
                                if (this.doubleTapCountdown > 0 && tapDist < MAX_DOUBLE_TAP_DISTANCE)
                                {
                                    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)
                        {
                            // is this a double tap?
                            float tapDist = Math.Abs(Vector2.Distance(lastTapLocation, touchLocation.Position));
                            if (this.doubleTapCountdown > 0 && tapDist < MAX_DOUBLE_TAP_DISTANCE)
                            {
                                this.showAddComponentMenu();
                            }
                            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;

                }

                // update lastTapLocation
                lastTapLocation = touchLocation.Position;
            }

            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.doubleTapCountdown = 0;
     this.currentState = ComponentManagerState.removeComponentMenu;
     this.removeMenu.Show();
 }