public async Task LaunchPlayer(Core.Models.Program program, bool isLaunchedFromTile) { await ShowSplashScreen(program.Name); var zipService = new ZipService(); var tempFolder = ApplicationData.Current.TemporaryFolder; var file = await tempFolder.CreateFileAsync(TempProgramName, CreationCollisionOption.ReplaceExisting); var stream = await file.OpenStreamForWriteAsync(); await zipService.ZipCatrobatPackage(stream, program.BasePath); var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = false }; //await project.Save(); ??? TODO: this was in the previous version of catrobat --> do we need to save the project at this point? await LaunchPlayer(program.Name, isLaunchedFromTile); // TODO: manage closing/relaunching of the Player // TODO: review ...LaunchFileAsync (1 line underneath) --> seems to be that it never finishes //bool success = await Windows.System.Launcher.LaunchFileAsync(file, options); //if (success) //{ // // File launch success //} //else //{ // // File launch failed //} }
public async Task DrawPictureAsync(Core.Models.Program program = null, Look lookToEdit = null) { _program = program; _lookToEdit = lookToEdit; //TODO refactor this --> use Storage-service StorageFolder localFolder = ApplicationData.Current.LocalFolder; string paintTempFolderPath = Path.GetDirectoryName(StorageConstants.TempPaintImagePath); string paintTempFileName = Path.GetFileName(StorageConstants.TempPaintImagePath); StorageFolder paintTempFolder = await localFolder.CreateFolderAsync(paintTempFolderPath, CreationCollisionOption.OpenIfExists); if (program != null && lookToEdit != null) { using (var storage = StorageSystem.GetStorage()) { await storage.DeleteFileAsync(StorageConstants.TempPaintImagePath); string filePath = Path.Combine(program.BasePath, StorageConstants.ProgramLooksPath, lookToEdit.FileName); if(await storage.FileExistsAsync(filePath)) { await storage.CopyFileAsync(filePath, StorageConstants.TempPaintImagePath); } else { //ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Import_FileNotFound, //AppResourcesHelper.Get("Import_FileNotFoundText, null, MessageBoxOptions.Ok); await CreateDefaultImage(); } } } else { await CreateDefaultImage(); } var file = await paintTempFolder.GetFileAsync(paintTempFileName); var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = false }; try { bool success = await Windows.System.Launcher.LaunchFileAsync(file, options); if (success) { // File launch OK } else { // File launch failed } } catch (Exception) { if (Debugger.IsAttached) Debugger.Break(); } }
public async Task DrawPictureAsync(Core.Models.Program program = null, Look lookToEdit = null) { _program = program; _lookToEdit = lookToEdit; //TODO refactor this --> use Storage-service StorageFolder localFolder = ApplicationData.Current.LocalFolder; string paintTempFolderPath = Path.GetDirectoryName(StorageConstants.TempPaintImagePath); string paintTempFileName = Path.GetFileName(StorageConstants.TempPaintImagePath); StorageFolder paintTempFolder = await localFolder.CreateFolderAsync(paintTempFolderPath, CreationCollisionOption.OpenIfExists); if (program != null && lookToEdit != null) { using (var storage = StorageSystem.GetStorage()) { await storage.DeleteFileAsync(StorageConstants.TempPaintImagePath); string filePath = Path.Combine(program.BasePath, StorageConstants.ProgramLooksPath, lookToEdit.FileName); if (await storage.FileExistsAsync(filePath)) { await storage.CopyFileAsync(filePath, StorageConstants.TempPaintImagePath); } else { //ServiceLocator.NotifictionService.ShowMessageBox(AppResourcesHelper.Get("Import_FileNotFound, //AppResourcesHelper.Get("Import_FileNotFoundText, null, MessageBoxOptions.Ok); await CreateDefaultImage(); } } } else { await CreateDefaultImage(); } var file = await paintTempFolder.GetFileAsync(paintTempFileName); var options = new Windows.System.LauncherOptions { DisplayApplicationPicker = false }; try { bool success = await Windows.System.Launcher.LaunchFileAsync(file, options); if (success) { // File launch OK } else { // File launch failed } } catch (Exception) { if (Debugger.IsAttached) { Debugger.Break(); } } }