Exemplo n.º 1
0
        /// <summary>
        /// Activity Enumerator - Exceutes all activities of dialog one by one.
        /// </summary>
        /// <returns></returns>
        public override IEnumerator <System.Threading.Tasks.Task> GetActivities()
        {
            //Task of help command activity, waits untill user presses the '*'.
            Task <ActivityResult> helpSpeech = this.Create_SpeechQuestionAnswerActivityForHelpMenu();

            yield return(helpSpeech.ContinueWith((task) =>
            {
                if (task.Exception != null)
                {
                    //Set menuitem as failed.
                    this.menuItem = SelectedMenuItem.Failed;
                }
            }));

            //Ask for dtmf menu.
            Task <ActivityResult> dtmfMenuSpeech = this.Create_SpeechQuestionAnswerActivityForDtmfMenu();

            yield return(dtmfMenuSpeech.ContinueWith((task) =>
            {
                if (task.Exception == null)
                {
                    RecognitionResult result = dtmfMenuSpeech.Result.Output["Result"] as RecognitionResult;
                    this.menuItem = (SelectedMenuItem)Enum.Parse(typeof(SelectedMenuItem), result.Semantics.Value.ToString(), true);
                }
                else
                {
                    //Set menuitem as failed.
                    this.menuItem = SelectedMenuItem.Failed;
                }
            }));
        }
Exemplo n.º 2
0
 void TouchEnded(CCTouch touch, CCEvent touchEvent)
 {
     Debug.Assert(MenuState == CCMenuState.TrackingTouch, "[Menu TouchEnded] -- invalid state");
     if (SelectedMenuItem != null)
     {
         SelectedMenuItem.Selected = false;
         SelectedMenuItem.Activate();
     }
     MenuState = CCMenuState.Waiting;
 }
Exemplo n.º 3
0
    protected MenuItem[] GetCurrentMenu()
    {
        var m = Menu;

        foreach (var s in SelectedMenuItem.Take(SelectedMenuItem.Count - 1))
        {
            m = m[s].Children;
        }

        return(m);
    }
Exemplo n.º 4
0
        /// <summary>
        /// Raise the dialog completed event.
        /// </summary>
        protected override void RaiseDialogCompleteEvent()
        {
            //Set the output.
            Dictionary <string, object> output = new Dictionary <string, object>();

            if (base.Exception != null)
            {
                this.menuItem = SelectedMenuItem.Failed;
            }
            output.Add("SelectedMenuItem", this.menuItem);
            DialogCompleteHandler(new DialogCompletedEventArgs(output, base.Exception));
        }
        private void setupWindow(SelectedMenuItem selectedUserInterFace)
        {
            switch (selectedUserInterFace)
            {
            case SelectedMenuItem.report_MonthalyAttendance:
                bodyGrid.Children.Add(new MonthalyAttendance());
                break;

            case SelectedMenuItem.MS_Bandh:
                bodyGrid.Children.Add(new Bandh());
                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);


            foreach (MenuItem item in m_menuItems)
            {
                item.Update(gameTime);
            }

            if (KeyboardExtended.Current.NothingPressed)
            {
                KeyboardState state = Keyboard.GetState();
                if (state.GetPressedKeys().Length == 0)
                {
                    m_lastKeyboardInput = DateTime.MinValue;
                }

                if ((DateTime.Now - m_lastKeyboardInput).TotalMilliseconds > KeyboardDelay)
                {
                    if (state.IsKeyDown(Keys.Down) || (state.IsKeyDown(Keys.Tab) && !(state.IsKeyDown(Keys.LeftShift) || state.IsKeyDown(Keys.RightShift))))
                    {
                        SelectedIndex++;
                        ResetLastKeyboardTime();
                    }
                    if (state.IsKeyDown(Keys.Up) || (state.IsKeyDown(Keys.Tab) && (state.IsKeyDown(Keys.LeftShift) || state.IsKeyDown(Keys.RightShift))))
                    {
                        SelectedIndex--;
                        ResetLastKeyboardTime();
                    }


                    if (state.IsKeyDown(Keys.Home))
                    {
                        SelectedIndex = 0;
                    }
                    if (state.IsKeyDown(Keys.End))
                    {
                        SelectedIndex = m_menuItems.Count - 1;
                    }
                }
                if (state.IsKeyDown(Keys.Enter) || state.IsKeyDown(Keys.Space))
                {
                    SelectedMenuItem.Activate();
                }
            }
        }
        private void CoreWindow_PointerMoved(CoreWindow sender, PointerEventArgs args)
        {
            // if contained with the whole Menu control
            if (IsOpened && _bounds.Contains(args.CurrentPoint.Position))
            {
                // if hover over current opened item
                if (SelectedMenuItem.ContainsPoint(args.CurrentPoint.Position))
                {
                    return;
                }

                foreach (MenuItem menuItem in Items)
                {
                    if (menuItem.ContainsPoint(args.CurrentPoint.Position))
                    {
                        SelectedMenuItem.HideMenu();
                        menuItem.Focus(FocusState.Keyboard);
                        menuItem.ShowMenu();
                    }
                }
            }
        }
 public ChildWindowPrototype(TIMELINE.WpfWindow.Home_Menu.Menu mainWindow, SelectedMenuItem openWindow)
 {
     InitializeComponent();
     _parentWindow = mainWindow;
     setupWindow(openWindow);
 }
Exemplo n.º 9
0
        private void SelectedMenuItem_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {//these properties are not to be persisted we will igore them...
            if (e.PropertyName == "IsSelected" ||
                e.PropertyName == "IsExpanded" ||
                e.PropertyName == "IsValid" ||
                e.PropertyName == "NotValidMessage" ||
                e.PropertyName == "LastModifiedBy" ||
                e.PropertyName == "LastModifiedByDate")
            {
                return;
            }
            //Key ID Logic...
            if (e.PropertyName == "MenuItemID")
            {     //make sure it is has changed...
                if (SelectedMenuItemMirror.MenuItemID != SelectedMenuItem.MenuItemID)
                { //convert to the Entity MenuItem...
                    MenuItem     menuItem    = MenuItemList.FirstOrDefault(q => q.AutoID == SelectedMenuItem.AutoID);
                    EntityStates entityState = GetMenuItemState(menuItem);

                    if (entityState == EntityStates.Unchanged ||
                        entityState == EntityStates.Modified)
                    {//once a key is added it can not be modified...
                        MessageBox.Show("Once A Key Is Added It Can Not Be Modified.");
                        return;
                    }
                }
            }//end KeyID logic...

            object propertyChangedValue = SelectedMenuItem.GetPropertyValue(e.PropertyName);
            object prevPropertyValue    = SelectedMenuItemMirror.GetPropertyValue(e.PropertyName);
            string propertyType         = SelectedMenuItem.GetPropertyType(e.PropertyName);
            //in some instances the value is not really changing but yet it still is tripping property change..
            //This will ensure that the field has physically been modified...
            //As well when we revert back it constitutes a property change but they will be = and it will bypass the logic...
            bool objectsAreEqual;

            if (propertyChangedValue == null)
            {
                if (prevPropertyValue == null)//both values are null
                {
                    objectsAreEqual = true;
                }
                else//only one value is null
                {
                    objectsAreEqual = false;
                }
            }
            else
            {
                if (prevPropertyValue == null)//only one value is null
                {
                    objectsAreEqual = false;
                }
                else //both values are not null use .Equals...
                {
                    objectsAreEqual = propertyChangedValue.Equals(prevPropertyValue);
                }
            }
            if (!objectsAreEqual)
            {
                //Here we do property change validation if false is returned we will reset the value
                //Back to its mirrored value and return out of the property change w/o updating the repository...
                if (MenuItemPropertyChangeIsValid(e.PropertyName, propertyChangedValue, prevPropertyValue, propertyType))
                {//pass in the propertyname and value as we will update the CRUD MenuItem and pass the
                    //change to the repository...
                    Update(SelectedMenuItem, e.PropertyName, propertyChangedValue);
                    //set the mirrored objects field...
                    SelectedMenuItemMirror.SetPropertyValue(e.PropertyName, propertyChangedValue);
                    SelectedMenuItemMirror.IsValid         = SelectedMenuItem.IsValid;
                    SelectedMenuItemMirror.IsExpanded      = SelectedMenuItem.IsExpanded;
                    SelectedMenuItemMirror.NotValidMessage = SelectedMenuItem.NotValidMessage;
                }
                else
                {
                    SelectedMenuItem.SetPropertyValue(e.PropertyName, prevPropertyValue);
                    SelectedMenuItem.IsValid         = SelectedMenuItemMirror.IsValid;
                    SelectedMenuItem.IsExpanded      = SelectedMenuItemMirror.IsExpanded;
                    SelectedMenuItem.NotValidMessage = SelectedMenuItemMirror.NotValidMessage;
                }
            }
        }
Exemplo n.º 10
0
    public void HandleButtons()
    {
        // Get the current inputs
        var input = API.Input.Get();

        // Helper for getting the state of a key, making sure it's been released before pressed again
        bool getKeyState(string name, bool singleInput = true)
        {
            if (!input.ContainsKey(name))
            {
                PreviousInputs[name] = false;
                return(false);
            }

            if (PreviousInputs.ContainsKey(name) && PreviousInputs[name] && singleInput)
            {
                PreviousInputs[name] = input[name];
                return(false);
            }

            PreviousInputs[name] = input[name];
            return(input[name]);
        }

        // Toggle showing the UI
        if (getKeyState("LeftCtrl", false) && getKeyState("X"))
        {
            ToggleShowUI();
        }

        // Don't handle inputs if we're not showing the UI
        if (!ShowUI)
        {
            return;
        }

        // Get properties
        var menu          = GetCurrentMenu();
        var selectedIndex = GetSelectedMenuItemIndex;
        var menuItem      = menu.ElementAtOrDefault(selectedIndex);

        // If the user selects the item
        if (getKeyState("Enter") || getKeyState("Space"))
        {
            // If null we go back to the previous menu
            if (menuItem == null)
            {
                SelectedMenuItem.RemoveAt(SelectedMenuItem.Count - 1);
                return;
            }

            // Call handler
            var r = menuItem.OnSelected?.Invoke(menuItem);

            // If there are children we navigate to the sub-menu
            if (menuItem.Children.Any())
            {
                SelectedMenuItem.Add(0);
            }

            // Unpause if the action returned true
            if (r == true)
            {
                ToggleShowUI();
                return;
            }
        }

        // Menu navigation
        if (getKeyState("Down"))
        {
            if (selectedIndex < menu.Length - (HasBackOption ? 0 : 1))
            {
                SelectedMenuItem[SelectedMenuItem.Count - 1]++;
            }
            else
            {
                SelectedMenuItem[SelectedMenuItem.Count - 1] = 0;
            }
        }
        if (getKeyState("Up"))
        {
            if (selectedIndex > 0)
            {
                SelectedMenuItem[SelectedMenuItem.Count - 1]--;
            }
            else
            {
                SelectedMenuItem[SelectedMenuItem.Count - 1] = menu.Length - (HasBackOption ? 0 : 1);
            }
        }

        // Horizontal menu navigation
        if (menuItem?.Options.Any() == true)
        {
            if (getKeyState("Left") && menuItem.CanDecreaseOptionsIndex)
            {
                menuItem.SelectedOption--;
            }
            if (getKeyState("Right") && menuItem.CanIncreaseOptionsIndex)
            {
                menuItem.SelectedOption++;
            }
        }
    }
Exemplo n.º 11
0
    public void UpdateUI()
    {
        // Update game version UI
        GameVersion.UpdateUI(ShowUI);

        // Don't draw the UI if we're not showing it
        if (!ShowUI)
        {
            return;
        }

        // Add selection index if not set
        if (!SelectedMenuItem.Any())
        {
            SelectedMenuItem.Add(0);
        }

        // Get current menu
        var menu          = GetCurrentMenu();
        var selectedIndex = GetSelectedMenuItemIndex;

        // TODO: Allow these to be modified from settings
        // TODO: Only draw within the game frame
        // UI values
        int       xPos           = 50;
        Color     defaultColor   = Color.White;
        Color     highlightColor = Color.Yellow;
        int       yPos           = 50;
        const int lineHeight     = 20;

        // Add every menu item
        for (var i = 0; i < menu.Length; i++)
        {
            // Get the menu
            var m = menu[i];

            // Get the name
            var name = m.DisplayName;

            // If there are options for the item we add horizontal scroll indicators
            if (m.Options.Any())
            {
                if (m.CanDecreaseOptionsIndex)
                {
                    name = $"< {name}";
                }
                if (m.CanIncreaseOptionsIndex)
                {
                    name = $"{name} >";
                }
            }
            // If there are children we show an indicator
            if (m.Children.Any())
            {
                name = $"{name} ->";
            }

            // Add the text to the UI
            DrawString(xPos, yPos, name, i == selectedIndex ? highlightColor : defaultColor);

            // Increment the y position
            yPos += lineHeight;
        }

        // Add the back option to return to previous menu
        if (HasBackOption)
        {
            yPos += lineHeight / 2;
            DrawString(xPos, yPos, "<- Back", selectedIndex == menu.Length ? highlightColor : defaultColor);
        }

        Color valueColor = Color.Orange;
        int   valueYPos  = 5;
        int   valueXPos  = 200;

        // Add values
        foreach (var v in Values)
        {
            DrawString(valueXPos, valueYPos, v.DisplayText, valueColor);
            valueYPos += lineHeight;
        }

        void DrawString(int x, int y, string str, Color c)
        {
            if (RenderUIInGame)
            {
                API.Gui.DrawString(x, y, str, c, fontsize: 12, fontstyle: "Bold", backcolor: Color.Black);
            }
            else
            {
                API.Gui.Text(x, y, str, c);
            }
        }
    }
Exemplo n.º 12
0
 protected void SetSelectedMenuItem(SelectedMenuItem selected)
 {
     SelectedItem = selected;
     SetSelectedOnSettingsItemEvent?.Invoke(SelectedItem);
 }