private async Task Logon() { Key = CryptoInterface.GestAesKey(LoginPasswordBox.Password); LoginPasswordBox.Password = ""; IBuffer A = await StorageInterface.ReadBufferFromRoamingFolder("PWM/A"); IBuffer B = await StorageInterface.ReadBufferFromRoamingFolder("PWM/B"); //Debug.WriteLine("Up to here I believe this to be OK"); //Debug.WriteLine(LoginPasswordBox.Password.GetHexString()); //Debug.WriteLine(Key); IBuffer EA = CryptoInterface.EncryptAes(Key, A); //Debug.WriteLine("Now this could be unreachable code"); if (!CryptographicBuffer.Compare(B, EA))//Falsches Passwort, da die testfiles nicht zampassen { Debug.WriteLine("FALSCHES PASSWORT"); await UserInteraction.ShowDialogAsync("INFORMATION", "Falsches Passwort!"); return; } Debug.WriteLine("HAVE DONE SETUP WITH PASSWORD"); MODE_REGULAR.Visibility = MODE_REGULAR_BAR.Visibility = Visibility.Visible; MODE_LOGIN.Visibility = MODE_SETUP.Visibility = Visibility.Collapsed; await Refresh(); }
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); }
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(); }
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"); }