diff --git a/CompactGraphics/Graphics.cs b/CompactGraphics/Graphics.cs index 5e4c33d..34a788f 100644 --- a/CompactGraphics/Graphics.cs +++ b/CompactGraphics/Graphics.cs @@ -163,6 +163,13 @@ public struct SmallRect } #endregion /// + /// Initilise the virtual screen at the currrent cosole dimensions. + /// + public Graphics() : this(Console.WindowWidth, Console.WindowHeight) + { + + } + /// /// Initilises the Virtual screen. /// /// width of the screen diff --git a/CompactGraphics/Menu.cs b/CompactGraphics/Menu.cs new file mode 100644 index 0000000..18bd8d6 --- /dev/null +++ b/CompactGraphics/Menu.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; + +namespace CompactGraphics +{ + /// + /// A base for Widget Based Menus + /// + public class Menu + { + /// + /// The graphics object to link to + /// + protected Graphics g; + /// + /// The list of widgets on page, in draw order. + /// + protected List onPage; + /// + /// The numeric status of the menu, used for navigation. + /// + public int Status { get { return status; } } + protected int status; + public Menu() + { + g = new Graphics(Console.WindowWidth, Console.WindowHeight); + onPage = new List(); + } + public Menu(Graphics g) + { + this.g = g; + onPage = new List(); + } + /// + /// Steps to the next frame by adding all the widgets to the current frame. + /// DOES NOT PUSH + /// + public virtual void StepFrame() + { + foreach (Widget widget in onPage) + { + widget.Draw(g); + } + } + /// + /// Steps to the next frame by adding all the widgets to teh current frame, giving them the users input. + /// + /// The input to handle + public virtual void StepFrame(ConsoleKeyInfo keyinfo) + { + foreach (Widget widget in onPage) + { + widget.Draw(g, keyinfo); + } + } + } +} diff --git a/TestApp/Program.cs b/TestApp/Program.cs index 9256f23..edefe04 100644 --- a/TestApp/Program.cs +++ b/TestApp/Program.cs @@ -1,15 +1,23 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; + +using CompactGraphics; namespace TestApp { class Program { static void Main(string[] args) { + Graphics graphics = new Graphics(); + + //Contunually draw frames + while (true) + { + //draw the frame counter at the top of the screen. + graphics.Draw($"Fps: {graphics.Fps}", ConsoleColor.White, 0, 0); + //now that all drawing is done, push the frame to the buffer. + graphics.pushFrame(); + } } } } diff --git a/TestApp/TestApp.csproj b/TestApp/TestApp.csproj index 94b34c2..9ccaba3 100644 --- a/TestApp/TestApp.csproj +++ b/TestApp/TestApp.csproj @@ -33,6 +33,9 @@ 4 + + ..\CompactGraphics\bin\Debug\netstandard2.0\CompactGraphics.dll +