示例#1
0
        public CodeSearchControl()
        {
            InitializeComponent();
            // Add the "VsColors" brushes to the WPF resources of the control, so that the
            // resource keys used on the XAML file can be resolved dynamically.
            Resources.MergedDictionaries.Add(VsResources.BuildResourceDictionary());
            DataContext = new CodeSearchViewModel();

            _progressBarTracker = new ProgressBarTracker(ProgressBar);

            InitComboBox(SearchCodeCombo, new ComboBoxInfo {
                TextChanged    = text => { ViewModel.SearchCodeValue = text; },
                SearchFunction = RefreshSearchResults,
                NextElement    = SearchFilePathsCombo,
            });
            InitComboBox(SearchFilePathsCombo, new ComboBoxInfo {
                TextChanged     = text => { ViewModel.SearchFilePathsValue = text; },
                SearchFunction  = RefreshSearchResults,
                PreviousElement = SearchCodeCombo,
                NextElement     = FileTreeView,
                InitialItems    =
                {
                    "*",
                    "*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc",
                    "*.htm;*.html;*.xml;*.gif;*.jpg;*.png;*.css;*.disco;*.js;*.srf",
                    "*.xml;*.xsl;*.xslt;*.xsd;*.dtd",
                    "*.txt",
                    "*.cs;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.vb;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.*",
                }
            });
        }
        public OpenFileControl()
        {
            InitializeComponent();
            // Add the "VsColors" brushes to the WPF resources of the control, so that the
            // resource keys used on the XAML file can be resolved dynamically.
            Resources.MergedDictionaries.Add(VsResources.BuildResourceDictionary());
            DataContext = new OpenFileViewModel();

            SearchFileTextBox.TextChanged += (s, e) => {
                ViewModel.SearchPattern = SearchFileTextBox.Text;
                RefreshSearchResults(false);
            };
        }
示例#3
0
        public CodeSearchControl()
        {
            InitializeComponent();
            // Add the "VsColors" brushes to the WPF resources of the control, so that the
            // resource keys used on the XAML file can be resolved dynamically.
            Resources.MergedDictionaries.Add(VsResources.BuildResourceDictionary());
            DataContext = new CodeSearchViewModel();

            _progressBarTracker = new ProgressBarTracker(ProgressBar);

            InitComboBox(SearchCodeCombo, new ComboBoxInfo {
                TextChanged    = text => { ViewModel.SearchCodeValue = text; },
                SearchFunction = RefreshSearchResults,
                NextElement    = SearchFilePathsCombo,
            });
            InitComboBox(SearchFilePathsCombo, new ComboBoxInfo {
                TextChanged     = text => { ViewModel.SearchFilePathsValue = text; },
                SearchFunction  = RefreshSearchResults,
                PreviousElement = SearchCodeCombo,
                InitialItems    =
                {
                    "*",
                    "*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc",
                    "*.htm;*.html;*.xml;*.gif;*.jpg;*.png;*.css;*.disco;*.js;*.srf",
                    "*.xml;*.xsl;*.xslt;*.xsd;*.dtd",
                    "*.txt",
                    "*.cs;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.vb;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.*",
                }
            });

            // Setup custom NextElement logic to account for swapping tree/list views
            SearchFilePathsCombo.PrePreviewKeyDown += (s, e) => {
                if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down)
                {
                    if (!SearchFilePathsCombo.IsDropDownOpen)
                    {
                        if (ViewModel.FlattenSearchResults)
                        {
                            FileListBox.Focus();

                            if (FileListBox.SelectedItem == null)
                            {
                                FileListBox.SelectedIndex = 0;
                            }

                            var listBoxItem = (ListBoxItem)FileListBox.ItemContainerGenerator.ContainerFromItem(FileListBox.SelectedItem);
                            if (listBoxItem != null)
                            {
                                listBoxItem.Focus();
                            }
                        }
                        else
                        {
                            FileTreeView.Focus();
                        }
                        e.Handled = true;
                    }
                }
            };
        }