Inheritance: IFolderPicker
		private async void BrowseButton_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				var folderPicker = new FolderPicker()
				{
					CommitButtonText = "Open",
					SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
					ViewMode = PickerViewMode.List
				};
				folderPicker.FileTypeFilter.Add(".shp");

				_folder = await folderPicker.PickSingleFolderAsync();
				if (_folder != null)
				{
					var qopts = new QueryOptions(CommonFileQuery.OrderByName, new string[] { ".shp" });
					var query = _folder.CreateFileQueryWithOptions(qopts);
					var files = await query.GetFilesAsync();
					FileListCombo.ItemsSource = files;
					FileListCombo.Visibility = (files.Any()) ? Visibility.Visible : Visibility.Collapsed;
				}
			}
			catch (Exception ex)
			{
				var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
        private async void btnSelectFile_Click(object sender, RoutedEventArgs e)
        {
            // Clear previous returned file name, if it exists, between iterations of this scenario
            textBlockFileSelected.Text = "";

            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                textBlockFileSelected.Text = "Picked Folder: " + folder.Name;
                this.selectedFolder        = folder;
            }
            else
            {
                textBlockFileSelected.Text = "Operation cancelled.";
            }
        }
        //-------------------------------------------------------------------------------
        #region selectButton_Click コミケカタログデータフォルダ選択ボタン
        //-------------------------------------------------------------------------------
        //
        private async void selectButton_Click(object sender, RoutedEventArgs e) {
            FolderPicker picker = new FolderPicker();
            picker.FileTypeFilter.Add("*");
            var folder = await picker.PickSingleFolderAsync();

            if (folder == null) { return; }

            buttonSelect.IsEnabled = false;

            progressInitialize.Visibility = textProgress.Visibility = Windows.UI.Xaml.Visibility.Visible;
            textError.Text = "";

            Func<int, int, int, int, bool> update = (curr1, all1, curr2, all2) => {
                textProgress.Text = string.Format("タスク {0} / {1} , ファイル {2} / {3}", curr1, all1, curr2, all2);
                progressInitialize.Value = 100.0 * ((double)curr2 / (double)all2);

                return !_backed;
            };

            Action<string> error = (str) => {
                textError.Text = str;
                progressInitialize.Visibility = textProgress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                buttonSelect.IsEnabled = true;
            };

            if (folder != null) {
                await CatalogData.copyToLocal(folder, update, error);
            }
        }
Beispiel #4
0
        public static MenuCommand[] MenuFolders(IFileItem item)
        {
            var list = new List <MenuCommand>();

            if (Storages.LibraryStorage.Content?.Content?.folders is null)
            {
                return(list.ToArray());
            }

            list.Add(new MenuCommand(GetResourceTitle("Folders/RegisterFolder"), new kurema.FileExplorerControl.Helper.DelegateAsyncCommand(async _ =>
            {
                var picker = new Windows.Storage.Pickers.FolderPicker();
                picker.FileTypeFilter.Add("*");
                var folder = await picker.PickSingleFolderAsync();
                if (folder is null)
                {
                    return;
                }

                var foldersTemp = Storages.LibraryStorage.Content.Content.folders.ToList();
                var folderNew   = await Storages.Library.libraryFolder.GetLibraryFolderFromStorageAsync(folder);
                foldersTemp.Add(folderNew);
                Storages.LibraryStorage.Content.Content.folders = foldersTemp.ToArray();

                Storages.LibraryStorage.OnLibraryUpdateRequest(Storages.LibraryStorage.LibraryKind.Folders);

                await Storages.LibraryStorage.Content.SaveAsync();
            })));

            return(list.ToArray());
        }
        public Task LaunchFileSelectionServiceAsync()
        {
            FolderPicker savePicker = new FolderPicker();
            savePicker.FileTypeFilter.Add("*");
            savePicker.CommitButtonText = "Save All";
            Task task = null;

            #if WINDOWS_PHONE_APP

            this.completionSource = new TaskCompletionSource<int>();
            savePicker.PickFolderAndContinue();
            task = this.completionSource.Task;

            #endif
            #if WINDOWS_APP

            task = savePicker.PickSingleFolderAsync().AsTask().ContinueWith(
              fileTask =>
              {
                  this.storageFolder = fileTask.Result;
              });

            #endif

            return task;
        }
        private async void GetThumbnailButton_Click(object sender, RoutedEventArgs e)
        {
            rootPage.ResetOutput(ThumbnailImage, OutputTextBlock);

            // Pick a folder
            FolderPicker folderPicker = new FolderPicker();
            foreach (string extension in FileExtensions.Image)
            {
                folderPicker.FileTypeFilter.Add(extension);
            }

            StorageFolder folder = await folderPicker.PickSingleFolderAsync();
            if (folder != null)
            {
                const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView;
                const uint size = 200;
                using (StorageItemThumbnail thumbnail = await folder.GetThumbnailAsync(thumbnailMode, size))
                {
                    if (thumbnail != null)
                    {
                        MainPage.DisplayResult(ThumbnailImage, OutputTextBlock, thumbnailMode.ToString(), size, folder, thumbnail, false);
                    }
                    else
                    {
                        rootPage.NotifyUser(Errors.NoImages, NotifyType.StatusMessage);
                    }
                }
            }
            else
            {
                rootPage.NotifyUser(Errors.Cancel, NotifyType.StatusMessage);
            }
        }
Beispiel #7
0
        private async void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
        {
            try
            {
                switch (args.InvokedItem)
                {
                case "Home":

                    var picker = new Windows.Storage.Pickers.FolderPicker();
                    picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
                    picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                    picker.FileTypeFilter.Add("*");

                    IStorageFolder folder = await picker.PickSingleFolderAsync();

                    if (folder != null)
                    {
                        ContentFrame.Navigate(typeof(FileListingPage), folder);
                    }
                    else
                    {
                        /// TODO handle error
                    }
                    break;
                }
            } catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            FolderPicker fp = new FolderPicker();
            fp.SuggestedStartLocation = PickerLocationId.Desktop;
            fp.ViewMode = PickerViewMode.Thumbnail;
            fp.FileTypeFilter.Add(".jpeg");
            fp.FileTypeFilter.Add(".jpg");
            fp.FileTypeFilter.Add(".png");
            var file = await fp.PickSingleFolderAsync();
            f1 = await file.GetFilesAsync();
           if(file!=null)
            {
                StorageFile sf = f1[0];
                foreach(StorageFile a in f1 )
                {
                IRandomAccessStream i = await a.OpenAsync(FileAccessMode.Read);
                BitmapImage b = new BitmapImage();
                b.SetSource(i);
                flip.Items.Add(b);
            
                }

            }
           
        }
        private async void clickbtn_Click(object sender, RoutedEventArgs e)
        {
            FolderPicker fp = new FolderPicker();
            fp.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            fp.ViewMode = PickerViewMode.Thumbnail;
            fp.FileTypeFilter.Add(".jpg");
            fp.FileTypeFilter.Add(".png");
            fp.FileTypeFilter.Add(".jpeg");
            var file = await fp.PickSingleFolderAsync();
            fl = await file.GetFilesAsync();
            if (file != null)
            {
                StorageFile sf = fl[0];
                foreach (StorageFile images in fl)
                {
                    IRandomAccessStream str = await images.OpenAsync(FileAccessMode.Read);
                    BitmapImage bitmapimage = new BitmapImage();
                    bitmapimage.SetSource(str);

                    fp1.Items.Add(bitmapimage);
                 

                 
                }
        
            }

        }
        /// <summary>
        /// Set the path to save the session files
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void changeSessionDataPathButton_Click(object sender, RoutedEventArgs e)
        {
            // If the app is snapped the FolderPicker won't work
            bool unsnapped = ((Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped) || 
                Windows.UI.ViewManagement.ApplicationView.TryUnsnap());

            if (unsnapped)
            {
                FolderPicker fp = new FolderPicker();
                fp.FileTypeFilter.Add("*");

                StorageFolder sf = await fp.PickSingleFolderAsync();

                if (sf != null)
                {
                    // Save accessToken for the selected folder
                    string pickedFolderToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(sf);

                    settings.UpdateValue("MSBandViewer-sessionDataPathToken", pickedFolderToken);

                    settings.Data.sessionDataPath = sessionDataPathTextBlock.Text = sf.Path;
                    settings.UpdateValue("MSBandViewer-sessionDataPath", settings.Data.sessionDataPath);

                    ToolTipService.SetToolTip(sessionDataPathTextBlock, settings.Data.sessionDataPath);
                }
            }
        }
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     FolderPicker fp = new FolderPicker();
     fp.FileTypeFilter.Add("*");
     fp.SuggestedStartLocation = PickerLocationId.Desktop;
     fp.ViewMode = PickerViewMode.Thumbnail;
     var files = await fp.PickSingleFolderAsync();
     iol = await files.GetFilesAsync();
    //IReadOnlyList<StorageFolder> file = iol
     Myobj myobj = new Myobj();
     ObservableCollection<Myobj> datasource = new ObservableCollection<Myobj>();
    //Windows.Storage.Streams.IRandomAccessStream iras = await sf.OpenAsync(FileAccessMode.Read);
    sf = iol[0];
    //IReadOnlyList<IStorageFile> file = ;
    foreach (StorageFile a in iol)
    {
        myobj.Name = sf.DisplayName.ToString();
        //gw.DisplayMemberPath = "Name";
        var tn = await sf.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView);
        BitmapImage bi = new BitmapImage();
        bi.SetSource(tn);
        myobj.Thumbnail = bi;
        datasource.Add(myobj);
    }
        this.gw.ItemsSource = datasource;
      //  gw.DisplayMemberPath = "data";
        
    
 }
 private async void ChooseFolder(object sender, RoutedEventArgs e) {
     var filePicker = new FolderPicker();
     filePicker.FileTypeFilter.Add("*");
     filePicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
     folder = await filePicker.PickSingleFolderAsync();
     if (folder != null) {
         BoxFolderPath.Text = folder.Path;
     }
 }
 public UnzipViewModel(UnzipModel unzip)
 {
     this._unzip = unzip;
     filePicker = InitFilePicker();
     folderPicker = new FolderPicker();
     FileSelectCommand = new UnzipCommand(()=>SelectFile(),()=>true);
     FolderSelectCommand = new UnzipCommand(() => SelectFolder(), () => true);
     ExtractCommand = new UnzipCommand(() => Extract(), () => true);
 } 
        async private void Button_Click(object sender, RoutedEventArgs e)
        {


            //FileOpenPicker fop = new FileOpenPicker();
            //fop.ViewMode = PickerViewMode.Thumbnail;
            //fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            //fop.FileTypeFilter.Add(".jpeg");
            //fop.FileTypeFilter.Add(".jpg");
            //fop.FileTypeFilter.Add(".png");
            //StorageFile sf =await fop.PickSingleFileAsync();
            FolderPicker fp = new FolderPicker();

            fp.ViewMode = PickerViewMode.List;
            fp.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            fp.FileTypeFilter.Add(".jpeg");
            fp.FileTypeFilter.Add(".jpg");
            fp.FileTypeFilter.Add(".png");
            var sfs = await fp.PickSingleFolderAsync();
            //FlipView fv = new FlipView();
            try
            {
                if (sfs != null)
                {
                    sfiles = await sfs.GetFilesAsync();

                    foreach (StorageFile f in sfiles)
                    {
                        count++;
                        using (IRandomAccessStream ir = await f.OpenAsync(FileAccessMode.Read))
                        {
                            BitmapImage bi = new BitmapImage();
                            BitmapImage lbi = bi;


                            bi.SetSource(ir);
                            fv.Items.Add(bi);
                            lv.Items.Add(bi);
                            imgProp[count] = await f.Properties.GetImagePropertiesAsync();
                            //sp.Children.Add(img);



                        }

                    }
                    // sp.Children.Add(fv);
                }
            }
            catch (Exception exc)
            {

            }


        }
 async public void PickFolder()
 {
     FolderPicker picker = new FolderPicker();
     picker.FileTypeFilter.Add(".xls");
     StorageFolder folder = await picker.PickSingleFolderAsync();
     if (folder != null)
     {
         StorageApplicationPermissions.FutureAccessList.AddOrReplace("DefaultFolder", folder);
     }
 }
 private async void ChooseStartIn(object sender, RoutedEventArgs e) {
     var filePicker = new FolderPicker();
     filePicker.FileTypeFilter.Add("*");
     filePicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
     var folder = await filePicker.PickSingleFolderAsync();
     if (folder != null) {
         TextBoxAppDir.Text = folder.Path;
         ParentPage.UpdateAppBarButtons();
     }
 }
        private async void loadDirectory_Click(object sender, RoutedEventArgs e)
        {
            PhotoOrganizer photoOrganizer = new PhotoOrganizer();
            PhotoCollection photoCollection = new PhotoCollection();

            FolderPicker directoryPicker = new FolderPicker();
            directoryPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
            directoryPicker.FileTypeFilter.Add(".jpg");
            directoryPicker.FileTypeFilter.Add(".jpeg");
            directoryPicker.FileTypeFilter.Add(".png");
            directoryPicker.FileTypeFilter.Add(".gif");
            directoryPicker.ViewMode = PickerViewMode.Thumbnail;

            StorageFolder folder = await directoryPicker.PickSingleFolderAsync();
            if (folder != null)
            {
                StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);

                IReadOnlyList<StorageFile> roFiles = await folder.GetFilesAsync();
                List<StorageFile> files = roFiles.ToList();

                foreach (StorageFile file in files)
                {
                    if (file.FileType.ToUpper() == ".JPG" || file.FileType.ToUpper() == ".JPEG")
                    {
                        photoCollection.Add(new Photo(file));
                    }
                }

                var currentView = ApplicationView.GetForCurrentView();
                CoreApplicationView photoViewer = CoreApplication.CreateNewView();

                await photoViewer.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    async () =>
                    {
                        var newWindow = Window.Current;
                        var newAppView = ApplicationView.GetForCurrentView();
                        newAppView.Title = "Photo Viewer";

                        var frame = new Frame();
                        frame.Navigate(typeof(CollectionViewer), photoCollection);
                        newWindow.Content = frame;
                        newWindow.Activate();

                        await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
                            newAppView.Id,
                            ViewSizePreference.UseMinimum,
                            currentView.Id,
                            ViewSizePreference.UseMinimum);
                    }
                    );
            }
        }
Beispiel #18
0
        public async void Openfolder(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
            picker.FileTypeFilter.Add("*");
            Windows.Storage.StorageFolder folder = await picker.PickSingleFolderAsync();

            fileviewer1.setdirectory(folder);
        }
        public IAsyncOperation<StorageFolder> PromptAsync()
        {
            var folderPicker = new FolderPicker
                               {
                                   ViewMode = PickerViewMode.List,
                                   SuggestedStartLocation = PickerLocationId.ComputerFolder,
                                   FileTypeFilter = {"*"}
                               };

            return folderPicker.PickSingleFolderAsync();
        }
 // Store the folder to access again later
 public async void SetMasterFolder()
 {
     FolderPicker picker = new FolderPicker();
     //a filter is needed despite being a folder picker
     picker.FileTypeFilter.Add(".mp3");
     picker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
     StorageFolder masterFolder = await picker.PickSingleFolderAsync();
     if (masterFolder != null)
     {
         var listToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(masterFolder, masterFolder.Path);
     }
 }
 private async void Button_Click_1(object sender, RoutedEventArgs e)
 {
     FolderPicker folderPicker = new FolderPicker();
     folderPicker.SuggestedStartLocation = PickerLocationId.Downloads;
     GeneralSettings.SetFilters(folderPicker);
     StorageFolder folder = await folderPicker.PickSingleFolderAsync();
     if (folder != null)
     {
         StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
         this.tempFilePathBox.Text = folder.Path;
     }
 }
Beispiel #22
0
		private async void BrowseButton_Tapped(object sender, RoutedEventArgs e)
		{
			MessageDialog errorDialog = null;

			if (this.EnsureUnsnapped())
			{
				FolderPicker folderPicker = new FolderPicker();
				folderPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;
				folderPicker.FileTypeFilter.Add(".");

				StorageFolder folder = await folderPicker.PickSingleFolderAsync();
				if (folder != null)
				{
					VisualStateManager.GoToState(this, "Loading", true);

					// Reset everything just in case first.
					TunesDataSource.Reset(firstRunComplete: true);

					// Application now has read/write access to all content in the picked folder (including other sub-folder content)
					TuneOut.AppData.Settings.SetLibraryLocation(folder);

					bool hasData = await TunesDataSource.Load();
					if (hasData)
					{
						// Completed First-Run
						TuneOut.AppData.Settings.IsFirstRunComplete = true;

						// Go to MainPage
						await App.Current.Navigate(typeof(MainPage), null);
						return;
					}
					else
					{
						// Error: file problem.
						errorDialog = new MessageDialog(TuneOut.AppData.LocalizationManager.GetString("FirstRunPage/FileErrorDialog/Text"), TuneOut.AppData.LocalizationManager.GetString("FirstRunPage/FileErrorDialog/Title"));
					}
				}
				else
				{
					// User cancelled.
					return;
				}
			}
			else
			{
				// Error: cannot unsnap.
				errorDialog = new MessageDialog(TuneOut.AppData.LocalizationManager.GetString("LayoutAwarePage/UnsnapText"));
			}

			VisualStateManager.GoToState(this, "NotLoading", true);
			await errorDialog.ShowAsync();
		}
 private async void ChangeFolderClick(object sender, RoutedEventArgs e)
 {
     Windows.Storage.Pickers.FolderPicker picker = new Windows.Storage.Pickers.FolderPicker();
     picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
     picker.FileTypeFilter.Add(".jpg");
     picker.FileTypeFilter.Add(".png");
     StorageFolder f = await picker.PickSingleFolderAsync();
     dataSource = new xBindSampleModel.FileDataSource();
     myGridView.ItemsSource = dataSource;
     LoadingPanel.Visibility = Visibility.Visible;
     await dataSource.SetupDataSource(f);
     LoadingPanel.Visibility = Visibility.Collapsed;
 }
Beispiel #24
0
        public Welcome()
        {
            Current = this;
            this.InitializeComponent();

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;

            _picker = new FolderPicker();
            _picker.SettingsIdentifier = "wpsystem";
            _picker.FileTypeFilter.Add("*");
        }
 private async void Button_Click_1(object sender, RoutedEventArgs e)
 {
     FolderPicker folderPicker = new FolderPicker();
     folderPicker.SuggestedStartLocation = PickerLocationId.Downloads;
     SetFilters(folderPicker);
     StorageFolder folder = await folderPicker.PickSingleFolderAsync();
     if (folder != null)
     {
         StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
         ConfigData.Instance.TempFilePath = folder.Path;
         ConfigData.Instance.Save();
     }
 }
        private void PickFolderButton_Click(object sender, RoutedEventArgs e)
        {
            // Clear previous returned folder name, if it exists, between iterations of this scenario
            OutputTextBlock.Text = "";

            FolderPicker folderPicker = new FolderPicker();
            folderPicker.SuggestedStartLocation = PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add(".docx");
            folderPicker.FileTypeFilter.Add(".xlsx");
            folderPicker.FileTypeFilter.Add(".pptx");

            folderPicker.PickFolderAndContinue();
        }
Beispiel #27
0
        private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var hwnd = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle; //WinRT.Interop.WindowNative.GetWindowHandle(this);
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();
            folderPicker.FileTypeFilter.Add("*");
            //WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, hwnd);
            //IInitializeWithCoreWindow initializeWithCoreWindow;// 这个不能使用
            var initializeWithCoreWindow = folderPicker.As<IInitializeWithWindow>();
            initializeWithCoreWindow.Initialize(hwnd);

            // Now you can call methods on folderPicker
            var folder = await folderPicker.PickSingleFolderAsync();
            Debug.WriteLine(folder.Path);
        }
Beispiel #28
0
            public async void BeginTest()
            {
                if (staCode == null)
                {
                    var staFile = enumerateFiles(Package.Current.InstalledLocation).First(x => x.DisplayName == "sta");
                    staCode = new StreamReader((await staFile.OpenReadAsync()).AsStream(0)).ReadToEnd();
                }
                (Application.Current as App).Activation += activation;

                FolderPicker picker = new FolderPicker();
                picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add(".js");
                picker.PickFolderAndContinue();
            }
        private async void PickFolder()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            folderPicker.ViewMode = PickerViewMode.List;
            folderPicker.FileTypeFilter.Add(".csv");
            StorageFolder outputFolder = await folderPicker.PickSingleFolderAsync();

            if (outputFolder != null)
            {
                // Application now has read/write access to the picked file
                this.currentFolderLocationText.Text = "Dir: " + outputFolder.Path;
                StorageFile storageFile;
                try
                {
                    storageFile = await outputFolder.GetFileAsync(AcHelper.RECORD_FILE_NAME);

                    Debug.WriteLine("File Found " + AcHelper.RECORD_FILE_NAME);
                }
                catch
                {
                    storageFile = await outputFolder.CreateFileAsync(AcHelper.RECORD_FILE_NAME);

                    Debug.WriteLine("Created File " + AcHelper.RECORD_FILE_NAME);
                }
                AcHelper.setRecordsFile(storageFile);


                //// Write picked file location to cache file
                //StorageFolder cacheFolder = await StorageFolder.GetFolderFromPathAsync(ApplicationData.Current.LocalFolder.Path);
                //StorageFile pathStorageFile;
                //try
                //{
                //    pathStorageFile = await cacheFolder.GetFileAsync(cacheFileName);
                //    Debug.WriteLine("File Found " + cacheFileName);
                //}
                //catch
                //{
                //    Debug.WriteLine("File Not Found");
                //    pathStorageFile = await cacheFolder.CreateFileAsync(cacheFileName);
                //}
                //AcHelper.WriteToFileWithoutAppend(pathStorageFile, outputFolder.Path);
            }
            else
            {
                this.currentFolderLocationText.Text = "Error!";
            }
        }
Beispiel #30
0
        public static async Task SelectLocalDirectoryAsync()
        {
            var folderPicker = new FolderPicker()
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            folderPicker.FileTypeFilter.Add("*");
            var folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                StorageApplicationPermissions.FutureAccessList.AddOrReplace(SettingLocalStorageDirectory, folder);
            }
        }
Beispiel #31
0
        public ZipViewModel(ZipModel zipModel)
        {
            _zipModel = zipModel;
            _filePicker = InitFilePicker();
            _folderPicker = new FolderPicker();
            _folderPicker.ViewMode = PickerViewMode.List;
            _folderPicker.FileTypeFilter.Add("*");

            // commands initialized
            ZipCommand = new ZipCommand(()=>Compress(),()=>true);
            FolderSelectCommand = new ZipCommand(()=> SelectFolderToZip(),()=>true);
            FilesSelectCommand = new ZipCommand(() => SelectMultipleFile(), () => true);
            //CompressionLevelChange = new ZipCommand(()=>SetCompressionLevel(SelectedItem),()=>true);

        }
        private async void ExecuteMethode()
        {
            var folderPicker = new FolderPicker();
            folderPicker.FileTypeFilter.Add(".jpg");
            folderPicker.ViewMode = PickerViewMode.Thumbnail;
            folderPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            folderPicker.SettingsIdentifier = "FolderPicker";

            var folder = await folderPicker.PickSingleFolderAsync();
            if (folder != null)
            {
                StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
            }
            _sourcepath = folder;
        }
Beispiel #33
0
        private async void ChangeFolderClick(object sender, RoutedEventArgs e)
        {
            Windows.Storage.Pickers.FolderPicker picker = new Windows.Storage.Pickers.FolderPicker();
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".png");
            StorageFolder f = await picker.PickSingleFolderAsync();

            dataSource              = new xBindSampleModel.FileDataSource();
            myGridView.ItemsSource  = dataSource;
            LoadingPanel.Visibility = Visibility.Visible;
            await dataSource.SetupDataSource(f);

            LoadingPanel.Visibility = Visibility.Collapsed;
        }
Beispiel #34
0
        async private System.Threading.Tasks.Task SetLocalDirMedia()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
            };

            folderPicker.FileTypeFilter.Add(".wmv");
            folderPicker.FileTypeFilter.Add(".mp4");
            folderPicker.FileTypeFilter.Add(".wma");
            folderPicker.FileTypeFilter.Add(".mp3");

            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                speedText.Text = "Picked folder: " + folder.Name;
                IReadOnlyList <StorageFile> fileList = await folder.GetFilesAsync();

                bool first = false;

                foreach (StorageFile file in fileList)
                {
                    VideoFileInfoList.Add(new VideoFileInfoData(file.Name, file.Path));



                    // mediaPlayer is a MediaPlayerElement defined in XAML
                    if (file != null)
                    {
                        if (!first)
                        {
                            mediaPlayer.Source = MediaSource.CreateFromStorageFile(file);

                            mediaPlayer.MediaPlayer.Play();

                            first = true;
                        }
                    }
                }
            }
            else
            {
                UpShowText("Operation cancelled.");
            }
        }
        private async void OpenFolderClick(object sender, RoutedEventArgs e)
        {
            var picker = new FolderPicker()
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                FileTypeFilter = { "*" },
            };

#if WINDOWS_APP
            var folder = await picker.PickSingleFolderAsync();
            DisplayFolderInfo(folder);
#elif WINDOWS_PHONE_APP
            picker.PickFolderAndContinue();
#endif
        }
 public static void SetFilters(FolderPicker folderPicker)
 {
     folderPicker.FileTypeFilter.Add(".docx");
     folderPicker.FileTypeFilter.Add(".mp3");
     folderPicker.FileTypeFilter.Add(".ogg");
     folderPicker.FileTypeFilter.Add(".zip");
     folderPicker.FileTypeFilter.Add(".rar");
     folderPicker.FileTypeFilter.Add(".exe");
     folderPicker.FileTypeFilter.Add(".iso");
     folderPicker.FileTypeFilter.Add(".mdf");
     folderPicker.FileTypeFilter.Add(".avi");
     folderPicker.FileTypeFilter.Add(".mpeg");
     folderPicker.FileTypeFilter.Add(".rm");
     folderPicker.FileTypeFilter.Add(".wma");
     folderPicker.FileTypeFilter.Add(".wav");
 }
Beispiel #37
0
    private async void OpenFileAsync()
    {
        Debug.Log("In Async ");
        var folderPicker = new Windows.Storage.Pickers.FolderPicker();

        folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
        folderPicker.FileTypeFilter.Add("*");

        Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

        if (folder != null)
        {
            // Application now has read/write access to all contents in the picked folder
            // (including other sub-folder contents)
            Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
            IReadOnlyList <StorageFile> sortedItems = await folder.GetFilesAsync(CommonFileQuery.OrderByName);

            utility.numFrames = sortedItems.Count - 1;
            frameCounter      = sortedItems.Count - 1;
            List <StreamReader> stream_reader_files = new List <StreamReader>();
            Debug.Log("total number of files: " + sortedItems.Count);
            foreach (StorageFile file in sortedItems)
            {
                var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

                using (var inputStream = stream.GetInputStreamAt(0))
                {
                    var reader = new DataReader(inputStream);
                    byteArray = new byte[stream.Size];
                    await reader.LoadAsync((uint)stream.Size);

                    reader.ReadBytes(byteArray);
                    stream_reader_files.Add(new StreamReader(new MemoryStream(byteArray)));
                }
            }
            Debug.Log("the stream_reader_files length is:" + stream_reader_files.Count);
            utility.ReadFrames(stream_reader_files);
            utility.GetStructureData();
            isAsyncDone = true;
            Debug.Log("GetStructureData in async in working.");
        }
        else
        {
            Debug.Log("cancelled. clicked");
            isCancelled = true;
        }
    }
Beispiel #38
0
        async Task<StorageFolder> PickOutputFolder(string title)
        {
#if WINDOWS_PHONE_APP
            await new MessageDialog("Not supported on Windows Phone. Please run on a Windows PC instead.").ShowAsync();

            return null;
#else
            var folderPicker = new FolderPicker
            {
                CommitButtonText = title,
                SuggestedStartLocation = PickerLocationId.Desktop,
                FileTypeFilter = { ".png" },
            };

            return await folderPicker.PickSingleFolderAsync();
#endif
        }
Beispiel #39
0
 public async Task<bool> ChooseNewFolderAsync()
 {
     FolderPicker folderPicker = new FolderPicker()
     {
         SuggestedStartLocation = PickerLocationId.DocumentsLibrary
     };
     folderPicker.FileTypeFilter.Add(".xml");
     IStorageFolder folder = await folderPicker.PickSingleFolderAsync();
     if (folder != null)
     {
         excuseFolder = folder;
         return true;
     }
     MessageDialog warningDialog = new MessageDialog("No excuse folder chosen");
     await warningDialog.ShowAsync();
     return false;
 }
Beispiel #40
0
        async private void SongLocation_Click(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");
            Windows.Storage.StorageFolder folderPath = await folderPicker.PickSingleFolderAsync();

            if (folderPath != null)
            {
                // Application now has read/write access to the picked file
                this.txtSongPathName.Text = folderPath.Path;
            }
            else
            {
                this.txtSongPathName.Text = "Operation cancelled.";
            }
        }
        public async static Task <StorageFolder> StorageFolderPicker(string token)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            //folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");
            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace(token, folder);
                return(folder);
            }
            else
            {
                return(null);
            }
        }
Beispiel #42
0
        private async void BtnDestinationFolder_Click(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
            };

            folderPicker.FileTypeFilter.Add("*");
            DestinationFolder = await folderPicker.PickSingleFolderAsync();

            if (DestinationFolder != null)
            {
                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", DestinationFolder);
                txtDestinationInput.Text = "Picked folder: " + DestinationFolder.Name;
            }
            else
            {
                txtDestinationInput.Text = "Operation cancelled.";
            }
        }
Beispiel #43
0
    private async void ButtonAddFolder_Click(object sender, RoutedEventArgs e)
    {
        var picker = new Windows.Storage.Pickers.FolderPicker();

        picker.FileTypeFilter.Add("*");
        var folder = await picker.PickSingleFolderAsync();

        if (folder is null)
        {
            return;
        }

        if (DataContext is ViewModels.LibraryMemberViewModel vm && vm.Content != null)
        {
            var items = vm.Content?.Items?.ToList() ?? new List <object>();
            items.Add(await Managers.BookManager.GetTokenFromPathOrRegister(folder));
            vm.Content.Items = items.ToArray();
            //vm.OnPropertyChanged(nameof(vm.Items));
        }
    }
Beispiel #44
0
        private async void SaveToFile(object sender, RoutedEventArgs e)
        {
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            await localFolder.CreateFolderAsync("9mabt17s", CreationCollisionOption.OpenIfExists);

            StorageFolder temp = await localFolder.GetFolderAsync("9mabt17s");

            StorageFile themeConfiguration = await temp.CreateFileAsync("Theme.Config", Windows.Storage.CreationCollisionOption.ReplaceExisting);

            string[] lines = { ThemeName.Text, ThemeTextBox1.Text, ThemeTextBox2.Text, ThemeTextBox3.Text, ThemeTextBox4.Text, ThemeTextBox5.Text };
            File.WriteAllLines(themeConfiguration.Path, lines);

            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");


            if (Image01d != null && Image01n != null && Image02d != null && Image02n != null && Image03d != null && Image03n != null && Image04d != null && Image04n != null && Image09d != null && Image09n != null && Image10d != null && Image10n != null && Image11d != null && Image11n != null && Image13d != null && Image13n != null && Image50d != null && Image50n != null && IconThumnail != null)
            {
                StorageFolder folder = await folderPicker.PickSingleFolderAsync();

                if (folder != null)
                {
                    StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                    await Task.Run(() =>
                    {
                        try
                        {
                            ZipFile.CreateFromDirectory(temp.Path, $"{folder.Path}\\{Guid.NewGuid()}.udw");
                            Debug.WriteLine("folder zipped");
                        }
                        catch (Exception w)
                        {
                            Debug.WriteLine(w);
                        }
                    });
                }
            }
        }
Beispiel #45
0
        /// <summary>
        /// Select directory to save the image stream
        /// </summary>
        /// <param name="stream"></param>
        public async void SelectDirectory(Stream stream)
        {
            this.stream = stream;
            IRandomAccessStream randomAccessStream = this.stream.AsRandomAccessStream();
            var wbm = new WriteableBitmap(600, 800);
            await wbm.SetSourceAsync(randomAccessStream);

            string fileName     = "image.jpg";
            var    folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");
            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            string SelectedFolderPath = folder.Path;

            if (folder != null)
            {
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                StorageFile file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

                using (var storageStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, storageStream);

                    var pixelStream = wbm.PixelBuffer.AsStream();
                    var pixels      = new byte[pixelStream.Length];
                    await pixelStream.ReadAsync(pixels, 0, pixels.Length);

                    encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, (uint)wbm.PixelWidth, (uint)wbm.PixelHeight, 200, 200, pixels);
                    await encoder.FlushAsync();
                }
            }
        }
Beispiel #46
0
        public static async Task <StorageFolder> OpenFolderPicker(string token)
        {
            try
            {
                var folderPicker = new Windows.Storage.Pickers.FolderPicker();
                folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                folderPicker.FileTypeFilter.Add("*");
                var folder = await folderPicker.PickSingleFolderAsync();

                if (folder != null)
                {
                    Windows.Storage.AccessCache.StorageApplicationPermissions.
                    FutureAccessList.AddOrReplace(token, folder);
                }
                return(folder);
            }
            catch (Exception ex)
            {
                ThrowUnHandleException(ex);
                await UIHelper.ShowMessageDialog("Unable to open the specified folder.");

                return(null);
            }
        }
Beispiel #47
0
        public async Task GetBooks()
        {
            // Get library from a folder picker
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");

            // Get the metadata.db file
            StorageFile   MetadataFile  = default;
            StorageFolder LibraryFolder = await folderPicker.PickSingleFolderAsync();

            if (LibraryFolder != null)
            {
                // copy sqlite database file to temporary local folder,
                // because UWP file access permissions don't work in SQLite.
                MetadataFile = await StorageFile.GetFileFromPathAsync(LibraryFolder.Path + "\\metadata.db");

                await MetadataFile.CopyAsync(ApplicationData.Current.LocalFolder, MetadataFile.Name, NameCollisionOption.ReplaceExisting);
            }

            // Read books from Calibre's sqlite database
            using (SqliteConnection sqlite = new SqliteConnection($"Filename={MetadataFile.Name}"))
            {
                try
                {
                    sqlite.Open();

                    SqliteCommand createTable
                        = new SqliteCommand(
                              "SELECT " +
                              "   books.title, " +
                              "   books.sort, " +
                              "   IFNULL(series.name, \"\")," +
                              "   books.series_index, " +
                              "   authors.name, " +
                              "   books.author_sort, " +
                              "   books.path, " +
                              "   books.id " +
                              "FROM " +
                              "   books " +
                              "   LEFT JOIN books_authors_link ON books.id = books_authors_link.book " +
                              "   LEFT JOIN authors ON authors.id = books_authors_link.author" +
                              "   LEFT JOIN books_series_link ON books.id = books_series_link.book " +
                              "   LEFT JOIN series ON series.id = books_series_link.series " +
                              "ORDER BY books.sort",
                              sqlite);

                    SqliteDataReader query = createTable.ExecuteReader();

                    while (query.Read())
                    {
                        string title_name   = query.GetString(0);
                        string title_sort   = query.GetString(1);
                        string series_name  = query.GetString(2);
                        string series_index = query.GetString(3);
                        string author_name  = query.GetString(4);
                        string author_sort  = query.GetString(5);
                        string path         = query.GetString(6);

                        Uri cover = new Uri(LibraryFolder.Path + "\\" + path + "\\cover.jpg");

                        Book book = new Book(
                            title_name,
                            title_sort,
                            series_name,
                            series_index,
                            author_name,
                            author_sort,
                            cover
                            );

                        Books.Add(book);
                    }

                    sqlite.Close();
                }
                catch (SqliteException e)
                {
                    Debug.WriteLine(e.Message);
                }
            }
        }
        /// <summary>
        /// Сохраняет развертку в локальную папку
        /// </summary>
        /// <param name="data"></param>
        /// <param name="Tail"></param>
        /// <param name="time"></param>
        /// <param name="nameFile"></param>
        /// <returns></returns>
        public async Task saveAsync(int[,] data, int[,] Tail, string time, string nameFile, bool Taill)
        {
            string cul          = "en-US";
            var    folderPicker = new Windows.Storage.Pickers.FolderPicker();

            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add("*");

            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                StorageFolder storageFolderRazvertka = await folder.CreateFolderAsync("Развертка", CreationCollisionOption.OpenIfExists);

                StorageFile sampleFile = await storageFolderRazvertka.CreateFileAsync(nameFile + time + ".txt", CreationCollisionOption.ReplaceExisting);

                var stream = await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                using (var outputStream = stream.GetOutputStreamAt(0))
                {
                    using (var dataWriter = new Windows.Storage.Streams.DataWriter(outputStream))
                    {
                        string s = "i" + "\t" + "Ch1" + "\t" + "Ch2" + "\t" + "Ch3" + "\t" + "Ch4" + "\t" + "Ch5" + "\t" + "Ch6" + "\t" + "Ch7" + "\t" + "Ch8" + "\t" + "Ch9" + "\t" + "Ch10" + "\t" + "Ch11" + "\t" + "Ch12" + "\r\n";
                        for (int i = 0; i < 1024; i++)
                        {
                            s = s + (i + 1).ToString() + "\t";
                            for (int j = 0; j < 12; j++)
                            {
                                s = s + data[j, i] + "\t";
                            }
                            if (i < 1023)
                            {
                                s = s + "\r\n";
                            }
                            else
                            {
                            }
                        }
                        dataWriter.WriteString(s);
                        s = null;
                        await dataWriter.StoreAsync();

                        await outputStream.FlushAsync();
                    }
                }
                stream.Dispose(); // Or use the stream variable (see previous code snippet) with a using statement as well.
                if (Taill)
                {
                    // storageFolderRazvertka = await storageFolderRazvertka.CreateFolderAsync("Развертка", CreationCollisionOption.OpenIfExists);
                    sampleFile = await storageFolderRazvertka.CreateFileAsync(nameFile + time + "Хвост" + ".txt", CreationCollisionOption.ReplaceExisting);

                    stream = await sampleFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

                    using (var outputStream = stream.GetOutputStreamAt(0))
                    {
                        using (var dataWriter = new Windows.Storage.Streams.DataWriter(outputStream))
                        {
                            string s = "i" + "\t" + "Ch1" + "\t" + "Ch2" + "\t" + "Ch3" + "\t" + "Ch4" + "\t" + "Ch5" + "\t" + "Ch6" + "\t" + "Ch7" + "\t" + "Ch8" + "\t" + "Ch9" + "\t" + "Ch10" + "\t" + "Ch11" + "\t" + "Ch12" + "\r\n";
                            for (int i = 0; i < 20000; i++)
                            {
                                s = s + (i + 1).ToString() + "\t";
                                for (int j = 0; j < 12; j++)
                                {
                                    s = s + Tail[j, i] + "\t";
                                }
                                if (i < 19999)
                                {
                                    s = s + "\r\n";
                                }
                                else
                                {
                                }

                                dataWriter.WriteString(s);
                                s = null;
                            }

                            await dataWriter.StoreAsync();

                            await outputStream.FlushAsync();
                        }
                    }
                    stream.Dispose();
                }
            }
        }