예제 #1
0
        // </SnippetOnCancel>


        // <SnippetFindSourcesClick>
        private async void findSourcesButton_Click(object sender, RoutedEventArgs e)
        {
            var sources = await PhotoImportManager.FindAllSourcesAsync();

            foreach (PhotoImportSource source in sources)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content = source.DisplayName;
                item.Tag     = source;
                sourcesComboBox.Items.Add(item);
            }
        }
예제 #2
0
        /// <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);
            }
        }