├── ConsoleButtons ├── .vs │ └── ConsoleButtons │ │ └── v16 │ │ ├── .suo │ │ └── Browse.VC.db ├── ConsoleButtons.csproj ├── ConsoleButtons.sln ├── Mouse.cs ├── PInvokes.cs ├── Properties │ └── AssemblyInfo.cs ├── UIComponent.cs ├── UIManager.cs └── obj │ └── Debug │ ├── .NETFramework,Version=v4.7.2.AssemblyAttributes.cs │ ├── ConsoleButtons.csproj.CopyComplete │ ├── ConsoleButtons.csproj.CoreCompileInputs.cache │ ├── ConsoleButtons.csproj.FileListAbsolute.txt │ ├── ConsoleButtons.csprojAssemblyReference.cache │ ├── ConsoleButtons.dll │ ├── ConsoleButtons.pdb │ ├── DesignTimeResolveAssemblyReferences.cache │ └── DesignTimeResolveAssemblyReferencesInput.cache └── README.md /ConsoleButtons/.vs/ConsoleButtons/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/.vs/ConsoleButtons/v16/.suo -------------------------------------------------------------------------------- /ConsoleButtons/.vs/ConsoleButtons/v16/Browse.VC.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/.vs/ConsoleButtons/v16/Browse.VC.db -------------------------------------------------------------------------------- /ConsoleButtons/ConsoleButtons.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {436C565E-B4B5-4E0C-8F69-A30A2551D93E} 8 | Library 9 | Properties 10 | ConsoleButtons 11 | ConsoleButtons 12 | v4.7.2 13 | 512 14 | true 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /ConsoleButtons/ConsoleButtons.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31205.134 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleButtons", "ConsoleButtons.csproj", "{436C565E-B4B5-4E0C-8F69-A30A2551D93E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {436C565E-B4B5-4E0C-8F69-A30A2551D93E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {436C565E-B4B5-4E0C-8F69-A30A2551D93E}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {436C565E-B4B5-4E0C-8F69-A30A2551D93E}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {436C565E-B4B5-4E0C-8F69-A30A2551D93E}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {A9DC60FC-A242-49C7-B5D8-B2E2E439F758} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /ConsoleButtons/Mouse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace ConsoleButtons 6 | { 7 | public struct Mouse 8 | { 9 | public static Point ConsoleMousePoint = new Point(0, 0); 10 | public static AABB LocalMousePoint = new AABB(0, 0, 2, 2); 11 | public static Point MousePoint = new Point(0, 0); 12 | 13 | public static int PreviousClickState = 0; 14 | public static int ClickState = 0; 15 | public static bool Holding = false; 16 | public static bool Clicked = false; 17 | 18 | public void Update(Window.Rect windowRect) 19 | { 20 | ClickState = MouseExt.GetAsyncKeyState(VK.LBUTTON); 21 | MousePoint = MouseExt.GetCursorPosition(); 22 | 23 | Holding = IsHolding(); 24 | Clicked = IsPreviousHolding() && !IsHolding(); 25 | 26 | LocalMousePoint.x = MousePoint.X - windowRect.Left; 27 | LocalMousePoint.y = MousePoint.Y - windowRect.Top; 28 | 29 | (ConsoleMousePoint.X, ConsoleMousePoint.Y) = Window.ConvertPxToConsole(LocalMousePoint.x, LocalMousePoint.y, windowRect); 30 | 31 | if (LocalMousePoint.x > windowRect.Right - windowRect.Left) 32 | LocalMousePoint.x = windowRect.Right - windowRect.Left; 33 | if (LocalMousePoint.x < 0) 34 | LocalMousePoint.x = 0; 35 | 36 | if (LocalMousePoint.y > windowRect.Bottom - windowRect.Top) 37 | LocalMousePoint.y = windowRect.Bottom - windowRect.Top; 38 | if (LocalMousePoint.y < 0) 39 | LocalMousePoint.y = 0; 40 | 41 | PreviousClickState = ClickState; 42 | } 43 | public bool IsPreviousHolding() 44 | { 45 | return Convert.ToBoolean(PreviousClickState & MouseExt.MousePressed); 46 | } 47 | public bool IsHolding() 48 | { 49 | return Convert.ToBoolean(ClickState & MouseExt.MousePressed); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /ConsoleButtons/PInvokes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace ConsoleButtons 6 | { 7 | public static class Window 8 | { 9 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 10 | public static extern IntPtr FindWindow(string strClassName, string strWindowName); 11 | 12 | [DllImport("user32.dll")] 13 | public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle); 14 | 15 | public struct Rect 16 | { 17 | public int Left { get; set; } 18 | public int Top { get; set; } 19 | public int Right { get; set; } 20 | public int Bottom { get; set; } 21 | } 22 | 23 | public static int Remap(int value, int low1, int high1, int low2, int high2) 24 | { 25 | return low2 + (value - low1) * (high2 - low2) / (high1 - low1); 26 | } 27 | public static float Remap(float value, float low1, float high1, float low2, float high2) 28 | { 29 | return low2 + (value - low1) * (high2 - low2) / (high1 - low1); 30 | } 31 | 32 | public static (int x, int y) ConvertConsoleToPx(int X, int Y, Rect WindowRect) 33 | { 34 | return (Remap(X, 0, Console.BufferWidth, 0, WindowRect.Right - WindowRect.Left - X / 3), Remap(Y, 0, Console.WindowHeight, 30, WindowRect.Bottom - WindowRect.Top - Convert.ToInt32(Y / 1.3))); 35 | } 36 | 37 | //public static (int x, int y) ConvertPxToConsole(int X, int Y, Rect WindowRect) 38 | //{ 39 | // return (Remap(X, 0, WindowRect.Right - WindowRect.Left, 0, Console.WindowWidth), Remap(Y, 30, WindowRect.Bottom - WindowRect.Top, 0, Console.WindowHeight)); 40 | //} 41 | 42 | public static (int x, int y) ConvertPxToConsole(int X, int Y, Rect WindowRect) 43 | { 44 | return (Remap(X, 0, WindowRect.Right - WindowRect.Left, 0, Console.WindowWidth + X / 200), Remap(Y, 30, WindowRect.Bottom - WindowRect.Top, 0, Console.WindowHeight + Y / 200)); 45 | } 46 | } 47 | public static class MouseExt 48 | { 49 | public const int MousePressed = 0x8000; 50 | 51 | [DllImport("user32.dll")] 52 | public static extern int GetAsyncKeyState(VK vKeys); 53 | 54 | [DllImport("user32.dll")] 55 | static extern bool GetCursorPos(out POINT lpPoint); 56 | 57 | public static Point GetCursorPosition() 58 | { 59 | POINT lpPoint; 60 | GetCursorPos(out lpPoint); 61 | 62 | return lpPoint; 63 | } 64 | 65 | [StructLayout(LayoutKind.Sequential)] 66 | public struct POINT 67 | { 68 | public int X; 69 | public int Y; 70 | 71 | public static implicit operator Point(POINT point) 72 | { 73 | return new Point(point.X, point.Y); 74 | } 75 | } 76 | } 77 | public enum VK : int 78 | { 79 | LBUTTON = 0x01, 80 | RBUTTON = 0x02, 81 | MBUTTON = 0x04 82 | } 83 | public static class DisableConsoleQuickEdit 84 | { 85 | const uint ENABLE_QUICK_EDIT = 0x0040; 86 | 87 | // STD_INPUT_HANDLE (DWORD): -10 is the standard input device. 88 | const int STD_INPUT_HANDLE = -10; 89 | 90 | [DllImport("kernel32.dll", SetLastError = true)] 91 | static extern IntPtr GetStdHandle(int nStdHandle); 92 | 93 | [DllImport("kernel32.dll")] 94 | static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); 95 | 96 | [DllImport("kernel32.dll")] 97 | static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); 98 | 99 | internal static bool Go() 100 | { 101 | IntPtr consoleHandle = GetStdHandle(STD_INPUT_HANDLE); 102 | 103 | // get current console mode 104 | uint consoleMode; 105 | if (!GetConsoleMode(consoleHandle, out consoleMode)) 106 | { 107 | // ERROR: Unable to get console mode. 108 | return false; 109 | } 110 | 111 | // Clear the quick edit bit in the mode flags 112 | consoleMode &= ~ENABLE_QUICK_EDIT; 113 | 114 | // set the new mode 115 | if (!SetConsoleMode(consoleHandle, consoleMode)) 116 | { 117 | // ERROR: Unable to set console mode 118 | return false; 119 | } 120 | 121 | return true; 122 | } 123 | } 124 | } -------------------------------------------------------------------------------- /ConsoleButtons/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Console Buttons")] 9 | [assembly: AssemblyDescription("Clickable buttons for console!")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technoo")] 12 | [assembly: AssemblyProduct("ConsoleButtons")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("436c565e-b4b5-4e0c-8f69-a30a2551d93e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ConsoleButtons/UIComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | 4 | namespace ConsoleButtons 5 | { 6 | public class UIComponent 7 | { 8 | public AABB AABB; 9 | public Point ConsolePosition; 10 | public bool IsHoveringOver; 11 | 12 | protected bool initialized; 13 | 14 | public event Action OnClick; 15 | public event Action OnHold; 16 | public event Action OnHoverOver; 17 | public event Action OnHoverStop; 18 | 19 | public virtual void Update() { } 20 | public virtual void Clicked() => OnClick?.Invoke(); 21 | public virtual void Hold() => OnHold?.Invoke(); 22 | public virtual void HoveringOver() 23 | { 24 | OnHoverOver?.Invoke(); 25 | IsHoveringOver = true; 26 | } 27 | public void StoppedHovering() 28 | { 29 | OnHoverStop?.Invoke(); 30 | IsHoveringOver = false; 31 | } 32 | } 33 | 34 | public struct AABB 35 | { 36 | public int x, y; 37 | public int width, height; 38 | 39 | public AABB(int x, int y, int w, int h) 40 | { 41 | this.x = x; 42 | this.y = y; 43 | width = w; 44 | height = h; 45 | } 46 | } 47 | 48 | public class Button : UIComponent 49 | { 50 | private string text; 51 | 52 | public Button(string text, int x, int y, int w, int h) 53 | { 54 | this.text = text; 55 | AABB = new AABB(x, y, w, h); 56 | ConsolePosition = new Point(x, y); 57 | 58 | if (!initialized) 59 | Init(); 60 | } 61 | public Button(string text, int x, int y) 62 | { 63 | this.text = text; 64 | AABB = new AABB(x, y, text.Length * 9, 16); 65 | ConsolePosition = new Point(x, y); 66 | 67 | if (!initialized) 68 | Init(); 69 | } 70 | 71 | public void Init() 72 | { 73 | if (initialized) 74 | return; 75 | 76 | WriteWithNoColor(); 77 | 78 | (AABB.x, AABB.y) = Window.ConvertConsoleToPx(AABB.x, AABB.y, UIManager.WindowRect); 79 | 80 | initialized = true; 81 | } 82 | public void WriteWithNoColor() 83 | { 84 | Console.ForegroundColor = ConsoleColor.White; 85 | Console.SetCursorPosition(ConsolePosition.X, ConsolePosition.Y); 86 | Console.WriteLine(text); 87 | } 88 | public void WriteWithColor(ConsoleColor color) 89 | { 90 | Console.ForegroundColor = color; 91 | Console.SetCursorPosition(ConsolePosition.X, ConsolePosition.Y); 92 | Console.WriteLine(text, color); 93 | } 94 | } 95 | public class CheckBox : UIComponent 96 | { 97 | public bool IsChecked; 98 | 99 | private string text; 100 | private char markChar; 101 | 102 | public CheckBox(string text, char markChar, bool isChecked, int x, int y) 103 | { 104 | this.text = text; 105 | this.markChar = markChar; 106 | IsChecked = isChecked; 107 | 108 | AABB = new AABB(x, y, 20, 16); 109 | ConsolePosition = new Point(x, y); 110 | 111 | if (!initialized) 112 | Init(); 113 | } 114 | public CheckBox(string text, char markChar, bool isChecked, bool collideWithText, int x, int y) 115 | { 116 | this.text = text; 117 | this.markChar = markChar; 118 | IsChecked = isChecked; 119 | 120 | AABB = new AABB(x, y, collideWithText ? 20 + (" " + text).Length * 8 : 20, 16); 121 | 122 | ConsolePosition = new Point(x, y); 123 | 124 | if (!initialized) 125 | Init(); 126 | } 127 | 128 | public void Init() 129 | { 130 | if (initialized) 131 | return; 132 | 133 | WriteWithNoColor(); 134 | 135 | (AABB.x, AABB.y) = Window.ConvertConsoleToPx(AABB.x, AABB.y, UIManager.WindowRect); 136 | 137 | initialized = true; 138 | } 139 | 140 | public override void Clicked() 141 | { 142 | base.Clicked(); 143 | IsChecked = !IsChecked; 144 | } 145 | 146 | public void WriteWithNoColor() 147 | { 148 | Console.ForegroundColor = ConsoleColor.White; 149 | Console.SetCursorPosition(ConsolePosition.X, ConsolePosition.Y); 150 | Console.WriteLine(IsChecked ? $"[{markChar}] {text}" : $"[ ] {text}"); 151 | } 152 | public void WriteWithColor(ConsoleColor color) 153 | { 154 | Console.ForegroundColor = color; 155 | Console.SetCursorPosition(ConsolePosition.X, ConsolePosition.Y); 156 | Console.WriteLine(IsChecked ? $"[{markChar}] {text}" : $"[ ] {text}"); 157 | } 158 | } 159 | public class Slider : UIComponent 160 | { 161 | public float Value; 162 | 163 | private int size; 164 | //private float minValue, maxValue; 165 | private float maxValue; 166 | private bool toInt; 167 | private char fillChar, unfilledChar; 168 | 169 | public Slider(float initialValue, float maxValue, int size, bool toInt, char fillChar, char unfilledChar, int x, int y) 170 | { 171 | Value = initialValue; 172 | 173 | this.fillChar = fillChar; 174 | this.toInt = toInt; 175 | this.unfilledChar = unfilledChar; 176 | this.size = size; 177 | //this.minValue = minValue; 178 | this.maxValue = maxValue; 179 | 180 | AABB = new AABB(x+1, y, 8 * size, 16); 181 | ConsolePosition = new Point(x, y); 182 | 183 | if (!initialized) 184 | Init(); 185 | } 186 | 187 | public override void Hold() 188 | { 189 | (int CX, int CY) = Window.ConvertConsoleToPx(ConsolePosition.X, ConsolePosition.Y, UIManager.WindowRect); 190 | (int conSize, _) = Window.ConvertConsoleToPx(size, 0, UIManager.WindowRect); 191 | 192 | float remappedValues = Window.Remap(Mouse.LocalMousePoint.x - CX / 600, CX + 7, CX + conSize, 0, maxValue); 193 | Value = toInt ? (int)remappedValues : remappedValues; 194 | 195 | base.Hold(); 196 | } 197 | 198 | public void Init() 199 | { 200 | if (initialized) 201 | return; 202 | 203 | WriteWithNoColor(); 204 | 205 | (AABB.x, AABB.y) = Window.ConvertConsoleToPx(AABB.x, AABB.y, UIManager.WindowRect); 206 | 207 | initialized = true; 208 | } 209 | public void WriteWithNoColor() 210 | { 211 | Console.ForegroundColor = ConsoleColor.White; 212 | 213 | Console.SetCursorPosition(ConsolePosition.X - 1, ConsolePosition.Y); 214 | Console.WriteLine('['); 215 | 216 | Console.SetCursorPosition(ConsolePosition.X + size, ConsolePosition.Y); 217 | Console.WriteLine(']'); 218 | 219 | for (int i = 0; i < size; i++) 220 | { 221 | Console.SetCursorPosition(ConsolePosition.X + i, ConsolePosition.Y); 222 | float value = (Value / maxValue) * size; 223 | if (i < value) 224 | Console.WriteLine(fillChar); 225 | else 226 | Console.WriteLine(unfilledChar); 227 | } 228 | 229 | } 230 | public void WriteWithColor(ConsoleColor color) 231 | { 232 | Console.ForegroundColor = color; 233 | Console.SetCursorPosition(ConsolePosition.X - 1, ConsolePosition.Y); 234 | Console.WriteLine('['); 235 | 236 | Console.SetCursorPosition(ConsolePosition.X + size, ConsolePosition.Y); 237 | Console.WriteLine(']'); 238 | 239 | for (int i = 0; i < size; i++) 240 | { 241 | Console.SetCursorPosition(ConsolePosition.X + i, ConsolePosition.Y); 242 | float value = (Value / maxValue) * size; 243 | if (i < value) 244 | Console.WriteLine(fillChar); 245 | else 246 | Console.WriteLine(unfilledChar); 247 | } 248 | } 249 | public override void Update() 250 | { 251 | //if (Value <= minValue) 252 | // Value = minValue; 253 | if (Value <= 0) 254 | Value = 0; 255 | if (Value >= maxValue) 256 | Value = maxValue; 257 | } 258 | } 259 | } -------------------------------------------------------------------------------- /ConsoleButtons/UIManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | 6 | namespace ConsoleButtons 7 | { 8 | public class UIManager 9 | { 10 | private Process ThisProcess = Process.GetCurrentProcess(); 11 | private IntPtr WindowHandlePtr; 12 | public static Window.Rect WindowRect; 13 | 14 | public List Components; 15 | 16 | private Mouse Mouse; 17 | private int currentTop = 0; 18 | 19 | public UIManager() 20 | { 21 | Console.OutputEncoding = Encoding.UTF8; 22 | Console.CursorVisible = false; 23 | DisableConsoleQuickEdit.Go(); 24 | 25 | WindowHandlePtr = ThisProcess.MainWindowHandle; 26 | WindowRect = new Window.Rect(); 27 | Mouse = new Mouse(); 28 | Components = new List(); 29 | } 30 | 31 | public void AddToComponents(UIComponent component) 32 | { 33 | Components.Add(component); 34 | } 35 | 36 | public void Update() 37 | { 38 | Window.GetWindowRect(WindowHandlePtr, ref WindowRect); 39 | Mouse.Update(WindowRect); 40 | 41 | for (int i = 0; i < Components.Count; i++) 42 | { 43 | UICollision(Components[i], Mouse.LocalMousePoint); 44 | Components[i].Update(); 45 | } 46 | } 47 | 48 | public void UICollision(UIComponent component, AABB b) 49 | { 50 | AABB a = component.AABB; 51 | if (a.x < b.x + b.width && 52 | a.x + a.width > b.x && 53 | a.y < b.y + b.height && 54 | a.y + a.height > b.y) 55 | { 56 | if (Mouse.Holding) 57 | { 58 | component.Hold(); 59 | } 60 | else if (Mouse.Clicked) 61 | { 62 | component.Clicked(); 63 | } 64 | else 65 | { 66 | component.HoveringOver(); 67 | } 68 | } 69 | else 70 | { 71 | component.StoppedHovering(); 72 | } 73 | } 74 | 75 | public void Clear() 76 | { 77 | Console.Clear(); 78 | currentTop = 0; 79 | } 80 | 81 | public void WriteLine(string text, ConsoleColor color) 82 | { 83 | Console.SetCursorPosition(Console.CursorLeft, Console.CursorTop+currentTop); 84 | Console.ForegroundColor = color; 85 | Console.WriteLine(text); 86 | currentTop++; 87 | } 88 | } 89 | 90 | /*public interface IConsole 91 | { 92 | T DefaultColor { get; set; } 93 | void WriteLine(string text, T Color); 94 | void Write(string text, T Color); 95 | } 96 | 97 | public class DefaultConsole : IConsole 98 | { 99 | private ConsoleColor _defaultColor; 100 | public ConsoleColor DefaultColor 101 | { 102 | get { return _defaultColor; } 103 | set { _defaultColor = value; } 104 | } 105 | public void WriteLine(string text, ConsoleColor Color) 106 | { 107 | Console.ForegroundColor = Color; 108 | Console.WriteLine(text); 109 | } 110 | 111 | public void Write(string text, ConsoleColor Color) 112 | { 113 | Console.ForegroundColor = Color; 114 | Console.Write(text); 115 | } 116 | }*/ 117 | } 118 | -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] 5 | -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.csproj.CopyComplete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/ConsoleButtons.csproj.CopyComplete -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.csproj.CoreCompileInputs.cache: -------------------------------------------------------------------------------- 1 | 0833dbd9001eb510f1bc5b1badce55671a6ea187 2 | -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | C:\Users\Technoo\source\repos\ConsoleButtons\bin\Debug\ConsoleButtons.dll 2 | C:\Users\Technoo\source\repos\ConsoleButtons\bin\Debug\ConsoleButtons.pdb 3 | C:\Users\Technoo\source\repos\ConsoleButtons\obj\Debug\ConsoleButtons.csprojAssemblyReference.cache 4 | C:\Users\Technoo\source\repos\ConsoleButtons\obj\Debug\ConsoleButtons.csproj.CoreCompileInputs.cache 5 | C:\Users\Technoo\source\repos\ConsoleButtons\obj\Debug\ConsoleButtons.dll 6 | C:\Users\Technoo\source\repos\ConsoleButtons\obj\Debug\ConsoleButtons.pdb 7 | C:\Users\Technoo\source\repos\ConsoleButtons\bin\Debug\Colorful.Console.dll 8 | C:\Users\Technoo\source\repos\ConsoleButtons\obj\Debug\ConsoleButtons.csproj.CopyComplete 9 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\bin\Debug\ConsoleButtons.dll 10 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\bin\Debug\ConsoleButtons.pdb 11 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\bin\Debug\Colorful.Console.dll 12 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\obj\Debug\ConsoleButtons.csprojAssemblyReference.cache 13 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\obj\Debug\ConsoleButtons.csproj.CoreCompileInputs.cache 14 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\obj\Debug\ConsoleButtons.csproj.CopyComplete 15 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\obj\Debug\ConsoleButtons.dll 16 | C:\Users\Technoo\Documents\GitClones\ConsoleButtons\ConsoleButtons\obj\Debug\ConsoleButtons.pdb 17 | -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/ConsoleButtons.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/ConsoleButtons.dll -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/ConsoleButtons.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/ConsoleButtons.pdb -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/DesignTimeResolveAssemblyReferences.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/DesignTimeResolveAssemblyReferences.cache -------------------------------------------------------------------------------- /ConsoleButtons/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wTechnoo/ConsoleButtons/423e7a8616935701134253582fb0babb5ea879c4/ConsoleButtons/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Console Buttons

2 | 3 |

project-image

4 | 5 |

Clickable UI for C# Console

6 |

Buttons, checkboxes, sliders and more!

7 | 8 |

⚠️ Warning

9 |

Console buttons will only work when launched through the built .EXE on RELEASE mode

10 | 11 |

✔️ Changes (24/12/21)

12 |

1. Removed Colorful.Console dependency

13 |

2. Added proper WriteLine and Clear that works as expected (default Console.WriteLine wasn't producing proper results)

14 |

3. Renamed some of the scripts

15 | 16 |

❔ To be worked on

17 |

1. Adding a way to the user to use their own/downloaded console packages (such as Colorful.Console or any other color package)

18 | 19 |

📌Package

20 |

Download the package through nugget or build it yourself!

21 | 22 |

⌨️ Example Usage

23 | 24 | 25 | ```csharp 26 | static void Main(string[] args) 27 | { 28 | UIManager manager = new UIManager(); 29 | 30 | //Button constructor that auto detects the COLLIDER WIDTH based on how many characters there are on the text. 31 | Button button = new Button("Sign Up", 0, 0); 32 | button.OnHoverOver += () => { button.WriteWithColor(ConsoleColor.Gray); }; 33 | button.OnHoverStop += () => { button.WriteWithNoColor(); }; 34 | button.OnClick += () => { button.WriteWithColor(ConsoleColor.Red); Thread.Sleep(50); }; 35 | button.OnHold += () => { button.WriteWithColor(ConsoleColor.Red); }; 36 | 37 | //Checkbox constructor order (text string, marked checkbox char, is initialized as checked, collide with text, X and Y) 38 | CheckBox checkBox = new CheckBox("Checkbox", 'X', false, true, 0, 0); 39 | checkBox.OnHoverOver += () => { checkBox.WriteWithColor(ConsoleColor.Gray); }; 40 | checkBox.OnHoverStop += () => { checkBox.WriteWithNoColor(); }; 41 | checkBox.OnClick += () => { checkBox.WriteWithColor(ConsoleColor.Cyan); Thread.Sleep(50); }; 42 | checkBox.OnHold += () => { checkBox.WriteWithColor(ConsoleColor.Red); }; 43 | 44 | //Slider constructor order (initial value, max value, slider size, convert to int, filled char, unfilled char, X and Y) 45 | Slider slider = new Slider(0, 10, 10, false, '█', ' ', 5,5); 46 | slider.OnHoverOver += () => { slider.WriteWithColor(ConsoleColor.Gray); }; 47 | slider.OnHoverStop += () => { slider.WriteWithNoColor(); }; 48 | slider.OnHold += () => { slider.WriteWithColor(ConsoleColor.Red); Console.Write(slider.Value, ConsoleColor.Aqua); }; 49 | 50 | manager.AddToComponents(button); 51 | manager.AddToComponents(checkBox); 52 | manager.AddToComponents(slider); 53 | 54 | while (true) 55 | { 56 | manager.Update(); 57 | } 58 | 59 | Console.ReadKey(); 60 | } 61 | ``` 62 | --------------------------------------------------------------------------------