private void EvaluateRuleCoverage() { _treeView.ClearObjects(); var colliding = new TreeNodeWithCount("Colliding Rules"); var ignore = new TreeNodeWithCount("Ignore Rules Used"); var update = new TreeNodeWithCount("Update Rules Used"); var outstanding = new TreeNodeWithCount("Outstanding Failures"); var allRules = Ignorer.Rules.Union(Updater.Rules).ToList(); AddDuplicatesToTree(allRules); _treeView.AddObjects(new [] { colliding, ignore, update, outstanding }); var cts = new CancellationTokenSource(); var btn = new Button("Cancel"); Action cancelFunc = () => { cts.Cancel(); }; Action closeFunc = () => { Application.RequestStop(); }; btn.Clicked += cancelFunc; var dlg = new Dialog("Evaluating", MainWindow.DlgWidth, 6, btn); var stage = new Label("Evaluating Failures") { Width = Dim.Fill(), X = 0, Y = 0 }; var progress = new ProgressBar() { Height = 2, Width = Dim.Fill(), X = 0, Y = 1 }; var textProgress = new Label("0/0") { TextAlignment = TextAlignment.Right, Width = Dim.Fill(), X = 0, Y = 2 }; dlg.Add(stage); dlg.Add(progress); dlg.Add(textProgress); Task.Run(() => { EvaluateRuleCoverageAsync(stage, progress, textProgress, cts.Token, colliding, ignore, update, outstanding); }, cts.Token).ContinueWith((t) => { btn.Clicked -= cancelFunc; btn.Text = "Done"; btn.Clicked += closeFunc; dlg.SetNeedsDisplay(); cts.Dispose(); });; Application.Run(dlg); }
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); }
private void AddUnStagedWindow(Toplevel top) { _unStagedWindow = new Window("unstaged") { X = Pos.Right(_workspaceWindow), Y = 1, Width = Dim.Percent(30), Height = Dim.Fill() }; top.Add(_unStagedWindow); var unStagedTreeView = new TreeView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; var scrollView = new ScrollView() { KeepContentAlwaysInViewport = true, ShowVerticalScrollIndicator = true, ShowHorizontalScrollIndicator = true, ContentSize = new Size(200, 150), X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; scrollView.Add(unStagedTreeView); _unStagedWindow.Add(scrollView); //_unStagedWindow.Add(unStagedTreeView); _gitRepoInfo.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(_gitRepoInfo.Status)) { unStagedTreeView.ClearObjects(); unStagedTreeView.AddObjects(_gitRepoInfo.Status.Value.Select(x => new TreeItem() { Text = x.FilePath })); //unStagedTreeView.SetNeedsDisplay(); //scrollView.SetNeedsDisplay(); } }; }
private void SetupFileTree() { // setup delegates treeViewFiles.TreeBuilder = new DelegateTreeBuilder <FileSystemInfo> ( // Determines how to compute children of any given branch GetChildren, // As a shortcut to enumerating half the file system, tell tree that all directories are expandable (even if they turn out to be empty later on) (o) => o is DirectoryInfo ); // Determines how to represent objects as strings on the screen treeViewFiles.AspectGetter = FileSystemAspectGetter; treeViewFiles.AddObjects(DriveInfo.GetDrives().Select(d => d.RootDirectory)); }
internal void SetUp(Toplevel top) { var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File (F9)", new MenuItem [] { new MenuItem("_New...", "", () => New()), new MenuItem("_Find...", "", () => Find()), new MenuItem("_Run...", "", () => Run()), new MenuItem("_Refresh...", "", () => Publish()), new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_Diagnostics", new MenuItem [] { mi_default = new MenuItem() { Title = "Query Catalogue", Action = () => Query(nameof(CataloguePatcher)) }, mi_default = new MenuItem() { Title = "Query Data Export", Action = () => Query(nameof(DataExportPatcher)) }, }), new MenuBarItem("_Color Scheme", new MenuItem [] { mi_default = new MenuItem() { Title = "Default", Checked = true, CheckType = MenuItemCheckStyle.Radio, Action = () => SetColorScheme(mi_default) }, mi_green = new MenuItem() { Title = "Green", Checked = false, CheckType = MenuItemCheckStyle.Radio, Action = () => SetColorScheme(mi_green) }, }), }); top.Add(menu); _win = new Window() { X = 0, Y = 1, // menu Width = Dim.Fill(1), Height = Dim.Fill(1) // status bar }; _defaultColorScheme = ColorScheme = _win.ColorScheme; _greenColorScheme = new ColorScheme() { Disabled = Application.Driver.MakeAttribute(Color.Black, Color.Black), Focus = Application.Driver.MakeAttribute(Color.Black, Color.Green), HotFocus = Application.Driver.MakeAttribute(Color.Black, Color.Green), HotNormal = Application.Driver.MakeAttribute(Color.BrightYellow, Color.Black), Normal = Application.Driver.MakeAttribute(Color.Green, Color.Black), }; _treeView = new TreeView <object> () { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill() }; // Determines how to compute children of any given branch _treeView.TreeBuilder = new DelegateTreeBuilder <object>(ChildGetter); _treeView.AddObjects( new string[] { Catalogues, Projects, Loads, CohortConfigs, BuiltCohorts, Other }); _win.Add(_treeView); top.Add(_win); _treeView.ObjectActivated += _treeView_ObjectActivated; _treeView.KeyPress += treeView_KeyPress; _treeView.SelectionChanged += _treeView_SelectionChanged; _treeView.AspectGetter = AspectGetter; var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.Q | Key.CtrlMask, "~^Q~ Quit", () => Quit()), new StatusItem(Key.R | Key.CtrlMask, "~^R~ Run", () => Run()), new StatusItem(Key.F | Key.CtrlMask, "~^F~ Find", () => Find()), new StatusItem(Key.N | Key.CtrlMask, "~^N~ New", () => New()), new StatusItem(Key.F5, "~F5~ Refresh", () => Publish()), }); top.Add(statusBar); string scheme = UserSettings.ConsoleColorScheme; if (scheme == "green") { SetColorScheme(mi_green); } }