RaspberryMenus 0.1.0

dotnet add package RaspberryMenus --version 0.1.0
NuGet\Install-Package RaspberryMenus -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RaspberryMenus" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RaspberryMenus --version 0.1.0
#r "nuget: RaspberryMenus, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RaspberryMenus as a Cake Addin
#addin nuget:?package=RaspberryMenus&version=0.1.0

// Install RaspberryMenus as a Cake Tool
#tool nuget:?package=RaspberryMenus&version=0.1.0

Raspberry

Raspberry is an easy way to quickly make menus for your next Console Application in c#.

Getting Started

Installation

To download Raspberry, navigate to the NuGet package manager in Visual Studios and search for RaspberryMenus. Click on the one by ChobbyCode, and hit install.

Creating

To create a menu in Raspberry, simply create an instance of the Menu class:

// You must give it the name of the menu

Menu menu = new Menu("PutTheNameOfTheMenuHere");

To create an option to add to your menu, you can create a menu option:

Options should be provided with a name, description and a menu that they will open.

// Options require a name, description and an already existing menu to open.

MenuOption newOption = new MenuOption("OptionName", "OptionDescription", MenuTheOptionWillOpen);

To add an option to a menu:

// To add it to a menu, type the name of the menu and say addOption and pass in your option.

menu.AddOption(newOption);

Raspberry also needs to be provided a default menu, and told when to start:

// Just pass in an already existing menu
Rasp.SetDefaultMenu(defaultMenu);
Rasp.StartRaspberry();

Below is a quick demo, that allows you to move between two different menus.

using Raspberry;
using Raspberry.Menus;

namespace Demo
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Menu menu = new Menu("main"); // main menu
            Menu sec = new Menu("second"); // second menu

            // Create buttons for main menu
            MenuOption openSec = new MenuOption("second", "Open the second menu", sec);
            menu.AddOption(openSec);

            // Create buttons for second menu
            MenuOption closeSec = new MenuOption("closeSec", "Close the second menu", menu);
            sec.AddOption(closeSec);

            // Start the menu
            Rasp.SetDefaultMenu(menu);
            Rasp.StartRaspberry();
        }
    }
}

Custom Actions

Now, just having menus on your app is no good. You need functionality. Luckily Raspberry has an easy way to add functionality to an option.

Instead of creating a MenuOption, create a MenuAction. Menu actions have event handlers which are called when the window is opened.

Below is a modified version of the first program to have a MenuAction instead of an MenuOption.

MenuActions work the same as MenuOptions but require event handlers instead.

Menu menu = new Menu("main"); // main menu
Menu actionMenu = new Menu("Action Menu"); // main menu

// Create buttons for main menu
MenuOption openSec = new MenuOption("second", "Open the second menu", actionMenu);
menu.AddOption(openSec);

// Create buttons for second menu
MenuAction action = new MenuAction("Action", "Run An Action", actionMenu);
actionMenu.AddOption(action);

// When the event handler is called we run the function
action.onOpen += ActionRunned;

// Start the menu
Rasp.SetDefaultMenu(menu);
Rasp.StartRaspberry();

action.onOpen calls a function called ActionRunned. We can create this function as below.

public static void ActionRunned (object sender, EventArgs e)
{
    Console.WriteLine("Action Run");
    Console.ReadLine();
}

In summary, we swapped the MenuOption out for a MenuAction and created a function for it to call when ran.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 258 10/23/2023