Git Product home page Git Product logo

djaus2 / meadow.projectlab.extension2 Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 4.91 MB

Based upon the Meadow.Foundation project sample, MicroLayoutMenu. This implments a Multi-level Menu System with menu Up/Down as well as [Select] (choose item and move to next menu level) and [Back] (go back one menu level).

License: Creative Commons Zero v1.0 Universal

C# 100.00%
csharp meadow projectlab

meadow.projectlab.extension2's Introduction

Meadow.ProjectLab.Extensions2

Based upon the Meadow.Foundation project sample, MicroLayoutMenu.
This implments a Multi-level Menu System with menu Up/Down as well as [Select] (choose item and move to next menu level) and [Back] (go back one menu level).


Latest: Added a new project Hierarchical that has hierarchical menu navigation.
Selection determines the next menu level options.
MultiMenu just has cascading menus. The same at each level regardless.

Update 2: [Bug fix] Remove 2nd instantiation of menus that causes menu handlers to be called twice.

Update 1: [Bug Fix] App had been renamed so path to image needed change.

Update 1.1: Also Long Click (1.5s) on left resets menu to top level with no previous selections.


The board
The WILDERNESS LABS Project Lab V3 board

Links


Nb: Suggested update for MicroLayoutMenu

The original MicroLayoutMenu project has a bug that, if ShowMenuScreen is uncommented, the textual scxreen fails to be drawn.

  • In MeadowApp.cs change:
        public override Task Run()
        {
            ShowDemoScreen();

            //ShowMenuScreen();

            return base.Run();
        }
  • To:
        public override Task Run()
        {
            ShowDemoScreen();

            // Move to Menu after 5sec
            Thread.Sleep(5000);

           _screen.Controls.Clear(); // <-This IS needed!
           ShowMenuScreen();

            return base.Run();
        }

This implements the clearing of the Demo screen controls before the textual menu is drawn.


About (this) MultiMenu project

When it runs, the demo screen shows.

The demo screen

After a period the first level of the menu shows.

The menu screen

The blue buttons are, bottom right, used to navigate the menu. The top and bottom buttons are used to move up and down the menu. The right button is used to select an item and move to the next level. The left button is used to go back to the previous menu level. The Demo screen suggests this navigation scenario but the drawn buttons there aren't actionable.

When a menu item is selected, it is pushed onto the Stack with other data for that menu level. The menu is then cleared and the next level is drawn. When [Back] is selected and the previous menu level is redrawn, the previous menu menu data is recovered from the Stack and the item previously selected there is reselected.

Extensible Menu System

The menu data is held in a List<MenuItem> and is defined in MenuItem.cs. The MenuData class defines the data for each menu level:

    public class MenuData
    {
        public string Title { get; set; }
        public string Items { get; set; }
    }

That is, there is a Title for each level as well as a CSV list of items for that level.

To add or remove menu levels, simply add instantiated MenuData items in the List<MenuData> in MenuData.cs, or remove them. Each menu level requires a corresponding method in MultiMenu.cs to handle the menu level of the form:

       private void Action3(object sender, EventArgs e)
        {
            int actionNo = 3;
            int index = _menu.SelectedRow;
            //Do Whatever for previous menu

            MenuData md = AppSettings.MenuDataList[actionNo];
            ShowMenuScreen(md.Title, md.Items, Action4);
        }

For each additional level, replace the 3 in the method code with the order for the level in the list, that is numbered from zero. Any additional menu method need to be linked in the previous method via the last arguement in ShowMenuScreen(). In the case above, the next level is Action4. Any functionality based upon a menu selection at a level would be inserted below //Do Whatever for previous menu in the next level method.

meadow.projectlab.extension2's People

Contributors

djaus2 avatar

Watchers

John Kattenhorn avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.