Ejemplo n.º 1
0
        private void CommandTextBox_OnQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            _lastChosenCommand = null;

            if (args.ChosenSuggestion is CommandItemViewModel commandItem)
            {
                CommandSelected(commandItem);
            }
        }
Ejemplo n.º 2
0
        private void CommandSelected(CommandItemViewModel commandItem)
        {
            var executedCommand = ViewModel.Commands.FirstOrDefault(c =>
                                                                    c.ExecutedCommand.Value.Equals(commandItem.ExecutedCommand.Value,
                                                                                                   StringComparison.OrdinalIgnoreCase))?.ExecutedCommand;

            if (executedCommand != null)
            {
                ViewModel.SetProfile(executedCommand.ShellProfile.Clone());
            }
        }
Ejemplo n.º 3
0
        private void CommandTextBox_OnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                ViewModel.SetFilter(sender.Text.Trim());
            }
            // TODO: Else branch added for Tab-selection hack mentioned above.
            else if (_tabSelectedCommand != null)
            {
                ViewModel.Command = _tabSelectedCommand.ExecutedCommand.Value;
                CommandSelected(_tabSelectedCommand);

                _tabSelectedCommand = null;
            }
        }
Ejemplo n.º 4
0
        private Func <ICommandItem, IEnumerable <ICommandItem> > SortCommandItems <T>(ItemsViewModel <T> itemsVieModel)
            where T : IHasIsSelected, INotifyPropertyChanged
        {
            return((parent) =>
            {
                var descs = ((IDictionary <string, object>)itemsVieModel.SortDescriptions).Values.Cast <ISortDescription <T> >();
                var commands = descs.Select(desc => new CommandItemViewModel($"{parent.Name}/by {desc.Name}", new Func <ICommandItem, IEnumerable <ICommandItem> >((parent) => new CommandItemViewModel[]
                {
                    new CommandItemViewModel($"{parent.Name}{CommandItem.PathSeparator}Ascending", null, new RelayCommand(() => {
                        desc.IsDescending = false;
                        itemsVieModel.SortDescription = desc;
                    })),
                    new CommandItemViewModel($"{parent.Name}{CommandItem.PathSeparator}Descending", null, new RelayCommand(() => {
                        desc.IsDescending = true;
                        itemsVieModel.SortDescription = desc;
                    })),
                })));

                var none = new CommandItemViewModel($"{parent.Name}{CommandItem.PathSeparator}Clear", "", new RelayCommand(() => itemsVieModel.SortDescription = null));
                commands = commands.Concat(new CommandItemViewModel[] { none });

                return commands;
            });
        }
Ejemplo n.º 5
0
 private void CommandTextBox_OnSuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
 {
     _lastChosenCommand = args.SelectedItem as CommandItemViewModel;
 }