public bool SetText(string strNewText, LogStatusType lsType) { if (strNewText == null) { return(true); } if (lsType != LogStatusType.Info) { return(true); } if (m_bUseThread && (m_th == null)) { ThreadStart ts = new ThreadStart(this.GuiThread); m_th = new Thread(ts); m_th.Start(); } if (!m_bUseThread && (m_dlgModal == null)) { m_dlgModal = ConstructStatusDialog(); } lock (m_objSync) { m_strProgress = strNewText; } return((m_dlgModal != null) ? m_dlgModal.SetText(strNewText, lsType) : true); }
public static void Replace(PwDatabase pd, XmlReplaceOptions opt) { if (pd == null) { Debug.Assert(false); return; } if (opt == null) { Debug.Assert(false); return; } StatusProgressForm dlg = null; try { if ((opt.Flags & XmlReplaceFlags.StatusUI) != XmlReplaceFlags.None) { dlg = StatusProgressForm.ConstructEx(KPRes.XmlReplace, true, false, opt.ParentForm, KPRes.XmlReplace + "..."); } PerformXmlReplace(pd, opt, dlg); } finally { if (dlg != null) { StatusProgressForm.DestroyEx(dlg); } } }
public void EndLogging() { if(m_dlg == null) { Debug.Assert(false); return; } m_dlg.EndLogging(); m_dlg.Close(); UIUtil.DestroyForm(m_dlg); m_dlg = null; }
public StatusProgressFormWrapper(Form fParent, string strTitle, bool bCanCancel, bool bMarqueeProgress) { m_dlg = new StatusProgressForm(); m_dlg.InitEx(strTitle, bCanCancel, bMarqueeProgress, fParent); if(fParent != null) m_dlg.Show(fParent); else m_dlg.Show(); }
/// <summary> /// Downloads some favicons. /// </summary> /// <param name="entries">The entries.</param> private void downloadSomeFavicons(KeePassLib.Collections.PwObjectList <PwEntry> entries) { StatusProgressForm progressForm = new StatusProgressForm(); progressForm.InitEx("Downloading Favicons", true, false, m_host.MainWindow); progressForm.Show(); progressForm.SetProgress(0); float progress = 0; float outputLength = (float)entries.UCount; int downloadsCompleted = 0; string errorMessage = ""; int errorCount = 0; foreach (PwEntry pwe in entries) { string message = ""; progressForm.SetText("Title: " + pwe.Strings.ReadSafe("Title") + "; User Name: " + pwe.Strings.ReadSafe("UserName"), LogStatusType.Info); downloadOneFavicon(pwe, ref message); if (message != "") { errorMessage = "For an entry with URL '" + pwe.Strings.ReadSafe("URL") + "': " + message; errorCount++; } downloadsCompleted++; progress = (downloadsCompleted / outputLength) * 100; progressForm.SetProgress((uint)Math.Floor(progress)); System.Threading.Thread.Sleep(100); if (progressForm.UserCancelled) { break; } } progressForm.Hide(); progressForm.Close(); if (errorMessage != "") { if (errorCount == 1) { MessageBox.Show(errorMessage, "Download error"); } else { MessageBox.Show(errorCount + " errors occurred. The last error message is shown here. To see the other messages, select a smaller group of entries and use the right click menu to start the download.\n" + errorMessage, "Download errors"); } } m_host.MainWindow.UpdateUI(false, null, false, null, true, null, true); m_host.MainWindow.UpdateTrayIcon(); }
private static StatusProgressForm BeginStatusDialog(string strText) { StatusProgressForm dlg = new StatusProgressForm(); dlg.InitEx(PwDefs.ShortProductName, false, true, null); dlg.Show(); dlg.StartLogging(strText ?? string.Empty, false); return(dlg); }
public void EndLogging() { lock (m_objSync) { m_bTerminate = true; } m_th = null; if (m_dlgModal != null) { DestroyStatusDialog(m_dlgModal); m_dlgModal = null; } }
private static void EndStatusDialog(StatusProgressForm dlg) { if (dlg == null) { Debug.Assert(false); return; } dlg.EndLogging(); dlg.Close(); UIUtil.DestroyForm(dlg); }
private async Task CheckBreach(CheckTypeEnum breachType) { if (!pluginHost.Database.IsOpen) { MessageBox.Show("You must first open a database", Resources.MessageTitle); return; } var dialog = new CheckerPrompt(breachType, breachType != CheckTypeEnum.Password); if (dialog.ShowDialog() == DialogResult.OK) { progressForm = new StatusProgressForm(); var progressIndicator = new Progress <ProgressItem>(ReportProgress); progressForm.InitEx("Checking Breaches", false, breachType == CheckTypeEnum.SiteDomain, pluginHost.MainWindow); progressForm.Show(); progressForm.SetProgress(0); List <BreachedEntry> result = new List <BreachedEntry>(); if (dialog.CheckAllBreaches) { progressForm.Tag = new ProgressHelper(Enum.GetValues(typeof(BreachEnum)).Length); foreach (var breach in Enum.GetValues(typeof(BreachEnum))) { var foundBreaches = await CheckBreaches(supportedBreachCheckers[(BreachEnum)breach](client, pluginHost), dialog.ExpireEntries, dialog.OnlyCheckOldEntries, dialog.IgnoreDeletedEntries, progressIndicator); result.AddRange(foundBreaches); ((ProgressHelper)progressForm.Tag).CurrentBreach++; } } else { progressForm.Tag = new ProgressHelper(1); var foundBreaches = await CheckBreaches(supportedBreachCheckers[dialog.SelectedBreach](client, pluginHost), dialog.ExpireEntries, dialog.OnlyCheckOldEntries, dialog.IgnoreDeletedEntries, progressIndicator); result.AddRange(foundBreaches); } progressForm.Close(); if (!result.Any()) { MessageBox.Show("No breached entries found.", Resources.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var breachedEntriesDialog = new BreachedEntriesDialog(pluginHost); breachedEntriesDialog.AddBreaches(result); breachedEntriesDialog.ShowDialog(); } } pluginHost.MainWindow.Show(); }
private void DestroyStatusDialog(StatusProgressForm dlg) { if (dlg != null) { MainForm mfOwner = ((m_fOwner != null) ? (m_fOwner as MainForm) : null); if ((m_bUseThread == false) && (mfOwner != null)) { // mfOwner.RedirectActivationPop(); mfOwner.UIBlockInteraction(false); } StatusProgressForm.DestroyEx(dlg); // Conflict with 3116455 // if(mfOwner != null) mfOwner.Activate(); // Prevent disappearing } }
private StatusProgressForm ConstructStatusDialog() { StatusProgressForm dlg = StatusProgressForm.ConstructEx( m_strTitle, false, true, (m_bUseThread ? null : m_fOwner), null); dlg.SetProgress(m_uProgress); MainForm mfOwner = ((m_fOwner != null) ? (m_fOwner as MainForm) : null); if ((m_bUseThread == false) && (mfOwner != null)) { // mfOwner.RedirectActivationPush(dlg); mfOwner.UIBlockInteraction(true); } return(dlg); }
private void GuiThread() { uint uProgress = InitialProgress; string strProgress = InitialStatus; StatusProgressForm dlg = null; while (true) { lock (m_objSync) { if (m_bTerminate) { break; } if (m_uProgress != uProgress) { uProgress = m_uProgress; if (dlg != null) { dlg.SetProgress(uProgress); } } if (m_strProgress != strProgress) { strProgress = m_strProgress; if (dlg == null) { dlg = ConstructStatusDialog(); } dlg.SetText(strProgress, LogStatusType.Info); } } Application.DoEvents(); } DestroyStatusDialog(dlg); }
private void DestroyStatusDialog(StatusProgressForm dlg) { if (dlg != null) { MainForm mfOwner = ((m_fOwner != null) ? (m_fOwner as MainForm) : null); if ((m_bUseThread == false) && (mfOwner != null)) { mfOwner.RedirectActivationPop(); mfOwner.UIBlockInteraction(false); } dlg.EndLogging(); dlg.Close(); dlg.Dispose(); if (mfOwner != null) { mfOwner.Activate(); // Prevent disappearing } } }
private async Task CheckBreach(CheckTypeEnum breachType, PwGroup group) { var dialog = new CheckerPrompt(breachType, breachType != CheckTypeEnum.Password); if (dialog.ShowDialog() == DialogResult.OK) { progressForm = new StatusProgressForm(); var progressIndicator = new Progress <ProgressItem>(ReportProgress); progressForm.InitEx("Checking Breaches", true, breachType == CheckTypeEnum.SiteDomain, pluginHost.MainWindow); progressForm.Show(); progressForm.SetProgress(0); List <BreachedEntry> result = new List <BreachedEntry>(); try { if (dialog.CheckAllBreaches) { var breaches = Enum.GetValues(typeof(BreachEnum)).Cast <BreachEnum>().Where(b => b.GetAttribute <CheckerTypeAttribute>().Type == breachType); progressForm.Tag = new ProgressHelper(breaches.Count()); foreach (var breach in breaches) { var foundBreaches = await CheckBreaches(supportedBreachCheckers[(BreachEnum)breach](client, pluginHost), group, dialog.ExpireEntries, dialog.OnlyCheckOldEntries, dialog.IgnoreDeletedEntries, dialog.IgnoreExpiredEntries, progressIndicator, () => progressForm.ContinueWork()); result.AddRange(foundBreaches); ((ProgressHelper)progressForm.Tag).CurrentBreach++; } } else { progressForm.Tag = new ProgressHelper(1); var foundBreaches = await CheckBreaches(supportedBreachCheckers[dialog.SelectedBreach](client, pluginHost), group, dialog.ExpireEntries, dialog.OnlyCheckOldEntries, dialog.IgnoreDeletedEntries, dialog.IgnoreExpiredEntries, progressIndicator, () => progressForm.ContinueWork()); result.AddRange(foundBreaches); } } catch (Exception ex) { result = null; MessageBox.Show(pluginHost.MainWindow, ex.Message, Resources.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { progressForm.Close(); } if (result != null) { if (!result.Any()) { MessageBox.Show(pluginHost.MainWindow, "No breached entries found.", Resources.MessageTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var breachedEntriesDialog = new BreachedEntriesDialog(pluginHost); breachedEntriesDialog.AddBreaches(result); breachedEntriesDialog.ShowDialog(); } } } pluginHost.MainWindow.Show(); }