private static async Task <StorageFile> NavigateFileSystem(int folderType, String targetName, int collisionOption, StorageFolder specialFolder = null)
        {
            Debug.WriteLine("STARTING");
            StorageFolder storageFolder;

            if (folderType == OTHER)
            {
                if (specialFolder == null)
                {
                    storageFolder = KnownFolders.PicturesLibrary;
                    await UserInteraction.ShowDialogAsync("WARNING", "The file could not be saved in the desired Location.\r\nIt will be saved to your PicturesLibrary");
                }
                else
                {
                    storageFolder = specialFolder;
                }
            }
            else if (folderType == BASE)
            {
                storageFolder = BaseFolder;
            }
            else if (folderType == ROAMING)
            {
                storageFolder = ApplicationData.Current.RoamingFolder;
            }
            else
            {
                storageFolder = ApplicationData.Current.LocalFolder;
            }
            targetName = targetName.Replace("\\", "/");
            String[] paths = targetName.Split('/');
            if (paths.Length > 1)
            {
                for (int i = 0; i < paths.Length - 1; i++)
                {
                    storageFolder = await storageFolder.CreateFolderAsync(paths[i], CreationCollisionOption.OpenIfExists);
                }
            }
            if (collisionOption == REPLACE)
            {
                return(await storageFolder.CreateFileAsync(paths[paths.Length - 1], CreationCollisionOption.ReplaceExisting));
            }
            else
            {
                return(await storageFolder.CreateFileAsync(paths[paths.Length - 1], CreationCollisionOption.OpenIfExists));
            }
        }
        private static async Task LoadBaseFolderAsync()
        {
            String Token = await ReadFromLocalFolder("BaseFolderFutureAccessToken.token");

            if (Token == null || Token.Equals(""))
            {
                Token = await PickExternalStorageFolder();

                if (Token == null || Token.Equals(""))//Full-On FAIL => Just give up and exit, but notify the user
                {
                    await UserInteraction.ShowDialogAsync("ERROR", "Unable to load required resources.\n App will be closed.");

                    ForceTerminateApp();
                }
            }
            BaseFolderFutureAccessToken = Token;
            await WriteToLocalFolder("BaseFolderFutureAccessToken.token", BaseFolderFutureAccessToken);
        }
Exemplo n.º 3
0
        private async void DeleteSingleFile(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < Files.Length; i++)
            {
                if (sender == DeleteButton[i])
                {
                    try
                    {
                        await Files[i].DeleteAsync();
                    }
                    catch (Exception ex)
                    {
                        ex.PrintStackTrace();
                        await UserInteraction.ShowDialogAsync("ERROR", "Fehler beim Löschen des Ordners");
                    }
                    Files = await SourceFolder.GetStorageFileArray();

                    ReLoadPage();
                }
            }
            DeactivateMultiSelect();
        }
Exemplo n.º 4
0
        private async void Download()
        {
            String Token = await StorageInterface.ReadFromLocalFolder("Storage.Garfield.token");

            if (Token == null || Token.Equals(""))
            {
                await UserInteraction.ShowDialogAsync("INFORMATION", "You will now be prompted to chose a Folder in which to save the Comic. This App will create a new Folder within the Folder you selected, called \"Garfield\", which will be used to store the images (in order not to confuse them with your files). The App will remember the location you have picked and will use this location until you change it in the Settings.");

                Token = await StorageInterface.PickExternalStorageFolder();

                await StorageInterface.WriteToLocalFolder("Storage.Garfield.token", Token);
            }
            try
            {
                await StorageInterface.WriteBytesToKnownFolder("Garfield/Garfield_" + date.ToString("yyyy_MM_dd") + ".gif", await NetworkInterface.DownloadGarfield(date), Token);
            }
            catch (Exception e)
            {
                e.PrintStackTrace();
                UserInteraction.ShowToast("ERROR! Could not save file.", "Garfield");
                return;
            }
            UserInteraction.ShowToast("Comic has successfully been saved", "Garfield");
        }
Exemplo n.º 5
0
 private void Pacer_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     rapid = !rapid;
     UserInteraction.ShowToast("Sensors", "Toggled Mode");
 }
Exemplo n.º 6
0
 private void StartStop_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     logging = !logging;
     Log();
     UserInteraction.ShowToast("Sensors", "Start/Stop Request handled");
 }