public EcasContext(EcasTriggerSystem coll, EcasTrigger trigger, EcasEvent e, EcasPropertyDictionary props) { if(coll == null) throw new ArgumentNullException("coll"); if(trigger == null) throw new ArgumentNullException("trigger"); if(e == null) throw new ArgumentNullException("e"); if(props == null) throw new ArgumentNullException("props"); m_coll = coll; m_trigger = trigger; m_eOccured = e; m_props = props; }
private void TriggerSystem_RaisingEvent(object sender, EcasRaisingEventArgs e) { EcasPropertyDictionary dict = e.Properties; if (dict == null) { Debug.Assert(false); return; } string command = dict.Get <String>(EcasProperty.CommandID); if (command != null && command.Equals(Util.ToolbarConnectBtnId)) { ConnectRDPtoKeePassEntry(false, true); } }
private void TriggerSystem_RaisingEvent(object sender, EcasRaisingEventArgs e) { //Check if the event is our toggle button and toggle the highlights on or off accordingly. EcasPropertyDictionary dict = e.Properties; if (dict == null) { Debug.Assert(false); return; } string command = e.Properties.Get <string>(EcasProperty.CommandID); if (command != null && command.Equals(ToggleBtnCommand)) { _highlightsOn = !_highlightsOn; //Save the scrollbar state so we can restore it. ListView lv = (_host.MainWindow.Controls.Find( "m_lvEntries", true)[0] as ListView); if (lv == null) { Debug.Assert(false); return; } int topIndex = lv.TopItem.Index; if (!_highlightsOn) { _host.MainWindow.RefreshEntriesList(); } _host.MainWindow.UpdateUI(false, null, false, null, true, null, false); //Reset scroll position of the list. lv.TopItem = lv.Items[topIndex]; } }
public EcasRaisingEventArgs(EcasEvent evt, EcasPropertyDictionary props) { m_evt = evt; m_props = props; }
// Public for plugins public void SaveDatabaseAs(PwDatabase pdToSave, IOConnectionInfo iocTo, bool bOnline, object sender, bool bCopy) { PwDatabase pd = (pdToSave ?? m_docMgr.ActiveDatabase); if(!pd.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; Guid eventGuid = Guid.NewGuid(); if(this.FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(true, bCopy, pd, eventGuid); this.FileSaving(sender, args); if(args.Cancel) return; } DialogResult dr; IOConnectionInfo ioc = iocTo; if((ioc != null) && (ioc.Path.Length > 0)) { dr = DialogResult.OK; // Caller (plugin) specified target file } else if(bOnline) { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(true, pd.IOConnectionInfo.CloneDeep(), true, true); dr = iocf.ShowDialog(); ioc = iocf.IOConnectionInfo; UIUtil.DestroyForm(iocf); } else { SaveFileDialogEx sfdDb = UIUtil.CreateSaveFileDialog(KPRes.SaveDatabase, UrlUtil.GetFileName(pd.IOConnectionInfo.Path), UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt, KPRes.KdbxFiles, true), 1, AppDefs.FileExtension.FileExt, AppDefs.FileDialogContext.Database); GlobalWindowManager.AddDialog(sfdDb.FileDialog); dr = sfdDb.ShowDialog(); GlobalWindowManager.RemoveDialog(sfdDb.FileDialog); if(dr == DialogResult.OK) ioc = IOConnectionInfo.FromPath(sfdDb.FileName); } if(dr == DialogResult.OK) { EcasPropertyDictionary dProps = new EcasPropertyDictionary(); dProps.Set(EcasProperty.IOConnectionInfo, ioc); dProps.Set(EcasProperty.Database, pd); Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavingDatabaseFile, dProps); UIBlockInteraction(true); ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); ShutdownBlocker sdb = new ShutdownBlocker(this.Handle, KPRes.SavingDatabase); bool bSuccess = true; try { PreSavingEx(pd, ioc); pd.SaveAs(ioc, !bCopy, swLogger); PostSavingEx(!bCopy, pd, ioc, swLogger); } catch(Exception exSaveAs) { MessageService.ShowSaveWarning(ioc, exSaveAs, true); bSuccess = false; } sdb.Dispose(); swLogger.EndLogging(); // Immediately after the UIBlockInteraction call the form might // be closed and UpdateUIState might crash, if the order of the // two methods is swapped; so first update state, then unblock UpdateUIState(false); UIBlockInteraction(false); // Calls Application.DoEvents() if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } if(bSuccess) Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavedDatabaseFile, dProps); } }