/// <summary> /// Display the source properties when a new source is selected. /// </summary> /// <param name="sender">The source of the selection changed event</param> /// <param name="e">Details about the selection chagned event</param> private void SourceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { // reset any previous items this.itemsToImport = null; this.fileListView.ItemsSource = null; // enable find options this.OnlyImages.IsEnabled = true; this.OnlyVideo.IsEnabled = true; this.ImagesAndVideo.IsEnabled = true; // set the default to find Images and Video this.ImagesAndVideo.IsChecked = true; // clear any values in the source properties this.propertiesTxtBox.Text = ""; if (e.AddedItems.Count != 0) { this.importSource = e.AddedItems.First() as PhotoImportSource; DisplaySourceProperties(); // enable Find New and Find All buttons, disable the rest this.findNewItemsButton.IsEnabled = true; this.findAllItemsButton.IsEnabled = true; this.selectNewButton.IsEnabled = false; this.selectNoneButton.IsEnabled = false; this.selectAllButton.IsEnabled = false; this.deleteButton.IsEnabled = false; this.importButton.IsEnabled = false; } }
public ListViewBaseView() { this.InitializeComponent(); items = new GeneratorIncrementalLoadingClass <SuperJupiter.Shared.SampleListItems>(30, (count) => { return(new SuperJupiter.Shared.SampleListItems { Name = ("Item number: ") + count }); }); ItemsList.Source = items; }
/// <summary> /// Creates a GeneratorIncrementalLoadingClass and sets the FindItemsResult to the filelist for display /// </summary> /// <param name="list">PhotoImportFindItemResult list</param> private void setIncrementalFileList(PhotoImportFindItemsResult list) { // GeneratorIncrementalLoadingClass is used to incrementally load items in the Listview view including thumbnails this.itemsToImport = new GeneratorIncrementalLoadingClass <ImportableItemWrapper>(list.TotalCount, (int index) => { return(new ImportableItemWrapper(list.FoundItems[index])); }); this.fileListView.ItemsSource = this.itemsToImport; }
/// <summary> /// Enumerate all PTP / MTP sources when FindAllSources button is clicked. /// </summary> /// <param name="sender">The source of the click event</param> /// <param name="e">Details about the click event </param> private async void OnFindSourcesClicked(object sender, RoutedEventArgs e) { try { rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage); // clear our list of items to import this.itemsToImport = null; this.fileListView.ItemsSource = this.itemsToImport; // reset UI elements this.progressBar.Value = 0.0; this.propertiesTxtBox.Text = ""; // disable all buttons until source selection is made setButtonState(false); // reenable source selection this.sourceListBox.IsEnabled = true; // clear find criteria this.OnlyImages.IsChecked = false; this.OnlyVideo.IsChecked = false; this.ImagesAndVideo.IsChecked = false; // Dispose any created import session if (this.session != null) { this.session.Dispose(); this.session = null; } // Check to ensure API is supported bool importSupported = await PhotoImportManager.IsSupportedAsync(); if (importSupported) { // enumerate all available sources to where we can import from sourceListBox.ItemsSource = await PhotoImportManager.FindAllSourcesAsync(); } else { rootPage.NotifyUser("Import is not supported.", NotifyType.ErrorMessage); } } catch (Exception ex) { rootPage.NotifyUser("FindAllSourcesAsync Failed. " + "Exception: " + ex.ToString(), NotifyType.ErrorMessage); } }
private void Scenario8Reset(object sender, RoutedEventArgs e) { if (employees != null) { employees.CollectionChanged -= _employees_CollectionChanged; } employees = new GeneratorIncrementalLoadingClass<Employee>(1000, (count) => { return new Employee() { Name = "Name" + count, Organization = "Organization" + count }; }); employees.CollectionChanged += _employees_CollectionChanged; employeesCVS.Source = employees; tbCollectionChangeStatus.Text = String.Empty; }
/// <summary> /// Helper method to Enumerate all importable items /// </summary> /// <param name="contentType">the content type</param> /// <param name="selectionMode">the selection mode</param> private async void findItems(PhotoImportContentTypeFilter contentType, PhotoImportItemSelectionMode selectionMode) { rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage); // Disable buttons and lists to prevent unexpected reentrance. setButtonState(false); this.sourceListBox.IsEnabled = false; this.cts = new CancellationTokenSource(); try { this.progressRing.IsActive = true; this.itemsToImport = null; this.fileListView.ItemsSource = null; // Dispose any created import session if (this.session != null) { this.session.Dispose(); } // Create the import session from the source selected this.session = importSource.CreateImportSession(); RaisePropertyChanged("AppendSessionDateToDestinationFolder"); // Progress handler for FindItemsAsync var progress = new Progress <uint>((result) => { rootPage.NotifyUser(String.Format("Found {0} Files", result.ToString()), NotifyType.StatusMessage); }); // Find all items available importable item from our source this.itemsResult = await session.FindItemsAsync(contentType, selectionMode).AsTask(cts.Token, progress); setIncrementalFileList(this.itemsResult); DisplayFindItemsResult(); if (this.itemsResult.HasSucceeded) { // disable Find New , Find All and Delete button. this.findNewItemsButton.IsEnabled = false; this.findAllItemsButton.IsEnabled = false; this.deleteButton.IsEnabled = false; // enable list selection , folder options and import buttons this.selectNewButton.IsEnabled = true; this.selectNoneButton.IsEnabled = true; this.selectAllButton.IsEnabled = true; this.importButton.IsEnabled = true; this.fileListView.IsEnabled = true; this.AddSessionDateFolder.IsEnabled = true; this.NoSubFolder.IsEnabled = true; this.FileDateSubfolder.IsEnabled = true; this.ExifDateSubfolder.IsEnabled = true; this.KeepOriginalFolder.IsEnabled = true; } else { rootPage.NotifyUser("FindItemsAsync did not succeed or was not completed.", NotifyType.StatusMessage); // re-enable Find New and Find All buttons this.findNewItemsButton.IsEnabled = true; this.findAllItemsButton.IsEnabled = true; this.progressRing.IsActive = false; } this.progressRing.IsActive = false; // Set the CancellationTokenSource to null when the work is complete. cts = null; } catch (Exception ex) { rootPage.NotifyUser("Error: Operation incomplete. " + "Exception: " + ex.ToString(), NotifyType.ErrorMessage); } }
/// <summary> /// Creates a GeneratorIncrementalLoadingClass and sets the FindItemsResult to the filelist for display /// </summary> /// <param name="list">PhotoImportFindItemResult list</param> private void setIncrementalFileList (PhotoImportFindItemsResult list) { // GeneratorIncrementalLoadingClass is used to incrementally load items in the Listview view including thumbnails this.itemsToImport = new GeneratorIncrementalLoadingClass<ImportableItemWrapper>(list.TotalCount, (int index) => { return new ImportableItemWrapper(list.FoundItems[index]); }); this.fileListView.ItemsSource = this.itemsToImport; }
/// <summary> /// Helper method to Enumerate all importable items /// </summary> /// <param name="contentType">the content type</param> /// <param name="selectionMode">the selection mode</param> private async void findItems(PhotoImportContentTypeFilter contentType, PhotoImportItemSelectionMode selectionMode) { rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage); // Disable buttons and lists to prevent unexpected reentrance. setButtonState(false); this.sourceListBox.IsEnabled = false; this.cts = new CancellationTokenSource(); try { this.progressRing.IsActive = true; this.itemsToImport = null; this.fileListView.ItemsSource = null; // Dispose any created import session if (this.session != null) { this.session.Dispose(); this.session = null; } // Create the import session from the source selected this.session = importSource.CreateImportSession(); RaisePropertyChanged("AppendSessionDateToDestinationFolder"); // Progress handler for FindItemsAsync var progress = new Progress<uint>((result) => { rootPage.NotifyUser(String.Format("Found {0} Files", result.ToString()), NotifyType.StatusMessage); }); // Find all items available importable item from our source this.itemsResult = await session.FindItemsAsync(contentType, selectionMode).AsTask(cts.Token, progress); setIncrementalFileList(this.itemsResult); DisplayFindItemsResult(); if (this.itemsResult.HasSucceeded) { // disable Find New , Find All and Delete button. this.findNewItemsButton.IsEnabled = false; this.findAllItemsButton.IsEnabled = false; this.deleteButton.IsEnabled = false; // enable list selection , folder options and import buttons this.selectNewButton.IsEnabled = true; this.selectNoneButton.IsEnabled = true; this.selectAllButton.IsEnabled = true; this.importButton.IsEnabled = true; this.fileListView.IsEnabled = true; this.AddSessionDateFolder.IsEnabled = true; this.NoSubFolder.IsEnabled = true; this.FileDateSubfolder.IsEnabled = true; this.ExifDateSubfolder.IsEnabled = true; this.KeepOriginalFolder.IsEnabled = true; } else { rootPage.NotifyUser("FindItemsAsync did not succeed or was not completed.", NotifyType.StatusMessage); // re-enable Find New and Find All buttons this.findNewItemsButton.IsEnabled = true; this.findAllItemsButton.IsEnabled = true; this.progressRing.IsActive = false; } this.progressRing.IsActive = false; // Set the CancellationTokenSource to null when the work is complete. cts = null; } catch (Exception ex) { rootPage.NotifyUser("Error: Operation incomplete. " + "Exception: " + ex.ToString(), NotifyType.ErrorMessage); } }
/// <summary> /// Display the source properties when a new source is selected. /// </summary> /// <param name="sender">The source of the selection changed event</param> /// <param name="e">Details about the selection chagned event</param> private void SourceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { // reset any previous items this.itemsToImport = null; this.fileListView.ItemsSource = null; // clear any values in the source properties this.propertiesTxtBox.Text = ""; if (e.AddedItems.Count != 0) { // enable find options this.OnlyImages.IsEnabled = true; this.OnlyVideo.IsEnabled = true; this.ImagesAndVideo.IsEnabled = true; // set the default to find Images and Video this.ImagesAndVideo.IsChecked = true; this.importSource = e.AddedItems.First() as PhotoImportSource; DisplaySourceProperties(); // enable Find New and Find All buttons, disable the rest this.findNewItemsButton.IsEnabled = true; this.findAllItemsButton.IsEnabled = true; this.selectNewButton.IsEnabled = false; this.selectNoneButton.IsEnabled = false; this.selectAllButton.IsEnabled = false; this.deleteButton.IsEnabled = false; this.importButton.IsEnabled = false; } }