public static void Run() { var app = new ConsoleApp(0, 0, 75, 22); var chart = new CpuAndMemoryChart(); var list = new Grid() { Size = new Size(30, 5) }; var source = new MemoryDataSource(); list.DataSource = source; Action syncChartToListAction = () => { source.Items.Clear(); if (chart.ViewModel.FocusedDataSeries != null && chart.ViewModel.FocusedDataPointIndex >= 0 && chart.ViewModel.FocusedDataPointIndex < chart.ViewModel.FocusedDataSeries.DataPoints.Count && chart.ViewModel.FocusedDataSeries.DataPoints.Count > 0) { source.Items.Add(new { Value = ContextAssistSearchResult.FromString(chart.ViewModel.FocusedDataSeries.DataPoints[chart.ViewModel.FocusedDataPointIndex].Y + "") }); } }; chart.ViewModel.FocusedDataPointChanged += syncChartToListAction; chart.ViewModel.FocusedSeriesChanged += syncChartToListAction; syncChartToListAction(); app.LayoutRoot.Controls.Add(chart); app.LayoutRoot.Controls.Add(list); app.Start(); }
public static void Run() { var app = new ConsoleApp(0, 0, 75, 22); var chart = new CpuAndMemoryChart(); var list = new ListView() { Size = new Size(30, 5) }; Action syncChartToListAction = () => { list.ViewModel.Items.Clear(); if (chart.ViewModel.FocusedDataSeries != null && chart.ViewModel.FocusedDataPointIndex >= 0 && chart.ViewModel.FocusedDataPointIndex < chart.ViewModel.FocusedDataSeries.DataPoints.Count && chart.ViewModel.FocusedDataSeries.DataPoints.Count > 0) { list.ViewModel.Items.Add(ContextAssistSearchResult.FromString(chart.ViewModel.FocusedDataSeries.DataPoints[chart.ViewModel.FocusedDataPointIndex].Y + "")); } }; chart.ViewModel.FocusedDataPointChanged += syncChartToListAction; chart.ViewModel.FocusedSeriesChanged += syncChartToListAction; syncChartToListAction(); app.Controls.Add(chart); app.Controls.Add(list); app.Run(); }
protected override System.Threading.Tasks.Task <List <ContextAssistSearchResult> > GetResultsAsync(string searchString) { return(Task.Factory.StartNew <List <ContextAssistSearchResult> >(() => { return states.Where(r => r.StartsWith(searchString, StringComparison.InvariantCultureIgnoreCase)) .Select(s => ContextAssistSearchResult.FromString(s)) .ToList(); })); }
public void TestBasePickerWithCustomConsole() { var picker = new ContextAssistPicker(); picker.Options.Add(ContextAssistSearchResult.FromString("Pizza")); picker.Options.Add(ContextAssistSearchResult.FromString("Pasta")); picker.Options.Add(ContextAssistSearchResult.FromString("Steak")); var choice = picker.Pick(new TestConsoleProvider("s{w}")); Assert.AreEqual("Steak", choice.DisplayText); Assert.AreEqual("Steak", choice.ResultValue); }
public void TestBasicAssistEndOfLineAfterASpace() { ConsoleProvider.Current = new TestConsoleProvider("choice: {control} {w}{down}{down}{enter}"); CliHelper cli = new CliHelper(); var picker = new ContextAssistPicker(); picker.Options.Add(ContextAssistSearchResult.FromString("Option 1")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 2")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 3")); cli.Reader.ContextAssistProvider = picker; var line = cli.Reader.ReadLine(); Assert.AreEqual("choice: Option 3", line.ToString()); }
public void TestCyclingUpThroughOptions() { ConsoleProvider.Current = new TestConsoleProvider("{control} {w}{up}{enter}"); CliHelper cli = new CliHelper(); var picker = new ContextAssistPicker(); picker.Options.Add(ContextAssistSearchResult.FromString("Option 1")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 2")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 3")); cli.Reader.ContextAssistProvider = picker; var line = cli.Reader.ReadLine(); Assert.AreEqual("Option 3", line.ToString()); }
public void TestBasicAssistMiddleOfLineReplacingCurrentToken() { ConsoleProvider.Current = new TestConsoleProvider("choice: abc after{left}{left}{left}{left}{left}{left}{control} {w}{down}{down}{enter}"); CliHelper cli = new CliHelper(); var picker = new ContextAssistPicker(); picker.Options.Add(ContextAssistSearchResult.FromString("Option 1")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 2")); picker.Options.Add(ContextAssistSearchResult.FromString("Option 3")); cli.Reader.ContextAssistProvider = picker; var line = cli.Reader.ReadLine(); Assert.AreEqual("choice: Option 3 after", line.ToString()); }
protected override System.Collections.Generic.List <ContextAssistSearchResult> GetResults(string searchString) { var allRemotes = new List <string> { "origin", "upstream", "dev", "release", "foo", "bar" }; return(allRemotes.Where(r => r.StartsWith(searchString, StringComparison.InvariantCultureIgnoreCase)) .Select(r => ContextAssistSearchResult.FromString(r)) .ToList()); }
public bool TryComplete(TabCompletionContext context, out string completion) { var allRemotes = new List <string> { "windows", "hyperv", "linux", "freebsd", "openbsd", "netbsd", "generic", "all", "vmcs" }; var list = allRemotes.Where(r => r.StartsWith(context.CompletionCandidate.ToLower(), StringComparison.InvariantCultureIgnoreCase)) .Select(r => ContextAssistSearchResult.FromString(r)) .ToList(); completion = list.FirstOrDefault().RichDisplayText.StringValue; return(!string.IsNullOrWhiteSpace(completion)); }
public StatePickerAssistant() { Options.AddRange(States.Select(s => ContextAssistSearchResult.FromString(s))); }
protected override System.Collections.Generic.List <ContextAssistSearchResult> GetResults(string searchString) { return(states.Where(r => r.StartsWith(searchString, StringComparison.InvariantCultureIgnoreCase)) .Select(s => ContextAssistSearchResult.FromString(s)) .ToList()); }