コード例 #1
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");
            }
                   ));
        }
コード例 #2
0
ファイル: M_PackMeRes.cs プロジェクト: daerlnaxe/Pack-My-Game
        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);
        }