示例#1
0
        private void CommandTextBox_OnQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            _lastChosenCommand = null;

            if (args.ChosenSuggestion is CommandItemViewModel commandItem)
            {
                CommandSelected(commandItem);
            }
        }
示例#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());
            }
        }
示例#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;
            }
        }
示例#4
0
文件: Sorting.cs 项目: msmcjp/mmfm
        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;
            });
        }
示例#5
0
 private void CommandTextBox_OnSuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
 {
     _lastChosenCommand = args.SelectedItem as CommandItemViewModel;
 }