Example #1
0
        public void KeyPressed(object sender, KeyEventArgs e)
        {
            if (e.Code == Keyboard.Key.Down || e.Code == Keyboard.Key.S || e.Code == Keyboard.Key.Up || e.Code == Keyboard.Key.W)
            {
                MenuItem nextSelectedMenuItem = _selectedMenuItem;

                if (e.Code == Keyboard.Key.Down || e.Code == Keyboard.Key.S)
                {
                    nextSelectedMenuItem = _menuItems.FirstOrDefault(c => c.Enable && c.Position > _selectedMenuItem.Position);
                }
                else if (e.Code == Keyboard.Key.Up || e.Code == Keyboard.Key.W)
                {
                    nextSelectedMenuItem = _menuItems.OrderByDescending(c => c.Position).FirstOrDefault(c => c.Enable && c.Position < _selectedMenuItem.Position);
                }

                if (nextSelectedMenuItem != null)
                {
                    PlaySound(_menuSoundBeep);
                    _selectedMenuItem = nextSelectedMenuItem;
                }
            }
            if (e.Code == Keyboard.Key.Return)
            {
                if (_selectedMenuItem != null)
                {
                    PlaySound(_menuSoundSelect);
                    MenuItemSelected?.Invoke(this, _selectedMenuItem.Item);
                }
            }
        }
Example #2
0
 public void FireMenuItemSelected()
 {
     if (MenuItemSelected != null)
     {
         MenuItemSelected.Invoke(this);
     }
 }
Example #3
0
 private void Menu_OnClick(object sender, FormEventData e)
 {
     if (Hoverring_Item_Index != -1 && MenuItemSelected != null)
     {
         MenuItemSelected.Invoke(this, Hoverring_Item_Index);
     }
 }
Example #4
0
 public Menu(IActivitySystem activitySystem, string menuName, MenuItemSelected onSelectCallback, params MenuItem[] items)
 {
     MenuItems         = new List <MenuItem>(items);
     MenuName          = menuName;
     OnSelectCallback += onSelectCallback;
     SelectedItem      = MenuItems.FirstOrDefault();
     _activitySystem   = activitySystem;
 }
Example #5
0
        void Initialize(EvasObject parent)
        {
            _menu = new GenList(parent)
            {
                BackgroundColor = EColor.Transparent,
                Style           = "solid/default",
            };

            _menu.ItemSelected += (s, e) =>
            {
                MenuItemSelected?.Invoke(this, e);
            };

            _menu.Show();
            PackEnd(_menu);

            _defaultClass = new GenItemClass("double_label")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return(((Item)obj).Title);
                    }
                    else
                    {
                        return(null);
                    }
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon")
                    {
                        var icon = ((Item)obj).Icon;

                        if (icon != null)
                        {
                            var image = new ElmSharp.Image(parent)
                            {
                                MinimumWidth  = Forms.ConvertToScaledPixel(24),
                                MinimumHeight = Forms.ConvertToScaledPixel(24)
                            };
                            var result = image.Load(ResourcePath.GetPath(icon));
                            return(image);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }
        public Task <Unit> Handle(MenuItemSelected request, CancellationToken cancellationToken)
        {
            if (_menuItems.TryGetValue(request.Item, out var selectedItem))
            {
                selectedItem.Invoke(_navigationService);
            }

            return(Unit.Task);
        }
Example #7
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            if ((Site != null) && Site.DesignMode)
            {
                return;
            }

            NSBundle.MainBundle.LoadNib("SideMenu", this, null);
            RootView.Frame = new CGRect(0, 0, RootView.Frame.Width, Superview.Frame.Height);
            AddSubview(RootView);

            var imageDecoder = new WebPCodec();

            ImageViewBackground.Image = imageDecoder.Decode(NSBundle.MainBundle.PathForResource("Images/background", "webp"));

            ViewMenuHome.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuHome.BackgroundColor   = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuPhotos.BackgroundColor = ViewMenuCuriosities.BackgroundColor = ViewMenuAuthor.BackgroundColor = ViewMenuMuseum.BackgroundColor = ViewMenuMedia.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Home);
            }));
            ViewMenuPhotos.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuPhotos.BackgroundColor = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuHome.BackgroundColor   = ViewMenuCuriosities.BackgroundColor = ViewMenuAuthor.BackgroundColor = ViewMenuMuseum.BackgroundColor = ViewMenuMedia.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Photos);
            }));
            ViewMenuMedia.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuMedia.BackgroundColor = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuHome.BackgroundColor  = ViewMenuPhotos.BackgroundColor = ViewMenuCuriosities.BackgroundColor = ViewMenuAuthor.BackgroundColor = ViewMenuMuseum.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Media);
            }));
            ViewMenuCuriosities.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuCuriosities.BackgroundColor = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuHome.BackgroundColor        = ViewMenuPhotos.BackgroundColor = ViewMenuAuthor.BackgroundColor = ViewMenuMuseum.BackgroundColor = ViewMenuMedia.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Curiosities);
            }));
            ViewMenuAuthor.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuAuthor.BackgroundColor = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuHome.BackgroundColor   = ViewMenuPhotos.BackgroundColor = ViewMenuCuriosities.BackgroundColor = ViewMenuMuseum.BackgroundColor = ViewMenuMedia.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Author);
            }));
            ViewMenuMuseum.AddGestureRecognizer(new UITapGestureRecognizer((obj) =>
            {
                ViewMenuMuseum.BackgroundColor = AppColors.DarkGray.ChangeAlpha(0.3f);
                ViewMenuHome.BackgroundColor   = ViewMenuPhotos.BackgroundColor = ViewMenuCuriosities.BackgroundColor = ViewMenuAuthor.BackgroundColor = ViewMenuMedia.BackgroundColor = UIColor.Clear;
                MenuItemSelected?.Invoke(this, PageName.Museum);
            }));

            SetStyles();
        }
Example #8
0
        private void InternalMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var menuItem = e.SelectedItem as MenuListItem;

            if (menuItem != null)
            {
                MenuItemSelected?.Invoke(this, menuItem);
                ((MenuListView)sender).SelectedItem = null;;
            }
        }
Example #9
0
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     if (HasOptionsMenu)
     {
         var e = new OnMenuItemSelectedEventArgs(item.ItemId);
         MenuItemSelected?.Invoke(this, e);
         if (e.Finished)
         {
             return(true);
         }
     }
     return(base.OnOptionsItemSelected(item));
 }
Example #10
0
        public void JoystickButtonPressed(RenderWindow target, object sender, JoystickButtonEventArgs arg)
        {
#if DEBUG
            $"Controller ({arg.JoystickId}) Button Pressed: {arg.Button})".Log();
#endif
            // Press A button
            if (arg.Button == 0)
            {
                if (_selectedMenuItem.Item == MenuItemType.Back && _selectedMenuItem.Parent != MenuItemType.None)
                {
                    _selectedMenuItem = _menuItems.SingleOrDefault(c => c.Item == _selectedMenuItem.Parent);
                }
                else if (_selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo)
                {
                    _selectedMenuItem.FunctionObject?.Invoke(!(bool)_selectedMenuItem.FunctionObject(null, null), null);
                }
                else if (_selectedMenuItem.SubMenuItems != null)
                {
#if DEBUG
                    "SUB Menu".Log();
#endif
                    _scoreOffset      = Point2.Zero;
                    _scoreOffsetStep  = 1;
                    _selectedMenuItem = _selectedMenuItem.SubMenuItems.OrderBy(c => c.Position).FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage);
                }

                if (_selectedMenuItem != null)
                {
                    PlaySound(_menuSoundSelect);
                    MenuItemSelected?.Invoke(this, _selectedMenuItem.Item);
                }
            }
            // Press B button
            else if (arg.Button == 1)
            {
                MenuItem nextSelectedMenuItem = _selectedMenuItem;

                if (_selectedMenuItem.Parent != MenuItemType.None)
                {
                    nextSelectedMenuItem = _menuItems.SingleOrDefault(c => c.Item == _selectedMenuItem.Parent);
                }

                if (nextSelectedMenuItem != null)
                {
                    PlaySound(_menuSoundBeep);
                    _selectedMenuItem = nextSelectedMenuItem;
                }
            }
        }
Example #11
0
        void MenuItemTapped(object sender, System.EventArgs e)
        {
            closeMenu();
            CircularImage view = sender as CircularImage;

            if (view == null)
            {
                return;
            }
            FabMenuEventArgs ev = new FabMenuEventArgs();

            ev.menuIndex = view.TAG;
            MenuItemSelected.Invoke(sender, ev);

            System.Diagnostics.Debug.WriteLine("Index: " + view.TAG);
        }
Example #12
0
        void Initialize(EvasObject parent)
        {
            _menu = new GenList(parent)
            {
                BackgroundColor = _backgroundColor
            };

            _menu.ItemSelected += (s, e) =>
            {
                MenuItemSelected?.Invoke(this, e);
            };

            _menu.Show();
            PackEnd(_menu);

            _defaultClass = new GenItemClass(Styles.MaterialNavigation)
            {
                GetTextHandler = (obj, part) =>
                {
                    return(((MItem)obj).Title);
                },
                GetContentHandler = (obj, part) =>
                {
                    var icon = ((MItem)obj).Icon;

                    if (icon != null)
                    {
                        var image  = new Image(parent);
                        var result = image.Load(Path.Combine(Applications.Application.Current.DirectoryInfo.Resource, icon));
                        return(image);
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }
Example #13
0
        public void KeyPressed(RenderWindow target, object sender, KeyEventArgs e)
        {
            if (e.Code == Keyboard.Key.Down || e.Code == Keyboard.Key.S ||
                e.Code == Keyboard.Key.Up || e.Code == Keyboard.Key.W ||
                e.Code == Keyboard.Key.Escape)
            {
                MenuItem nextSelectedMenuItem = _selectedMenuItem;

                if (e.Code == Keyboard.Key.Down || e.Code == Keyboard.Key.S)
                {
                    nextSelectedMenuItem = GetMenuItems().FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage && c.Position > _selectedMenuItem.Position);
                }
                else if (e.Code == Keyboard.Key.Up || e.Code == Keyboard.Key.W)
                {
                    nextSelectedMenuItem = GetMenuItems().OrderByDescending(c => c.Position).FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage && c.Position < _selectedMenuItem.Position);
                }
                else if (e.Code == Keyboard.Key.Escape && _selectedMenuItem.Parent != MenuItemType.None)
                {
                    nextSelectedMenuItem = _menuItems.SingleOrDefault(c => c.Item == _selectedMenuItem.Parent);
                }

                if (nextSelectedMenuItem != null)
                {
                    PlaySound(_menuSoundBeep);
                    _selectedMenuItem = nextSelectedMenuItem;
                }
            }
            else if (e.Code == Keyboard.Key.Left && _selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo)
            {
                _selectedMenuItem.FunctionObject?.Invoke((bool)_selectedMenuItem.FunctionObject(null, null), -YesNoVolumeStep);
            }
            else if (e.Code == Keyboard.Key.Right && _selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo)
            {
                _selectedMenuItem.FunctionObject?.Invoke((bool)_selectedMenuItem.FunctionObject(null, null), YesNoVolumeStep);
            }
            else if (e.Code == Keyboard.Key.Return)
            {
                if (_selectedMenuItem.Item == MenuItemType.Back && _selectedMenuItem.Parent != MenuItemType.None)
                {
                    _selectedMenuItem = _menuItems.SingleOrDefault(c => c.Item == _selectedMenuItem.Parent);
                }
                else if (_selectedMenuItem.FunctionType == MenuItemFunctionType.YesNo)
                {
                    _selectedMenuItem.FunctionObject?.Invoke(!(bool)_selectedMenuItem.FunctionObject(null, null), null);
                }
                else if (_selectedMenuItem.SubMenuItems != null)
                {
#if DEBUG
                    "SUB Menu".Log();
#endif
                    _scoreOffset      = Point2.Zero;
                    _scoreOffsetStep  = 1;
                    _selectedMenuItem = _selectedMenuItem.SubMenuItems.OrderBy(c => c.Position).FirstOrDefault(c => c.Enable && c.FunctionType != MenuItemFunctionType.CustomPage);
                }

                if (_selectedMenuItem != null)
                {
                    PlaySound(_menuSoundSelect);
                    MenuItemSelected?.Invoke(this, _selectedMenuItem.Item);
                }
            }
        }
 public static void OnMenuItemSelected(MenuItem item, object parameter = null)
 {
     MenuItemSelected?.Invoke(item, parameter);
 }
Example #15
0
        public override void HandleGameKey(IStateOwner pOwner, GameKeys g)
        {
            //handle up and down to change the currently selected menu item.
            //Other game keys we pass on to the currently selected item itself for additional handling.
            bool triggered     = false;
            var  OriginalIndex = SelectedIndex;

            if (g == GameKeys.GameKey_Down)
            {
                if (ActivatedItem != null)
                {
                    ActivatedItem.ProcessGameKey(pOwner, g);
                }
                else
                {
                    //move selected index upwards.

                    SelectedIndex = GetNextIndex(SelectedIndex);
                    while (!MenuElements[SelectedIndex].GetSelectable())
                    {
                        SelectedIndex = GetNextIndex(SelectedIndex);
                    }
                }
                triggered = true;
                //should also skip if disabled...
            }
            else if (g == GameKeys.GameKey_Drop)
            {
                if (ActivatedItem != null)
                {
                    ActivatedItem.ProcessGameKey(pOwner, g);
                }
                else
                { //move selected index downwards.
                    SelectedIndex = GetPreviousIndex(SelectedIndex);

                    while (!MenuElements[SelectedIndex].GetSelectable())
                    {
                        SelectedIndex = GetPreviousIndex(SelectedIndex);
                    }
                }
                triggered = true;
            }

            if (g == GameKeys.GameKey_RotateCW || g == GameKeys.GameKey_MenuActivate || g == GameKeys.GameKey_Pause)
            {
                if (ActivatedItem != null)
                {
                    TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.MenuItemActivated.Key, pOwner.Settings.std.EffectVolume);
                    ActivatedItem.OnDeactivated();
                    ActivatedItem = null;
                }
                else
                {
                    //Activate the currently selected item.
                    var currentitem = MenuElements[SelectedIndex];
                    TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.MenuItemActivated.Key, pOwner.Settings.std.EffectVolume);
                    ActivatedItem = currentitem;
                    MenuItemActivated?.Invoke(this, new MenuStateMenuItemActivatedEventArgs(currentitem));

                    currentitem.OnActivated();
                }
                triggered = true;
            }

            else if (OriginalIndex != SelectedIndex)
            {
                TetrisGame.Soundman.PlaySound(pOwner.AudioThemeMan.MenuItemSelected.Key, pOwner.Settings.std.EffectVolume);
                var previousitem = MenuElements[OriginalIndex];
                var currentitem  = MenuElements[SelectedIndex];
                MenuItemDeselected?.Invoke(this, new MenuStateMenuItemSelectedEventArgs(previousitem));
                MenuItemSelected?.Invoke(this, new MenuStateMenuItemSelectedEventArgs(currentitem));
                previousitem.OnDeselected();
                currentitem.OnSelected();
            }

            if (!triggered)
            {
                var currentitem = MenuElements[SelectedIndex];
                currentitem.ProcessGameKey(pOwner, g);
            }
            //throw new NotImplementedException();
        }
Example #16
0
 protected void OnMenuItemSelected(MenuItemSelectedEventArgs menuItemSelectedEventArgs)
 {
     MenuItemSelected?.Invoke(this, menuItemSelectedEventArgs);
 }