Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 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();
     }));
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
            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());
            }
Ejemplo n.º 9
0
            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));
            }
Ejemplo n.º 10
0
 public StatePickerAssistant()
 {
     Options.AddRange(States.Select(s => ContextAssistSearchResult.FromString(s)));
 }
Ejemplo n.º 11
0
 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());
 }