public static void Main(string [] args) { Application.Init(); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Close", "", () => Close()), new MenuItem("_Quit", "", () => { Application.RequestStop(); }) }), new MenuBarItem("_Edit", new MenuItem [] { new MenuItem("_Copy", "", null), new MenuItem("C_ut", "", null), new MenuItem("_Paste", "", null) }), }); var login = new Label("Login: "******"Password: "******"") { X = Pos.Right(password), Y = Pos.Top(login), Width = 40, ColorScheme = new ColorScheme() { Focus = Attribute.Make(Color.BrightYellow, Color.DarkGray), Normal = Attribute.Make(Color.Green, Color.BrightYellow), HotFocus = Attribute.Make(Color.BrightBlue, Color.Brown), HotNormal = Attribute.Make(Color.Red, Color.BrightRed), }, }; var passText = new TextField("") { Secret = true, X = Pos.Left(loginText), Y = Pos.Top(password), Width = Dim.Width(loginText) }; surface.Add(login, password, loginText, passText); Application.Top.Add(menu, surface); Application.Run(); }
public GGPackExplorerWindow(GGPack pack) : base("GGPack Explorer") { Width = Dim.Fill(); Y = 1; Height = Dim.Fill(); _pack = pack; var entries = _pack.Entries.Select(e => e.Name).ToList(); _listViewEntries = new ListView(entries) { Width = Dim.Percent(50), Height = Dim.Fill() }; _detailView = new TextView { X = Pos.Percent(50), Width = Dim.Fill(), Height = Dim.Fill(), Text = string.Empty, }; _listViewEntries.SelectedChanged += OnSelectedChanged; Add(_listViewEntries, _detailView); OnSelectedChanged(); }
private void DrawResults() { resultBlock = new ResultView("Result", ScriptBlockRunner.ScriptBlock.LastResult?.FilteredResult) { X = 0, Y = Pos.Percent(0) + 2, Width = this.Width, Height = Dim.Percent(30) }; Add(resultBlock); warningBlock = new ResultView("Warnings", ScriptBlockRunner.ScriptBlock.LastResult?.Warninings) { X = 0, Y = Pos.Percent(30) + 1, Width = this.Width, Height = Dim.Percent(45) }; Add(warningBlock); ErrorBlock = new ResultView("Errors", ScriptBlockRunner.ScriptBlock.LastResult?.Errors) { X = 0, Y = Pos.Percent(60) + 1, Width = this.Width, Height = Dim.Percent(90) }; Add(ErrorBlock); }
private static void SetupChampionList() { var championListWindow = new FrameView("Champions") { X = Pos.Percent(0), Y = Pos.Percent(10) + 1, // Leave place for top level menu and Summoner search // By using Dim.Fill(), it will automatically resize without manual intervention Width = Dim.Percent(20), Height = Dim.Fill() }; ChampionsView = championListWindow; var championsListView = new ListView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; championsListView.AllowsMultipleSelection = true; championsListView.AllowsMarking = true; championsListView.SetSource(LeagueUtilities.GetChampionListElements()); ChampionsListView = championsListView; ChampionsView.Add(championsListView); }
/// <summary> /// Starts this instance. /// </summary> public void Start() { if (IsStarted) { return; } IsStarted = true; dialog = new Dialog(applicationName, toplevel.Frame.Width - 2, toplevel.Frame.Height - 1); progress = new ProgressBar() { X = Pos.Center(), Y = Pos.Center(), Height = 1, Width = Dim.Percent(50), }; label = new Label(initialText) { X = Pos.Center(), Y = Pos.Center() + 1, Height = 1, Width = Dim.Percent(50) }; dialog.Add(progress, label); runState = Application.Begin(dialog); Application.RunLoop(runState, false); }
public OKBox(string question) : base("TextInputBox") { X = Pos.Center(); Y = Pos.Center(); Width = Dim.Percent(40); Height = Dim.Percent(20); ColorScheme = Colors.Menu; lbl = new(question) { Width = Dim.Fill(), Y = 1, TextAlignment = TextAlignment.Centered }; ok = new("OK") { X = Pos.Center(), Y = 5 }; ok.Clicked += () => { OkClicked?.Invoke(this, null); }; Add(lbl, ok); } }}
private void UpdateRoomFrame() { var room = World.Player.CurrentLocation; _roomContentsObjects = new List <IHasStats>(); _roomContentsObjects.Add(room); if (room.ControllingFaction != null) { _roomContentsObjects.Add(room.ControllingFaction); } _roomContentsObjects.AddRange(World.Player.GetCurrentLocationSiblings(true)); _roomContentsObjects.AddRange(World.Player.CurrentLocation.Items); if (_roomContents != null) { Remove(_roomContents); _roomContents.SelectedChanged -= UpdateDetailPane; } //use a scroll view _roomContentsRenderer.SetCollection(_roomContentsObjects); _roomContents = new ListView(_roomContentsRenderer) { X = Pos.Percent(70), Width = Dim.Fill(), Height = Dim.Percent(75) }; _roomContents.SelectedChanged += UpdateDetailPane; Add(_roomContents); }
public void Dim_Validation_Do_Not_Throws_If_NewValue_Is_DimAbsolute_And_OldValue_Is_Another_Type_After_Sets_To_LayoutStyle_Absolute() { Application.Init(new FakeDriver(), new FakeMainLoop(() => FakeConsole.ReadKey(true))); var t = Application.Top; var w = new Window("w") { Width = Dim.Fill(0), Height = Dim.Sized(10) }; var v = new View("v") { Width = Dim.Width(w) - 2, Height = Dim.Percent(10) }; w.Add(v); t.Add(w); t.Ready += () => { v.LayoutStyle = LayoutStyle.Absolute; Assert.Equal(2, v.Width = 2); Assert.Equal(2, v.Height = 2); }; Application.Iteration += () => Application.RequestStop(); Application.Run(); Application.Shutdown(); }
public LogWindow() : base("Log") { X = 0; Y = 1; Width = Dim.Percent(60); Height = Dim.Fill(); Add(items = new ListView(keys) { X = 0, Y = 0, Width = Dim.Sized(20), Height = Dim.Fill(), CanFocus = true, }); items.SelectedChanged += () => { Console.WriteLine("CHANGE!"); }; logView = new TextView() { X = 20, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), CanFocus = false }; Add(logView); keys.Add("Test"); }
private static void SetupSummonerSearchView() { var summonerSearchInfoWindow = new FrameView("Find summoner") { X = Pos.Percent(0), Y = 1, // Leave place for top level menu and Summoner search // By using Dim.Fill(), it will automatically resize without manual intervention Width = Dim.Fill(), Height = Dim.Percent(10) + 1 }; UsernameTextField = new TextField("") { X = Pos.Center(), Y = Pos.Percent(3), Width = 30, Height = 1 }; summonerSearchInfoWindow.Add(UsernameTextField); var searchSummoner = new Button("Search") { X = Pos.Center() + 30, Y = Pos.Percent(3) }; searchSummoner.Clicked += SearchButtonClickedHandler; summonerSearchInfoWindow.Add(searchSummoner); SummonerSearchView = summonerSearchInfoWindow; }
static void LoadFile() { OpenDialog openFileDialog = new OpenDialog("Select File", "Select a *.cdb file to open"); openFileDialog.Height = Dim.Percent(70f); openFileDialog.Width = Dim.Percent(70f); openFileDialog.AllowedFileTypes = new string[] { ".cdb" }; openFileDialog.AllowsMultipleSelection = false; openFileDialog.CanChooseDirectories = false; openFileDialog.CanChooseFiles = true; Application.Run(openFileDialog); List <string> files = new List <string>(openFileDialog.FilePaths); if (files.Count < 1) { PrintStatus("No file was selected to open.", StatusLevel.Error); return; } RookDB loadedDB = new RookDB(System.IO.File.ReadAllText(files[0]), files[0]); if (loadedDB.IsValid()) { currDB = loadedDB; currTableView.Source = new EditorListRenderer(currDB.tables.First().Value); columnHeaders.UpdateColumns(currDB.tables.First().Value.columns.ToArray()); UpdateWindowName(); UpdateTableDisplay(); PrintStatus("Loaded database: " + loadedDB.filename, StatusLevel.Default); } else { PrintStatus("Could not load database, file was invalid.", StatusLevel.Error); } }
public override void ConfigureSettingsPane() { SettingsPane = new FrameView("Settings") { X = Pos.Right(LeftPane), Y = 1, // for menu Width = Dim.Fill(), Height = 8, CanFocus = false, ColorScheme = Colors.TopLevel, }; _deviceDetailsFrame = new FrameView("Device Details") { X = 0, Y = 0, Height = 6, Width = Dim.Percent(50), }; SettingsPane.Add(_deviceDetailsFrame); _deviceLocationFrame = new FrameView("Device Location") { X = Pos.Right(_deviceDetailsFrame), Y = Pos.Y(_deviceDetailsFrame), Height = 6, Width = Dim.Percent(50), }; SettingsPane.Add(_deviceLocationFrame); ConfigureHostPane(""); }
public TextCheckBox(string question, params ustring[] labels) : base("TextCheckBox") { var str = ""; X = Pos.Center(); Y = Pos.Center(); Width = Dim.Percent(40); Height = Dim.Percent(20); ColorScheme = Colors.Menu; lbl = new(question) { Width = Dim.Fill(), Y = 1, TextAlignment = TextAlignment.Centered }; input = new(labels) { Width = Dim.Fill(), Y = 3 }; ok = new("OK") { X = Pos.Center(), Y = 5 }; ok.Clicked += () => { OkClicked?.Invoke(this, input.SelectedItem); }; Add(lbl, input, ok); }
public WorkerApp() { Data = "WorkerApp"; Width = Dim.Percent(80); Height = Dim.Percent(50); ColorScheme = Colors.Base; var label = new Label("Worker collection Log") { X = Pos.Center(), Y = 0 }; Add(label); listLog = new ListView(log) { X = 0, Y = Pos.Bottom(label), Width = Dim.Fill(), Height = Dim.Fill() }; Add(listLog); }
public override void Setup() { var s = "This is a test intended to show how TAB key works (or doesn't) across text fields."; Win.Add(new TextField(s) { X = 5, Y = 1, Width = Dim.Percent(80), ColorScheme = Colors.Dialog }); var textView = new TextView() { X = 5, Y = 3, Width = Dim.Percent(80), Height = Dim.Percent(40), ColorScheme = Colors.Dialog }; textView.Text = s; Win.Add(textView); // BUGBUG: 531 - TAB doesn't go to next control from HexView var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))) { X = 5, Y = Pos.Bottom(textView) + 1, Width = Dim.Percent(80), Height = Dim.Percent(40), ColorScheme = Colors.Dialog }; Win.Add(hexView); var dateField = new DateField(System.DateTime.Now) { X = 5, Y = Pos.Bottom(hexView) + 1, Width = Dim.Percent(40), ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(dateField); var timeField = new TimeField(System.DateTime.Now) { X = Pos.Right(dateField) + 5, Y = Pos.Bottom(hexView) + 1, Width = Dim.Percent(40), ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(timeField); }
public void Percent_ThrowsOnIvalid() { var dim = Dim.Percent(0); Assert.Throws <ArgumentException> (() => dim = Dim.Percent(-1)); Assert.Throws <ArgumentException> (() => dim = Dim.Percent(101)); Assert.Throws <ArgumentException> (() => dim = Dim.Percent(100.0001F)); Assert.Throws <ArgumentException> (() => dim = Dim.Percent(1000001)); }
View CreateClass(Type type) { // Instantiate view var view = (View)Activator.CreateInstance(type); //_curView.X = Pos.Center (); //_curView.Y = Pos.Center (); view.Width = Dim.Percent(75); view.Height = Dim.Percent(75); // Set the colorscheme to make it stand out view.ColorScheme = Colors.Base; // If the view supports a Text property, set it so we have something to look at if (view.GetType().GetProperty("Text") != null) { try { view.GetType().GetProperty("Text")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Text") }); } catch (TargetInvocationException e) { MessageBox.ErrorQuery("Exception", e.InnerException.Message, "Ok"); view = null; } } // If the view supports a Title property, set it so we have something to look at if (view != null && view.GetType().GetProperty("Title") != null) { view?.GetType().GetProperty("Title")?.GetSetMethod()?.Invoke(view, new [] { ustring.Make("Test Title") }); } // If the view supports a Source property, set it so we have something to look at if (view != null && view.GetType().GetProperty("Source") != null && view.GetType().GetProperty("Source").PropertyType == typeof(Terminal.Gui.IListDataSource)) { var source = new ListWrapper(new List <ustring> () { ustring.Make("Test Text #1"), ustring.Make("Test Text #2"), ustring.Make("Test Text #3") }); view?.GetType().GetProperty("Source")?.GetSetMethod()?.Invoke(view, new [] { source }); } // Set Settings _computedCheckBox.Checked = view.LayoutStyle == LayoutStyle.Computed; // Add _hostPane.Add(view); //DimPosChanged (); _hostPane.LayoutSubviews(); _hostPane.Clear(); _hostPane.SetNeedsDisplay(); UpdateSettings(view); UpdateTitle(view); view.LayoutComplete += LayoutCompleteHandler; return(view); }
public override void Setup() { List <string> items = new List <string> (); foreach (var dir in new [] { "/etc", @"\windows\System32" }) { if (Directory.Exists(dir)) { items = Directory.GetFiles(dir).Union(Directory.GetDirectories(dir)) .Select(Path.GetFileName) .Where(x => char.IsLetterOrDigit(x [0])) .OrderBy(x => x).ToList(); } } // ListView var lbListView = new Label("Listview") { ColorScheme = Colors.TopLevel, X = 0, Width = 30 }; var listview = new ListView(items) { X = 0, Y = Pos.Bottom(lbListView) + 1, Height = Dim.Fill(2), Width = 30 }; listview.OpenSelectedItem += (ListViewItemEventArgs e) => lbListView.Text = items [listview.SelectedItem]; Win.Add(lbListView, listview); // ComboBox var lbComboBox = new Label("ComboBox") { ColorScheme = Colors.TopLevel, X = Pos.Right(lbListView) + 1, Width = Dim.Percent(60) }; var comboBox = new ComboBox() { X = Pos.Right(listview) + 1, Y = Pos.Bottom(lbListView) + 1, Height = Dim.Fill(2), Width = Dim.Percent(60) }; comboBox.SetSource(items); comboBox.SelectedItemChanged += (object sender, ustring text) => lbComboBox.Text = text; Win.Add(lbComboBox, comboBox); }
/// <summary> /// Initializes a new instance of the <see cref="ConsoleForm"/> class. /// </summary> public ConsoleForm() : base() { viewSiteManager = new ViewSiteManager(); Width = Dim.Percent(100); Height = Dim.Percent(100); X = 0; Y = 0; MenuBar = new XafMenuBar { X = 0, Y = 0, Width = Dim.Percent(100), Height = 1 }; ConsoleWindow = new WindowEx("") { Width = Dim.Percent(100), Height = Dim.Percent(100), X = 0, Y = 1, }; ActionContainerExit = new XafMenuBarActionContainer(MenuBar, "Exit") { ActionCategory = "Exit" }; MenuBar.ActionContainers.Add(ActionContainerExit); NavBarActionControlContainer = new NavBarActionControlContainer { ActionCategory = NavigationHelper.DefaultContainerId, ParentView = ConsoleWindow, }; ConsoleWindow.Load += ConsoleWindow_Load; var viewSiteControl = new View() { X = 20, Y = 0, Height = Dim.Percent(100), Width = Dim.Percent(80) }; viewSiteManager.ViewSiteControl = viewSiteControl; ConsoleWindow.Add(viewSiteControl); Add(MenuBar, ConsoleWindow); }
public virtual void ConfigureLeftPane(string title) { LeftPane = new Window(title) { X = 0, Y = 1, Width = Dim.Percent(25), Height = Dim.Fill(), CanFocus = false, ColorScheme = Colors.TopLevel, }; }
private void AddWorkspaceWindow(Toplevel top) { _workspaceWindow = new Window("Workspace") { X = 0, Y = 1, Width = 15, Height = Dim.Percent(30) }; top.Add(_workspaceWindow); AddWorkSpaceMenu(_workspaceWindow); }
public Toplevel Top() { var top = new Toplevel() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; var win = new Window(Name) { X = 0, Y = 0, Width = Dim.Percent(90), Height = Dim.Percent(90) }; var scroll = new ScrollView(new Rect(0, 0, 10, 10)) { ColorScheme = new ColorScheme() { Normal = new Terminal.Gui.Attribute(Color.Brown) } }; var scroller = new ScrollBarView(new Rect(0, 0, 10, 10), 2, 4, true); Application.Iteration += (s, e) => { scroll.Frame = new Rect(0, 0, win.Frame.Width - 2, win.Frame.Height - 2); scroll.ContentSize = new Size(win.Frame.Width - 2, win.Frame.Height - 2); scroller.X = Pos.Right(win); scroller.Y = 0; scroll.Height = Dim.Percent(90); }; List <string> data = Enumerable.Range(0, 100).Select(a => Guid.NewGuid().ToString()).ToList(); var list = new ListView(data); scroll.Add(list); //win.Add(list); win.Add(scroll); var operations = CreateOperationsView(top, win); top.Add(win, operations, scroller); return(top); }
private void InitTime() { timeFrame.X = Pos.Percent(30); timeFrame.Y = 3; timeFrame.Width = Dim.Percent(43); timeFrame.Height = Dim.Fill(); timeListView.CanFocus = true; timeFrame.Add(timeListView); this.Add(timeFrame); }
static Dialog BuildUninstallServiceDialog() { var cancel = new Button("Cancel"); cancel.Clicked += () => { Application.RequestStop(); }; Dialog dlg = new Dialog("Uninstall service", 50, 15, cancel) { Width = Dim.Percent(80), Height = Dim.Percent(80) }; ServiceController[] scServices; scServices = ServiceController.GetServices(); var jsdalLikeServices = scServices.Where(sc => sc.ServiceName.ToLower().Contains("jsdal")).ToList(); var items = jsdalLikeServices.Select(s => $"({s.Status}) {s.DisplayName}").ToArray(); dlg.Add(new Label(1, 1, "Select a jsdal service to uninstall:")); for (var i = 0; i < items.Length; i++) { var local = i; var but = new Button(1, 3 + i, items[i]); but.Clicked += () => { var service = jsdalLikeServices[local]; int ret = MessageBox.Query(80, 10, "Confirm action", $"Are you sure you want to uninstall '{service.ServiceName}'?", "Confirm", "Cancel"); if (ret == 0) { ManagementObject wmiService; wmiService = new ManagementObject("Win32_Service.Name='" + service.ServiceName + "'"); wmiService.Get(); wmiService.Delete(); MessageBox.Query(30, 8, "", "Service uninstalled", "Ok"); Application.RequestStop(); } else if (ret == 1) { } }; dlg.Add(but); } return(dlg); }
public static Window Init() { _window.Add(content); _window.Width = Dim.Percent(80); _window.Height = Dim.Percent(80); _window.X = Pos.Center(); _window.Y = Pos.Center(); _window.Add(quit); return(_window); }
private void InitDate() { dateFrame.X = 0; dateFrame.Y = 3; dateFrame.Width = Dim.Percent(30); dateFrame.Height = Dim.Fill(); dateListView.CanFocus = true; dateListView.AllowsMarking = true; dateFrame.Add(dateListView); this.Add(dateFrame); }
public void Percent_SetsValue() { float f = 0; var dim = Dim.Percent(f); Assert.Equal($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString()); f = 0.5F; dim = Dim.Percent(f); Assert.Equal($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString()); f = 100; dim = Dim.Percent(f); Assert.Equal($"Dim.Factor(factor={f / 100:0.###}, remaining={false})", dim.ToString()); }
public override void Setup() { Win.Title = this.GetName(); Win.Y = 1; // menu Win.Height = Dim.Fill(1); // status bar Top.LayoutSubviews(); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Quit", "", () => Quit()), }) , new MenuBarItem("_View", new MenuItem [] { miShowPrivate = new MenuItem("_Include Private", "", () => ShowPrivate()) { Checked = false, CheckType = MenuItemCheckStyle.Checked }, new MenuItem("_Expand All", "", () => treeView.ExpandAll()), new MenuItem("_Collapse All", "", () => treeView.CollapseAll()) }), }); Top.Add(menu); treeView = new TreeView <object> () { X = 0, Y = 0, Width = Dim.Percent(50), Height = Dim.Fill(), }; treeView.AddObjects(AppDomain.CurrentDomain.GetAssemblies()); treeView.AspectGetter = GetRepresentation; treeView.TreeBuilder = new DelegateTreeBuilder <object> (ChildGetter, CanExpand); treeView.SelectionChanged += TreeView_SelectionChanged; Win.Add(treeView); textView = new TextView() { X = Pos.Right(treeView), Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; Win.Add(textView); }
public static void Init() { #region operation complete Complete.ColorScheme = new ColorScheme() { Normal = TGAttribute.Make(Color.Black, Color.BrightGreen), Focus = TGAttribute.Make(Color.Black, Color.BrightGreen), HotNormal = TGAttribute.Make(Color.Black, Color.BrightGreen), HotFocus = TGAttribute.Make(Color.Black, Color.BrightGreen) }; Complete.Width = 25; Complete.Height = 3; Complete.X = Pos.Center(); Complete.Y = Pos.Center(); Complete.Add(quitComplete); #endregion #region file info Extract.AllFiles.ColorScheme = Program.ArchivedList; Extract.AllFiles.Width = Dim.Percent(80); Extract.AllFiles.Height = Dim.Percent(80); Extract.AllFiles.X = Pos.Center(); Extract.AllFiles.Y = Pos.Center(); Extract.AllFiles.Add(Extract.infoLabel); Extract.AllFiles.Add(Extract.allFilesNext); Extract.AllFiles.Add(Extract.allFilesLast); Extract.AllFiles.Add(Extract.quitAllFiles); #endregion #region error Error.ColorScheme = new ColorScheme() { Normal = TGAttribute.Make(Color.White, Color.BrightRed), Focus = TGAttribute.Make(Color.White, Color.BrightRed), HotNormal = TGAttribute.Make(Color.White, Color.BrightRed), HotFocus = TGAttribute.Make(Color.White, Color.BrightRed) }; Error.Width = 50; Error.Height = Dim.Percent(50); Error.X = Pos.Center(); Error.Y = Pos.Center(); #endregion }
private static void SetupSummonerInfo() { var summonerInfoWindow = new FrameView("Summoner Information") { X = Pos.Percent(0), Y = Pos.Percent(10) + 1, // Leave place for top level menu and Summoner search // By using Dim.Fill(), it will automatically resize without manual intervention Width = Dim.Percent(35), Height = Dim.Fill() }; SummonerInfoView = summonerInfoWindow; }