示例#1
0
 public Button(int x, int y, String text, String iD, Window parentWindow)
     : base(x, y, 1, text.Count() + 2, parentWindow, iD)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColour;
     Selectable = true;
 }
示例#2
0
        public SaveMenu(String data, Window parentWindow)
            : base("Save Menu", 6, (Console.WindowWidth / 2) - 30, 60, 20, parentWindow)
        {
            Text = data;

            fileSelect = new FileBrowser(PostionX + 2, PostionY + 2, Width - 4, 13, FileInfo.Path, "fileSelect", this);

            var openLabel = new Label("Name", PostionX + 16, PostionY + 2, "openLabel", this);
            openTxtBox = new TextBox(PostionX + 16, PostionY + 7, FileInfo.Filename, "openTxtBox", this) { Selectable = true };

            saveBtn = new Button(PostionX + 18, PostionY + 2, "Save", "loadBtn", this);
            saveBtn.Action = delegate() { SaveFile(); };
            cancelBtn = new Button(PostionX + 18, PostionY + 9, "Cancel", "cancelBtn", this);
            cancelBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(fileSelect);
            Inputs.Add(openLabel);
            Inputs.Add(openTxtBox);
            Inputs.Add(saveBtn);
            Inputs.Add(cancelBtn);

            CurrentlySelected = saveBtn;

            Draw();
            MainLoop();
        }
示例#3
0
        public DropdownItem(String text, int x, String iD, Window parentWindow)
            : base(x, parentWindow.PostionY + 1, 1, parentWindow.Width - 2, parentWindow, iD)
        {
            Text = text;

            Selectable = true;
        }
示例#4
0
        public Resolution(Window parentWindow)
            : base("Change Resolution", 6, (Console.WindowWidth / 2) - 15, 30, 8, parentWindow)
        {
            var widthLabel = new Label("Width", PostionX + 2, PostionY + 2, "widthLabel", parentWindow) { BackgroundColour = ConsoleColor.Gray };
            widthTxtBox = new TextBox(PostionX + 2, PostionY + 10, Console.WindowWidth.ToString(), "widthTxtBox", this, 5);
            var widthMaxBtn = new Button(PostionX + 2, PostionY + 17, "Max", "widthMaxBtn", this);
            widthMaxBtn.Action = delegate() { widthTxtBox.SetText(Console.LargestWindowWidth.ToString()); };

            var heightLabel = new Label("Height", PostionX + 4, PostionY + 2, "widthLabel", parentWindow) { BackgroundColour = ConsoleColor.Gray };
            heightTxtBox = new TextBox(PostionX + 4, PostionY + 10, Console.WindowHeight.ToString(), "heightTxtBox", this, 5);
            var heightMaxBtn = new Button(PostionX + 4, PostionY + 17, "Max", "heighthMaxBtn", this);
            heightMaxBtn.Action = delegate() { heightTxtBox.SetText(Console.LargestWindowHeight.ToString()); };

            applyBtn = new Button(PostionX + 6, PostionY + 2, "Apply", "applyBtn", this);
            applyBtn.Action = delegate() { Apply(); };

            exitBtn = new Button(PostionX + 6, PostionY + 10, "Exit", "exitBtn", this);
            exitBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(widthLabel);
            Inputs.Add(widthTxtBox);
            Inputs.Add(widthMaxBtn);
            Inputs.Add(heightLabel);
            Inputs.Add(heightTxtBox);
            Inputs.Add(heightMaxBtn);
            Inputs.Add(applyBtn);
            Inputs.Add(exitBtn);

            CurrentlySelected = applyBtn;

            Draw();
            MainLoop();
        }
示例#5
0
 public Label(String text, int x, int y, String iD, Window parentWindow)
     : base(x, y, 1, text.Count(), parentWindow, iD)
 {
     Text = text;
     BackgroundColour = parentWindow.BackgroundColour;
     Selectable = false;
 }
示例#6
0
        public Alert(String Message, Window parentWindow, ConsoleColor backgroundColour, String Title)
            : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentWindow)
        {
            BackgroundColour = backgroundColour;

            Create(Message, parentWindow);
        }
示例#7
0
        private void Create(String Message, Window parentWindow)
        {
            var count = 0;
            while ((count*45) < Message.Count())
            {
                var splitMessage = Message.PadRight(textLength * (count + 1), ' ').Substring((count * textLength), textLength);
                var messageLabel = new Label(splitMessage, PostionX + 2 + count, PostionY + 2, "messageLabel", this);
                Inputs.Add(messageLabel);

                count++;
            }

            /*
            var messageLabel = new Label(Message, PostionX + 2, PostionY + 2, "messageLabel", this);
            messageLabel.BackgroundColour = BackgroundColour;*/

            okBtn = new Button(PostionX + Height - 2, PostionY + 2, "OK", "OkBtn", this);
            okBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(okBtn);

            CurrentlySelected = okBtn;

            Draw();
            MainLoop();
        }
示例#8
0
 public RadioButton(int x, int y, String iD, String radioGroup, Window parentWindow)
     : base(x, y, 1, 3, parentWindow, iD)
 {
     RadioGroup = radioGroup;
     BackgroundColour = parentWindow.BackgroundColour;
     Selectable = true;
 }
示例#9
0
        public MenuItem(String text, String iD, Window parentWindow)
            : base(0, 0, 1, 0, parentWindow, iD)
        {
            Text = text;

            Selectable = true;
        }
示例#10
0
        public LoadMenu(String path, Dictionary<String, String> fileTypes, Window parentWindow)
            : base("Load Menu", Math.Min(6, Console.WindowHeight - 22), (Console.WindowWidth / 2) - 30, 60, 20, parentWindow)
        {
            BackgroundColour = ConsoleColor.White;
            FileTypes = fileTypes;

            fileSelect = new FileBrowser(PostionX + 2, PostionY + 2, 56, 13, path, "fileSelect", this, true, "txt");
            fileSelect.ChangeItem = delegate() { UpdateCurrentlySelectedFileName(); };
            fileSelect.SelectFile = delegate() { LoadFile(); };

            var openLabel = new Label("Open", PostionX + 16, PostionY + 2, "openLabel", this);
            openTxtBox = new TextBox(PostionX + 16, PostionY + 7, "openTxtBox", this, Width - 13) { Selectable = false };

            fileTypeDropdown = new Dropdown(PostionX + 18, PostionY + 40, FileTypes.Select(x => x.Value).ToList(), "fileTypeDropdown", this, 17);
            fileTypeDropdown.OnUnselect = delegate() { UpdateFileTypeFilter(); };

            loadBtn = new Button(PostionX + 18, PostionY + 2, "Load", "loadBtn", this);
            loadBtn.Action = delegate() { LoadFile(); };
            cancelBtn = new Button(PostionX + 18, PostionY + 9, "Cancel", "cancelBtn", this);
            cancelBtn.Action = delegate() { ExitWindow(); };

            Inputs.Add(fileSelect);
            Inputs.Add(loadBtn);
            Inputs.Add(cancelBtn);
            Inputs.Add(openLabel);
            Inputs.Add(openTxtBox);
            Inputs.Add(fileTypeDropdown);

            CurrentlySelected = fileSelect;

            Draw();
            MainLoop();
        }
示例#11
0
        public Menu(String text, int x, int y, String iD, Window parentWindow)
            : base(x, y, 1, text.Count() + 2, parentWindow, iD)
        {
            Text = text;
            Xpostion = x;
            Ypostion = y;

            Selectable = true;
        }
示例#12
0
        public Window(int postionX, int postionY, int width, int height, Window parentWindow)
        {
            PostionY = postionY;
            PostionX = postionX;
            Width = width;
            Height = height;

            ParentWindow = parentWindow;
        }
示例#13
0
        public TextBox(int x, int y, String text, String iD, Window parentWindow, int length = 38)
            : base(x, y, 1, length, parentWindow, iD)
        {
            Text = text;

            CursorPostion = text.Length;

            Selectable = true;
        }
示例#14
0
        public Input(int xPostion, int yPostion, int height, int width, Window parentWindow, String iD)
        {
            ParentWindow = parentWindow;
            ID = iD;

            Xpostion = xPostion;
            Ypostion = yPostion;

            Height = height;
            Width = width;
        }
示例#15
0
        public FileBrowser(int x, int y, int width, int height, String path, String iD, Window parentWindow, bool includeFiles = false, string filterByExtension = "*")
            : base(x, y, height, width, parentWindow, iD)
        {
            CurrentPath = path;
            CurrentlySelectedFile = "";
            IncludeFiles = includeFiles;
            FilterByExtension = filterByExtension;
            Drives = Directory.GetLogicalDrives().ToList();

            GetFileNames();
            Selectable = true;
        }
示例#16
0
        public Dropdown(int x, int y, List<String> options, String iD, Window parentWindow, int length = 20)
            : base(x, y, 1, length - 2 + 3, parentWindow, iD)
        {
            Xpostion = x;
            Ypostion = y;
            Options = options;
            Text = Options.First();
            Length = length;
            BackgroudColour = parentWindow.BackgroundColour;

            Selectable = true;
        }
示例#17
0
        public MenuDropdown(int Xpostion, int Ypostion, List<MenuItem> menuItems, Window parentWindow)
            : base(Xpostion, Ypostion, 20, menuItems.Count() + 2, parentWindow)
        {
            for (var i = 0; i < menuItems.Count(); i++)
            {
                menuItems[i].ParentWindow = this;
                menuItems[i].Width = this.Width - 2;
                menuItems[i].Xpostion = Xpostion + i + 1;
                menuItems[i].Ypostion = this.PostionY + 1;
            }

            MenuItems = menuItems;

            Inputs.AddRange(MenuItems);

            CurrentlySelected = MenuItems.FirstOrDefault();

            BackgroundColour = ConsoleColor.DarkGray;
            Draw();
            MainLoop();
        }
示例#18
0
        public void LoadData(Window parent)
        {
            var fileTypes = new Dictionary<String, String>() {{"txt", "Text Document"}, {"*", "All Files"}};

            var loadMenu = new LoadMenu(fileTypes, parent);

            if (loadMenu.DataLoaded) //Data Load was successful
            {
                parent.ExitWindow();

                textArea.SetText(loadMenu.Data);
                fileLabel.SetText(' ' + loadMenu.FileNameLoaded + ' ');

                Draw();

                FileInfo.Filename = loadMenu.FileNameLoaded;
                FileInfo.Path = loadMenu.PathOfLoaded;
                FileInfo.HasChanged = false;

                SelectItemByID("textArea");
            }
        }
示例#19
0
        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();
        }
示例#20
0
        public DropdownSpread(int Xpostion, int Ypostion, List<String> options, Window parentWindow, Dropdown root)
            : base(Xpostion, Ypostion, 20, options.Count(), parentWindow)
        {
            for (var i = 0; i < options.Count(); i++)
            {
                var item = new DropdownItem(options[i], Xpostion + i, "option" + i, this);

                item.Action = delegate() {
                    root.Text = ((DropdownItem)CurrentlySelected).Text;
                    root.Draw();
                };

                DropdownItems.Add(item);
            }

            Inputs.AddRange(DropdownItems);

            CurrentlySelected = DropdownItems.FirstOrDefault(x => x.Text == root.Text);

            BackgroundColour = ConsoleColor.DarkGray;
            Draw();
            MainLoop();
        }
示例#21
0
        public void NewFile(Window parent)
        {
            if (FileInfo.HasChanged)
            {
                var saveCheck = new Confirm(parent, "You have unsaved changes! Do you wish to save?", "Save");
                if (saveCheck.Result) //User wishs to save
                {
                    if (!SaveData(parent)) //Save was cancelled
                        return;
                }
            }

            FileInfo.Filename = "Untitled.txt";
            FileInfo.HasChanged = false;

            textArea.SetText("");
            fileLabel.SetText(FileInfo.Filename);

            parent.ExitWindow();
            SelectItemByID("textArea");

            Draw();
        }
示例#22
0
 public TextArea(int x, int y, int width, int height, String iD, Window parentWindow)
     : base(x, y, height, width, parentWindow, iD)
 {
     Selectable = true;
 }
示例#23
0
 public CheckBox(int x, int y, String iD, Window parentWindow)
     : base(x, y, 1, 3, parentWindow, iD)
 {
     BackgroundColour = parentWindow.BackgroundColour;
      Selectable = true;
 }
示例#24
0
        public Boolean SaveData(Window parent)
        {
            var saveMenu = new SaveMenu(textArea.GetText(), parent);

            if (saveMenu.FileWasSaved) //Data Save was successful
            {
                parent.ExitWindow();

                fileLabel.SetText(' ' + saveMenu.FileSavedAs + ' ');

                Draw();

                FileInfo.Filename = saveMenu.FileSavedAs;
                FileInfo.Path = saveMenu.PathToFile;
                FileInfo.HasChanged = false;

                SelectItemByID("textArea");
            }

            return saveMenu.FileWasSaved;
        }
示例#25
0
        private void ExitApp(Window parent)
        {
            if (FileInfo.HasChanged)
            {
                var saveCheck = new Confirm(parent, "You have unsaved changes! Do you wish to save?", "Save");
                if (saveCheck.Result) //User wishs to save
                {
                    if (!SaveData(parent)) //Save was cancelled
                        return;
                }
            }

            var exitCheck = new Confirm(parent, "Are you sure you wish to Exit?", "Exit");
            if (!exitCheck.Result)
                return;

            ProgramInfo.ExitProgram = true;
        }
示例#26
0
 public PopupWindow(String title, int postionX, int postionY, int width, int height, Window parentWindow)
     : base(postionX, postionY, width, height, parentWindow)
 {
     Title = title;
 }
示例#27
0
 public Confirm(Window parentWindow, String Message, String Title = "Confirm")
     : base(Title, 6, (Console.WindowWidth / 2) - 25, 50, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentWindow)
 {
     Create(Message, parentWindow);
 }
示例#28
0
 public Alert(String Message, Window parentWindow, String Title)
     : base(Title, 6, (Console.WindowWidth / 2) - 30, 25, 5 + (int)Math.Ceiling(((Double)Message.Count() / textLength)), parentWindow)
 {
     Create(Message, parentWindow);
 }
示例#29
0
 public FullWindow(int postionX, int postionY, int width, int height, Window parentWindow)
     : base(postionX, postionY, width, height, parentWindow)
 {
     BackgroundColour = ConsoleColor.Gray;
 }
示例#30
0
 public TextBox(int x, int y, String iD, Window parentWindow, int length = 38)
     : base(x, y, 1, length, parentWindow, iD)
 {
     Selectable = true;
 }