示例#1
0
        private void setupStateHotspots()
        {
            stateHotspots = new StateHotspot[Enum.GetNames(typeof(eState)).Length];

            // Getting the rectangles for the hotspots
            int top  = Screen.PrimaryScreen.Bounds.Height / 2 - MARGIN / 2 - HOTSPOTSIZE;
            int left = Screen.PrimaryScreen.Bounds.Width - HOTSPOTSIZE;

            Rectangle commandStateHotspot   = new Rectangle(left, top - HOTSPOTSIZE, HOTSPOTSIZE, HOTSPOTSIZE * 2);
            Rectangle dictationStateHotspot = new Rectangle(left, top + HOTSPOTSIZE + MARGIN, HOTSPOTSIZE, HOTSPOTSIZE * 2);

            // Creating the hotspots
            StateHotspot commandState = new StateHotspot(new CommandState(), commandStateHotspot, true, Properties.Resources.commandButtonsActive, Properties.Resources.commandButtonInactive);

            commandState.OnSelected           += CommandState_OnSelected;
            stateHotspots[(int)eState.Command] = commandState;

            StateHotspot dictationState = new StateHotspot(new DictationState(), dictationStateHotspot, false, Properties.Resources.dictationButtonsActive, Properties.Resources.dictationButtonInactive);

            dictationState.OnSelected           += CommandState_OnSelected;
            stateHotspots[(int)eState.Dictation] = dictationState;

            // Setting the current state to be the command state
            currentState = commandState.GetState();
        }
示例#2
0
        private void CommandState_OnSelected(StateHotspot sender, ControlState newState)
        {
            // Stopping the current state
            currentState.Stop();

            // Switching to the new state
            currentState = newState;

            // Switching the selected state hotspot to the new state hotspot
            selectedStateHotspot.selected = false;
            selectedStateHotspot          = sender;
            selectedStateHotspot.selected = true;

            // Starting the new state
            currentState.Start();
        }
示例#3
0
        public StateController()
        {
            //Creating the hotspots that will be used to change the states
            setupStateHotspots();

            //Setting the current state to command state
            currentState                  = stateHotspots[(int)eState.Command].GetState();
            selectedStateHotspot          = stateHotspots[(int)eState.Command];
            selectedStateHotspot.selected = true;

            //Registering state controller to be drawn to the overlay form
            SharedFormsSingleton.Instance().overlayForm.RegisterOverlay(this);

            //Setting up state controller to listen to the update timer tick
            EventSingleton.Instance().updateTimer.Tick += updateTimer_Tick;
        }