Task ITvisionAppStartup.Startup(ITuiEngine tui) { var skin = _skinManager.CurrentSkin; var lbl = new TvLabel(skin, new Viewport(new TvPoint(0, 0), 2, 1, 0), new LabelState() { Text = "label", }); lbl.Viewport.MoveTo(new TvPoint(4, 3)); tui.UI.Add(lbl); var check = new TvCheckbox(skin, new Viewport(new TvPoint(0, 0), 10, 1, 0), new CheckboxState()); check.Viewport.MoveTo(new TvPoint(8, 7)); tui.UI.Add(check); var button = new TvButton(skin, new Viewport(new TvPoint(0, 0), 4, 1, 0), new ButtonState() { Text = "btn" }); button.Viewport.MoveTo(new TvPoint(4, 6)); button.Viewport.Grow(4, 0); button.OnClick = new DelegateCommand <ButtonState>(async s => { lbl.State.Text = "F**k yeah!"; check.State.Checked = TvCheckboxState.Checked; }); button.AsComponent().AddViewport(new Viewport(new TvPoint(7, 8), 10)); tui.UI.Add(button); var textbox = new TvTextbox(skin, new Viewport(new TvPoint(12, 9), 8, 1, 0), new TextboxState()); tui.UI.Add(textbox); //await Task.Delay(6000); //button.State.Text = "---Uuuups"; return(Task.CompletedTask); }
public DialogManager(ISkinManager skinManager, ITuiEngine engine) { _skinManager = skinManager; _ui = engine.UI; _outsideDialogControls = new List <TvControlMetadata>(); }
Task ITvisionAppStartup.Startup(ITuiEngine tui) { var skin = _skinManager.CurrentSkin; var dvpf = _layoutManager.DynamicViewportFactory; var mainStackPanel = new TvStackPanel(tui.UI, "mainStackPanel"); mainStackPanel.AsComponent().AddViewport(dvpf.Create(vpf => vpf.FullViewport().Translate(new TvPoint(0, 1)).Grow(0, -3))); mainStackPanel.Layout.Add("*", "3"); var listFilesGrid = new TvGrid(tui.UI, new GridState(1, 2)); mainStackPanel.At(0).Add(listFilesGrid); tui.UI.Add(mainStackPanel); // TODO: Implement BorderedPanel // mainStackPanel.At(1).Add(new BorderedPanel()); var textbox = new TvTextbox(skin, null, new TextboxState()); //var left = new TvList<FileItem>(skin, new Viewport(new TvPoint(0, 0), 10, 1, 0), // new ListState<FileItem>(Enumerable.Empty<FileItem>(), f => new TvListItem() { Text = f.Name })); var actind = new TvActivityIndicator(skin, new Viewport(new TvPoint(0, 22), 1, 1, 0) , new ActivityIndicatorState()); tui.UI.Add(actind); var left = new TvList <FileItem>(skin, new Viewport(new TvPoint(0, 0), 10, 1, 0), ListState <FileItem> .From(Enumerable.Empty <FileItem>()) .AddFixedColumn(fi => fi.IsDirectory ? "*" : " ", width: 2) .AddColumn(fi => fi.Name) .Build()); left.StyleProvider .Use(Core.Colors.TvColor.Red, Core.Colors.TvColor.Blue) .When(f => (f.FileAttributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden) .AppliesToColumn(1); var right = new TvList <FileItem>(skin, new Viewport(new TvPoint(0, 0), 10, 1, 0), new ListState <FileItem>(Enumerable.Empty <FileItem>(), new TvListColumnSpec <FileItem>() { Transformer = f => f.Name })); right.StyleProvider .Use(Core.Colors.TvColor.Red, Core.Colors.TvColor.Blue) .When(f => (f.FileAttributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden) .AppliesToColumn(1); var menu = new TvMenuBar(skin, dvpf.Create(vpf => vpf.FullViewport().TakeRows(1, 0)), new MenuBarState(new[] { "Left", "Edit", "Command", "Options", "Help", "Right" }), opt => { opt.ItemsSpacedBy(4); }); //var window = new TvWindow(skin, vpf.FullViewport().CreateCentered(20, 10), new WindowState(tui.UI)); //var label = new TvLabel(skin, new Viewport(new TvPoint(0, 0), 9, 1, 0), new LabelState() { Text = "In Window" }); //window.State.UI.Add(label); var label = new TvLabel(skin, new Viewport(new TvPoint(0, 0), 9, 1, 0), new LabelState() { Text = "In Window" }); var dialog = _dialogManager.CreateDialog(dvpf.Create(vpf => vpf.FullViewport().CreateCentered(20, 10)), d => { d.State.UI.Add(label); }); var sleft = TvStatexControl.Wrap <TvList <FileItem>, ListState <FileItem>, FileList>(left, opt => { opt.UseStore("left"); opt.UseStatexTransformation((fl, cs) => { cs.Clear(); cs.AddRange(fl.Items); }); opt.On(c => c.OnItemClicked) .Dispatch((s, args) => new TvAction <string>("FETCH_DIR", args.FullName)) .When(f => f.IsDirectory); opt.OnKeyEvent(e => e.AsConsoleKeyInfo().Key == System.ConsoleKey.Enter) .Dispatch(s => new TvAction <FileItem>("FETCH_INFO", s[s.SelectedIndex])); opt.OnKeyEvent(e => e.AsConsoleKeyInfo().Key == System.ConsoleKey.Backspace) .Dispatch(s => new TvAction("FETCH_BACK")); }); var sright = TvStatexControl.Wrap <TvList <FileItem>, ListState <FileItem>, FileList>(right, opt => { opt.UseStore("right"); opt.UseStatexTransformation((fl, cs) => { cs.Clear(); cs.AddRange(fl.Items); }); opt.On(c => c.OnItemClicked) .Dispatch((s, args) => new TvAction <string>("FETCH_DIR", args.FullName)) .When(f => f.IsDirectory); }); listFilesGrid.Use(0, 0).Add(left); listFilesGrid.Use(0, 1).Add(right); var bottom = new TvStackPanel(tui.UI, "BottomContainer"); bottom.Layout.Add(new LayoutSize()); bottom.AsComponent().AddViewport(dvpf.Create(vpf => vpf.BottomViewport(2))); bottom.At(0).Add(textbox); tui.UI.Add(bottom); tui.UI.Add(menu); //tui.UI.Add(window); _dialogManager.ShowDialog(dialog); if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { _storeSelector.GetStore <FileList>("left").Dispatch(new TvAction <string>("FETCH_DIR", "/")); _storeSelector.GetStore <FileList>("right").Dispatch(new TvAction <string>("FETCH_DIR", "/home/eiximenis")); } else { _storeSelector.GetStore <FileList>("left").Dispatch(new TvAction <string>("FETCH_DIR", "C:\\")); _storeSelector.GetStore <FileList>("right").Dispatch(new TvAction <string>("FETCH_DIR", "D:\\")); } return(Task.CompletedTask); }
public TuiEngineHost(ITuiEngine engine) { _engine = engine ?? throw new ArgumentNullException(nameof(engine)); _cancelTokenSource = new CancellationTokenSource(); }
public HookContext(ITuiEngine engine) { ComponentTree = engine.UI; }