private void CommandSimulate_Executed(object sender, ExecutedRoutedEventArgs e) { // Verouillage des textbox ActiveBox = false; BindingExpression be = chosenBox.GetBindingExpression(TextBox.TextProperty); be.UpdateSource(); // Lancement de la simulation if (Model.Simulate()) { // simulation terminée, on peut masquer SimulationOk = true; DxMBox.ShowDial(SPRLang.SimuSuccess); } else { // On réactive en cas d'erreur ActiveBox = true; // SimulationOk = false; DxMBox.ShowDial(SPRLang.SimuFail); } //string tmp = _Model.ChosenFolder; }
/// <summary> /// Show a message window, called by delegate (useful with async) /// </summary> /// <param name="sender"></param> /// <param name="message"></param> /// <param name="title"></param> public static bool?Dispatch_Mbox(object sender, string message, string title, E_DxButtons buttons = E_DxButtons.Ok, string optMessage = null) { bool?res = false; Application.Current.Dispatcher?.Invoke(() => res = DxMBox.ShowDial(message, title, buttons, optMessage)); return(res); }
internal void PrepareApply() { HeTrace.WriteLine($"--- Prepare Apply ---"); TaskLauncher tl = new TaskLauncher() { AutoCloseWindow = true, ProgressIHM = new Splash() { Model = new EphemProgress(Core), }, MethodToRun = () => Core.ApplyChanges(), }; if (tl.Launch(Core) == true) { DxMBox.ShowDial(SPRLang.Paths_Modified); } else { DxMBox.ShowDial("Error"); } ActiveSimulate = true; ActiveApply = false; }
/// <summary> /// Appliquer les changements de la simulation dans les fichiers de configuration de launchbox. /// </summary> /// <returns></returns> internal bool Apply() { HeTrace.WriteLine(@"Process start ..."); // Envnew /* * Assignation des properties settings ? * Todo réfléchir car je ne sauve pas au fur et à mesure mais en même temps ça m'évite * avec une sauvegarde systématique d'oublier éventuellement ce que je voulais faire */ // Dematriochka Dematriochka(); // Sauvegarde previousFolderPath = PlatformObject.Folder; PlatformObject.Folder = //[0].OldRelatPath; // Assignation du chemin path des games à la plateforme PlatformObject.Folder = PlatformPaths.ApplicationPath.RelatPath; // Assignation du chemin path des games à la plateforme if (!Global.DebugMode) { PluginHelper.DataManager.Save(); DxMBox.ShowDial(SPRLang.Paths_Modified); } // Régénération panneau de gauche HeTrace.WriteLine(@"Process finish ..."); // Envnew return(true); }
private void Launch(IGame game) { bool?res = DxMBox.ShowDial(Lang.Launch_Question, "Question", DxMBoxButtons.YesNo); ITrace.WriteLine($"Window Result: {res}"); // obsolète ? ImageDetails[] images = game.GetAllImagesWithDetails(); ITrace.WriteLine($"Images Found: {images.Length}"); foreach (ImageDetails image in images) { ITrace.WriteLine(image.ImageType); ITrace.WriteLine(image.Region); ITrace.WriteLine(image.FilePath); ITrace.WriteLine(); } /* * ITrace.WriteLine($"Méthode algo2"); * * List<string> stringImages = new List<string>(); * * var platform = PluginHelper.DataManager.GetPlatformByName(game.Platform); * IPlatformFolder[] folders = platform.GetAllPlatformFolders(); * foreach (var folder in folders) * { * ITrace.WriteLine($"Folder: {folder.MediaType}"); * ITrace.WriteLine($"Folder: {folder.FolderPath}"); * * } */ }
private void CommandApply_Executed(object sender, ExecutedRoutedEventArgs e) { if (Model.Apply()) { // Refill panel information string separator; if (Separator == 1) { separator = @"\"; } else { separator = @"/"; } Model.FormatMainPaths(separator); DialogResult = true; } else { DxMBox.ShowDial(SPRLang.Paths_Not_Modified, SPRLang.Error); } SimulationOk = false; ActiveBox = true; }
public static bool?AskDxMBox(string message, string title, E_DxButtons buttons, string optionnalMessage = null) { return(Application.Current.Dispatcher?.Invoke ( () => { return DxMBox.ShowDial(message, title, buttons, optionnalMessage); } )); }
private void CommandMigrate_Executed(object sender, ExecutedRoutedEventArgs e) { // Avertissement DxMBox.ShowDial(SPRLang.Warning_Music, DxTBLang.Warning, optMessage: SPRLang.W_Music_Message); Main_Window mw = new Main_Window(); mw.ShowDialog(); //W_Migrate wMig = new W_Migrate(_Model.SelectedPlatform); //wMig.ShowDialog(); }
// Note sur cette portion on va surtout plus vérifier un peu tout, tel que l'existence des répertoires private void Exec_Simulate(object sender, ExecutedRoutedEventArgs e) { ActivePage = null; if (_Model.Verifications()) { DxMBox.ShowDial(SPRLang.SimuSuccess); ActiveApply = true; } else { DxMBox.ShowDial(SPRLang.SimuFail, title: DxTBLang.Warning); //optMessage: chemin ActiveApply = false; } }
internal void RemoveMusicF() { if (SelectedMusic == null) { return; } if (SelectedMusic.IsSelected) { DxMBox.ShowDial("You must select another before to delete it"); return; } OpDFiles.Trash(SelectedMusic.DestPath); LoadMusics(); }
internal void RemoveVideoF() { if (SelectedVideo == null) { return; } if (SelectedVideo.IsSelected) { DxMBox.ShowDial("You must select another before to delete it"); return; } OpDFiles.Trash(SelectedVideo.DestPath); LoadVideos(); }
/// <summary> /// Delete function /// </summary> /// <param name="toDel"></param> private void DeleteFile(string toDel) { bool?res = DxMBox.ShowDial(Lang.Trash_Question + $"\n{toDel}", Lang.Trash_FileTitle, DxButtons.YesNo); if (res == true) { try { FileSystem.DeleteFile(toDel, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); } catch (Exception exc) { Console.WriteLine(exc); } } }
/// <summary> /// Open path in explorer /// </summary> /// <param name="targetPath"></param> internal static void OpenInExplorer_Command(string targetPath) { try { if (System.IO.Directory.Exists(targetPath)) { Process.Start("explorer.exe", targetPath); } else { DxMBox.ShowDial($"{SPRLang.Path_D_Exist}: '{targetPath}'"); } } catch (Exception exc) { } }
internal void LockedMigrate() { try { W_LockedMigrate wLM = new W_LockedMigrate() { Model = new MigrateLModel(CBAckupPlatform, SelectedPlatform), }; wLM.ShowDialog(); } catch (Exception exc) { DxMBox.ShowDial(exc.Message); HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); } }
internal void EditGames() { try { W_GamePaths wp = new W_GamePaths() { Model = new GamePathsModel(SelectedPlatform), }; wp.ShowDialog(); } catch (Exception exc) { DxMBox.ShowDial(exc.Message); HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); } }
internal void EditPlatform() { try { //PreviousPlatformState = SelectedPlatform; // Cliché des dossiers CBAckupPlatform = C_Platform.Platform_Maker(SelectedPlatform, SelectedPlatform.GetAllPlatformFolders()); // Lancement de la modification des paths W_PlatformPaths wPP = new W_PlatformPaths() { Model = new PlatformModel(SelectedPlatform.Name) }; if (wPP.ShowDialog() != true) { return; } // Rafraichissement if (!Global.DebugMode)// && !wp.Model.PlatformObject.Folder.Equals(oldPath)) { Initialize(); //SelectedPlatform = PluginHelper.DataManager.GetPlatformByName(CBAckupPlatform.PlatformName); } if (!CBAckupPlatform.ApplicationPath.OldPath.Equals(SelectedPlatform.Folder) && DxMBox.ShowDial(SPRLang.QChange_GamesPaths, "Question", E_DxButtons.No | E_DxButtons.Yes) == true) { W_GamePaths wp = new W_GamePaths() { Model = new GamePathsModel(SelectedPlatform, CBAckupPlatform?.PlatformName), }; wp.ShowDialog(); } } catch (Exception exc) { DxMBox.ShowDial(exc.Message); HeTrace.WriteLine(exc.Message); HeTrace.WriteLine(exc.StackTrace); } }
internal static void CheckGamesValidity(ObservableCollection <ShortGame> selectedGames, string selectedPlatform) { string platformXmlFile = Path.Combine(Config.HLaunchBoxPath, Config.PlatformsFolder, $"{selectedPlatform}.xml"); //IEnumerable<ShortGame> filteredGames = new List<ShortGame>(selectedGames); foreach (var g in selectedGames.ToList()) { Dictionary <string, bool?> res = CheckGameValidity(g, platformXmlFile); bool?keepit = true; // Erreur sur le chemin principal if (res == null) { DxMBox.ShowDial($"{LanguageManager.Instance.Lang.S_MainLAppBroken} '{g.Title}'"); keepit = false; } else { bool test = true; // Vérification si c'est utile d'afficher la fenêtre foreach (var kvp in res) { test &= (bool)kvp.Value; } if (test == false) { keepit = SafeBoxes.ShowStatus( $"{LanguageManager.Instance.Lang.S_GameStatus4} '{g.Title}'." + $"\n{LanguageManager.Instance.Lang.Q_KeepIt}", LanguageManager.Instance.Lang.S_GameStatus, res); } } if (keepit != true) { selectedGames.Remove(g); g.IsSelected = false; continue; } } }
/* * /// <summary> * /// Travail sur le fichier xml contenant les plateformes * /// </summary> * /// <param name="platformsFile"></param> * /// <param name="machineName"></param> * private void WorkOnPlatformFile(string platformsFile, string machineName) * { * using (XML_Platforms xPlat = new XML_Platforms(platformsFile)) * { * // Backup du fichier de la plateforme; * BackupPlatformsFile(platformsFile); * * // On demande pour REMPLACER la machine si elle existe déjà * if (xPlat.Exists("Name", machineName)) * { * bool? res = AskDxMBox("Platform is Already present, replace it ?", "Question", E_DxButtons.Yes | E_DxButtons.No, machineName); * if (res == true) * { * xPlat.RemoveElemByChild(Tag.Platform, Tag.Name, machineName); * xPlat.RemoveElemByChild(Tag.PlatformFolder, Tag.Platform, machineName); * UpdateStatus?.Invoke(this, "The has been removed"); * } * else * { * UpdateStatus?.Invoke(this, "Injection aborted"); * return; * } * } * * // Injection en mode true verbatim * XElement verbatimPlatform = XML_Platforms.GetPlatformNode(_SelectedPlatformXML); * xPlat.InjectPlatform(verbatimPlatform); * var verbatimPFolders = XML_Platforms.GetFoldersNodes(_SelectedPlatformXML); * xPlat.InjectPlatFolders(verbatimPFolders); * * UpdateStatus?.Invoke(this, $"Platform {machineName} injected"); * * xPlat.Save(platformsFile); * } * }*/ /* * /// <summary> * /// Copie les images * /// </summary> * /// <param name="srcFolder"></param> * protected void Copy_Images(string srcFolder, string destination) * { * foreach (string d in Directory.GetDirectories(srcFolder)) * { * // string dirName = Path.GetFileName(d); * * UpdateStatus?.Invoke(this, $"\t{Lang.I_Copy} {Lang.Images} '{srcFolder}' => '{TImagesP}'"); * * CopyContent(d, destination); * } * }*/ /* * /// <summary> * /// * /// </summary> * /// <param name="dossier"></param> * /// <param name="folderPath">Dossier de destination</param> * /// <remarks> * /// Recherche le répertoire définitif avant de copier, conserve la structure. * /// </remarks> * protected void CopyContent(string dossier, string folderPath) * { * if (string.IsNullOrEmpty(folderPath)) * return; * * folderPath = Path.GetFullPath(folderPath, PS.Default.LastLBpath); * string target = null; * * // récupération des fichiers * foreach (string f in Directory.EnumerateFiles(dossier, "*.*", SearchOption.AllDirectories)) * { * if (CancelToken.IsCancellationRequested) * return; * * try * { * UpdateStatus?.Invoke(this, $"\t{Lang.Source}: {f}"); * * string tail = f.Replace(dossier, ""); * Debug.WriteLine($"t:{tail}"); * * target = Path.Combine(folderPath, tail.Substring(1)); * UpdateStatus?.Invoke(this, $"\t{Lang.Target}: {target}"); * * * Directory.CreateDirectory(Path.GetDirectoryName(target)); * * File.Copy(f, target, true); * } * catch (IOException ioex) * { * UpdateStatus?.Invoke(this, $"\t***Error copy {target}\r\n {ioex.Message}"); * } * catch (UnauthorizedAccessException UnAuthExc) * { * UpdateStatus?.Invoke(this, $"\t{UnAuthExc.Message}"); * * } * catch (Exception exc) * { * UpdateStatus?.Invoke(this, $"\t{exc.Message}"); * } * } * // Debug.WriteLine($"Copy Simu: {d} <|> {folderPath}"); * }*/ protected void Delete(string tmpPath) { try { Directory.Delete(tmpPath, true); } catch (UnauthorizedAccessException uae) { Application.Current.Dispatcher?.Invoke(() => { DxMBox.ShowDial( LanguageManager.Instance.Lang.S_DeleteByYs, LanguageManager.Instance.Lang.Word_Information, E_DxButtons.Ok, $"{DxTBLang.Delete}: {tmpPath}"); }); Process.Start("explorer.exe", @$ "{tmpPath}"); } }
/// <summary> /// /// </summary> /// <param name="game"></param> /// <returns></returns> private bool Launch4One(IGame game) { ITrace.WriteLine($"[Launch4One] process for {game.Title}"); ImageDetails[] images = game.GetAllImagesWithDetails(); ITrace.WriteLine($"[Launch4One] Images Found: {images.Length}"); //ExtImageDetails[] extImages = ExtImageDetails.Convert(images); var extImages = Array.ConvertAll(images, item => (ExtImageDetails)item); Md5Func Md5Job = new Md5Func(); Md5Job.CurrentPosition += (x) => { DxProgressB1.SCurrentProgress = x; }; Md5Job.CurrentFile += (file) => { DxProgressB1.SCurrentOP = file; }; Task t1 = Task.Run(() => Md5Job.Calculate_MD5(extImages, 10)); t1.ContinueWith((antecedant) => DxProgressB1.AsyncCloseIt()); //Calculate_MD5(extImages); // La fenêtre bloque la suite tant qu'elle n'est pas fermée DxProgressB1.ModalShow("[Launch4One] CleanImages - Calculate MD5", images.Length); ITrace.WriteLine("[Launch4One] Fin de Calculate Md5"); // Scan des doublons; List <List <ExtImageDetails> > Doublons = Scan(extImages); int dNumber = Doublons.Count(); if (dNumber < 1) { DxMBox.ShowDial($"{Lang.Duplicate_No_Res}: {game.Title}", Lang.Scan_Title, DxButtons.Ok); } //ManualProcess PManualDuplicates(Doublons, game); ITrace.WriteLine("[Launch4One] Fin"); return(true); }
/// <summary> /// One game selected /// </summary> /// <param name="selectedGame"></param> public void OnSelected(IGame selectedGame) { Mouse.OverrideCursor = Cursors.Arrow; ITrace.WriteLine("On Selected"); bool?res = DxMBox.ShowDial(Lang.LaunchO_Question, "Question", DxButtons.YesNo); ITrace.WriteLine($"Window Result: {res}"); try { if (res == true) { Launch4One(selectedGame); } } catch (Exception exc) { ITrace.WriteLine(exc.ToString()); } }
private void CommandResetFac_Executed(object sender, ExecutedRoutedEventArgs e) { Model.ResetFactory(); SimulationOk = false; //ActiveApply = false; // Refill panel information string separator; if (Separator == 1) { separator = @"\"; } else { separator = @"/"; } DxMBox.ShowDial(SPRLang.IReset_Factory); // Model.FormatMainPaths(separator); }
private void Exec_Apply(object sender, ExecutedRoutedEventArgs e) { if (_Model.Apply() == true) { DxMBox.ShowDial(SPRLang.Transfert_Success); } else { DxMBox.ShowDial(SPRLang.Transfert_Fail); } // Todo afficher un relevé d'informations /* * Relevé d'informations * - X fichiers passés car similaires * - X fichiers écrasés * - X fichiers transférés sans collision * - X fichiers problèmes */ }
internal void Save(string outputFile) { try { Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); byte[] jsonUtf8Bytes; var options = new JsonSerializerOptions { WriteIndented = true }; jsonUtf8Bytes = JsonSerializer.SerializeToUtf8Bytes(this, options); using (var sw = File.Create(outputFile)) { sw.Write(jsonUtf8Bytes); } } catch (IOException ioExc) { DxMBox.ShowDial(ioExc.Message, $"Error on writing lang file '{outputFile}'"); } }
/// <summary> /// Répertoire de travail pour le jeu (voir si utile) /// </summary> //private string _GamePath; internal static bool PrepareToContinue(ObservableCollection <ShortGame> selectedGames, string platformName) { // Vérification des fichiers pour chaque jeu (ne gère pas les vidéos) LaunchBoxFunc.CheckGamesValidity(selectedGames, platformName); if (selectedGames.Count == 0) { if (selectedGames.Count > 1) { DxMBox.ShowDial("No game selected"); } return(false); } _SelectedGames = selectedGames; /*W_Games gamesWindow = new W_Games(); * gamesWindow.SelectedGames = selectedGames; * * if (gamesWindow.ShowDialog() != true) * { * return false; * } * * if (selectedGames.Count == 0) * { * if (selectedGames.Count > 1) * DxMBox.ShowDial("No game selected"); * * return false; * } * _SelectedGames = gamesWindow.SelectedGames; */ return(true); }