public static void Uninstall(IProgressForm form) { // Uninstallation of Flash consists of the following steps: // 1. Delete all auto-updater tasks. // 2. Delete all Flash Player services. // 3. Delete all Flash Center services. // 4. Exit all browsers and other processes that may interfere with uninstallation. // 5. Remove all Flash Player references from the registry. // 6. Remove Flash Center files from the file system. // 7. Remove Flash Player files from the file system. form.UpdateProgressLabel("Stopping Flash auto-updater task...", true); DeleteTask("Adobe Flash Player Updater"); form.UpdateProgressLabel("Stopping Flash auto-updater service...", true); DeleteService("AdobeFlashPlayerUpdateSvc"); form.UpdateProgressLabel("Stopping Flash Center services...", true); DeleteService("Flash Helper Service"); form.TickProgress(); DeleteService("FlashCenterService"); form.UpdateProgressLabel("Exiting all browsers...", true); StopProcesses(); form.UpdateProgressLabel("Cleaning up registry...", true); UninstallRegistry(); form.UpdateProgressLabel("Removing Flash Center...", true); DeleteFlashCenter(); form.UpdateProgressLabel("Removing Flash Player...", true); DeleteFlashPlayer(); }
private void ShowProgressForm() { //DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Darkroom"); //if (m_ModernStyle) //{ // m_ProgressForm = new ProgressFormModern(); //} //else //{ m_ProgressForm = new ProgressForm(); // } m_ProgressForm.Icon = m_Icon; m_ProgressForm.StartPosition = FormStartPosition.CenterScreen; m_Progress = m_ProgressForm as IProgressForm; if (!String.IsNullOrEmpty(m_Title)) { m_ProgressForm.Text = m_Title; } if (!String.IsNullOrEmpty(m_StatusText)) { m_Progress.StatusText = m_StatusText; } m_ProgressForm.Load += new EventHandler(m_ProgressForm_Load); m_ProgressForm.ShowDialog(); m_ProgressForm.Close(); }
private void ShowProgressForm() { if (m_ModernStyle) { m_ProgressForm = new ProgressFormModern(); } else { m_ProgressForm = new ProgressForm(); } m_ProgressForm.Icon = m_Icon; m_ProgressForm.StartPosition = FormStartPosition.CenterScreen; m_Progress = m_ProgressForm as IProgressForm; if (!String.IsNullOrEmpty(m_Title)) { m_ProgressForm.Text = m_Title; } if (!String.IsNullOrEmpty(m_StatusText)) { m_Progress.StatusText = m_StatusText; } m_ProgressForm.Load += new EventHandler(m_ProgressForm_Load); m_ProgressForm.ShowDialog(); m_ProgressForm.Close(); }
/// <summary> /// Completedイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (_processForm.Visible_IProgress) { _processForm.Close_IProgress(); } _backgroundWorker.Dispose(); _backgroundWorker = null; _work = null; objectParameter = null; _processForm = null; }
/// <summary> /// 初期化 /// </summary> /// <param name="ProgressForm">Progressダイアログ</param> /// <param name="work">実行方法</param> /// <param name="o">パラメーター</param> /// <returns></returns> public bool InitBackgroundWorker(IProgressForm ProgressForm, Func <object, int> work, object o, Action cancel) { if (null != _backgroundWorker) { return(false); } _workResult = (int)EResult.Failed; _work = work; _cancel = cancel; objectParameter = o; _processForm = ProgressForm; _processForm.StopEvent_IProgress += Stop; _processForm.StartTask_IProgress += StartTask; _backgroundWorker = new BackgroundWorker(); _backgroundWorker.WorkerReportsProgress = true; _backgroundWorker.WorkerSupportsCancellation = true; _backgroundWorker.DoWork += BackgroundWorker_DoWork; _backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; _backgroundWorker.ProgressChanged += BackgroundWorker_ProgressChanged; return(true); }
// ј’“”Ќ√ќ¬џ… метод передачи файла через BackgroundWorker public void FileTransferInBackground(DoWorkEventArgs args, BackgroundWorker bw, string sourceFileName, string destinationFileName) { Stream source = null; Stream destination = null; try { source = File.Open(sourceFileName, FileMode.Open, FileAccess.Read); destination = File.Open(destinationFileName, FileMode.Create); BinaryWriter writer = new BinaryWriter(destination); BinaryReader reader = new BinaryReader(source); byte[] buffer = new byte[1024 * 1024]; int count = 0; long totalBytes = source.Length; long readBytes = 0; int progress = 0; while ((count = reader.Read(buffer, 0, buffer.Length)) > 0) { if (bw.CancellationPending == true) { args.Cancel = true; break; } writer.Write(buffer, 0, count); readBytes += count; //if (totalBytes > 0) // progress = (int)(readBytes * 100 / totalBytes); //bw.ReportProgress(progress); if (totalBytes > 0) { int p = (int)((double)readBytes * 100 / totalBytes); if (p > progress) { progress = p; bw.ReportProgress(progress); } } } } catch (Exception ex) { throw new UserFriendlyException(ex); } finally { if (source != null) { source.Close(); source = null; } if (destination != null) { destination.Close(); destination = null; } } }
private void UploadFile() { worker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true, }; worker.DoWork += new DoWorkEventHandler(UploadFileDoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UploadFileCompleted); worker.ProgressChanged += new ProgressChangedEventHandler(TransferFileProgressChanged); progress = new ProgressForm(); progress.SetTitle = CaptionHelper.GetLocalizedText("FileAttachments", "UploadingFile"); progress.CancelButtonClick += new EventHandler<EventArgs>(TransferFileCancelButtonClick); worker.RunWorkerAsync(); progress.Show(); }
private void UploadExaminationFile() { worker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true, }; worker.DoWork += new DoWorkEventHandler(UploadExaminationFileDoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UploadExaminationCompleted); worker.ProgressChanged += new ProgressChangedEventHandler(UploadExaminationProgressChanged); progress = new ProgressForm(); progress.SetTitle = CaptionHelper.GetLocalizedText("CustomFomrsMessages", "ImportExamProgress"); progress.CancelButtonClick += new EventHandler<EventArgs>(UploadExaminationCancelButtonClick); worker.RunWorkerAsync(); progress.Show(); }
public static void Install(IProgressForm form, InstallFlags flags) { if (flags.IsNoneSet()) { // No packages should be installed. return; } string flash32Path = SystemInfo.GetFlash32Path(); string flash64Path = SystemInfo.GetFlash64Path(); string system32Path = SystemInfo.GetSystem32Path(); string flashProgram32Path = SystemInfo.GetProgramFlash32Path(); List <string> registryToApply = new List <string>() { Properties.Resources.installGeneral }; if (Environment.Is64BitOperatingSystem) { registryToApply.Add(Properties.Resources.installGeneral64); } form.UpdateProgressLabel("Installing Flash Player utilities...", true); ExtractArchive("flash_gen_32.zip", system32Path); form.UpdateProgressLabel("Extracting uninstaller..", true); ExtractArchive("flash_uninstaller.zip", flashProgram32Path); if (flags.IsSet(InstallFlags.PEPPER)) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Chrome...", true); ExtractArchive("flash_pp_32.zip", flash32Path); registryToApply.Add(Properties.Resources.installPP); } if (flags.IsSet(InstallFlags.NETSCAPE)) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Firefox...", true); ExtractArchive("flash_np_32.zip", flash32Path); registryToApply.Add(Properties.Resources.installNP); } if (flags.IsSet(InstallFlags.ACTIVEX)) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Internet Explorer...", true); ExtractArchive("flash_ocx_32.zip", flash32Path); } if (flags.IsSet(InstallFlags.PLAYER)) { form.UpdateProgressLabel("Installing 32-bit Standalone Flash Player...", true); ExtractArchive("flash_player_32.zip", flashProgram32Path); string name = "Flash Player"; string description = "Standalone Flash Player " + UpdateChecker.GetFlashVersion(); string executable = Path.Combine(flashProgram32Path, UpdateChecker.GetFlashPlayerExecutable()); if (UpdateChecker.IsDebug()) { name += " (Debug)"; description += " (Debug)"; } if (flags.IsSet(InstallFlags.PLAYER_START_MENU)) { CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), executable, name, description); } if (flags.IsSet(InstallFlags.PLAYER_DESKTOP)) { CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), executable, name, description); } } if (Environment.Is64BitOperatingSystem) { if (flags.IsSet(InstallFlags.PEPPER)) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Chrome...", true); ExtractArchive("flash_pp_64.zip", flash64Path); registryToApply.Add(Properties.Resources.installPP64); } if (flags.IsSet(InstallFlags.NETSCAPE)) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Firefox...", true); ExtractArchive("flash_np_64.zip", flash64Path); registryToApply.Add(Properties.Resources.installNP64); } if (flags.IsSet(InstallFlags.ACTIVEX)) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Internet Explorer...", true); ExtractArchive("flash_ocx_64.zip", flash64Path); } } form.UpdateProgressLabel("Applying registry changes...", true); RegistryManager.ApplyRegistry(registryToApply); if (flags.IsSet(InstallFlags.ACTIVEX)) { form.UpdateProgressLabel("Activating 32-bit Flash Player for Internet Explorer...", true); RegisterActiveX(Path.Combine(flash32Path, string.Format("Flash32_{0}.ocx", SystemInfo.GetVersionPath()))); if (Environment.Is64BitOperatingSystem) { form.UpdateProgressLabel("Activating 64-bit Flash Player for Internet Explorer...", true); RegisterActiveX(Path.Combine(flash64Path, string.Format("Flash64_{0}.ocx", SystemInfo.GetVersionPath()))); } } }
private void worker_DoWork(object sender, DoWorkEventArgs e) { object[] args = e.Argument as object[]; BackgroundWorker bw = sender as BackgroundWorker; string targetFileName = args[0] as String; string tempFileName = String.Empty;//args[1]; Dictionary<string, string> dictionary = args[1] as Dictionary<string, string>; bool result = true; StreamReader reader = null; StreamWriter writer = null; try { tempFileName = Path.Combine(Path.GetDirectoryName(targetFileName), Path.GetFileNameWithoutExtension(targetFileName) + ".tmp"); File.Copy(targetFileName, tempFileName, true);// создаем копию целевой файла reader = new StreamReader(File.Open(targetFileName, FileMode.Open)); writer = new StreamWriter(File.Open(tempFileName, FileMode.OpenOrCreate)); int progress = 0; long position = 0; long total = reader.BaseStream.Length; //int linesCount = 0; while (reader.EndOfStream == false) { if (bw.CancellationPending == true) { e.Cancel = true; result = false; break; } StringBuilder line = new StringBuilder(reader.ReadLine()); position += line.Length; //if (line.ToString().Contains('%') == true) if (Contains(line, '%') == true) { foreach (string code in dictionary.Keys) line.Replace(code, dictionary[code]); } writer.WriteLine(line); int p = (int)((double)position * 100 / total); if (p > progress) { progress = p; bw.ReportProgress(progress); } } } catch (Exception ex) { result = false; e.Result = new BWResult { Error = true, Result = ex.Message }; } finally { if (writer != null) writer.Close(); if (reader != null) reader.Close(); } // если не было аборта, то временный файл заменяет текущий файл if (File.Exists(targetFileName) == true && File.Exists(tempFileName) == true && (result == true)) { try { File.Replace(tempFileName, targetFileName, null); e.Result = new BWResult { Error = false, Result = targetFileName }; } catch (Exception) { result = false; } } // в любом случае удаляем временный файл if (File.Exists(tempFileName) == true) { try { File.Delete(tempFileName); } catch (Exception) { } } }
private void FillRtfTemplate(string conclutionFileName, Dictionary<string, string> dictionary) { worker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); progress = new ProgressForm(); progress.CancelButtonClick += new EventHandler<EventArgs>(this.CancelButtonClick); progress.SetTitle = CaptionHelper.GetLocalizedText("Captions", "FillRtfTemplateProgressFormTitle"); worker.RunWorkerAsync(new object[] { conclutionFileName, dictionary }); progress.Show(); }
public static void Install(IProgressForm form, bool installPP, bool installNP, bool installOCX) { if (!installPP && !installNP && !installOCX) { // No packages should be installed. return; } string flash32Path = SystemInfo.GetFlash32Path(); string flash64Path = SystemInfo.GetFlash64Path(); string system32Path = SystemInfo.GetSystem32Path(); List <string> registryToApply = new List <string>() { Properties.Resources.installGeneral }; if (Environment.Is64BitOperatingSystem) { registryToApply.Add(Properties.Resources.installGeneral64); } form.UpdateProgressLabel("Installing Flash Player utilities...", true); ExtractArchive("flash_gen_32.zip", system32Path); form.UpdateProgressLabel("Extracting uninstaller..", true); ExtractArchive("flash_uninstaller.zip", flash32Path); if (installPP) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Chrome...", true); ExtractArchive("flash_pp_32.zip", flash32Path); registryToApply.Add(Properties.Resources.installPP); } if (installNP) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Firefox...", true); ExtractArchive("flash_np_32.zip", flash32Path); registryToApply.Add(Properties.Resources.installNP); } if (installOCX) { form.UpdateProgressLabel("Installing 32-bit Flash Player for Internet Explorer...", true); ExtractArchive("flash_ocx_32.zip", flash32Path); registryToApply.Add(Properties.Resources.installOCX); } if (Environment.Is64BitOperatingSystem) { if (installPP) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Chrome...", true); ExtractArchive("flash_pp_64.zip", flash64Path); registryToApply.Add(Properties.Resources.installPP64); } if (installNP) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Firefox...", true); ExtractArchive("flash_np_64.zip", flash64Path); registryToApply.Add(Properties.Resources.installNP64); } if (installOCX) { form.UpdateProgressLabel("Installing 64-bit Flash Player for Internet Explorer...", true); ExtractArchive("flash_ocx_64.zip", flash64Path); registryToApply.Add(Properties.Resources.installOCX64); } } form.UpdateProgressLabel("Applying registry changes...", true); RegistryManager.ApplyRegistry(registryToApply); if (installOCX) { form.UpdateProgressLabel("Activating 32-bit Flash Player for Internet Explorer...", true); RegisterActiveX(Path.Combine(flash32Path, string.Format("Flash_{0}.ocx", SystemInfo.GetVersionPath()))); if (Environment.Is64BitOperatingSystem) { form.UpdateProgressLabel("Activating 64-bit Flash Player for Internet Explorer...", true); RegisterActiveX(Path.Combine(flash64Path, string.Format("Flash_{0}.ocx", SystemInfo.GetVersionPath()))); } } }