private Taskbar() { if (Taskbar.m_isWin7) { this.m_taskbarList = (WinAPIs.ITaskbarList4)new WinAPIs.CTaskbarList(); m_taskbarList.HrInit(); } this.m_taskbarProgress = new TaskbarProgress(this); }
public static void SetErrorState() { TaskbarProgress.SetState(TaskbarProgress.eStates.Error); }
public static void Continue() { TaskbarProgress.SetState(TaskbarProgress.eStates.Normal); }
static string RunUnrar(string pth) { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Indeterminate); int read = 1; int rr = 0; int count = 0; while ("l" == "l") { if (File.Exists(locTemp + "from" + read + ".txt")) { string pathF = File.ReadAllText(locTemp + "from" + read + ".txt"); read++; rr++; string pathT = File.ReadAllText(locTemp + "to" + read + ".txt"); string pathNew = new DirectoryInfo(pathF).Name; string pathRec = pathNew; pathNew = pathT + @"\" + pathNew; Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(pathNew); count = count + dir.GetFiles("*.r*", SearchOption.AllDirectories).Length; Console.WriteLine("Counting.."); ///////////////////////////////////////////// Console.WriteLine(count + " rar files"); int totalAmountOfRars = count; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); System.Diagnostics.Stopwatch ew = System.Diagnostics.Stopwatch.StartNew(); // -------------------------------------------------------------------------------- string source = pathNew; DirectoryInfo dire = new DirectoryInfo(pathNew); bool k = false; int nm = 1; while (k == false) { int fileCount = dire.GetFiles("*.rar", SearchOption.AllDirectories).Length; string[] myList = new string[fileCount + 1]; string[] myListFull = new string[fileCount + 1]; foreach (FileInfo torre in dire.GetFiles("*.rar", SearchOption.AllDirectories)) { Console.WriteLine(torre.Name); myListFull[nm] = (Path.GetFileNameWithoutExtension(torre.Name)); myList[nm++] = torre.FullName; } nm = 1; try { foreach (FileInfo f in dire.GetFiles("*.rar", SearchOption.AllDirectories)) { source = f.FullName; string sourcealt = f.Directory.FullName; //Console.WriteLine(d); //Console.WriteLine(f); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); string time = DateTime.Now.ToString("HH:mm:ss"); Console.Write("[{0}]", time); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write(" --> "); Console.ForegroundColor = ConsoleColor.White; Console.Write("Extracting files '"); Console.ForegroundColor = ConsoleColor.Green; Console.Write(myListFull[nm]); Console.ForegroundColor = ConsoleColor.White; Console.Write("'... "); Process myProcess = new Process(); myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal; myProcess.StartInfo.CreateNoWindow = false; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.FileName = "cmd.exe"; string pthso = sourcealt; string pfiles = "C:\\Program Files\\WinRAR\\winrar.exe"; string command = "/c \"\"" + pfiles + "\"\" x " + myList[nm] + " *.* " + pthso; //Console.WriteLine(command); //Console.ReadLine(); ConsoleSpiner spin = new ConsoleSpiner(); bool ffk = true; myProcess.StartInfo.Arguments = command; TaskbarProgress.SetValue(handle, totalAmountOfRars - count, totalAmountOfRars); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Normal); myProcess.Start(); myProcess.WaitForExit(); while (ffk == true) { bool isRunning = !myProcess.HasExited; if (isRunning == false) { ffk = false; break; } spin.Turn(); } //string dirtoDel = sourcealt + "\\*.r*"; count--; nm++; } } catch (System.Exception excpt) { Console.WriteLine(excpt.Message); } k = true; break; } /*foreach (FileInfo file in dire.GetFiles("*.rar")) * { * Console.ForegroundColor = ConsoleColor.Gray; * Console.WriteLine(); * string time = DateTime.Now.ToString("HH:mm:ss"); * Console.Write("[{0}]", time); * Console.ForegroundColor = ConsoleColor.Magenta; * Console.Write(" --> "); * Console.ForegroundColor = ConsoleColor.White; * Console.Write("Extracting files '"); * Console.ForegroundColor = ConsoleColor.Green; * string temppath = Path.Combine(file.Name); * Console.Write(pth); * Console.ForegroundColor = ConsoleColor.White; * Console.Write("'... "); * Process myProcess = new Process(); * //myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; * myProcess.StartInfo.CreateNoWindow = true; * myProcess.StartInfo.UseShellExecute = false; * myProcess.StartInfo.FileName = "cmd.exe"; * myProcess.StartInfo.Arguments = "C:\\Program Files\\WinRAR\\winrar.exe e - s " + source + " *.* "; * myProcess.Start(); * myProcess.WaitForExit(); * Console.WriteLine("CMD DONE!"); * Console.ReadLine(); * System.Threading.Thread.Sleep(200); * * }*/ // -------------------------------------------------------------------------------- File.Delete(pathNew + "\\*.r*"); ew.Stop(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; TimeSpan t = TimeSpan.FromSeconds(ew.Elapsed.TotalSeconds); string answer = string.Format("{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); Console.WriteLine(); if (count == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.Write("Couldn't find any (more) rar files to extract."); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); return(null); } else { Console.Write("Extraction of {0} files took ", count); Console.ForegroundColor = ConsoleColor.White; Console.Write("{0} seconds", answer); Console.WriteLine(); return(null); } } else { break; } return("0"); } return("0"); }
private void updateTaskbarProgress(TaskbarProgress.TaskbarStates state = TaskbarProgress.TaskbarStates.Normal) { updateTaskbarProgress(prgMajor.Value, prgMajor.Maximum, state); }
protected override void OnFormClosed(FormClosedEventArgs e) { TaskbarProgress.Clear(); base.OnFormClosed(e); }
private void DisplayProgress(ProgressChangedEventArgs e) { toolStripProgressBar_Info.Style = ProgressBarStyle.Blocks; toolStripProgressBar_Info.Value = e.ProgressPercentage; TaskbarProgress.SetValue(this.Handle, e.ProgressPercentage, 100); }
private void btnPause_Click(object sender, EventArgs e) { Player.Pause(); TaskbarProgress.SetState(Handle, Player.Paused ? TaskbarStates.Paused : TaskbarStates.Normal); }
private void trimData() { Timer.Reset(); Timer.Start(); string[] files = Directory.GetFiles("C:\\Diplomarbeit_Geoelektrik\\daten_mit_topography\\"); Process p = checkForProcess("RES2DINV_3.59.118"); if (p == null) { p = Process.Start("C:\\Diplomarbeit_Geoelektrik\\daten von usb-stick\\RES2DINV_3.59.118.exe"); } try { Thread.Sleep(500); IntPtr res2dHandle = p.MainWindowHandle; ShowWindow(res2dHandle, SW_MAXIMIZE); //show window maximized SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "System Resources", 5)); //set focus to start dialog and wait for it InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //change settings: read inversion parameters from .inv InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateTextEntry("C:\\Diplomarbeit_Geoelektrik\\daten von usb-stick\\Gresten Modelblock-fix.ivp"); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); for (int i = CurrentFile; i < files.Length; i++) //run through all files in given directory from startAtFile to endAtFile { if (!Timer.IsRunning) { Timer.Reset(); Timer.Start(); } TaskbarProgress.SetValue(MainHandle, CurrentFile, files.Length - 1); //progress on taskbar if (i % 6 == 0 && restart) { throw new RestartException(i); } else { restart = true; } if (StopAtNext) { StopAtNext = false; ManageBot.Abort(); Stop(false); } MyConsole.WriteLine("#" + i + " started."); //files to be saved string invfilename = SAVETOINV + files[i].Split('.')[0].Split('\\').Last() + ".inv"; //Split for filename and add .inv string datfilename = SAVETOTRIM + files[i].Split('\\').Last(); //Split for filename //if already exist, delete if (File.Exists(invfilename)) { MyConsole.WriteLine("#" + i + " (" + invfilename.Split('\\').Last() + ") existed, so it was removed."); File.Delete(invfilename); } if (File.Exists(datfilename)) { Console.WriteLine("#" + i + " (" + datfilename.Split('\\').Last() + ") existed, so it was removed."); File.Delete(datfilename); } //read .dat file InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SleepHelper.WaitForWindow(BASIC_INTERVAL, "Input 2D resistivity data file", 5); InputSimulator.SimulateTextEntry(files[i]); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Message", 5)); if (SleepHelper.CheckForWindow(new string[] { "Data Error", "Convergence Warning" })) { MyConsole.WriteLine("#" + i + " skipped due to error."); CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; Properties.Settings.Default.Save(); throw new NotIntendedException(i, "Data Error or RMS error too high."); } InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); /*SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Incomplete Gauss-Newton method", 5)); * Thread.Sleep(150); * //check * if (!SleepHelper.GetActiveWindowTitle().Contains("Incomplete Gauss-Newton method")) * { * throw new NotIntendedException(i, "Read .dat file"); * }*/ InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //least squares inversion InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(1000); SleepHelper.WaitForWindow(BASIC_INTERVAL, "File Name for Inversion Results", 5); InputSimulator.SimulateTextEntry(invfilename); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Enter Additional Iterations", 1400)); if (SleepHelper.CheckForWindow(new string[] { "Data Error", "Convergence Warning" })) { MyConsole.WriteLine("#" + i + " skipped due to error."); CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; Properties.Settings.Default.Save(); throw new NotIntendedException(i, "Data Error or RMS error too high."); } InputSimulator.SimulateTextEntry("0"); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(150); SleepHelper.WaitForCursor(BASIC_INTERVAL, Cursors.Arrow); //window has a slight delay Thread.Sleep(150); //check if everything went right if (!File.Exists(invfilename)) { throw new NotIntendedException(i, "Least squares inversion: File not generated"); } //display - show results Thread.Sleep(150); InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //edit data - rms statistics SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Message", 5)); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); IntPtr test2 = SleepHelper.WaitForWindow(BASIC_INTERVAL, "RMS Error Analysis Window", 5); SetForegroundWindow(test2); Thread.Sleep(300); //check if everything went right if (!SleepHelper.GetActiveWindowTitle().Contains("RMS Error Analysis Window")) { throw new NotIntendedException(i, "Edit data - RMS statistics"); } for (int redo = 0; redo < 26; redo++) { InputSimulator.SimulateKeyPress(VirtualKeyCode.LEFT); Thread.Sleep(10); } //trim data InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //exit Thread.Sleep(30); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Trim data set", 5)); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //trim data? Thread.Sleep(30); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Message", 5)); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //to trim you need to save Thread.Sleep(100); ShowWindow(res2dHandle, SW_MINIMIZE); //minimize maximize, to work around a bug (otherwise filesave dialog does not appear) Thread.Sleep(250); ShowWindow(res2dHandle, SW_MAXIMIZE); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Output edited data file", 5)); InputSimulator.SimulateTextEntry(datfilename); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(1000); //file needs some time until it is saved //check if everything is right if (!File.Exists(datfilename)) { throw new NotIntendedException(i, "Trim data: File not generated"); } //close display window InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); //change output path? NO. (sometimes not needed) InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); MyConsole.WriteLine("#" + i + " finished."); //update progress CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; //progress in settings Properties.Settings.Default.Save(); Timer.Stop(); TimeIntervals.Add(Timer.ElapsedMilliseconds); } } catch (RestartException rsexc) { restart = false; MyConsole.WriteLine(rsexc); p.Kill(); p.Close(); TrimBot.Abort(); } catch (ThreadAbortException taexc) { restart = false; MyConsole.WriteLine("#" + Properties.Settings.Default.progress + ": Trimbot aborted."); Timer.Stop(); } catch (NotIntendedException niexc) { restart = false; MyConsole.WriteLine(niexc); Crashes++; p.Kill(); p.Close(); TrimBot.Abort(); } catch (Exception exc) { restart = false; MyConsole.WriteLine("#" + Properties.Settings.Default.progress + ":\n" + exc); Crashes++; p.Kill(); p.Close(); TrimBot.Abort(); } }
private void createxyz() { Timer.Reset(); Timer.Start(); string[] files = Directory.GetFiles("C:\\Diplomarbeit_Geoelektrik\\daten_trimmed\\"); Process p = checkForProcess("RES2DINV_3.59.118"); if (p == null) { p = Process.Start("C:\\Diplomarbeit_Geoelektrik\\daten von usb-stick\\RES2DINV_3.59.118.exe"); } try { Thread.Sleep(500); IntPtr res2dHandle = p.MainWindowHandle; ShowWindow(res2dHandle, SW_MAXIMIZE); //show window maximized SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "System Resources", 5)); //set focus to start dialog and wait for it InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //change settings: read inversion parameters from .inv InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateTextEntry("C:\\Diplomarbeit_Geoelektrik\\daten von usb-stick\\Gresten Modelblock-fix.ivp"); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); for (int i = CurrentFile; i < files.Length; i++) //run through all files in given directory from startAtFile to endAtFile { if (!Timer.IsRunning) { Timer.Reset(); Timer.Start(); } TaskbarProgress.SetValue(MainHandle, CurrentFile, files.Length - 1); //progress on taskbar if (StopAtNext) { StopAtNext = false; ManageBot.Abort(); Stop(false); } MyConsole.WriteLine("#" + i + " started."); //files to be saved string invtrimfilename = SAVETOTRIMINV + files[i].Split('.')[0].Split('\\').Last() + ".inv"; //Split for filename and add .inv string xyzfilename = SAVETOXYZ + files[i].Split('.')[0].Split('\\').Last() + ".xyz"; //Split for filename and add .xyz //if already exist, delete if (File.Exists(invtrimfilename)) { MyConsole.WriteLine("#" + i + " (" + invtrimfilename.Split('\\').Last() + ") existed, so it was removed."); File.Delete(invtrimfilename); } if (File.Exists(xyzfilename)) { Console.WriteLine("#" + i + " (" + xyzfilename.Split('\\').Last() + ") existed, so it was removed."); File.Delete(xyzfilename); } //read .dat file InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SleepHelper.WaitForWindow(BASIC_INTERVAL, "Input 2D resistivity data file", 5); InputSimulator.SimulateTextEntry(files[i]); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Message", 5)); if (SleepHelper.CheckForWindow(new string[] { "Data Error", "Convergence Warning" })) { MyConsole.WriteLine("#" + i + " skipped due to error."); CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; Properties.Settings.Default.Save(); throw new NotIntendedException(i, "Data Error or RMS error too high."); } InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //least squares inversion InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "File Name for Inversion Results", 5)); Thread.Sleep(1500); InputSimulator.SimulateTextEntry(invtrimfilename); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Enter Additional Iterations", 2000)); if (SleepHelper.CheckForWindow(new string[] { "Data Error", "Convergence Warning" })) { MyConsole.WriteLine("#" + i + " skipped due to error."); CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; Properties.Settings.Default.Save(); throw new NotIntendedException(i, "Data Error or RMS error too high."); } InputSimulator.SimulateTextEntry("0"); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(150); SleepHelper.WaitForCursor(BASIC_INTERVAL, Cursors.Arrow); //window has a slight delay Thread.Sleep(150); //check if everything went right if (!File.Exists(invtrimfilename)) { throw new NotIntendedException(i, "Least squares inversion: File not generated"); } //display - show results Thread.Sleep(150); InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); //save xyz Thread.Sleep(2000); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.DOWN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Choose iteration number", 5)); Thread.Sleep(150); if (!SleepHelper.CheckForWindow(new string[] { "Choose iteration number" })) { throw new NotIntendedException(i, "Iteration number selection failed"); } InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(150); InputSimulator.SimulateTextEntry(xyzfilename); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); SetForegroundWindow(SleepHelper.WaitForWindow(BASIC_INTERVAL, "Message", 5)); if (!SleepHelper.CheckForWindow(new string[] { "Message" })) { throw new NotIntendedException(i, "Save .xyz: No Message Window"); } //close display window InputSimulator.SimulateKeyPress(VirtualKeyCode.MENU); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.UP); InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); Thread.Sleep(1000); //file needs some time until it is saved //check if everything is right if (!File.Exists(xyzfilename)) { throw new NotIntendedException(i, "Save .xyz: File not generated"); } InputSimulator.SimulateKeyPress(VirtualKeyCode.RIGHT); //change output path? NO. (sometimes not needed) InputSimulator.SimulateKeyPress(VirtualKeyCode.RETURN); MyConsole.WriteLine("#" + i + " finished."); //update progress CurrentFile = i + 1; Properties.Settings.Default.progress = i + 1; //progress in settings Properties.Settings.Default.Save(); Timer.Stop(); TimeIntervals.Add(Timer.ElapsedMilliseconds); throw new RestartException(i); } } catch (RestartException rsexc) { p.Kill(); p.Close(); TrimBot.Abort(); } catch (NotIntendedException niexc) { MyConsole.WriteLine(niexc); Crashes++; p.Kill(); p.Close(); TrimBot.Abort(); } catch (ThreadAbortException taexc) { MyConsole.WriteLine("#" + Properties.Settings.Default.progress + ": Trimbot aborted."); Timer.Stop(); } catch (Exception exc) { MyConsole.WriteLine("#" + Properties.Settings.Default.progress + ":\n" + exc); Crashes++; p.Kill(); p.Close(); TrimBot.Abort(); } }
/// <summary> /// On download progress changed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Download progress changed event arguments</param> private void OnDownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { downloadProgressBar.Maximum = (int)(e.TotalBytesToReceive); downloadProgressBar.Value = (int)(e.BytesReceived); TaskbarProgress.SetValue(this, e.BytesReceived, e.TotalBytesToReceive); }
private async void generateButton_Click(object sender, EventArgs e) { if (_cancellationTokenSource != null) { _cancellationTokenSource.Cancel(); _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; generateButton.Text = GenerateButtonText; progressBar1.Value = progressBar1.Minimum; TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); return; } // Validate parameters: bool PromptOverwriteExistingOutputFile(IReadOnlyCollection <string> paths) { var promptResult = MessageBox.Show(this, $"The following files already exist: '{string.Join(", ", paths.Select(x => $"'{x}'"))}'. Do you want to overwrite them?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question); return(promptResult == DialogResult.Yes); } var generators = _barGenerators .Where(x => x.Checked) .Select(x => x.Generator) .ToArray(); if (generators.Any() == false) { TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Error); MessageBox.Show(this, "At least one barcode version must be selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } BarCodeParameters parameters; try { parameters = _barCodeParametersValidator.GetValidatedParameters( rawInputPath: inputPathTextBox.Text, rawBaseOutputPath: outputPathTextBox.Text, rawBarWidth: barWidthTextBox.Text, rawImageWidth: imageWidthTextBox.Text, rawImageHeight: imageHeightTextBox.Text, useInputHeightForOutput: useInputHeightForOutputCheckBox.Checked, shouldOverwriteOutputPaths: PromptOverwriteExistingOutputFile, barGenerators: generators); } catch (OperationCanceledException) { TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); return; } catch (Exception ex) { AppendLog("Error validating input parameters. " + ex.ToString()); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Error); MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } AppendLog($@"Barcode generation starting... Input: '{parameters.InputPath}' Output: {string.Join(", ", parameters.GeneratorOutputPaths.Select(x => $"'{x.Value}'"))} Output width: {parameters.Width} Output height: {parameters.Height} Bar width: {parameters.BarWidth}"); // Register progression callback and ready cancellation source: var progress = new PercentageProgressHandler(percentage => { var progressBarValue = Math.Min(100, (int)Math.Round(percentage * 100, MidpointRounding.AwayFromZero)); Invoke(new Action(() => { if (_cancellationTokenSource != null) { progressBar1.Value = progressBarValue; TaskbarProgress.SetValue(Handle, progressBarValue, 100); } })); }); _cancellationTokenSource = new CancellationTokenSource(); var cancellationLocalRef = _cancellationTokenSource; // Actually create the barcode: IReadOnlyDictionary <IBarGenerator, Bitmap> result = null; try { generateButton.Text = CancelButtonText; generateButton.Enabled = false; // Prevent the user from cancelling for 1sec (it might not be obvious the generation has started) var dontCare = Task.Delay(1000).ContinueWith(t => { try { Invoke(new Action(() => generateButton.Enabled = true)); } catch { } }); await Task.Run(() => { result = _imageProcessor.CreateBarCodes( parameters, _ffmpegWrapper, _cancellationTokenSource.Token, progress, AppendLog); }, _cancellationTokenSource.Token); } catch (OperationCanceledException) { AppendLog("Operation cancelled."); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); return; } catch (Exception ex) { AppendLog("Error: " + ex.ToString()); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Error); MessageBox.Show(this, "Sorry, something went wrong. See the log for more information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } finally { generateButton.Text = GenerateButtonText; _cancellationTokenSource?.Dispose(); _cancellationTokenSource = null; } if (cancellationLocalRef.IsCancellationRequested) { AppendLog("Operation cancelled."); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); return; } // Save the barcode: AppendLog("Saving the images..."); try { foreach (var barcode in result) { var outputPath = parameters.GeneratorOutputPaths[barcode.Key]; barcode.Value.Save(outputPath); } } catch (Exception ex) { var message = $"Unable to save the images: {ex}"; AppendLog(message); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.Error); MessageBox.Show(this, message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } AppendLog("Barcode generated successfully!"); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); }
static void Main(string[] args) { Console.Title = "VerifyFiles v0.3 Beta"; Console.WriteLine("VerifyFiles v0.3 Beta"); string copyrightText = ""; if (DateTime.Now.Year != 2019) { copyrightText = "2019-" + DateTime.Now.Year; } else { copyrightText = "2019"; } Console.WriteLine("Copyright " + copyrightText + " - WorldUnited"); Console.WriteLine("Author: MeTonaTOR & ReenduX"); Console.WriteLine("------------------------------------------------------------"); if (!File.Exists("nfsw.exe")) { Console.WriteLine("Cannot find nfsw.exe, please place VerifyHash.exe directly to Need for Speed: World installation folder."); Console.WriteLine("------------------------------------------------------------"); Console.ReadKey(); Environment.Exit(0); } Console.WriteLine("This tool will verify your NFSW installation, if you agree \non that, press anything on keyboard."); Console.WriteLine("Otherwise, shut down this app by clicking on X or ALT+F4."); Console.ReadKey(); Console.WriteLine("------------------------------------------------------------"); bool taskDone = false; IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; do { while (!Console.KeyAvailable) { if (taskDone != true) { Console.WriteLine("[INFO] Loading hashes"); VerifyHash.VerifyHash vh = new VerifyHash.VerifyHash(); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Indeterminate); Task.Run(() => { while (vh.totalFilesScanned != vh.filesToScan) { TaskbarProgress.SetValue(handle, (int)(100 * vh.totalFilesScanned / vh.filesToScan), 100); Console.Title = "[" + vh.totalFilesScanned + "/" + vh.filesToScan + "] VerifyFiles v0.2 Beta"; Task.Delay(100); } }); vh.ScanLines((output) => Console.WriteLine(output)); if (vh.invalidFileList.Count != 0) { Console.WriteLine("------------------------------------------------------------"); Console.Title = "VerifyFiles v0.2 Beta"; Console.WriteLine(" Redownloading " + vh.invalidFileList.Count + " files: "); Task.Run(() => { while (vh.redownloadedCount != vh.badFiles) { TaskbarProgress.SetValue(handle, (int)(100 * vh.redownloadedCount / vh.badFiles), 100); Console.Title = "[" + vh.redownloadedCount + "/" + vh.badFiles + "] VerifyFiles v0.2 Beta"; Task.Delay(100); } }); vh.DownloadFiles((output) => Console.WriteLine(output)); } Console.WriteLine("------------------------------------------------------------"); Console.WriteLine(" All done! Results: "); Console.WriteLine(" Total Files Scanned: " + vh.totalFilesScanned.ToString()); Console.WriteLine(" Total Files To Scan: " + vh.filesToScan.ToString()); Console.WriteLine(" Mismatched Hash: " + vh.badFiles.ToString()); Console.WriteLine(" Redownloaded Files: " + vh.redownloadedCount.ToString()); Console.WriteLine("------------------------------------------------------------"); Console.WriteLine("Press ESC to quit."); taskDone = true; } } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); }
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs, int count, int fcount, int totalPerc) { int dcount = count; // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourceDirName); DirectoryInfo[] dirs = dir.GetDirectories(); if (!dir.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " + sourceDirName); } // If the destination directory doesn't exist, create it. if (!Directory.Exists(destDirName)) { Directory.CreateDirectory(destDirName); } // Get the files in the directory and copy them to the new location. FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { string dd = Path.Combine(destDirName, file.Name); if (File.Exists(dd)) { loc--; } } IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; foreach (FileInfo file in files) { if (totalPerc - loc == 0) { TaskbarProgress.SetValue(handle, totalPerc - loc, totalPerc); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Indeterminate); } else { TaskbarProgress.SetValue(handle, totalPerc - loc, totalPerc); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Normal); } try { string temppath = Path.Combine(destDirName, file.Name); string alttemppath = Path.Combine(sourceDirName, file.Name); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); string time = DateTime.Now.ToString("HH:mm:ss"); Console.Write("[{0}]", time); var spacer = GetFileSizeOnDisk(alttemppath); var space = SizeSuffix(spacer); Console.ForegroundColor = ConsoleColor.White; Console.Write(" ({0}/{1}) | {2}", fcount, dcount, space); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write(" --> "); Console.ForegroundColor = ConsoleColor.White; if (move == true) { Console.Write("Moving file '"); } else if (move == false) { Console.Write("Copying file '"); } Console.ForegroundColor = ConsoleColor.Green; //Console.Write(temppath); Console.Write(file.Name); Console.ForegroundColor = ConsoleColor.White; Console.Write("'... "); Console.Title = "Files left: " + loc + " | (" + fcount + "/" + dcount + ") | " + space + " " + file.Name; //if (!File.Exists("sizes.txt")) //{ // StreamWriter de = new StreamWriter("sizes.txt"); // de.WriteLine(0); //} //StreamReader r = new StreamReader("sizes.txt"); //StreamWriter d = new StreamWriter("sizes.txt"); //string AmountCopiede = r.ReadLine(); //long AmountCopied = Convert.ToInt64(AmountCopiede); //AmountCopied = AmountCopied + spacer; //d.WriteLine(AmountCopied); //Console.WriteLine(AmountCopied); if (move == true) { file.MoveTo(temppath); } else if (move == false) { file.CopyTo(temppath, false); } fcount++; count--; loc--; } catch (FileNotFoundException) { TaskbarProgress.SetValue(handle, totalPerc - loc, totalPerc); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Error); //Write Files to Log whicht couldn't be copy LogText += DateTime.Now.ToString() + ": " + file.FullName; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.Write("ERROR: "); //Console.ForegroundColor = ConsoleColor.Cyan; //Console.Write(file.Name); Console.ForegroundColor = ConsoleColor.White; Console.Write("File not found"); Console.Title = Console.Title + " ERROR: File Not Found"; Console.WriteLine(); fcount++; count--; loc--; } catch (Exception) { TaskbarProgress.SetValue(handle, totalPerc - loc, totalPerc); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Error); //Write Files to Log whicht couldn't be copy LogText += DateTime.Now.ToString() + ": " + file.FullName; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.Write("ERROR: "); //Console.ForegroundColor = ConsoleColor.Cyan; //Console.Write(file.Name); Console.ForegroundColor = ConsoleColor.White; Console.Write("File already exist"); Console.Title = Console.Title + " ERROR: File already exists"; Console.WriteLine(); fcount++; count--; loc--; } } // If copying subdirectories, copy them and their contents to new location. if (copySubDirs) { foreach (DirectoryInfo subdir in dirs) { string temppath = Path.Combine(destDirName, subdir.Name); string temppathk = Path.Combine(sourceDirName, subdir.Name); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(); string time = DateTime.Now.ToString("HH:mm:ss"); Console.Write("[{0}]", time); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write(" --> "); Console.ForegroundColor = ConsoleColor.White; Console.Write("Creating directory "); Console.ForegroundColor = ConsoleColor.Green; Console.Write(temppath); Console.ForegroundColor = ConsoleColor.White; Console.Write("... "); Console.WriteLine(); System.IO.DirectoryInfo dirf = new System.IO.DirectoryInfo(temppathk); count = dirf.GetFiles().Length; fcount = 1; int rrUno = 0; int readUno = 1; int countdoku = 0; while (rrUno == 0) { if (File.Exists(locTemp + "from" + readUno + ".txt")) { string pathFUno = File.ReadAllText(locTemp + "from" + readUno + ".txt"); readUno++; System.IO.DirectoryInfo dirh = new System.IO.DirectoryInfo(pathFUno); countdoku = countdoku + Directory.GetFileSystemEntries(pathFUno, "*", SearchOption.AllDirectories).Length; } else { rrUno++; break; } } DirectoryCopy(subdir.FullName, temppath, copySubDirs, count, fcount, countdoku); } } }
public void ProgressSet(int value) { toolStripBottomProgressBar.Value = value; TaskbarProgress.SetValue(Handle, toolStripBottomProgressBar.Value, toolStripBottomProgressBar.Maximum); }
public void ProgressIncrement() { toolStripBottomProgressBar.Value++; TaskbarProgress.SetValue(Handle, toolStripBottomProgressBar.Value, toolStripBottomProgressBar.Maximum); }
public static void Init(Form sourceForm) { TaskbarProgress.SetMainWindow(sourceForm); }
internal void AfterClosed() { TaskbarProgress.Clear(); }
public static void EnableItermediate() { TaskbarProgress.SetState(TaskbarProgress.eStates.Indeterminate); }
private void SetProgressbarAppearancForIndeterminate() { toolStripProgressBar_Info.Style = ProgressBarStyle.Marquee; TaskbarProgress.SetState(this.Handle, TaskbarProgress.TaskbarStates.Indeterminate); }
public static void EnableProgress(uint range) { TaskbarProgress.SetState(TaskbarProgress.eStates.Normal); maxRange = range; }
public static void Disable() { TaskbarProgress.SetState(TaskbarProgress.eStates.Disabled); }
public static void Pause() { TaskbarProgress.SetState(TaskbarProgress.eStates.Paused); }
private void updateTaskbarProgress(int value, int maximum, TaskbarProgress.TaskbarStates state = TaskbarProgress.TaskbarStates.Normal) { if (Configuration.getBool("COMPATIBILITY")) return; try { TaskbarProgress.SetState(this.Handle, state); TaskbarProgress.SetValue(this.Handle, value, maximum); } catch (System.Runtime.InteropServices.InvalidComObjectException) { } }
static void Main() { string pathToRec = null; CleanUp(); if (!File.Exists("copy.txt")) { int re = 1; string kfc = "tasty"; string input; bool ynd = false; bool ynds = false; string output; string defOut = @"J:\G\Flm"; Console.WriteLine("Is this a move job? (Y/N)"); while (ynds == false) { ConsoleKeyInfo choice = Console.ReadKey(); switch (choice.Key) { case ConsoleKey.Y: ynds = true; move = true; File.AppendAllText(locTemp + "move.c", "y"); break; case ConsoleKey.N: ynds = true; if (File.Exists(locTemp + "move.c")) { File.Delete(locTemp + "move.c"); } move = false; break; default: break; } } while (kfc == "tasty") { Input: Console.Clear(); Console.WriteLine(); Console.WriteLine("Enter input folder nr {0}. Type 'done' if finished.", re); input = Console.ReadLine(); input = input.Replace("\"", ""); if (input != "done") { if (!Directory.Exists(input)) { if (!File.Exists(input)) { Console.WriteLine("That is not a file nor a directory. Please check for spelling errors and try again"); Thread.Sleep(2400); goto Input; } } } else if (input == "done") { break; } if (!File.Exists("copy.txt")) { File.AppendAllText("copy.txt", input); } else { File.AppendAllText("copy.txt", ";" + input); } Console.WriteLine(); if (ynd == false) { Output: Console.WriteLine("Enter output folder nr {0}.", re); output = Console.ReadLine(); output = output.Replace("\"", ""); defOut = output; if (!Directory.Exists(output)) { if (File.Exists(output)) { string morc = "copy"; if (move == true) { morc = "move"; } else if (move == false) { morc = "copy"; } Console.WriteLine("That is not a directory, but a file. Please specify a directory to copy to."); Console.WriteLine("You can rename your file yourself after the {0}. Don't try to do that here.", morc); Console.WriteLine(); Console.WriteLine("Press any key to continue.."); Console.ReadKey(); Console.Clear(); goto Output; } } File.AppendAllText("copy.txt", ";" + output); if (re == 1) { Console.WriteLine("Use {0} as output on all copies?", re); Console.WriteLine("Y/N"); ConsoleKeyInfo choice = Console.ReadKey(); switch (choice.Key) { case ConsoleKey.Y: ynd = true; break; case ConsoleKey.N: ynd = false; break; default: break; } } } else if (ynd == true) { File.AppendAllText("copy.txt", ";" + defOut); } re++; } } int read = 1; string pathFrom; string pathTo; char[] delimiterChars = { ';' }; string text = File.ReadAllText("copy.txt"); System.Console.WriteLine("Original text: '{0}'", text); string[] words = text.Split(delimiterChars); System.Console.WriteLine("{0} words in text:", words.Length); if (File.Exists("copy.txt")) { if (File.Exists(locTemp + "move.c")) { move = true; } string k; int i = 0; int o = 1; read = 1; foreach (string s in words) { k = s; Console.WriteLine(k); if ("k" == "k") { string pathT; string pathF; pathF = k; pathT = k; if (i == 0) { if (File.Exists(locTemp + "from" + o + ".txt")) { o++; } pathF = k; File.WriteAllText(locTemp + "from" + o + ".txt", k); i++; o++; } else if (i == 1) { if (File.Exists(locTemp + "to" + o + ".txt")) { o++; } File.WriteAllText(locTemp + "to" + o + ".txt", k); pathT = k; i--; o--; } Console.WriteLine(); //DirectoryCopy(pathF, pathT, true); } } } read = 1; Console.Clear(); Console.WriteLine(); int copies = words.Length / 2; int readUno = 1; int rrUno = 0; int count = 0; int countdoku = 0; int folders = 0; while (rrUno == 0) { if (File.Exists(locTemp + "from" + readUno + ".txt")) { folders = folders + 1; string pathFUno = File.ReadAllText(locTemp + "from" + readUno + ".txt"); readUno++; System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(pathFUno); count = dir.GetFiles("*.*", SearchOption.AllDirectories).Length; countdoku = countdoku + dir.GetFiles("*.*", SearchOption.AllDirectories).Length; folders = folders + dir.GetDirectories("*", SearchOption.AllDirectories).Length; } else { rrUno++; break; } } loc = countdoku; if (move == true) { Console.WriteLine("{0} files inside {1} folders will be moved", countdoku, folders); } else if (move == false) { Console.WriteLine("{0} files inside {1} folders will be copied", countdoku, folders); } read = 1; int rr = 0; IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); while ("l" == "l") { TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Indeterminate); if (File.Exists(locTemp + "from" + read + ".txt")) { string pathF = File.ReadAllText(locTemp + "from" + read + ".txt"); read++; rr++; string pathT = File.ReadAllText(locTemp + "to" + read + ".txt"); System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(pathF); count = dir.GetFiles().Length; Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Green; if (move == true) { Console.WriteLine("Moving job: {0}/{1} containing {2} files..", rr, copies, count); } else if (move == false) { Console.WriteLine("Copy job: {0}/{1} containing {2} files..", rr, copies, count); } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); string pathNew = new DirectoryInfo(pathF).Name; string pathRec = pathNew; pathToRec = pathT; pathNew = pathT + @"\" + pathNew; Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Input: " + pathF + ", Output: " + pathT); Console.ForegroundColor = ConsoleColor.White; //pathT = pathT + @"\Copy" + rr; //string pathNew = Path.GetFileName(Path.GetDirectoryName(pathF)); System.Diagnostics.Stopwatch ew = System.Diagnostics.Stopwatch.StartNew(); bool isFile = false; if (!Directory.Exists(pathF)) { if (File.Exists(pathF)) { isFile = true; Console.WriteLine("Not a directory, but a file: " + pathF); File.Copy(pathF, pathNew); } else { Console.WriteLine("{0} doesn't exist, skipping", pathF); isFile = true; } } if (isFile == false) { DirectoryCopy(pathF, pathNew, true, count, 1, countdoku); } DirectoryInfo filesg = new DirectoryInfo(pathF); int torrent = filesg.GetFiles("*", SearchOption.AllDirectories).Length; if (torrent == 0) { Directory.Delete(pathF, true); } ew.Stop(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; TimeSpan t = TimeSpan.FromSeconds(ew.Elapsed.TotalSeconds); string answer = string.Format("{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); Console.WriteLine(); if (move == true) { Console.Write("Move of {0} took ", pathRec); } else if (move == false) { Console.Write("Copy of {0} took ", pathRec); } Console.ForegroundColor = ConsoleColor.White; Console.Write("{0} seconds", answer); Console.WriteLine(); } else { if (pathToRec == null) { pathToRec = Directory.GetCurrentDirectory(); } RunUnrar(pathToRec); RunUnrar(pathToRec); CleanUp(); File.Delete("copy.txt"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(); Console.WriteLine("DONE!"); sw.Stop(); Console.Beep(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; TimeSpan t = TimeSpan.FromSeconds(sw.Elapsed.TotalSeconds); string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); Console.WriteLine(); if (move == true) { Console.Write("Move took a total of "); } else if (move == false) { Console.Write("Copy took a total of "); } Console.ForegroundColor = ConsoleColor.White; Console.Write("{0} seconds", answer); Console.WriteLine(); TaskbarProgress.SetValue(handle, 100, 100); TaskbarProgress.SetState(handle, TaskbarProgress.TaskbarStates.Indeterminate); Console.ReadKey(); break; } } /*while ("k" == "k") * { * pathFrom = Directory.GetCurrentDirectory(); * Console.WriteLine("Enter input location."); * pathFrom = Console.ReadLine(); * if (pathFrom == "") * { * pathFrom = Directory.GetCurrentDirectory(); * } * else if (pathFrom == null) * { * pathFrom = Directory.GetCurrentDirectory(); * } * * Console.WriteLine("Input location: " + pathFrom); * Console.WriteLine("Enter output location."); * pathTo = Console.ReadLine(); * if (pathTo == "") * { * pathTo = @"J:\G\Flm"; * } * else if (pathTo == null) * { * pathTo = @"J:\G\Flm"; * } * string LogText = string.Empty; * // Copy from the current directory, include subdirectories. * Directory.CreateDirectory(pathTo + @"\CopiedFiles"); * pathTo = pathTo + @"\CopiedFiles"; * Console.Clear(); * Console.WriteLine("Input location: " + pathFrom); * Console.WriteLine(); * Console.WriteLine("Output location: " + pathTo); * Console.WriteLine(); * Console.WriteLine("Copying... "); * Console.WriteLine(); * Console.ForegroundColor = ConsoleColor.Green; * * DirectoryCopy(pathFrom, pathTo, true); * * Console.WriteLine(); * Console.ForegroundColor = ConsoleColor.Green; * Console.Write("D"); * Console.ForegroundColor = ConsoleColor.Red; * Console.Write("o"); * Console.ForegroundColor = ConsoleColor.Yellow; * Console.Write("n"); * Console.ForegroundColor = ConsoleColor.Magenta; * Console.Write("e"); * Console.ForegroundColor = ConsoleColor.Cyan; * Console.Write("!"); * Console.WriteLine(); * }*/ }