From a3cebdb6d6fb992045f26b2c8692ce3cf832a5c8 Mon Sep 17 00:00:00 2001 From: gusman Date: Sun, 10 Sep 2017 01:27:32 +0200 Subject: [PATCH 1/3] Added .net Standard 2.0 support Added .net Core test app --- Source/ConsoleDraw.sln | 25 ++-- Source/ConsoleDraw/ConsoleDraw.csproj | 87 ++---------- Source/ConsoleDraw/Cursor.cs | 8 +- Source/ConsoleDraw/Inputs/FileBrowser.cs | 2 +- Source/ConsoleDraw/Properties/AssemblyInfo.cs | 36 ----- Source/InlineTestApp/InlineTestApp.csproj | 2 +- Source/TestApp/TestApp.csproj | 2 +- Source/TestAppCore/Program.cs | 19 +++ Source/TestAppCore/TestAppCore.csproj | 12 ++ Source/TestAppCore/Untitled.txt | 1 + Source/TestAppCore/Windows/MainWindow.cs | 129 ++++++++++++++++++ Source/TestAppCore/Windows/SettingsWindow.cs | 55 ++++++++ 12 files changed, 250 insertions(+), 128 deletions(-) delete mode 100644 Source/ConsoleDraw/Properties/AssemblyInfo.cs create mode 100644 Source/TestAppCore/Program.cs create mode 100644 Source/TestAppCore/TestAppCore.csproj create mode 100644 Source/TestAppCore/Untitled.txt create mode 100644 Source/TestAppCore/Windows/MainWindow.cs create mode 100644 Source/TestAppCore/Windows/SettingsWindow.cs diff --git a/Source/ConsoleDraw.sln b/Source/ConsoleDraw.sln index 2f43efd..5b11335 100644 --- a/Source/ConsoleDraw.sln +++ b/Source/ConsoleDraw.sln @@ -1,24 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleDraw", "ConsoleDraw\ConsoleDraw.csproj", "{5978DE85-3FB9-4BAB-965F-95E4398309A2}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InlineTestApp", "InlineTestApp\InlineTestApp.csproj", "{06F8AAFC-0F1A-444F-B83C-A09600C22D14}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{09CC30E4-7830-4CF4-A15E-0DB02BB84F17}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAppCore", "TestAppCore\TestAppCore.csproj", "{34A44C85-C59E-414F-AA59-76C6A1F4B851}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleDraw", "ConsoleDraw\ConsoleDraw.csproj", "{6BDA9A64-00C4-49DA-A92A-BDDB7CF081AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5978DE85-3FB9-4BAB-965F-95E4398309A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5978DE85-3FB9-4BAB-965F-95E4398309A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5978DE85-3FB9-4BAB-965F-95E4398309A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5978DE85-3FB9-4BAB-965F-95E4398309A2}.Release|Any CPU.Build.0 = Release|Any CPU {06F8AAFC-0F1A-444F-B83C-A09600C22D14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {06F8AAFC-0F1A-444F-B83C-A09600C22D14}.Debug|Any CPU.Build.0 = Debug|Any CPU {06F8AAFC-0F1A-444F-B83C-A09600C22D14}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -27,8 +25,19 @@ Global {09CC30E4-7830-4CF4-A15E-0DB02BB84F17}.Debug|Any CPU.Build.0 = Debug|Any CPU {09CC30E4-7830-4CF4-A15E-0DB02BB84F17}.Release|Any CPU.ActiveCfg = Release|Any CPU {09CC30E4-7830-4CF4-A15E-0DB02BB84F17}.Release|Any CPU.Build.0 = Release|Any CPU + {34A44C85-C59E-414F-AA59-76C6A1F4B851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34A44C85-C59E-414F-AA59-76C6A1F4B851}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34A44C85-C59E-414F-AA59-76C6A1F4B851}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34A44C85-C59E-414F-AA59-76C6A1F4B851}.Release|Any CPU.Build.0 = Release|Any CPU + {6BDA9A64-00C4-49DA-A92A-BDDB7CF081AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6BDA9A64-00C4-49DA-A92A-BDDB7CF081AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6BDA9A64-00C4-49DA-A92A-BDDB7CF081AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6BDA9A64-00C4-49DA-A92A-BDDB7CF081AA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A2CC9091-31F8-47D8-999A-E002E00AA7A6} + EndGlobalSection EndGlobal diff --git a/Source/ConsoleDraw/ConsoleDraw.csproj b/Source/ConsoleDraw/ConsoleDraw.csproj index 99f5f76..f96091e 100644 --- a/Source/ConsoleDraw/ConsoleDraw.csproj +++ b/Source/ConsoleDraw/ConsoleDraw.csproj @@ -1,80 +1,15 @@ - - - + + - Debug - AnyCPU - {5978DE85-3FB9-4BAB-965F-95E4398309A2} - Library - Properties - ConsoleDraw + netstandard2.0;net45 ConsoleDraw - v4.5 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + ConsoleDraw - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + 4.3.0 + - - - \ No newline at end of file + + diff --git a/Source/ConsoleDraw/Cursor.cs b/Source/ConsoleDraw/Cursor.cs index 27e7763..c3ff7c0 100644 --- a/Source/ConsoleDraw/Cursor.cs +++ b/Source/ConsoleDraw/Cursor.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; -using System.Timers; namespace ConsoleDraw { @@ -26,9 +26,7 @@ public void PlaceCursor(int x, int y, char letter, ConsoleColor background = Con _background = background; WindowManager.WirteText("_", x, y, ConsoleColor.White, background); - blink = new Timer(500); - blink.Elapsed += new ElapsedEventHandler(BlinkCursor); - blink.Enabled = true; + blink = new Timer(BlinkCursor, null, 500, 500); } public void RemoveCursor() @@ -43,7 +41,7 @@ public void RemoveCursor() } - void BlinkCursor(object sender, ElapsedEventArgs e) + void BlinkCursor(object state) { if (_cursorShow) { diff --git a/Source/ConsoleDraw/Inputs/FileBrowser.cs b/Source/ConsoleDraw/Inputs/FileBrowser.cs index e5117c5..e74d74b 100644 --- a/Source/ConsoleDraw/Inputs/FileBrowser.cs +++ b/Source/ConsoleDraw/Inputs/FileBrowser.cs @@ -43,7 +43,7 @@ public FileBrowser(int x, int y, int width, int height, String path, String iD, CurrentlySelectedFile = ""; IncludeFiles = includeFiles; FilterByExtension = filterByExtension; - Drives = Directory.GetLogicalDrives().ToList(); + Drives = DriveInfo.GetDrives().Select(d => d.Name).ToList(); GetFileNames(); Selectable = true; diff --git a/Source/ConsoleDraw/Properties/AssemblyInfo.cs b/Source/ConsoleDraw/Properties/AssemblyInfo.cs deleted file mode 100644 index a304f31..0000000 --- a/Source/ConsoleDraw/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ConsoleDraw")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ConsoleDraw")] -[assembly: AssemblyCopyright("Copyright © 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9659aa3a-4637-41f9-a408-4e33d9d8483f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Source/InlineTestApp/InlineTestApp.csproj b/Source/InlineTestApp/InlineTestApp.csproj index 17acabd..2b67d0b 100644 --- a/Source/InlineTestApp/InlineTestApp.csproj +++ b/Source/InlineTestApp/InlineTestApp.csproj @@ -49,7 +49,7 @@ - {5978de85-3fb9-4bab-965f-95e4398309a2} + {6bda9a64-00c4-49da-a92a-bddb7cf081aa} ConsoleDraw diff --git a/Source/TestApp/TestApp.csproj b/Source/TestApp/TestApp.csproj index af74f7c..7584e64 100644 --- a/Source/TestApp/TestApp.csproj +++ b/Source/TestApp/TestApp.csproj @@ -51,7 +51,7 @@ - {5978de85-3fb9-4bab-965f-95e4398309a2} + {6bda9a64-00c4-49da-a92a-bddb7cf081aa} ConsoleDraw diff --git a/Source/TestAppCore/Program.cs b/Source/TestAppCore/Program.cs new file mode 100644 index 0000000..6ca3cf8 --- /dev/null +++ b/Source/TestAppCore/Program.cs @@ -0,0 +1,19 @@ +using ConsoleDraw; +using System; +using TestAppCore.Windows; + +namespace TestAppCore +{ + class Program + { + static void Main(string[] args) + { + //Setup + WindowManager.UpdateWindow(100, 48); + WindowManager.UpdateWindow(100, 48); + WindowManager.SetWindowTitle("Test App"); + + new MainWindow(); + } + } +} diff --git a/Source/TestAppCore/TestAppCore.csproj b/Source/TestAppCore/TestAppCore.csproj new file mode 100644 index 0000000..c83bb0a --- /dev/null +++ b/Source/TestAppCore/TestAppCore.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp2.0 + + + + + + + diff --git a/Source/TestAppCore/Untitled.txt b/Source/TestAppCore/Untitled.txt new file mode 100644 index 0000000..c70be8d --- /dev/null +++ b/Source/TestAppCore/Untitled.txt @@ -0,0 +1 @@ +Test Data \ No newline at end of file diff --git a/Source/TestAppCore/Windows/MainWindow.cs b/Source/TestAppCore/Windows/MainWindow.cs new file mode 100644 index 0000000..6f4bedd --- /dev/null +++ b/Source/TestAppCore/Windows/MainWindow.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using ConsoleDraw.Windows.Base; +using ConsoleDraw.Inputs; +using ConsoleDraw.Windows; +using System.IO; + +namespace TestAppCore.Windows +{ + public class MainWindow : FullWindow + { + public MainWindow() : base(0, 0, Console.WindowWidth, Console.WindowHeight, null) + { + var oneBtn = new Button(2, 2, "Button One", "oneBtn", this) { Action = delegate() { new Alert("You Clicked Button One", this, ConsoleColor.White); } }; + var twoBtn = new Button(4, 2, "Button Two", "twoBtn", this) { Action = delegate() { new Alert("You Clicked Button Two", this, ConsoleColor.White); } }; + var threeBtn = new Button(6, 2, "Long Alert", "threeoBtn", this) { Action = delegate() { new Alert("A web browser (commonly referred to as a browser) is a software application for retrieving, presenting and traversing information resources on the World Wide", this, ConsoleColor.White); } }; + + var displayAlertBtn = new Button(2, 20, "Display Alert", "displayAlertBtn", this) { Action = delegate() { new Alert("This is an Alert!", this, ConsoleColor.White); } }; + var displayConfirmBtn = new Button(4, 20, "Display Confirm", "displayConfirmBtn", this) { Action = delegate() { + var cf = new Confirm("This is a Confirm!", this, ConsoleColor.White); + + if(cf.ShowDialog() == ConsoleDraw.DialogResult.OK) + { + + } + } }; + var exitBtn = new Button(6, 20, "Exit", "exitBtn", this) { Action = delegate() { ExitWindow(); } }; + + var displaySettingBtn = new Button(2, 40, "Display Settings", "displaySettingsBtn", this) { Action = delegate() { new SettingsWindow(this); } }; + var displaySaveBtn = new Button(4, 40, "Display Save Menu", "displaySaveMenuBtn", this) { Action = delegate() { new SaveMenu("Untitled.txt", Directory.GetCurrentDirectory(), "Test Data", this); } }; + var displayLoadBtn = new Button(6, 40, "Display Load Menu", "displayLoadMenuBtn", this) { Action = delegate() { new LoadMenu(Directory.GetCurrentDirectory(), new Dictionary() {{"txt", "Text Document"}, {"*","All Files"}}, this); } }; + + var oneCheckBox = new CheckBox(10, 2, "oneCheckBox", this); + var oneCheckBoxLabel = new Label("Check Box One", 10, 6, "oneCheckBoxLabel", this); + var twoCheckBox = new CheckBox(12, 2, "twoCheckBox", this) { Checked = true }; + var twoCheckBoxLabel = new Label("Check Box Two", 12, 6, "twoCheckBoxLabel", this); + var threeCheckBox = new CheckBox(14, 2, "threeCheckBox", this); + var threeCheckBoxLabel = new Label("Check Box Three", 14, 6, "threeCheckBoxLabel", this); + + var groupOneLabel = new Label("Radio Button Group One", 9, 25, "oneCheckBoxLabel", this); + var oneRadioBtnGroupOne = new RadioButton(10, 25, "oneRadioBtnGroupOne", "groupOne", this) { Checked = true }; + var oneRadioBtnGroupOneLabel = new Label("Radio Button One", 10, 29, "oneCheckBoxLabel", this); + var twoRadioBtnGroupOne = new RadioButton(12, 25, "twoRadioBtnGroupOne", "groupOne", this); + var twoRadioBtnGroupOneLabel = new Label("Radio Button Two", 12, 29, "oneCheckBoxLabel", this); + var threeRadioBtnGroupOne = new RadioButton(14, 25, "threeRadioBtnGroupOne", "groupOne", this); + var threeRadioBtnGroupOneLabel = new Label("Radio Button Three", 14, 29, "oneCheckBoxLabel", this); + + var groupTwoLabel = new Label("Radio Button Group Two", 9, 50, "oneCheckBoxLabel", this); + var oneRadioBtnGroupTwo = new RadioButton(10, 50, "oneRadioBtnGroupTwo", "groupTwo", this) { Checked = true }; + var twoRadioBtnGroupTwo = new RadioButton(12, 50, "twoRadioBtnGroupTwo", "groupTwo", this); + var threeRadioBtnGroupTwo = new RadioButton(14, 50, "threeRadioBtnGroupTwo", "groupTwo", this); + + var textAreaLabel = new Label("Text Area", 16, 2, "textAreaLabel", this); + var textArea = new TextArea(17, 2, 60, 6, "txtArea", this); + textArea.BackgroundColour = ConsoleColor.DarkGray; + + var txtBoxLabel = new Label("Text Box", 24, 2, "txtBoxLabel", this); + var txtBox = new TextBox(24, 11, "txtBox", this); + + var fileSelect = new FileBrowser(26, 2, 40, 10, Directory.GetCurrentDirectory(), "fileSelect", this, true); + + var progressBar = new ProgressBar(10, 39, 2, 3, 70, "progressBar", this); + var progressBarLabel = new Label("10%", 39, 73, "oneCheckBoxLabel", this); + + var progressBarDownBtn = new Button(37, 2, "Progress Down", "displaySettingsBtn", this) { Action = delegate () { progressBar.PercentageComplete--; progressBarLabel.SetText(String.Format("{0}%", progressBar.PercentageComplete).PadRight(4)); } }; + var progressBarUpBtn = new Button(37, 18, "Progress Up", "displaySettingsBtn", this) { Action = delegate () { progressBar.PercentageComplete++; progressBarLabel.SetText(String.Format("{0}%", progressBar.PercentageComplete).PadRight(4)); } }; + + + + Inputs.Add(oneBtn); + Inputs.Add(twoBtn); + Inputs.Add(threeBtn); + Inputs.Add(oneCheckBox); + Inputs.Add(oneCheckBoxLabel); + Inputs.Add(twoCheckBox); + Inputs.Add(twoCheckBoxLabel); + Inputs.Add(threeCheckBox); + Inputs.Add(threeCheckBoxLabel); + + Inputs.Add(displayAlertBtn); + Inputs.Add(displayConfirmBtn); + Inputs.Add(exitBtn); + + Inputs.Add(groupOneLabel); + Inputs.Add(oneRadioBtnGroupOne); + Inputs.Add(oneRadioBtnGroupOneLabel); + Inputs.Add(twoRadioBtnGroupOne); + Inputs.Add(twoRadioBtnGroupOneLabel); + Inputs.Add(threeRadioBtnGroupOne); + Inputs.Add(threeRadioBtnGroupOneLabel); + + Inputs.Add(displaySettingBtn); + Inputs.Add(displaySaveBtn); + Inputs.Add(displayLoadBtn); + + Inputs.Add(groupTwoLabel); + Inputs.Add(oneRadioBtnGroupTwo); + Inputs.Add(twoRadioBtnGroupTwo); + Inputs.Add(threeRadioBtnGroupTwo); + + Inputs.Add(textAreaLabel); + Inputs.Add(textArea); + + Inputs.Add(txtBoxLabel); + Inputs.Add(txtBox); + + Inputs.Add(fileSelect); + + Inputs.Add(progressBarDownBtn); + Inputs.Add(progressBarUpBtn); + + Inputs.Add(progressBar); + Inputs.Add(progressBarLabel); + + List opts = new List() { "hello", "world"}; + var cb = new Dropdown(0, 0, opts, "cb", this); + cb.DropdownItems = new List(opts.Select(_=>new DropdownItem(_,10,"2", this)).ToArray()); + + Inputs.Add(cb); + + CurrentlySelected = oneBtn; + + Draw(); + MainLoop(); + } + + } +} \ No newline at end of file diff --git a/Source/TestAppCore/Windows/SettingsWindow.cs b/Source/TestAppCore/Windows/SettingsWindow.cs new file mode 100644 index 0000000..632f284 --- /dev/null +++ b/Source/TestAppCore/Windows/SettingsWindow.cs @@ -0,0 +1,55 @@ +using ConsoleDraw.Inputs; +using ConsoleDraw.Windows.Base; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TestAppCore.Windows +{ + public class SettingsWindow : PopupWindow + { + public SettingsWindow(Window parentWindow) + : base("Settings", 6, 10, 80, 20, parentWindow) + { + BackgroundColour = ConsoleColor.White; + + var appTitleLabel = new Label("App Title", 8, 12, "appTitleLabel", this); + var appTitleTxtBox = new TextBox(8, 25, Console.Title, "appTitleTxtBox", this, 10); + + var saveOnExitLabel = new Label("Save On Exit", 10, 12, "saveOnExitLabel", this); + var saveOneExitChkBox = new CheckBox(10, 25, "saveOnExitCheckBox", this); + + var byAllLabel = new Label("For All", 12, 12, "forAll", this); + var byAllRadioBtn = new RadioButton(12, 25, "byAllRadioBtn", "Users", this) { Checked = true }; + var justYouLabel = new Label("Just You", 14, 12, "justYou", this); + var justYouRadioBtn = new RadioButton(14, 25, "justYouRadioBtn", "Users", this); + + var applyBtn = new Button(24, 12, "Apply", "exitBtn", this) { Action = delegate() { ExitWindow(); } }; + var exitBtn = new Button(24, 20, "Exit", "exitBtn", this) { Action = delegate() { ExitWindow(); } }; + + Inputs.Add(appTitleLabel); + Inputs.Add(appTitleTxtBox); + + Inputs.Add(saveOnExitLabel); + Inputs.Add(saveOneExitChkBox); + + Inputs.Add(byAllLabel); + Inputs.Add(byAllRadioBtn); + Inputs.Add(justYouLabel); + Inputs.Add(justYouRadioBtn); + + Inputs.Add(applyBtn); + Inputs.Add(exitBtn); + + + CurrentlySelected = exitBtn; + + Draw(); + MainLoop(); + } + + + } +} From 4e508a3a2cdc313cc926399a373b2be16f107199 Mon Sep 17 00:00:00 2001 From: gusman Date: Sun, 10 Sep 2017 01:33:11 +0200 Subject: [PATCH 2/3] Corrected bad package condition for .net Core --- Source/ConsoleDraw/ConsoleDraw.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/ConsoleDraw/ConsoleDraw.csproj b/Source/ConsoleDraw/ConsoleDraw.csproj index f96091e..ff55a80 100644 --- a/Source/ConsoleDraw/ConsoleDraw.csproj +++ b/Source/ConsoleDraw/ConsoleDraw.csproj @@ -6,7 +6,7 @@ ConsoleDraw - + 4.3.0 From f893d3c67f26366723ccaf7ea34a5596af2cb1fc Mon Sep 17 00:00:00 2001 From: gusman Date: Sun, 10 Sep 2017 02:58:36 +0200 Subject: [PATCH 3/3] Some changes to enable compatibility with Linux and MacOS Made all color properties public --- Source/ConsoleDraw/Inputs/Button.cs | 8 +++--- Source/ConsoleDraw/Inputs/CheckBox.cs | 6 ++-- .../ConsoleDraw/Inputs/Dropdown/Dropdown.cs | 8 +++--- .../Inputs/Dropdown/DropdownItem.cs | 8 +++--- Source/ConsoleDraw/Inputs/FileBrowser.cs | 8 +++--- Source/ConsoleDraw/Inputs/Label.cs | 2 +- Source/ConsoleDraw/Inputs/Menu/Menu.cs | 10 +++---- Source/ConsoleDraw/Inputs/Menu/MenuItem.cs | 8 +++--- Source/ConsoleDraw/Inputs/ProgressBar.cs | 1 + Source/ConsoleDraw/Inputs/RadioButton.cs | 6 ++-- Source/ConsoleDraw/Inputs/TextArea.cs | 2 +- Source/ConsoleDraw/Inputs/TextBox.cs | 4 +-- Source/ConsoleDraw/WindowManager.cs | 28 ++++++++++++++++--- .../ConsoleDraw/Windows/Base/PopupWindow.cs | 6 ++-- Source/TestAppCore/Program.cs | 1 - Source/TestAppCore/TestAppCore.csproj | 1 + Source/TestAppCore/Windows/SettingsWindow.cs | 2 +- 17 files changed, 65 insertions(+), 44 deletions(-) diff --git a/Source/ConsoleDraw/Inputs/Button.cs b/Source/ConsoleDraw/Inputs/Button.cs index 8b0d248..1bfdfa9 100644 --- a/Source/ConsoleDraw/Inputs/Button.cs +++ b/Source/ConsoleDraw/Inputs/Button.cs @@ -10,12 +10,12 @@ namespace ConsoleDraw.Inputs { public class Button : Input { - private String Text; + public String Text; public ConsoleColor BackgroundColour = ConsoleColor.Gray; - private ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; - private ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor SelectedTextColour = ConsoleColor.White; private bool Selected = false; diff --git a/Source/ConsoleDraw/Inputs/CheckBox.cs b/Source/ConsoleDraw/Inputs/CheckBox.cs index 45e7a8c..b703872 100644 --- a/Source/ConsoleDraw/Inputs/CheckBox.cs +++ b/Source/ConsoleDraw/Inputs/CheckBox.cs @@ -11,10 +11,10 @@ namespace ConsoleDraw.Inputs public class CheckBox : Input { public ConsoleColor BackgroundColour = ConsoleColor.Gray; - private ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; - private ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor SelectedTextColour = ConsoleColor.White; private bool Selected = false; public bool Checked = false; diff --git a/Source/ConsoleDraw/Inputs/Dropdown/Dropdown.cs b/Source/ConsoleDraw/Inputs/Dropdown/Dropdown.cs index 64c4622..db50b28 100644 --- a/Source/ConsoleDraw/Inputs/Dropdown/Dropdown.cs +++ b/Source/ConsoleDraw/Inputs/Dropdown/Dropdown.cs @@ -10,10 +10,10 @@ namespace ConsoleDraw.Inputs { public class Dropdown : Input { - private ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor BackgroudColour = ConsoleColor.Gray; - private ConsoleColor SelectedTextColour = ConsoleColor.White; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor BackgroudColour = ConsoleColor.Gray; + public ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; private bool Selected = false; public List DropdownItems = new List(); diff --git a/Source/ConsoleDraw/Inputs/Dropdown/DropdownItem.cs b/Source/ConsoleDraw/Inputs/Dropdown/DropdownItem.cs index 1f46d27..19d9487 100644 --- a/Source/ConsoleDraw/Inputs/Dropdown/DropdownItem.cs +++ b/Source/ConsoleDraw/Inputs/Dropdown/DropdownItem.cs @@ -11,10 +11,10 @@ namespace ConsoleDraw.Inputs public class DropdownItem : Input { public String Text = ""; - private ConsoleColor TextColour = ConsoleColor.White; - private ConsoleColor BackgroudColour = ConsoleColor.DarkGray; - private ConsoleColor SelectedTextColour = ConsoleColor.Black; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; + public ConsoleColor TextColour = ConsoleColor.White; + public ConsoleColor BackgroudColour = ConsoleColor.DarkGray; + public ConsoleColor SelectedTextColour = ConsoleColor.Black; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; private bool Selected = false; public Action Action; diff --git a/Source/ConsoleDraw/Inputs/FileBrowser.cs b/Source/ConsoleDraw/Inputs/FileBrowser.cs index e74d74b..7d97419 100644 --- a/Source/ConsoleDraw/Inputs/FileBrowser.cs +++ b/Source/ConsoleDraw/Inputs/FileBrowser.cs @@ -21,10 +21,10 @@ public class FileBrowser : Input public bool IncludeFiles; public String FilterByExtension = "*"; - private ConsoleColor BackgroundColour = ConsoleColor.DarkGray; - private ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor SelectedTextColour = ConsoleColor.White; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; + public ConsoleColor BackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; private int cursorX; private int CursorX { get { return cursorX; } set { cursorX = value; GetCurrentlySelectedFileName(); SetOffset(); } } diff --git a/Source/ConsoleDraw/Inputs/Label.cs b/Source/ConsoleDraw/Inputs/Label.cs index 86485fe..c78eaae 100644 --- a/Source/ConsoleDraw/Inputs/Label.cs +++ b/Source/ConsoleDraw/Inputs/Label.cs @@ -11,7 +11,7 @@ namespace ConsoleDraw.Inputs public class Label : Input { private String Text = ""; - private ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor TextColour = ConsoleColor.Black; public ConsoleColor BackgroundColour = ConsoleColor.Gray; public Label(String text, int x, int y, String iD, Window parentWindow) : base(x, y, 1, text.Count(), parentWindow, iD) diff --git a/Source/ConsoleDraw/Inputs/Menu/Menu.cs b/Source/ConsoleDraw/Inputs/Menu/Menu.cs index 771e0da..f2cf3b5 100644 --- a/Source/ConsoleDraw/Inputs/Menu/Menu.cs +++ b/Source/ConsoleDraw/Inputs/Menu/Menu.cs @@ -10,11 +10,11 @@ namespace ConsoleDraw.Inputs { public class Menu : Input { - private String Text = ""; - private ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor BackgroudColour = ConsoleColor.Gray; - private ConsoleColor SelectedTextColour = ConsoleColor.White; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; + public String Text = ""; + public ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor BackgroudColour = ConsoleColor.Gray; + public ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; private bool Selected = false; public List MenuItems = new List(); diff --git a/Source/ConsoleDraw/Inputs/Menu/MenuItem.cs b/Source/ConsoleDraw/Inputs/Menu/MenuItem.cs index 7c3fc49..b1bfc82 100644 --- a/Source/ConsoleDraw/Inputs/Menu/MenuItem.cs +++ b/Source/ConsoleDraw/Inputs/Menu/MenuItem.cs @@ -11,10 +11,10 @@ namespace ConsoleDraw.Inputs public class MenuItem : Input { private String Text = ""; - private ConsoleColor TextColour = ConsoleColor.White; - private ConsoleColor BackgroudColour = ConsoleColor.DarkGray; - private ConsoleColor SelectedTextColour = ConsoleColor.Black; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; + public ConsoleColor TextColour = ConsoleColor.White; + public ConsoleColor BackgroudColour = ConsoleColor.DarkGray; + public ConsoleColor SelectedTextColour = ConsoleColor.Black; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.Gray; private bool Selected = false; public Action Action; diff --git a/Source/ConsoleDraw/Inputs/ProgressBar.cs b/Source/ConsoleDraw/Inputs/ProgressBar.cs index 97fefa7..3fc89dc 100644 --- a/Source/ConsoleDraw/Inputs/ProgressBar.cs +++ b/Source/ConsoleDraw/Inputs/ProgressBar.cs @@ -40,6 +40,7 @@ public override void Draw() WindowManager.WirteText("".PadRight(widthCompleted, '█'), Xpostion, Ypostion, BarColour, BackgroundColour); + WindowManager.WirteText("".PadRight(widthUncompleted, '▒'), Xpostion, Ypostion + widthCompleted, BarColour, BackgroundColour); } diff --git a/Source/ConsoleDraw/Inputs/RadioButton.cs b/Source/ConsoleDraw/Inputs/RadioButton.cs index 514d2f6..39e61b7 100644 --- a/Source/ConsoleDraw/Inputs/RadioButton.cs +++ b/Source/ConsoleDraw/Inputs/RadioButton.cs @@ -11,10 +11,10 @@ namespace ConsoleDraw.Inputs public class RadioButton : Input { public ConsoleColor BackgroundColour = ConsoleColor.Gray; - private ConsoleColor TextColour = ConsoleColor.Black; + public ConsoleColor TextColour = ConsoleColor.Black; - private ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; - private ConsoleColor SelectedTextColour = ConsoleColor.White; + public ConsoleColor SelectedBackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor SelectedTextColour = ConsoleColor.White; private bool Selected = false; public bool Checked = false; diff --git a/Source/ConsoleDraw/Inputs/TextArea.cs b/Source/ConsoleDraw/Inputs/TextArea.cs index 51b9735..892855f 100644 --- a/Source/ConsoleDraw/Inputs/TextArea.cs +++ b/Source/ConsoleDraw/Inputs/TextArea.cs @@ -37,7 +37,7 @@ private String Text { } private String TextWithoutNewLine { get { return RemoveNewLine(Text); } } - private ConsoleColor TextColour = ConsoleColor.White; + public ConsoleColor TextColour = ConsoleColor.White; public ConsoleColor BackgroundColour = ConsoleColor.Blue; private Cursor cursor = new Cursor(); diff --git a/Source/ConsoleDraw/Inputs/TextBox.cs b/Source/ConsoleDraw/Inputs/TextBox.cs index 832001a..930fdcc 100644 --- a/Source/ConsoleDraw/Inputs/TextBox.cs +++ b/Source/ConsoleDraw/Inputs/TextBox.cs @@ -18,8 +18,8 @@ public class TextBox : Input private int Offset = 0; private String Text = ""; - private ConsoleColor TextColour = ConsoleColor.White; - private ConsoleColor BackgroundColour = ConsoleColor.DarkGray; + public ConsoleColor TextColour = ConsoleColor.White; + public ConsoleColor BackgroundColour = ConsoleColor.DarkGray; private Cursor cursor = new Cursor(); diff --git a/Source/ConsoleDraw/WindowManager.cs b/Source/ConsoleDraw/WindowManager.cs index 03b3649..7263020 100644 --- a/Source/ConsoleDraw/WindowManager.cs +++ b/Source/ConsoleDraw/WindowManager.cs @@ -44,6 +44,10 @@ public static void WirteText(String text, int startX, int startY, ConsoleColor t public static void SetupWindow() { +#if NETSTANDARD2_0 + if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { +#endif startingBufferHeight = Console.BufferHeight; var whereToMove = Console.CursorTop + 1; //Move one line below visible @@ -54,7 +58,9 @@ public static void SetupWindow() Console.BufferHeight = whereToMove + Console.WindowHeight; Console.MoveBufferArea(0, 0, Console.WindowWidth, Console.WindowHeight, 0, whereToMove); - +#if NETSTANDARD2_0 + } +#endif Console.CursorVisible = false; startingX = Console.CursorTop; startingY = Console.CursorLeft; @@ -70,6 +76,11 @@ public static void EndWindow() Console.ForegroundColor = startingForegroundColour; Console.BackgroundColor = startingBackgroundColour; +#if NETSTANDARD2_0 + if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { +#endif + var whereToGet = startingX + 1; //Move one line below visible if (whereToGet < Console.WindowHeight) //If cursor is not on bottom line of visible whereToGet = Console.WindowHeight + 1; @@ -80,16 +91,23 @@ public static void EndWindow() Console.CursorVisible = true; Console.BufferHeight = startingBufferHeight; - //Console.WriteLine(); + +#if NETSTANDARD2_0 + } +#endif } public static void UpdateWindow(int width, int height) { Console.CursorVisible = false; - +#if NETSTANDARD2_0 + if(System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { +#endif if (width > Console.BufferWidth) //new Width is bigger then buffer { + Console.BufferWidth = width; Console.WindowWidth = width; } @@ -109,7 +127,9 @@ public static void UpdateWindow(int width, int height) Console.WindowHeight = height; Console.BufferHeight = height; } - +#if NETSTANDARD2_0 + } +#endif Console.BackgroundColor = ConsoleColor.Gray; WindowManager.DrawColourBlock(Console.BackgroundColor, 0, 0, Console.WindowHeight, Console.WindowWidth); //Flush Buffer } diff --git a/Source/ConsoleDraw/Windows/Base/PopupWindow.cs b/Source/ConsoleDraw/Windows/Base/PopupWindow.cs index ce5d5c3..e441af3 100644 --- a/Source/ConsoleDraw/Windows/Base/PopupWindow.cs +++ b/Source/ConsoleDraw/Windows/Base/PopupWindow.cs @@ -8,10 +8,10 @@ namespace ConsoleDraw.Windows.Base { public class PopupWindow : Window { - protected String Title; + public String Title; - protected ConsoleColor TitleBarColour = ConsoleColor.DarkGray; - protected ConsoleColor TitleColour = ConsoleColor.Black; + public ConsoleColor TitleBarColour = ConsoleColor.DarkGray; + public ConsoleColor TitleColour = ConsoleColor.Black; public PopupWindow(String title, int postionX, int postionY, int width, int height, Window parentWindow) : base(postionX, postionY, width, height, parentWindow) diff --git a/Source/TestAppCore/Program.cs b/Source/TestAppCore/Program.cs index 6ca3cf8..5521bd0 100644 --- a/Source/TestAppCore/Program.cs +++ b/Source/TestAppCore/Program.cs @@ -10,7 +10,6 @@ static void Main(string[] args) { //Setup WindowManager.UpdateWindow(100, 48); - WindowManager.UpdateWindow(100, 48); WindowManager.SetWindowTitle("Test App"); new MainWindow(); diff --git a/Source/TestAppCore/TestAppCore.csproj b/Source/TestAppCore/TestAppCore.csproj index c83bb0a..17d9667 100644 --- a/Source/TestAppCore/TestAppCore.csproj +++ b/Source/TestAppCore/TestAppCore.csproj @@ -3,6 +3,7 @@ Exe netcoreapp2.0 + linux-arm diff --git a/Source/TestAppCore/Windows/SettingsWindow.cs b/Source/TestAppCore/Windows/SettingsWindow.cs index 632f284..eee5aaf 100644 --- a/Source/TestAppCore/Windows/SettingsWindow.cs +++ b/Source/TestAppCore/Windows/SettingsWindow.cs @@ -16,7 +16,7 @@ public SettingsWindow(Window parentWindow) BackgroundColour = ConsoleColor.White; var appTitleLabel = new Label("App Title", 8, 12, "appTitleLabel", this); - var appTitleTxtBox = new TextBox(8, 25, Console.Title, "appTitleTxtBox", this, 10); + var appTitleTxtBox = new TextBox(8, 25, "Test Application", "appTitleTxtBox", this, 10); var saveOnExitLabel = new Label("Save On Exit", 10, 12, "saveOnExitLabel", this); var saveOneExitChkBox = new CheckBox(10, 25, "saveOnExitCheckBox", this);