private void OnBtnOK(object sender, EventArgs e) { EnableControlsEx(); Debug.Assert(m_btnOK.Enabled); if (!m_btnOK.Enabled) { return; } string strNewSeq = (m_rbSeqCustom.Checked ? m_rbKeySeq.Text : string.Empty); if (!m_bEditSequenceOnly) { AutoTypeAssociation atAssoc; if (m_iAssocIndex >= 0) { atAssoc = m_atConfig.GetAt(m_iAssocIndex); } else { atAssoc = new AutoTypeAssociation(); m_atConfig.Add(atAssoc); } atAssoc.WindowName = m_cmbWindow.Text; atAssoc.Sequence = strNewSeq; } else { m_atConfig.DefaultSequence = strNewSeq; } }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_atConfig != null); if (m_atConfig == null) { throw new InvalidOperationException(); } Debug.Assert(m_vStringDict != null); if (m_vStringDict == null) { throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); m_ctxKeySeq.Attach(m_rbKeySeq, this); m_ctxKeyCodes.Attach(m_rtbPlaceholders, this); if (!m_bEditSequenceOnly) { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureAutoTypeItem, KPRes.ConfigureAutoTypeItemDesc); } else // Edit keystrokes only { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureKeystrokeSeq, KPRes.ConfigureKeystrokeSeqDesc); } this.Icon = Properties.Resources.KeePass; // FontUtil.AssignDefaultBold(m_lblTargetWindow); // FontUtil.AssignDefaultBold(m_rbSeqDefault); // FontUtil.AssignDefaultBold(m_rbSeqCustom); UIUtil.EnableAutoCompletion(m_cmbWindow, false); // m_clrOriginalForeground = m_lblOpenHint.ForeColor; // m_clrOriginalBackground = m_cmbWindow.BackColor; // m_strOriginalWindowHint = m_lblTargetWindowInfo.Text; InitPlaceholdersBox(); string strInitSeq = m_atConfig.DefaultSequence; if (m_iAssocIndex >= 0) { AutoTypeAssociation asInit = m_atConfig.GetAt(m_iAssocIndex); m_cmbWindow.Text = asInit.WindowName; if (!m_bEditSequenceOnly) { strInitSeq = asInit.Sequence; } } else if (m_bEditSequenceOnly) { m_cmbWindow.Text = "(" + KPRes.Default + ")"; } else { strInitSeq = string.Empty; } bool bSetDefault = false; m_bBlockUpdates = true; if (strInitSeq.Length > 0) { m_rbSeqCustom.Checked = true; } else { m_rbSeqDefault.Checked = true; bSetDefault = true; } m_bBlockUpdates = false; if (bSetDefault) { m_rbKeySeq.Text = m_strDefaultSeq; } else { m_rbKeySeq.Text = strInitSeq; } try { if (NativeLib.IsUnix()) { PopulateWindowsListUnix(); } else { PopulateWindowsListWin(); } } catch (Exception) { Debug.Assert(false); } EnableControlsEx(); }
private void OnBtnOK(object sender, EventArgs e) { EnableControlsEx(); Debug.Assert(m_btnOK.Enabled); if(!m_btnOK.Enabled) return; string strNewSeq = (m_rbSeqCustom.Checked ? m_rbKeySeq.Text : string.Empty); if(!m_bEditSequenceOnly) { AutoTypeAssociation atAssoc; if(m_iAssocIndex >= 0) atAssoc = m_atConfig.GetAt(m_iAssocIndex); else { atAssoc = new AutoTypeAssociation(); m_atConfig.Add(atAssoc); } atAssoc.WindowName = m_cmbWindow.Text; atAssoc.Sequence = strNewSeq; } else m_atConfig.DefaultSequence = strNewSeq; }
private KdbContext EndXmlElement(KdbContext ctx, XmlReader xr) { Debug.Assert(xr.NodeType == XmlNodeType.EndElement); if ((ctx == KdbContext.KeePassFile) && (xr.Name == ElemDocNode)) { return(KdbContext.Null); } else if ((ctx == KdbContext.Meta) && (xr.Name == ElemMeta)) { return(KdbContext.KeePassFile); } else if ((ctx == KdbContext.Root) && (xr.Name == ElemRoot)) { return(KdbContext.KeePassFile); } else if ((ctx == KdbContext.MemoryProtection) && (xr.Name == ElemMemoryProt)) { return(KdbContext.Meta); } else if ((ctx == KdbContext.CustomIcons) && (xr.Name == ElemCustomIcons)) { return(KdbContext.Meta); } else if ((ctx == KdbContext.CustomIcon) && (xr.Name == ElemCustomIconItem)) { if (!m_uuidCustomIconID.Equals(PwUuid.Zero) && (m_pbCustomIconData != null)) { m_pwDatabase.CustomIcons.Add(new PwCustomIcon( m_uuidCustomIconID, m_pbCustomIconData)); } else { Debug.Assert(false); } m_uuidCustomIconID = PwUuid.Zero; m_pbCustomIconData = null; return(KdbContext.CustomIcons); } else if ((ctx == KdbContext.Binaries) && (xr.Name == ElemBinaries)) { return(KdbContext.Meta); } else if ((ctx == KdbContext.CustomData) && (xr.Name == ElemCustomData)) { return(KdbContext.Meta); } else if ((ctx == KdbContext.CustomDataItem) && (xr.Name == ElemStringDictExItem)) { if ((m_strCustomDataKey != null) && (m_strCustomDataValue != null)) { m_pwDatabase.CustomData.Set(m_strCustomDataKey, m_strCustomDataValue); } else { Debug.Assert(false); } m_strCustomDataKey = null; m_strCustomDataValue = null; return(KdbContext.CustomData); } else if ((ctx == KdbContext.Group) && (xr.Name == ElemGroup)) { if (PwUuid.Zero.Equals(m_ctxGroup.Uuid)) { m_ctxGroup.Uuid = new PwUuid(true); // No assert (import) } m_ctxGroups.Pop(); if (m_ctxGroups.Count == 0) { m_ctxGroup = null; return(KdbContext.Root); } else { m_ctxGroup = m_ctxGroups.Peek(); return(KdbContext.Group); } } else if ((ctx == KdbContext.GroupTimes) && (xr.Name == ElemTimes)) { return(KdbContext.Group); } else if ((ctx == KdbContext.GroupCustomData) && (xr.Name == ElemCustomData)) { return(KdbContext.Group); } else if ((ctx == KdbContext.GroupCustomDataItem) && (xr.Name == ElemStringDictExItem)) { if ((m_strGroupCustomDataKey != null) && (m_strGroupCustomDataValue != null)) { m_ctxGroup.CustomData.Set(m_strGroupCustomDataKey, m_strGroupCustomDataValue); } else { Debug.Assert(false); } m_strGroupCustomDataKey = null; m_strGroupCustomDataValue = null; return(KdbContext.GroupCustomData); } else if ((ctx == KdbContext.Entry) && (xr.Name == ElemEntry)) { // Create new UUID if absent if (PwUuid.Zero.Equals(m_ctxEntry.Uuid)) { m_ctxEntry.Uuid = new PwUuid(true); // No assert (import) } if (m_bEntryInHistory) { m_ctxEntry = m_ctxHistoryBase; return(KdbContext.EntryHistory); } return(KdbContext.Group); } else if ((ctx == KdbContext.EntryTimes) && (xr.Name == ElemTimes)) { return(KdbContext.Entry); } else if ((ctx == KdbContext.EntryString) && (xr.Name == ElemString)) { m_ctxEntry.Strings.Set(m_ctxStringName, m_ctxStringValue); m_ctxStringName = null; m_ctxStringValue = null; return(KdbContext.Entry); } else if ((ctx == KdbContext.EntryBinary) && (xr.Name == ElemBinary)) { if (string.IsNullOrEmpty(m_strDetachBins)) { m_ctxEntry.Binaries.Set(m_ctxBinaryName, m_ctxBinaryValue); } else { SaveBinary(m_ctxBinaryName, m_ctxBinaryValue, m_strDetachBins); m_ctxBinaryValue = null; GC.Collect(); } m_ctxBinaryName = null; m_ctxBinaryValue = null; return(KdbContext.Entry); } else if ((ctx == KdbContext.EntryAutoType) && (xr.Name == ElemAutoType)) { return(KdbContext.Entry); } else if ((ctx == KdbContext.EntryAutoTypeItem) && (xr.Name == ElemAutoTypeItem)) { AutoTypeAssociation atAssoc = new AutoTypeAssociation(m_ctxATName, m_ctxATSeq); m_ctxEntry.AutoType.Add(atAssoc); m_ctxATName = null; m_ctxATSeq = null; return(KdbContext.EntryAutoType); } else if ((ctx == KdbContext.EntryCustomData) && (xr.Name == ElemCustomData)) { return(KdbContext.Entry); } else if ((ctx == KdbContext.EntryCustomDataItem) && (xr.Name == ElemStringDictExItem)) { if ((m_strEntryCustomDataKey != null) && (m_strEntryCustomDataValue != null)) { m_ctxEntry.CustomData.Set(m_strEntryCustomDataKey, m_strEntryCustomDataValue); } else { Debug.Assert(false); } m_strEntryCustomDataKey = null; m_strEntryCustomDataValue = null; return(KdbContext.EntryCustomData); } else if ((ctx == KdbContext.EntryHistory) && (xr.Name == ElemHistory)) { m_bEntryInHistory = false; return(KdbContext.Entry); } else if ((ctx == KdbContext.RootDeletedObjects) && (xr.Name == ElemDeletedObjects)) { return(KdbContext.Root); } else if ((ctx == KdbContext.DeletedObject) && (xr.Name == ElemDeletedObject)) { m_ctxDeletedObject = null; return(KdbContext.RootDeletedObjects); } else { Debug.Assert(false); throw new FormatException(); } }
private void UpdateAutoTypeList(ListSelRestore r, AutoTypeAssociation aToSel, bool bUpdateState) { UIScrollInfo uiScroll = UIUtil.GetScrollInfo(m_lvAutoType, true); int s = m_lvAutoType.SelectedIndices.Count; int[] vSel = null; List<AutoTypeAssociation> lSel = new List<AutoTypeAssociation>(); if(aToSel != null) lSel.Add(aToSel); if((r == ListSelRestore.ByIndex) && (s > 0)) { vSel = new int[s]; m_lvAutoType.SelectedIndices.CopyTo(vSel, 0); } else if(r == ListSelRestore.ByRef) { foreach(ListViewItem lviSel in m_lvAutoType.SelectedItems) { AutoTypeAssociation a = (lviSel.Tag as AutoTypeAssociation); if(a == null) { Debug.Assert(false); } else lSel.Add(a); } } m_lvAutoType.BeginUpdate(); m_lvAutoType.Items.Clear(); string strDefault = "(" + KPRes.Default + ")"; foreach(AutoTypeAssociation a in m_atConfig.Associations) { ListViewItem lvi = m_lvAutoType.Items.Add(a.WindowName, (int)PwIcon.List); lvi.SubItems.Add((a.Sequence.Length > 0) ? a.Sequence : strDefault); lvi.Tag = a; foreach(AutoTypeAssociation aSel in lSel) { if(object.ReferenceEquals(a, aSel)) lvi.Selected = true; } } if(vSel != null) { foreach(int iSel in vSel) m_lvAutoType.Items[iSel].Selected = true; } UIUtil.Scroll(m_lvAutoType, uiScroll, true); m_lvAutoType.EndUpdate(); if(bUpdateState) EnableControlsEx(); }
private KdbContext EndXmlElement(KdbContext ctx, XmlReader xr) { Debug.Assert(xr.NodeType == XmlNodeType.EndElement); if((ctx == KdbContext.KeePassFile) && (xr.Name == ElemDocNode)) return KdbContext.Null; else if((ctx == KdbContext.Meta) && (xr.Name == ElemMeta)) return KdbContext.KeePassFile; else if((ctx == KdbContext.Root) && (xr.Name == ElemRoot)) return KdbContext.KeePassFile; else if((ctx == KdbContext.MemoryProtection) && (xr.Name == ElemMemoryProt)) return KdbContext.Meta; else if((ctx == KdbContext.CustomIcons) && (xr.Name == ElemCustomIcons)) return KdbContext.Meta; else if((ctx == KdbContext.CustomIcon) && (xr.Name == ElemCustomIconItem)) { if(!m_uuidCustomIconID.Equals(PwUuid.Zero) && (m_pbCustomIconData != null)) m_pwDatabase.CustomIcons.Add(new PwCustomIcon( m_uuidCustomIconID, m_pbCustomIconData)); else { Debug.Assert(false); } m_uuidCustomIconID = PwUuid.Zero; m_pbCustomIconData = null; return KdbContext.CustomIcons; } else if((ctx == KdbContext.Binaries) && (xr.Name == ElemBinaries)) return KdbContext.Meta; else if((ctx == KdbContext.CustomData) && (xr.Name == ElemCustomData)) return KdbContext.Meta; else if((ctx == KdbContext.CustomDataItem) && (xr.Name == ElemStringDictExItem)) { if((m_strCustomDataKey != null) && (m_strCustomDataValue != null)) m_pwDatabase.CustomData.Set(m_strCustomDataKey, m_strCustomDataValue); else { Debug.Assert(false); } m_strCustomDataKey = null; m_strCustomDataValue = null; return KdbContext.CustomData; } else if((ctx == KdbContext.Group) && (xr.Name == ElemGroup)) { if(PwUuid.Zero.Equals(m_ctxGroup.Uuid)) m_ctxGroup.Uuid = new PwUuid(true); // No assert (import) m_ctxGroups.Pop(); if(m_ctxGroups.Count == 0) { m_ctxGroup = null; return KdbContext.Root; } else { m_ctxGroup = m_ctxGroups.Peek(); return KdbContext.Group; } } else if((ctx == KdbContext.GroupTimes) && (xr.Name == ElemTimes)) return KdbContext.Group; else if((ctx == KdbContext.Entry) && (xr.Name == ElemEntry)) { // Create new UUID if absent if(PwUuid.Zero.Equals(m_ctxEntry.Uuid)) m_ctxEntry.Uuid = new PwUuid(true); // No assert (import) if(m_bEntryInHistory) { m_ctxEntry = m_ctxHistoryBase; return KdbContext.EntryHistory; } return KdbContext.Group; } else if((ctx == KdbContext.EntryTimes) && (xr.Name == ElemTimes)) return KdbContext.Entry; else if((ctx == KdbContext.EntryString) && (xr.Name == ElemString)) { m_ctxEntry.Strings.Set(m_ctxStringName, m_ctxStringValue); m_ctxStringName = null; m_ctxStringValue = null; return KdbContext.Entry; } else if((ctx == KdbContext.EntryBinary) && (xr.Name == ElemBinary)) { if(string.IsNullOrEmpty(m_strDetachBins)) m_ctxEntry.Binaries.Set(m_ctxBinaryName, m_ctxBinaryValue); else { SaveBinary(m_ctxBinaryName, m_ctxBinaryValue, m_strDetachBins); m_ctxBinaryValue = null; GC.Collect(); } m_ctxBinaryName = null; m_ctxBinaryValue = null; return KdbContext.Entry; } else if((ctx == KdbContext.EntryAutoType) && (xr.Name == ElemAutoType)) return KdbContext.Entry; else if((ctx == KdbContext.EntryAutoTypeItem) && (xr.Name == ElemAutoTypeItem)) { AutoTypeAssociation atAssoc = new AutoTypeAssociation(m_ctxATName, m_ctxATSeq); m_ctxEntry.AutoType.Add(atAssoc); m_ctxATName = null; m_ctxATSeq = null; return KdbContext.EntryAutoType; } else if((ctx == KdbContext.EntryHistory) && (xr.Name == ElemHistory)) { m_bEntryInHistory = false; return KdbContext.Entry; } else if((ctx == KdbContext.RootDeletedObjects) && (xr.Name == ElemDeletedObjects)) return KdbContext.Root; else if((ctx == KdbContext.DeletedObject) && (xr.Name == ElemDeletedObject)) { m_ctxDeletedObject = null; return KdbContext.RootDeletedObjects; } else { Debug.Assert(false); throw new FormatException(); } }
public AutoTypeAssociationBuffer() { mAutoTypeAssociation = new AutoTypeAssociation(); }
public AutoTypeAssociationBuffer(AutoTypeAssociation autoTypeAssociation) { mAutoTypeAssociation = autoTypeAssociation; }
private void OnFormLoad(object sender, EventArgs e) { Debug.Assert(m_atConfig != null); if(m_atConfig == null) throw new InvalidOperationException(); Debug.Assert(m_vStringDict != null); if(m_vStringDict == null) throw new InvalidOperationException(); GlobalWindowManager.AddWindow(this); m_ctxKeySeq.Attach(m_rbKeySeq, this); m_ctxKeyCodes.Attach(m_rtbPlaceholders, this); if(!m_bEditSequenceOnly) { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureAutoTypeItem, KPRes.ConfigureAutoTypeItemDesc); } else // Edit keystrokes only { BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KCMSystem, KPRes.ConfigureKeystrokeSeq, KPRes.ConfigureKeystrokeSeqDesc); } this.Icon = AppIcons.Default; // FontUtil.AssignDefaultBold(m_lblTargetWindow); // FontUtil.AssignDefaultBold(m_rbSeqDefault); // FontUtil.AssignDefaultBold(m_rbSeqCustom); UIUtil.EnableAutoCompletion(m_cmbWindow, false); // m_clrOriginalForeground = m_lblOpenHint.ForeColor; // m_clrOriginalBackground = m_cmbWindow.BackColor; // m_strOriginalWindowHint = m_lblTargetWindowInfo.Text; bool bRtl = Program.Translation.Properties.RightToLeft; if(bRtl) { // https://sourceforge.net/p/keepass/discussion/329220/thread/f98dece5/ m_rbKeySeq.RightToLeft = RightToLeft.No; m_rtbPlaceholders.RightToLeft = RightToLeft.No; } InitPlaceholdersBox(bRtl); string strInitSeq = m_atConfig.DefaultSequence; if(m_iAssocIndex >= 0) { AutoTypeAssociation asInit = m_atConfig.GetAt(m_iAssocIndex); m_cmbWindow.Text = asInit.WindowName; if(!m_bEditSequenceOnly) strInitSeq = asInit.Sequence; } else if(m_bEditSequenceOnly) m_cmbWindow.Text = "(" + KPRes.Default + ")"; else strInitSeq = string.Empty; bool bSetDefault = false; m_bBlockUpdates = true; if(strInitSeq.Length > 0) m_rbSeqCustom.Checked = true; else { m_rbSeqDefault.Checked = true; bSetDefault = true; } m_bBlockUpdates = false; if(bSetDefault) m_rbKeySeq.Text = m_strDefaultSeq; else m_rbKeySeq.Text = strInitSeq; try { if(NativeLib.IsUnix()) PopulateWindowsListUnix(); else PopulateWindowsListWin(); } catch(Exception) { Debug.Assert(false); } EnableControlsEx(); }