/// <summary>
        /// Opens the file dialog, to select the images 
        /// which will be shown.
        /// </summary>
        private async Task OpenFileDialogAsync()
        {
            this.IsLoading = true;

            var folderPicker = new Windows.Storage.Pickers.FolderPicker();
            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
            this.Pictures.Clear();
            try
            {
                IReadOnlyList<StorageFile> files = await folder.GetFilesAsync();
                foreach (StorageFile filename in files)
                {
                    this.Pictures.Add(await LoadPictureAsync(filename.Path));
                }
            }
            catch (Exception)
            {

            }
            finally
            {

                this.IsLoading = false;
            }
        }
Exemple #2
0
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

            var filesList =
                await folder.CreateFileQueryWithOptions(new QueryOptions(CommonFileQuery.DefaultQuery,
                                                                         new string[] { ".jpg" })).GetFilesAsync();

            for (int i = 0; i < filesList.Count; i++)
            {
                using (var stream = await filesList[i].OpenAsync(Windows.Storage.FileAccessMode.Read))
                {
                    Debug.WriteLine(filesList[i].Name);
                    var bitmapImage = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
                    await bitmapImage.SetSourceAsync(stream);

                    Image m = new Image();
                    m.Source = bitmapImage;
                    Stack.Children.Add(m);
                }
            }
        }
Exemple #3
0
        private async void PickPlayListFolderButton_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 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("PlaylistFolder", folder);
                ChosenFolderText.Text        = "Picked folder: " + folder.Name;
                SongListStorage.PlaylistDict = new ConcurrentDictionary <long, Playlist>();
                SongListStorage.LoadFlavours();
                SongListStorage.PlayListFolder = folder;
            }
            else
            {
                ChosenFolderText.Text = "No Folder Found.";
            }
        }
Exemple #4
0
        //Saves the current shapes and groups to a file
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads;
            picker.FileTypeFilter.Add("*");

            savefolder = await picker.PickSingleFolderAsync();

            Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("savefolder", savefolder);

            StorageFile obsolete = await savefolder.GetFileAsync("save.txt");

            if (obsolete != null)
            {
                await obsolete.DeleteAsync();
            }

            StorageFile savefile = await savefolder.CreateFileAsync("save.txt");

            IRandomAccessStream sw = await savefile.OpenAsync(FileAccessMode.ReadWrite);

            DataWriter writer     = new DataWriter(sw);
            Save       saveAction = new Save(group, writer, 0);

            actionmanager.takeAction(saveAction);
            actionmanager.executeActions();
            await writer.StoreAsync();
        }
Exemple #5
0
        //Loads the shapes and groups from a file
        private async void Load_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads;
            picker.FileTypeFilter.Add("*");

            savefolder = await picker.PickSingleFolderAsync();

            Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("savefolder", savefolder);

            StorageFile load = await savefolder.GetFileAsync("save.txt");

            IRandomAccessStream sw = await load.OpenAsync(FileAccessMode.Read);

            var        istream = sw.GetInputStreamAt(0);
            DataReader reader  = new DataReader(istream);
            await reader.LoadAsync(Convert.ToUInt32(sw.Size));

            string        loadstring = reader.ReadString(Convert.ToUInt32(sw.Size));
            List <string> lines      = new List <string>();

            lines.AddRange(loadstring.Split("\n"));
            lines.RemoveAt(0);
            lines.RemoveAt(lines.Count - 1);
            group.groupitems.Clear();
            itemcount = 1;
            Load loadAction = new Load(group, lines);

            actionmanager.takeAction(loadAction);
            actionmanager.executeActions();
            Update(true);
            Update(false);
        }
Exemple #6
0
        private async void ButtonExport_Click(object sender, RoutedEventArgs e)
        {
            DisableUi();

            try
            {
                var picker = new Windows.Storage.Pickers.FolderPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
                picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add(".html");

                Windows.Storage.StorageFolder folder = await picker.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);
                    await application.ExportTrainingAsync(training, training.ID + "_" + training.Name + ".html", folder);
                }
            }
            finally
            {
                EnableUi();
            }
        }
Exemple #7
0
        public async Task OpenFolderPicker()
        {
            try
            {
                // 이거 참 그지 같구만
                Windows.Storage.Pickers.FolderPicker folderPicker = new Windows.Storage.Pickers.FolderPicker();
                folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;
                folderPicker.FileTypeFilter.Add("*");

                StorageFolder folder = await folderPicker.PickSingleFolderAsync();

                if (folder != null)
                {
                    storageFolder = folder;
                }
                else
                {
                    CommonFeature.Feature.ShowMessageAsync("you selected nothing");
                    storageFolder = null;
                }
            }
            catch (Exception e)
            {
                CommonFeature.Feature.ShowMessageAsync("Exception OpenFolderPicker : " + e.Message);
            }
            // 참고해 봐야 할 듯
            //https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/FileAccess/cs
        }
        /// <summary>
        /// Set the folder to store images with FolderPicker.
        /// </summary>
        /// <returns>The folder user choose.</returns>
        public async Task <StorageFolder> SetFolderAsync()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                if (folder.Name != RootFolderName)
                {
                    var isEmpty = await IsFolderEmpty(folder).ConfigureAwait(false);

                    if (!isEmpty)
                    {
                        folder = await folder.CreateFolderAsync(RootFolderName, CreationCollisionOption.OpenIfExists);
                    }
                }
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace(PickFolderToken, folder);
            }

            return(folder);
        }
        private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();
            folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            folderPicker.FileTypeFilter.Add(".mp3");
            folderPicker.FileTypeFilter.Add(".m4a");
            folderPicker.FileTypeFilter.Add(".flac");
            folderPicker.FileTypeFilter.Add(".aac");
            StorageFolder folder = await folderPicker.PickSingleFolderAsync();
            if (folder != null)
            {
                if (folderPaths.SaveFoldertoStorage(folder))
                {
                    await Task.Run(() =>
                    {
                        folderPaths.SaveFoldertoSettings();
                    });
                }

            }
            else
            {

            }

        }
        private async void AppBarButton_Click_AddLocalDirectory(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();

            foreach (var ext in Books.BookManager.AvailableExtensionsArchive)
            {
                picker.FileTypeFilter.Add(ext);
            }
            var folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();

                var dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Started/Message"), rl.GetString("LoadingFolder/Title"));
                await dialog.ShowAsync();

                var storage = await BookShelfStorage.GetBookShelves();

                CurrentOperationCount++;
                storage.Add(BookShelfStorage.GetFlatBookShelf(await BookShelfStorage.GetFromStorageFolder(folder)));
                CurrentOperationCount--;
                Refresh();
                if (BookShelfList.Items != null)
                {
                    BookShelfList.SelectedIndex = BookShelfList.Items.Count - 1;
                }

                dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Completed/Message"), rl.GetString("LoadingFolder/Title"));
                await dialog.ShowAsync();
            }
            await BookShelfStorage.SaveAsync();
        }
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                Status.Text = "Starting...";
                Uri uri = (new Uri("https://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_30mb.mp4"));
                Windows.Storage.Pickers.FolderPicker folderPicker = new Windows.Storage.Pickers.FolderPicker();
                folderPicker.FileTypeFilter.Add("*");
                var folder = await folderPicker.PickSingleFolderAsync();

                var destinationFile = await folder.CreateFileAsync("sample.mp4", CreationCollisionOption.ReplaceExisting);

                await new TransferOperation().CreateDownload(
                    uri,
                    destinationFile,
                    new CancellationToken(),
                    new Progress <TransferOperation.TransferOperationProgress>(DownloadProgress),
                    chunkSize: 10_485_760
                    );
                Status.Text = "Complete !";
            }
            catch (Exception ex)
            {
                Status.Text = ex.Message;
            }
        }
Exemple #12
0
        public static async Task <StorageFolder> SelectFolder(string mruKey = null)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker()
            {
                ViewMode = Windows.Storage.Pickers.PickerViewMode.List,
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.ComputerFolder
            };

            picker.FileTypeFilter.Add("*");

            var folder = await picker.PickSingleFolderAsync();

            if (folder == null)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(mruKey))
            {
                var mru = StorageApplicationPermissions.MostRecentlyUsedList;
                mru.Add(folder, mruKey);
            }

            return(folder);
        }
        /// <summary>
        /// Implementation for picking a folder on UWP platform.
        /// </summary>
        /// Specifies one or multiple allowed types. When null, all folder types
        /// can be selected while picking.
        /// On UWP, specify a list of extensions, like this: ".jpg", ".png".
        /// <returns>
        /// Folder data object, or null when user cancelled picking folder
        /// </returns>
        public async Task <FolderData> PickFolder()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

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

            if (storageFolder == null)
            {
                return(null);
            }
            var folder = new FolderData()
            {
                FolderPath = storageFolder.Path + Path.DirectorySeparatorChar,
                FolderName = Path.GetDirectoryName(storageFolder.Path)
            };

            // Application now has read/write access to all contents in the picked folder
            // (including other sub-folder contents)
            //        StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
            var t = StorageApplicationPermissions.FutureAccessList.Add(storageFolder);

            if (tokenDictionary.ContainsKey(folder.FolderPath))
            {
                tokenDictionary[folder.FolderPath] = t;
            }
            else
            {
                tokenDictionary.Add(folder.FolderPath, t);
            }

            return(folder);
        }
        private async void AddFolder(Helpers.MediaHelper.MediaType mediaType, string Extensions)
        {
            string typeMedia = string.Empty;
            string filters   = string.Empty;

            localPlaylistItemsCount.Text = "-1";

            Windows.Storage.Pickers.PickerLocationId id = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
            if (mediaType == Helpers.MediaHelper.MediaType.Music)
            {
                typeMedia = "music";
                id        = Windows.Storage.Pickers.PickerLocationId.MusicLibrary;
                filters   = Helpers.MediaHelper.audioExts;
            }
            else if (mediaType == Helpers.MediaHelper.MediaType.Video)
            {
                typeMedia = "video";
                id        = Windows.Storage.Pickers.PickerLocationId.VideosLibrary;
                filters   = Helpers.MediaHelper.videoExts;
            }
            else if (mediaType == Helpers.MediaHelper.MediaType.Picture)
            {
                typeMedia = "picture";
                id        = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                filters   = Helpers.MediaHelper.pictureExts;
            }

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

            folderPicker.FileTypeFilter.Add("*");
            folderPicker.SuggestedStartLocation = id;
            folderPicker.SettingsIdentifier     = "PlaylistPicker";
            folderPicker.CommitButtonText       = "Select the folder to create a " + typeMedia + " Playlist";
            ClearErrorMessage();

            var folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                string fileToken = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(folder);
                try
                {
                    Shell.Current.DisplayWaitRing            = true;
                    ViewModelLocator.Settings.PlaylistFolder = folder.Path;
                    ViewModelLocator.Settings.PlaylistName   = await Helpers.MediaHelper.GetUniquePlaylistName(folder.Path);

                    ViewModelLocator.Settings.PlaylistFilters = filters;
                    ViewModelLocator.Settings.PlaylistPath    = await Helpers.MediaHelper.GetUniquePlaylistPath(folder.Path);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);
                }
                finally
                {
                    Shell.Current.DisplayWaitRing = false;
                    UpdateControls();
                }
            }
        }
        /// <summary>
        /// Download the selected items.
        /// </summary>
        private async void downloadButton_Click(object sender, RoutedEventArgs e)
        {
            bool unsnapped = ((ApplicationView.Value != ApplicationViewState.Snapped) ||
                              ApplicationView.TryUnsnap());

            if (!unsnapped)
            {
                NotifyUser("Cannot unsnap the sample.");
                return;
            }


            // Select a folder as target.
            Windows.Storage.Pickers.FolderPicker picker = new Windows.Storage.Pickers.FolderPicker();
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;

            picker.FileTypeFilter.Add("*");

            var folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                // Download the items.
                var itemsToDownload = itemGridView.SelectedItems.Select(i => (i as DataModel.SampleDataItem).Content);
                FTP.FTPDownloadManager.Instance.DownloadFTPItemsAsync(
                    itemsToDownload, folder, credential);
            }

            // Clear the selection.
            itemGridView.SelectedItems.Clear();
            itemListView.SelectedItems.Clear();
        }
Exemple #16
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var folderpicker = new Windows.Storage.Pickers.FolderPicker();

            folderpicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.ComputerFolder;
            folderpicker.FileTypeFilter.Add("*");

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

            string pathstr = folder.Path;

            Windows.Storage.StorageFile file = await folder.CreateFileAsync("sample.txt", CreationCollisionOption.GenerateUniqueName);

            List <string> output = new List <string>();

            foreach (StorageFile sfile in await folder.GetFilesAsync())
            {
                output.Add(sfile.Name + "\n");
            }

            stores.ItemsSource = output;

            if (!string.IsNullOrEmpty(path.Text) && !string.IsNullOrWhiteSpace(path.Text))
            {
                //string Path = path.Text;
                //DataAccess.AddData(Path);
                //StoreDirectories.Stores = await DataAccess.GetStores();
                //stores.ItemsSource = StoreDirectories.Stores;
            }
        }
Exemple #17
0
        private async void BrowseDefaultFolder_Click(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

            StorageFolder defaultfolder = await folderPicker.PickSingleFolderAsync();

            if (defaultfolder != null)
            {
                // Application now has read/write access to all contents in the picked folder
                // (including other sub-folder contents)
                StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", defaultfolder);
                DefaultDirectory.Text = defaultfolder.Name;
                await FeedFoldersToListView();

                LinkedFolder.Visibility        = Visibility.Visible;
                FolderLabel.Visibility         = Visibility.Visible;
                BrowseDefaultFolder.Visibility = Visibility.Collapsed;
            }
            else
            {
                DefaultDirectory.Text = "None";
            }
        }
Exemple #18
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            var opener = new Windows.Storage.Pickers.FolderPicker();

            opener.FileTypeFilter.Add(".txt");

            StorageFolder folder = await opener.PickSingleFolderAsync();

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

                // Got it.
                IReadOnlyList <StorageFile> files = await folder.GetFilesAsync();

                if (files != null)
                {
                    foreach (StorageFile f in files)
                    {
                        noteslist.Add(new Note()
                        {
                            name = f.DisplayName,
                            file = f
                        });
                    }

                    list.ItemsSource = noteslist;
                }
            }
        }
Exemple #19
0
        async void LetUserPickFolder()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
            };

            folderPicker.FileTypeFilter.Add("*");

            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                EmptyMessage.Visibility = Visibility.Collapsed;

                StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);

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

                App.MyDownLoadFolder = "PickedFolderToken";

                DisplayFiles(ref files);
            }
            else
            {
                // operation failed
            }
        }
Exemple #20
0
        private async Task <IList <StorageFile> > PickFolder()
        {
            IList <StorageFile> listMusicFiles = null;
            //IList<StorageFolder> listSubFolder = null;
            var folderPicker = new Windows.Storage.Pickers.FolderPicker
            {
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.MusicLibrary
            };

            folderPicker.FileTypeFilter.Add("*");

            StorageFolder choosenFolder = await folderPicker.PickSingleFolderAsync();

            m_PathFolderChoosen = choosenFolder.Path;

            if (choosenFolder != null)
            {
                Windows.Storage.AccessCache.StorageApplicationPermissions.
                FutureAccessList.AddOrReplace("PickedFolderToken", choosenFolder);
                listMusicFiles = ConvertList(await choosenFolder.GetFilesAsync());

                RemoveNotMusicFiles(listMusicFiles);
            }

            return(listMusicFiles);
        }
Exemple #21
0
        public async Task <List <Track> > AddTracks()
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

            var folder = await folderPicker.PickSingleFolderAsync();

            if (folder == null)
            {
                return(null);
            }

            var res   = new List <Track>();
            var files = await folder.GetFilesAsync();

            foreach (var file in files)
            {
                res.Add(new Track
                {
                    FileName      = file.Name,
                    AbsolutePath  = file.Path,
                    FileExtension = Path.GetExtension(file.Path),
                });
            }

            // 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);
            return(res);
        }
Exemple #22
0
        private async void AppBarButton_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                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.StorageFile sampleFile = await folder.CreateFileAsync("ReportBluetooth.txt", Windows.Storage.CreationCollisionOption.GenerateUniqueName);

                    await Windows.Storage.FileIO.WriteTextAsync(sampleFile, terminalText.Text);
                }
                else
                {
                    await new MessageDialog("Operation cancelled.").ShowAsync();
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message).ShowAsync();
            }
        }
        private async void AppBarButton(object sender, RoutedEventArgs e)
        {
            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)
            {
                if (DataColec.Count != 0)
                {
                    using (StreamWriter writer =
                               new StreamWriter(await folder.OpenStreamForWriteAsync(
                                                    "TempSob" + "." + "txt", CreationCollisionOption.GenerateUniqueName)))
                    {
                        string sSob = "DateTime" + "\t" + "SobTemp" + "\t" + "SumDTemp" + "\t" + "TempD1" + "\t" + "TempD2" + "\t" + "TempD3" + "\t" + "TempD4" + "\t" + "TempD5" + "\t" + "TempD6" + "\t" + "TempD7"
                                      + "\t" + "TempD8" + "\t" + "TempD9" + "\t" + "TempD10" + "\t" + "TempD11" + "\t" + "TempD12";

                        await writer.WriteLineAsync(sSob);

                        foreach (ClassTemp sob in DataColec)
                        {
                            string Sob = sob.dateTime.ToString() + "\t" + sob.colSob.ToString() + "\t" + sob.Temp.ToString() + "\t" + sob.mTemp[0].ToString() + "\t" + sob.mTemp[1].ToString() + "\t" +
                                         sob.mTemp[2].ToString() + "\t" + sob.mTemp[3].ToString() + "\t" + sob.mTemp[4].ToString() + "\t" + sob.mTemp[5].ToString() + "\t" + sob.mTemp[6].ToString() + "\t" + sob.mTemp[7].ToString() +
                                         "\t" + sob.mTemp[8].ToString() + "\t" + sob.mTemp[9].ToString() + "\t" + sob.mTemp[10].ToString() + "\t" + sob.mTemp[11].ToString();
                            await writer.WriteLineAsync(Sob);
                        }
                    }
                }
                if (DataColecN.Count != 0)
                {
                    using (StreamWriter writer =
                               new StreamWriter(await folder.OpenStreamForWriteAsync(
                                                    "TempSobN" + "." + "txt", CreationCollisionOption.GenerateUniqueName)))
                    {
                        string sSob = "DateTime" + "\t" + "STemp" + "\t" + "TempD1" + "\t" + "TempD2" + "\t" + "TempD3" + "\t" + "TempD4" + "\t" + "TempD5" + "\t" + "TempD6" + "\t" + "TempD7"
                                      + "\t" + "TempD8" + "\t" + "TempD9" + "\t" + "TempD10" + "\t" + "TempD11" + "\t" + "TempD12";


                        await writer.WriteLineAsync(sSob);

                        foreach (ClassTemp sob in DataColecN)
                        {
                            string Sob = sob.dateTime.ToString() + "\t" + sob.Temp.ToString() + "\t" + sob.mTemp[0].ToString() + "\t" + sob.mTemp[1].ToString() + "\t" +
                                         sob.mTemp[2].ToString() + "\t" + sob.mTemp[3].ToString() + "\t" + sob.mTemp[4].ToString() + "\t" + sob.mTemp[5].ToString() + "\t" + sob.mTemp[6].ToString() + "\t" + sob.mTemp[7].ToString() +
                                         "\t" + sob.mTemp[8].ToString() + "\t" + sob.mTemp[9].ToString() + "\t" + sob.mTemp[10].ToString() + "\t" + sob.mTemp[11].ToString();
                            await writer.WriteLineAsync(Sob);
                        }
                    }
                }

                MessageDialog messageDialog = new MessageDialog("Темп сохранен");
                await messageDialog.ShowAsync();
            }
            else
            {
            }
        }
Exemple #24
0
        public async Task <bool> ChangeUserDataFolder()
        {
            MediaManager.StopCacheDownload();


            try
            {
                var folderPicker = new Windows.Storage.Pickers.FolderPicker();
                folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads;
                folderPicker.FileTypeFilter.Add("*");

                var folder = await folderPicker.PickSingleFolderAsync();

                if (folder != null && folder.Path != _DownloadFolder?.Path)
                {
                    try
                    {
                        await CacheFolderMigration(folder);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                    }

                    if (false == String.IsNullOrWhiteSpace(CurrentFolderAccessToken))
                    {
                        Windows.Storage.AccessCache.StorageApplicationPermissions.
                        FutureAccessList.Remove(CurrentFolderAccessToken);
                        CurrentFolderAccessToken = null;
                    }

                    Windows.Storage.AccessCache.StorageApplicationPermissions.
                    FutureAccessList.AddOrReplace(FolderAccessToken, folder);

                    _DownloadFolder = folder;

                    CurrentFolderAccessToken = FolderAccessToken;
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
            }
            finally
            {
                try
                {
                    if (MediaManager != null)
                    {
                        await MediaManager.OnCacheFolderChanged();
                    }
                }
                catch { }
            }

            return(true);
        }
Exemple #25
0
        /// <summary>
        /// フォルダーを開く
        /// </summary>
        private async void ButtonOpenFolder_Click(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker
            {
                // フォルダーの選択ボタンのラベルのテキスト
                CommitButtonText = "このフォルダーを選択する",
                // 初期フォルダー
                SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
            };

            // すべてのファイル
            folderPicker.FileTypeFilter.Add("*");

            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder == null)
            {
                return;
            }

            // フォルダー内コンテンツの読み書きのアクセス権を追加する
            Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);

            // 選択されたファイルのパスをリストビューに表示する
            ListView.ItemsSource = await GetFileNmaeInFolderAsync(folder);
        }
Exemple #26
0
        private async void DefaultButton_Click(object sender, RoutedEventArgs e)
        {
            var folderPicker = new Windows.Storage.Pickers.FolderPicker();

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

            StorageFolder folder = await folderPicker.PickSingleFolderAsync();

            if (folder != null)
            {
                folder = await folder.CreateFolderAsync("Project Tracker");

                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                Globals.storageLocation = folder;
                if (!Globals.appSettings.Containers.ContainsKey("Storage"))
                {
                    Globals.appSettings.CreateContainer("Storage", ApplicationDataCreateDisposition.Always);
                }
                Globals.appSettings.Containers["Storage"].Values["DefaultLocation"] = Globals.storageLocation.Path;
                DefaultBlock.Text = Globals.storageLocation.Path;
            }
            else
            {
                var dialog = new MessageDialog("No folder selected!", "Operation Cancelled");

                await dialog.ShowAsync();
            }
            //Globals.appSettings.DeleteContainer("Storage");
        }
Exemple #27
0
        public async Task addLocation()
        {
            try
            {
                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)
                    StorageApplicationPermissions.FutureAccessList.AddOrReplace(folder.DisplayName, folder);
                }
                else
                {
                }
                fileAndFolderViewer.ListCol.Clear();


                ViewLeft.InitializeTreeView();
                ViewRight.InitializeTreeView();


                InitializeDataGridView();
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message).ShowAsync();
            }
        }
Exemple #28
0
        public async void EnqueueDocumentsInFolderPicker(string libraryName, IPromise promise)
        {
            if (!_libraries.ContainsKey(libraryName))
            {
                promise.Reject(new Exception($"Library {libraryName} has not been opened."));
                return;
            }

            try
            {
                // Allow the user to choose a folder to index.
                var folderPicker = new Windows.Storage.Pickers.FolderPicker
                {
                    SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
                };
                folderPicker.FileTypeFilter.Add("*");

                StorageFolder folder = null;
                await CoreApplication.MainView.Dispatcher.AwaitableRunAsync(async() => {
                    folder = await folderPicker.PickSingleFolderAsync();
                }).ConfigureAwait(false);;

                // Queue up the PDFs in the folder for indexing.
                await EnqueueDocuments(_libraries[libraryName], folder).ConfigureAwait(false);

                promise.Resolve(null);
            }
            catch (Exception e)
            {
                promise.Reject(e);
            }
        }
        private async void BtnOpenFolderDialogClick(object sender, RoutedEventArgs e)
        {
            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);
                files = await folder.GetFilesAsync();

                if (files.Count > 0)
                {
                    filesNames.Clear();
                    // Application now has read/write access to the picked file(s)

                    foreach (Windows.Storage.StorageFile file in files)
                    {
                        filesNames.Add(file.Name);
                    }
                    comboImagesNames.DataContext = filesNames;
                    comboImagesNames.UpdateLayout();
                    comboImagesNames.SelectionChangedTrigger = ComboBoxSelectionChangedTrigger.Always;
                    // comboImagesNames.SelectedItem = filesNames[0];
                }
            }
        }
Exemple #30
0
        private async Task SaveUsingFolderPicker(string beginDate, string endDate)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();

            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            picker.FileTypeFilter.Add(".csv"); //add any extension to avoid exception

            var folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                string strFilename = beginDate + "_To_" + endDate + ".csv";

                StorageFile file =
                    await folder.CreateFileAsync("Rpt" + strFilename, CreationCollisionOption.ReplaceExisting);

                _stringBuilder.Append("Some data");
                //foreach (var m in FlightData)
                //{
                //    _stringBuilder.Append(m.Id + "," + m.Date + "," + m.Price + "," + ...... + "\r\n");
                //}

                await FileIO.AppendLinesAsync(file, new List <string>() { _stringBuilder.ToString() });
            }
        }
 public MainPage()
 {
     this.InitializeComponent();
     //surveyPage = new SurveyPage(0);
     folderPicker   = new Windows.Storage.Pickers.FolderPicker();
     fileOpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
 }
       private async void OpenCollectionButton_Click(object sender, RoutedEventArgs e)
       {
           MarkedUp.AnalyticClient.SessionEvent("Opened a collection");
           StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
           StorageFolder collections = await localFolder.GetFolderAsync("Collections");

           Windows.Storage.Pickers.FolderPicker folderPicker = new Windows.Storage.Pickers.FolderPicker();
           folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
           folderPicker.FileTypeFilter.Add("*");
           folderPicker.CommitButtonText = "Open";

           StorageFolder chosenFolder = await folderPicker.PickSingleFolderAsync();
           if (chosenFolder != null)
           {
               OpenComicCollection(chosenFolder, collections);
           }
       }
 public FolderPicker()
 {
     _picker = new Windows.Storage.Pickers.FolderPicker();
 }
Exemple #34
0
        /// <summary>
        /// Allows loading a new test suite from the file picker
        /// </summary>
        private async void LoadTestListFromDisk(string ID)
        {
            var picker = new Windows.Storage.Pickers.FolderPicker();
            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.FileTypeFilter.Add("*");

            StorageFolder testfolder = await picker.PickSingleFolderAsync();
            
            if (testfolder != null)
            {
                var testcrawler = new TestCrawler();
                nonrecursivetestlist = await testcrawler.LoadFromFolder(testfolder, ID);

                TestsList.ItemsSource = nonrecursivetestlist.Tests;
                LoadTestsButtonBacking.Visibility = Visibility.Collapsed;
            }
        }
Exemple #35
0
        private void InteractiveImage_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {

            string name = (sender as Image).Name;
            vm.CurrentActivePanel = MainContent.SelectedIndex;
            if (name.CompareTo("LeftInteractiveImage") == 0)
            {
            }
            else if (name.CompareTo("RightInteractiveImage") == 0)
            {
                var picker = new Windows.Storage.Pickers.FolderPicker();
                picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.List;
                picker.FileTypeFilter.Add("*");
                Generic.ContinuationManager.PickFolderContinuableCurrent =
                    this as Generic.IPickFolderContinuable;
                picker.PickFolderAndContinue();
            }

        }
        private async void AppBarButton_Click_AddLocalDirectory(object sender, RoutedEventArgs e)
        {
            var picker= new Windows.Storage.Pickers.FolderPicker();
            foreach (var ext in Books.BookManager.AvailableExtensionsArchive)
            {
                picker.FileTypeFilter.Add(ext);
            }
            var folder = await picker.PickSingleFolderAsync();
            if (folder != null)
            {
                var rl = new Windows.ApplicationModel.Resources.ResourceLoader();

                var dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Started/Message"), rl.GetString("LoadingFolder/Title"));
                await dialog.ShowAsync();
                var storage = await BookShelfStorage.GetBookShelves();
                CurrentOperationCount++;
                storage.Add(BookShelfStorage.GetFlatBookShelf(await BookShelfStorage.GetFromStorageFolder(folder)));
                CurrentOperationCount--;
                Refresh();
                BookShelfList.SelectedIndex = BookShelfList.Items.Count - 1;

                dialog = new Windows.UI.Popups.MessageDialog(rl.GetString("LoadingFolder/Completed/Message"), rl.GetString("LoadingFolder/Title"));
                await dialog.ShowAsync();
            }
            await BookShelfStorage.SaveAsync();
        }
Exemple #37
0
 public static async void DownloadFolderSelect()
 {
     var folderPicker = new Windows.Storage.Pickers.FolderPicker();
     folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
     folderPicker.FileTypeFilter.Add(".mp4");
     _isDownloadSelecting = true;
     var folder = await folderPicker.PickSingleFolderAsync();
     _isDownloadSelecting = false;
     if (folder != null)
     {
         Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.AddOrReplace(PPTV.WinRT.CommonLibrary.ViewModel.Download.DownloadBase.DownloadFolderToken, folder);
         if (DownloadSelectAction != null)
             DownloadSelectAction();
     }
 }
Exemple #38
0
 public static async Task AddFolder()
 {
     var picker = new Windows.Storage.Pickers.FolderPicker();
     var folder = await picker.PickSingleFolderAsync();
     if (folder != null)
     {
         var list = await GetFolder();
         if (list != null)
         {
             list.Add(folder.Path);
         }
         else
         {
             list = new List<string>();
             list.Add(folder.Path);
         }
         var datafolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Data");
         var localfoldersfile = await datafolder.GetFileAsync("localfolders.json");
         await FileIO.WriteTextAsync(localfoldersfile, Class.data.ToJsonData(list));
     }
 }