private async void OnImageOpened(object sender, RoutedEventArgs e) { SetImageAndInkCanvasSize(); string playerName = LevelPageViewModel.GetCurrentPlayer(); string subName = LevelPageViewModel.GetSelectedSubLevelName(); string imgName = ViewModel.CurrentItem.ImagePath.Split("\\").Last(); string path = Path.Combine(playerName, subName, imgName); StorageFolder storageFolder = ApplicationData.Current.LocalFolder; if (File.Exists(Path.Combine(storageFolder.Path, path))) { StorageFile file = await storageFolder.GetFileAsync(path); IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); using (var inputStream = stream.GetInputStreamAt(0)) { await inkCanvas.InkPresenter.StrokeContainer.LoadAsync(inputStream); } stream.Dispose(); } else { inkCanvas.InkPresenter.StrokeContainer.Clear(); } }
private async void inkCanvas_SaveClick(object sender, RoutedEventArgs e) { var playerName = LevelPageViewModel.GetCurrentPlayer(); var subName = LevelPageViewModel.GetSelectedSubLevelName(); var imgName = ViewModel.CurrentItem.ImagePath.Split("\\").Last(); var path = Path.Combine(playerName, subName, imgName); StorageFolder storageFolder = ApplicationData.Current.LocalFolder; StorageFile file = await storageFolder.CreateFileAsync(path, CreationCollisionOption.ReplaceExisting); IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite); using (IOutputStream outputStream = stream.GetOutputStreamAt(0)) { await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(outputStream); await outputStream.FlushAsync(); } stream.Dispose(); }
private async void BtnDeveloper_Click(object sender, RoutedEventArgs e) { var dialog = new InputBoxDialog(); await dialog.ShowAsync(); if (dialog.Result == null) { return; } var command = dialog.Result.ToLower(); switch (command) { case "done": timer.Stop(); ViewModel.NextItem = null; ViewModel.GoBackLearnPage(); break; case "notdone": timer.Stop(); ViewModel.NextItem = null; var playerName = LevelPageViewModel.GetCurrentPlayer(); var level = LevelPageViewModel.GetSelectedLevel(); var joinedWord = string.Concat(playerName, ".", level, ".", Constants.LearnPage, ".", Constants.LevelCompleted); Reg.SaveSetting(joinedWord, false); Glob.MainFrame.GoBack(); break; case "activate": //var activation = new Activation(); //var questionString = activation.GetQuestionString(); //dialog.Title = "Client-id: " + questionString; //dialog.ShowValue = questionString; //await dialog.ShowAsync(); //await activation.Activate(dialog.Result); break; case "cmdhelp": case "showhelp": await Glob.MsgBox_Async( "Warning: Improper usage will lead to failure of the app!" + Environment.NewLine + "Activate +5->*5->Pxx/sun/55786, deactivate/no55786" + Environment.NewLine + "isfreeforpromotion=true, isfreeforpromotion=false, " + Environment.NewLine + "cmd0/ratingnotdone, cmd5/ratingdone, xxx/del/deletesettings/delall, " + Environment.NewLine + "cmd6/easy/completefalse"); break; case "isfreeforpromotion=false": case "cmd9=false": //Reg.SaveSetting(Glob.Settings.IsFreeForPromotion, false); await Glob.MsgBox_Async("IsFreeForPromotion = false"); break; case "isfreeforpromotion=true": case "cmd9=true": //Reg.SaveSetting(Glob.Settings.IsFreeForPromotion, true); await Glob.MsgBox_Async("IsFreeForPromotion = true"); break; case "deactivate": case "no55786": //Reg.SaveSetting(AppData.Addon100Lessons, false); //Reg.SaveSetting(AppData.Addon200Lessons, false); //MyConstants.IsPro200 = MyConstants.IsPro100 = false; await Glob.MsgBox_Async("Successfully De-Activated! Restart the App if required."); break; case "ratingdone": case "cmd5": //Reg.SaveSetting(Glob.Settings.Rating, 5); //Reg.SaveSetting(Glob.Settings.hide_count, 100); //Reg.SaveSetting(Glob.Settings.SimpleRatingDone, true); await Glob.MsgBox_Async("Done!"); break; case "ratingnotdone": case "cmd0": //Reg.SaveSetting(Glob.Settings.Rating, 0); //Reg.SaveSetting(Glob.Settings.hide_count, 100); //Reg.SaveSetting(Glob.Settings.SimpleRatingDone, false); await Glob.MsgBox_Async("Done!"); break; case "delall": case "deletesettings": await ApplicationData.Current.ClearAsync(); CoreApplication.Exit(); break; case "del": case "xxx": await Reg.DeleteAllSettings(true); await ApplicationData.Current.ClearAsync(); CoreApplication.Exit(); break; case "completefalse": case "cmd6": case "easy": //Reg.SaveSetting(Glob.Settings.CompletePrevious, false); //bCompletePrevious = false; //await Glob.MsgBox_Async("Done! CompletePrevious = false"); break; case "nocompletefalse": case "nocmd6": case "noeasy": //Reg.SaveSetting(Glob.Settings.CompletePrevious, true); //bCompletePrevious = true; //await Glob.MsgBox_Async("Easy mode activated: Navigate to any lesson now"); break; case "sun": //Use it for Emergency case "55786": //Use it for Emergency case "checkpurchase": //Use it for Emergency //Reg.SaveSetting(AppData.Addon200Lessons, true); //Reg.SaveSetting(Glob.Settings.GivenFreeForActivationCode, true); //MyConstants.IsPro200 = true; //await Glob.MsgBox_Async("Successfully Activated! Thanks for purchasing. Restart the App if required."); break; case "sun-easy": //Use it for Emergency case "55786-easy": //Use it for Emergency case "checkpurchase-easy": //Use it for Emergency //Reg.SaveSetting(AppData.Addon200Lessons, true); //Reg.SaveSetting(Glob.Settings.GivenFreeForActivationCode, true); //MyConstants.IsPro200 = true; //Reg.SaveSetting(Glob.Settings.CompletePrevious, false); //bCompletePrevious = false; //await Glob.MsgBox_Async("Successfully Activated! Thanks for purchasing. Restart the App if required." + // Environment.NewLine + "(Easy mode activated: Navigate to any lesson)"); break; default: break; } }