Unsure about creating a Multi Page App? #3909
-
Hey, I've been trying to create a sort of Multi Page App but have been unable to actually navigate to each of my windows. Which is why I'm asking if there is any bare-bones Example for switching between multiple window's? Thanks for the help in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Here is a multi page demo where main Program.cs using Terminal.Gui;
using YourNamespace;
Application.Init();
Application.Run(new MyTop());
Application.Shutdown(); MyTop.cs public partial class MyTop
{
private Window win1 = new Window() { Title = "Window1" ,Y=1, Width = Dim.Fill(),Height = Dim.Fill()};
private Window win2 = new Window() { Title = "Window2", Y = 1, Width = Dim.Fill(), Height = Dim.Fill() };
private Window win3 = new Window() { Title = "Window3", Y = 1, Width = Dim.Fill(), Height = Dim.Fill() };
public MyTop() {
InitializeComponent();
CanFocus = true;
window1MenuItem.Action = () => SetupWindow(1);
window2MenuItem.Action = () => SetupWindow(2);
window3MenuItem.Action = () => SetupWindow(3);
exitMenuItem.Action = () => Application.RequestStop();
}
private void SetupWindow(int windowNumber)
{
Remove(win1);
Remove(win2);
Remove(win3);
switch (windowNumber)
{
case 1: Add(win1);
break;
case 2: Add(win2);
break;
case 3: Add(win3);
break;
}
}
} MyTop.Designer.cs public partial class MyTop : Terminal.Gui.Toplevel {
private Terminal.Gui.MenuBar menuBar;
private Terminal.Gui.MenuBarItem fileF9Menu;
private Terminal.Gui.MenuItem exitMenuItem;
private Terminal.Gui.MenuBarItem windowMenu;
private Terminal.Gui.MenuItem window1MenuItem;
private Terminal.Gui.MenuItem window2MenuItem;
private Terminal.Gui.MenuItem window3MenuItem;
private void InitializeComponent() {
this.menuBar = new Terminal.Gui.MenuBar();
this.Width = Dim.Fill(0);
this.Height = Dim.Fill(0);
this.X = 0;
this.Y = 0;
this.Visible = true;
this.Arrangement = Terminal.Gui.ViewArrangement.Fixed;
this.Modal = false;
this.TextAlignment = Terminal.Gui.Alignment.Start;
this.menuBar.Width = Dim.Fill(0);
this.menuBar.Height = 1;
this.menuBar.X = 0;
this.menuBar.Y = 0;
this.menuBar.Visible = true;
this.menuBar.Arrangement = Terminal.Gui.ViewArrangement.Fixed;
this.menuBar.Data = "menuBar";
this.menuBar.TextAlignment = Terminal.Gui.Alignment.Start;
this.fileF9Menu = new Terminal.Gui.MenuBarItem();
this.fileF9Menu.Title = "_File (F9)";
this.exitMenuItem = new Terminal.Gui.MenuItem();
this.exitMenuItem.Title = "Exit";
this.exitMenuItem.Data = "exitMenuItem";
this.fileF9Menu.Children = new Terminal.Gui.MenuItem[] {
this.exitMenuItem};
this.windowMenu = new Terminal.Gui.MenuBarItem();
this.windowMenu.Title = "Window";
this.window1MenuItem = new Terminal.Gui.MenuItem();
this.window1MenuItem.Title = "Window 1";
this.window1MenuItem.Data = "window1MenuItem";
this.window2MenuItem = new Terminal.Gui.MenuItem();
this.window2MenuItem.Title = "Window 2";
this.window2MenuItem.Data = "window2MenuItem";
this.window3MenuItem = new Terminal.Gui.MenuItem();
this.window3MenuItem.Title = "Window 3";
this.window3MenuItem.Data = "window3MenuItem";
this.windowMenu.Children = new Terminal.Gui.MenuItem[] {
this.window1MenuItem,
this.window2MenuItem,
this.window3MenuItem};
this.menuBar.Menus = new Terminal.Gui.MenuBarItem[] {
this.fileF9Menu,
this.windowMenu};
this.Add(this.menuBar);
}
} |
Beta Was this translation helpful? Give feedback.
Here is a multi page demo where main
Toplevel
is written using TerminalGuiDesigner targetting v2.Program.cs
MyTop.cs