private void OnMoveUpEntry(object sender, RoutedEventArgs e) { SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; if (selectedItem == null) { return; } // Dummy entry stays last if (selectedItem.Dummy) { return; } // No need to move up the first entry int index = _CustomSearchFolders.IndexOf(selectedItem); if (index == 0) { return; } _CustomSearchFolders.Remove(selectedItem); _CustomSearchFolders.Insert(index - 1, selectedItem); EnsureSearchFolderHasDummyEntry(); }
private void OnMoveDownEntry(object sender, RoutedEventArgs e) { SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; if (selectedItem == null) { return; } // Dummy entry stays last if (selectedItem.Dummy) { return; } // No need to move down the last non-dummy entry int index = _CustomSearchFolders.IndexOf(selectedItem); if (index == _CustomSearchFolders.Count() - 2) { return; } _CustomSearchFolders.Remove(selectedItem); _CustomSearchFolders.Insert(index + 1, selectedItem); EnsureSearchFolderHasDummyEntry(); }
private void OnRemoveSearchFolder(object sender, RoutedEventArgs e) { System.Windows.Controls.Button selectedButton = sender as System.Windows.Controls.Button; SearchFolderItem selectedItem = (SearchFolderItem)(selectedButton.DataContext as System.Windows.Controls.ListBoxItem).Content; _CustomSearchFolders.Remove(selectedItem); EnsureSearchFolderHasDummyEntry(); }
private void SearchFolder_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (sender.GetType() == typeof(SearchFolderItem) && e.PropertyName == "Folder") { SearchFolderItem ChangedSearchFolder = (SearchFolderItem)sender; ChangedSearchFolder.IsEditable = false; ChangedSearchFolder.PropertyChanged -= SearchFolder_PropertyChanged; ChangeSearchFolder(ChangedSearchFolder); } }
private void OnSearchFolderViewSelectedItemChanged(object sender, RoutedEventArgs e) { SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; foreach (var sfi in _CustomSearchFolders) { if (sfi != selectedItem) { sfi.IsEditable = false; } } }
private void OnDeleteEntry(object sender, RoutedEventArgs e) { SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; if (selectedItem == null) { return; } _CustomSearchFolders.Remove(selectedItem); EnsureSearchFolderHasDummyEntry(); }
private void OnNewEntry(object sender, RoutedEventArgs e) { EnsureSearchFolderHasDummyEntry(); // The last entry is always a dummy one, so we can use it SearchFolderItem newItem = _CustomSearchFolders.Last(); newItem.Dummy = false; newItem.IsEditable = true; newItem.PropertyChanged += SearchFolder_PropertyChanged; EnsureSearchFolderHasDummyEntry(); }
private void SearchFoldersList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var listbox = sender as System.Windows.Controls.ListBox; SearchFolderItem selectedItem = (SearchFolderItem)listbox.SelectedItem; if (selectedItem == null) { return; } selectedItem.IsEditable = true; selectedItem.PropertyChanged += SearchFolder_PropertyChanged; EnsureSearchFolderHasDummyEntry(); }
private void OnChangeSearchFolder(object sender, RoutedEventArgs e) { System.Windows.Controls.Button selectedButton = sender as System.Windows.Controls.Button; SearchFolderItem selectedItem = (SearchFolderItem)(selectedButton.DataContext as System.Windows.Controls.ListBoxItem).Content; FolderBrowserDialog InputFileNameDlg = new FolderBrowserDialog(); if (InputFileNameDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } var selectedPath = InputFileNameDlg.SelectedPath; selectedItem.Folder = selectedPath; selectedItem.Dummy = false; EnsureSearchFolderHasDummyEntry(); }
private void OnEditEntry(object sender, RoutedEventArgs e) { SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; if (selectedItem == null) { return; } selectedItem.IsEditable = true; selectedItem.PropertyChanged += SearchFolder_PropertyChanged; foreach (var sfi in _CustomSearchFolders) { if (sfi != selectedItem) { sfi.IsEditable = false; } } EnsureSearchFolderHasDummyEntry(); }
private void OnBrowseEntry(object sender, RoutedEventArgs e) { // Ask the user for a path FolderBrowserDialog InputFileNameDlg = new FolderBrowserDialog(); if (InputFileNameDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } var selectedPath = InputFileNameDlg.SelectedPath; // Either edit the selected item or add a new one SearchFolderItem selectedItem = (SearchFolderItem)SearchFoldersList.SelectedItem; if (selectedItem == null || !selectedItem.IsEditable) { // The last entry is always a dummy one, so we can use it selectedItem = _CustomSearchFolders.Last(); } selectedItem.Folder = selectedPath; selectedItem.Dummy = false; selectedItem.IsEditable = true; foreach (var sfi in _CustomSearchFolders) { if (sfi != selectedItem) { sfi.IsEditable = false; } } EnsureSearchFolderHasDummyEntry(); }
private void ChangeSearchFolder(SearchFolderItem Item) { }