Beispiel #1
0
        public static Conclusion BootHakchi(Tasker tasker, Object syncObject = null)
        {
            // Continue the hakchi boot process
            tasker.SetStatus(Resources.BootingHakchi);
            MemoryStream hakchiLogStream = new MemoryStream();
            var          splitStream     = new SplitterStream(hakchiLogStream).AddStreams(Program.debugStreams);

            tasker.PushState(State.Waiting);
            try
            {
                hakchi.Shell.Execute("boot", null, splitStream, splitStream, 0, true);
            }
            catch { }
            tasker.PopState();

            hakchiLogStream.Seek(0, SeekOrigin.Begin);
            string hakchiLog;

            using (StreamReader sr = new StreamReader(hakchiLogStream))
            {
                hakchiLog = sr.ReadToEnd();
            }
            foreach (string line in hakchiLog.Split(Convert.ToChar(0x0A)))
            {
                if (line.StartsWith("flash md5 mismatch! "))
                {
                    throw new Exception(line);
                }
            }

            return(Conclusion.Success);
        }
Beispiel #2
0
 public Tasker.Conclusion ShowExportDialog(Tasker tasker, Object syncObject = null)
 {
     if (tasker.HostForm.Disposing)
     {
         return(Tasker.Conclusion.Undefined);
     }
     if (tasker.HostForm.InvokeRequired)
     {
         return((Tasker.Conclusion)tasker.HostForm.Invoke(new Func <Tasker, Object, Tasker.Conclusion>(ShowExportDialog), new object[] { tasker, syncObject }));
     }
     tasker.SetStatus(Resources.SelectDrive);
     try
     {
         using (ExportGamesDialog driveSelectDialog = new ExportGamesDialog())
         {
             tasker.PushState(Tasker.State.Paused);
             var result = driveSelectDialog.ShowDialog() == DialogResult.OK;
             tasker.PopState();
             if (!result)
             {
                 return(Tasker.Conclusion.Abort);
             }
             this.exportLinked    = driveSelectDialog.LinkedExport;
             this.exportDirectory = driveSelectDialog.ExportPath;
             if (!Directory.Exists(driveSelectDialog.ExportPath))
             {
                 Directory.CreateDirectory(driveSelectDialog.ExportPath);
             }
         }
         copyMode = exportLinked ? NesApplication.CopyMode.LinkedExport : NesApplication.CopyMode.Export;
         return(Tasker.Conclusion.Success);
     }
     catch (InvalidOperationException) { }
     return(Tasker.Conclusion.Abort);
 }
Beispiel #3
0
        public static Conclusion WaitForShellCycle(Tasker tasker, Object syncObject = null, int maxWaitTime = -1, string title = null, string message = null)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, object, int, string, string, Conclusion>(WaitForShellCycle), new object[] { tasker, syncObject, maxWaitTime, title, message }));
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            tasker.PushState(State.Waiting);
            var result = WaitingShellCycleForm.WaitForDevice(hostForm, maxWaitTime == -1 ? MembootWaitDelay : maxWaitTime);

            tasker.PopState();
            if (result == DialogResult.OK)
            {
                return(Conclusion.Success);
            }
            else if (result == DialogResult.No)
            {
                MessageForm.Show(hostForm, title == null ? Resources.WaitingForDevice : title, message == null ? Resources.WaitingForDeviceTakingALongTime : message, Resources.sign_clock);
            }

            return(Conclusion.Abort);
        }
Beispiel #4
0
        public static Conclusion WaitForShellCycle(Tasker tasker, Object syncObject = null)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, object, Conclusion>(WaitForShellCycle), new object[] { tasker, syncObject }));
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            tasker.PushState(State.Waiting);
            var result = WaitingShellCycleForm.WaitForDevice(hostForm, MembootWaitDelay);

            tasker.PopState();
            if (result == DialogResult.OK)
            {
                return(Conclusion.Success);
            }

            return(Conclusion.Abort);
        }
        public static DialogResult SelectFile(Tasker tasker, string[] files)
        {
            if (tasker.HostForm.Disposing)
            {
                return(DialogResult.Cancel);
            }
            if (tasker.HostForm.InvokeRequired)
            {
                return((DialogResult)tasker.HostForm.Invoke(new Func <Tasker, string[], DialogResult>(SelectFile), new object[] { tasker, files }));
            }
            try
            {
                using (var form = new SelectFileForm(files))
                {
                    tasker.PushState(Tasker.State.Paused);
                    var result = form.ShowDialog();
                    tasker.PopState();
                    selectedFile = form.listBoxFiles.SelectedItem != null?form.listBoxFiles.SelectedItem.ToString() : null;

                    return(result);
                }
            }
            catch (InvalidOperationException) { }
            return(DialogResult.Cancel);
        }
Beispiel #6
0
        public static Conclusion WaitForShellCycle(Tasker tasker, Object syncObject = null)
        {
            if (tasker.HostForm.InvokeRequired)
            {
                return((Conclusion)tasker.HostForm.Invoke(new Func <Tasker, object, Conclusion>(WaitForShellCycle), new object[] { tasker, syncObject }));
            }
            tasker.SetStatus(Resources.WaitingForDevice);
            tasker.PushState(State.Waiting);
            var result = WaitingShellCycleForm.WaitForDevice(tasker.HostForm, MembootWaitDelay);

            tasker.PopState();
            if (result == DialogResult.OK)
            {
                return(Conclusion.Success);
            }

            return(Conclusion.Abort);
        }
Beispiel #7
0
 public Tasker.Conclusion ShowFoldersManager(Tasker tasker, Object syncObject = null)
 {
     if (tasker.HostForm.Disposing)
     {
         return(Tasker.Conclusion.Undefined);
     }
     if (tasker.HostForm.InvokeRequired)
     {
         return((Tasker.Conclusion)tasker.HostForm.Invoke(new Func <Tasker, Object, Tasker.Conclusion>(ShowFoldersManager), new object[] { tasker, syncObject }));
     }
     tasker.SetStatus(Resources.RunningFoldersManager);
     try
     {
         using (FoldersManagerForm form = new FoldersManagerForm(Games, MainForm.StaticRef))
         {
             tasker.PushState(Tasker.State.Paused);
             var result = form.ShowDialog() == DialogResult.OK ? Tasker.Conclusion.Success : Tasker.Conclusion.Abort;
             tasker.PopState();
             return(result);
         }
     }
     catch (InvalidOperationException) { }
     return(Tasker.Conclusion.Abort);
 }