Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        internal static object LaunchOpProgress(I_AsyncSig Objet, Func <object> method, string title = null)
        {
            return(Application.Current.Dispatcher?.Invoke
                   (
                       () =>
            {
                EphemProgress ephem = new EphemProgress(Objet);

                TaskLauncher launcher = new TaskLauncher()
                {
                    AutoCloseWindow = true,
                    LoopDelay = 50,
                    ProgressIHM = new DxProgressB1(ephem),
                    MethodToRun = method,
                };

                if (launcher.Launch(Objet) == true)
                {
                    return true;
                }

                throw new OperationCanceledException("Interrupted by user");
            }
                   ));
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Objet"></param>
        /// <param name="method"></param>
        /// <param name="title">Titre de la tâche</param>
        /// <returns></returns>
        internal static bool?ZipCompressFolder(I_AsyncSigD Objet, Func <object> method, string title = null)
        {
            //DxDoubleProgress dp = null;
            return(Application.Current.Dispatcher?.Invoke
                   (
                       () =>
            {        // dp = new DxDoubleProgress(mawmaw)
                EphemProgressD ephem = new EphemProgressD(Objet);

                TaskLauncher launcher = new TaskLauncher()
                {
                    AutoCloseWindow = true,
                    LoopDelay = 50,
                    ProgressIHM = new DxDoubleProgress(ephem),
                    MethodToRun = method
                };
                if (launcher.Launch(Objet) == true)
                {
                    return true;
                }

                throw new OperationCanceledException("Interrupted by user");
            }

                   ));
        }
Esempio n. 4
0
        /*
         *      internal void NewFindPivot()
         *      {
         *          for (int i = 0; i < ExtPlatformGames.Count; i++)
         *          {
         *              C_Game game = ExtPlatformGames[i];
         *
         *              // Gestion d'éventuelle erreur
         *              if (game.ApplicationPath == null)
         *                  continue;
         *
         *              // On passe les jeux déjà ok
         *              if (game.ApplicationPath.RelatPath.Contains(PlatformRelatPath))
         *                  continue;
         *
         *              string[] arr = game.ApplicationPath.RelatPath.Split(@"\");
         *
         *              // Test avec le nom de plateforme
         *              if (arr.Contains(PlatformToReplace))
         *              {
         *                  HeTrace.WriteLine($"[Pivot] OldObject choice");
         *                  var posPlatName = Array.LastIndexOf(arr, SelectedPlatform.Name);
         *                  ToReplace = String.Join(@"\", arr, 0, posPlatName + 1);
         *                  return;
         *              }
         *
         *              // Test pour essayer via le nom du système
         *              if (arr.Contains(SelectedPlatform.Name))
         *              {
         *                  HeTrace.WriteLine($"[Pivot] ObjectPlatfotme choice");
         *                  var posPlatName = Array.LastIndexOf(arr, SelectedPlatform.Name);
         *                  // Détermination de la position du nom de la plateforme
         *
         *                  ToReplace = String.Join(@"\", arr, 0, posPlatName + 1);
         *
         *                  return;
         *              }
         *
         *              // Voir si dossier null
         *              // On récupère le nom du dernier dossier de la plateforme
         *              string lastDir = Path.GetFileName(SelectedPlatform.Folder);
         *              if (!string.IsNullOrEmpty(SelectedPlatform.Folder) && game.ApplicationPath.RelatPath.Contains(lastDir))
         *              {
         *                  HeTrace.WriteLine($"[Pivot] Last folder from platform choice");
         *                  var posPlatName = Array.LastIndexOf(arr, lastDir);
         *                  ToReplace = String.Join(@"\", arr, 0, posPlatName - 1); // +1 Pour prendre aussi le dernier dossier
         *
         *                  return;
         *
         *              }
         *
         *              ToReplace = SelectedPlatform.Folder;
         *              HeTrace.WriteLine($"[Pivot] No predict");
         *          }
         *      }
         *
         *      /// <summary>
         *      ///
         *      /// <summary>
         *      /// <remarks>
         *      /// La prédiction est trop difficile, car il y a trop d'incertitudes.
         *      /// Remplacé par une vérification si le premier jeu à modifier contiendrait le nom du système pour déterminer la chaine à remplacer
         *      /// Si ce n'est pas le cas on ne mettra rien, il y a une boite pour choisir à la main le dossier
         *      /// </remarks>
         *      [Obsolete]
         *      internal void FindPivot()
         *      {
         *          // Mise en place du système pivot/tail, on donne un mot, on conservera ce qu'il y a après
         *
         *          // Récupération du premier qui n'a pas le bon chemin (pour travailler dessus)
         *          //C_Game chosenGame = null;
         *          for (int i = 0; i < ExtPlatformGames.Count; i++)
         *          {
         *              C_Game game = ExtPlatformGames[i];
         *
         *              // Gestion d'éventuelle erreur
         *              if (game.ApplicationPath == null)
         *                  continue;
         *
         *              // On passe les jeux déjà ok
         *              if (game.ApplicationPath.RelatPath.Contains(PlatformRelatPath))
         *                  continue;
         *
         *              string[] arr = game.ApplicationPath.RelatPath.Split(@"\");
         *
         *              // Test pour essayer via le nom du système
         *              if (arr.Contains(SelectedPlatform.Name))
         *              {
         *                  HeTrace.WriteLine($"[Pivot] ObjectPlatfotme choice");
         *                  var posPlatName = Array.IndexOf(arr, SelectedPlatform.Name);
         *                  // Détermination de la position du nom de la plateforme
         *
         *                  ToReplace = String.Join(@"\", arr, 0, posPlatName + 1);
         *
         *                  return;
         *              }
         *
         *              // Voir si dossier null
         *              // On récupère le nom du dernier dossier de la plateforme
         *              string lastDir = Path.GetFileName(SelectedPlatform.Folder);
         *              if (!string.IsNullOrEmpty(SelectedPlatform.Folder) && game.ApplicationPath.RelatPath.Contains(lastDir))
         *              {
         *                  HeTrace.WriteLine($"[Pivot] Last folder from platform choice");
         *                  var posPlatName = Array.IndexOf(arr, lastDir);
         *                  ToReplace = String.Join(@"\", arr, 0, posPlatName + 1); // +1 Pour prendre aussi le dernier dossier
         *                  return;
         *
         *              }
         *
         *              // Dernier cas on prend le premier application path qui ne correspond pas
         *              ToReplace = Path.GetDirectoryName(game.ApplicationPath.RelatPath);
         *              HeTrace.WriteLine("[Pivot] Last choice - Edit is strongly recommended");
         *              return;
         *          }
         *
         *          ToReplace = SelectedPlatform.Folder;
         *          HeTrace.WriteLine($"[Pivot] No predict");
         *      }*/

        #endregion

        private void PrepareInitializeGames()
        {
            TaskLauncher tl = new TaskLauncher()
            {
                AutoCloseWindow = true,
                ProgressIHM     = new Splash()
                {
                    Model = new EphemProgress(Core),
                },
                MethodToRun = () => Core.InitializeGames()
            };

            tl.Launch(Core);

            HeTrace.RemoveMessenger("mee");
        }
Esempio n. 5
0
 public static bool?LaunchDouble(I_AsyncSigD objet, Func <object> method, string title)
 {
     return(Application.Current.Dispatcher?.Invoke
            (
                () =>
     {
         EphemProgressD mawmaw = new EphemProgressD(objet);
         TaskLauncher launcher = new TaskLauncher()
         {
             AutoCloseWindow = true,
             ProgressIHM = new DxDoubleProgress(mawmaw),
             MethodToRun = method,
         };
         return launcher.Launch(objet);
     }
            ));;
 }
Esempio n. 6
0
        internal void PrepareSimulation()
        {
            HeTrace.WriteLine($"--- Prepare Simulation ---");

            TaskLauncher tl = new TaskLauncher()
            {
                AutoCloseWindow = true,
                ProgressIHM     = new Splash()
                {
                    Model = new EphemProgress(Core),
                },
                MethodToRun = () => Core.Simulation(),
            };

            if (tl.Launch(Core) == true)
            {
                ActiveSimulate = false;
                ActiveApply    = true;
            }
        }
Esempio n. 7
0
        public bool Process()
        {
            Test_HasElement(Elements, nameof(Elements));

            if (HasErrors)
            {
                return(false);
            }

            DataPackGCore lbDPGCore = new DataPackGCore();
            TaskLauncher  launcher  = new TaskLauncher()
            {
                AutoCloseWindow = false,
                ProgressIHM     = new DxStateProgress(lbDPGCore),
                MethodToRun     = () => lbDPGCore.InjectGamesFo(Elements),
            };

            launcher.Launch(lbDPGCore);

            return(true);
        }
Esempio n. 8
0
        internal void Exec()
        {
            IEnumerable <DataTrans> datas = GetFiles();


            HeTrace.WriteLine("Copy");
            HashCopy hashCopy = new HashCopy();

            hashCopy.AskToUser    += SafeBoxes.HashCopy_AskToUser;
            hashCopy.UpdateStatus += (x, y) => HeTrace.WriteLine(y.Message);
            PersistProgressD mee = new PersistProgressD(hashCopy);

            TaskLauncher launcher = new TaskLauncher()
            {
                ProgressIHM     = new DxDoubleProgress(mee),
                AutoCloseWindow = true,
                MethodToRun     = () => hashCopy.VerifSevNCopy(datas),
            };

            launcher.Launch(hashCopy);
        }
Esempio n. 9
0
        public bool Process()
        {
            Test_HasElement(Elements, nameof(Elements));

            if (HasErrors)
            {
                return(false);
            }

            DPGMakerCore dpgC     = new DPGMakerCore();
            TaskLauncher launcher = new TaskLauncher()
            {
                AutoCloseWindow = false,
                ProgressIHM     = new DxStateProgress(dpgC),
                MethodToRun     = () => dpgC.MakeDPG_Comp(Elements),
            };

            launcher.Launch(dpgC);

            return(true);
        }
Esempio n. 10
0
        /// <summary>
        /// Vérifie l'intégrité des jeux (pas de renouvellement des jeux)
        /// </summary>
        public void PrepareCheckAllGames([CallerMemberName] string propertyName = null)
        {
            if (Core.ChosenMode == GamePathMode.None)
            {
                return;
            }

            HeTrace.WriteLine($"--- Check Validity of Games ({propertyName}) ---");

            TaskLauncher tl = new TaskLauncher()
            {
                AutoCloseWindow = true,
                ProgressIHM     = new Splash()
                {
                    Model = new EphemProgress(Core),
                },
                MethodToRun = () => Core.CheckAllGames(),
            };

            tl.Launch(Core);
        }
Esempio n. 11
0
        private bool Copy2(string srcFolder, string subFolder, string message, Collection <DataRep> collec)
        {
            srcFolder = Path.GetFullPath(srcFolder, Config.HLaunchBoxPath);
            DataRep dr = null;

            TreeChoose tc = new TreeChoose()
            {
                Model = new M_ChooseRaw()
                {
                    Info           = message,
                    Mode           = ChooseMode.File,
                    ShowFiles      = true,
                    StartingFolder = srcFolder
                }
            };

            if (tc.ShowDialog() == true)
            {
                string folderDest = Path.Combine(_Root, subFolder);
                dr      = DataTrans.MakeSrcnDest <DataRep>(tc.LinkResult, subFolder);
                dr.Name = dr.DestPath.Replace(subFolder, ".");

                DateTime oldLW = new DateTime();
                DataRep  oldDr = collec.FirstOrDefault(x => x.DestPath.Equals(dr.DestPath));
                if (oldDr != null)
                {
                    oldLW = File.GetLastWriteTimeUtc(oldDr.DestPath);
                }

                //
                EphemProgress ephem   = new EphemProgress();
                HashCopy      copyZat = new HashCopy();
                copyZat.AskToUser += PackMe_IHM.Ask4_FileConflict2;

                bool         copyres  = false;
                TaskLauncher launcher = new TaskLauncher()
                {
                    AutoCloseWindow = true,
                    ProgressIHM     = new DxProgressB1(ephem),
                    MethodToRun     = () => copyres = copyZat.CopyOneNVerif(dr),
                };
                launcher.Launch(copyZat);

                //
                if (!copyres)
                {
                    return(false);
                }

                DateTime newLW = File.GetLastWriteTimeUtc(dr.DestPath);
                if (oldLW == newLW)
                {
                    return(false);
                }

                if (oldDr != null)
                {
                    collec.Remove(oldDr);
                }

                collec.Add(dr);

                return(true);
                //return Copy(tc.LinkResult, Path.Combine(Root, subFolder));
            }

            return(false);
        }