private void PopulateNotes(string value) { Debug.Assert(!mNotesEditingActive, "Can't populate while editing!"); var builder = new RichTextBuilder { DefaultFont = Font }; if (String.IsNullOrEmpty(value)) { // Populate it with a watermark builder.Append(KPRes.Notes, FontStyle.Italic); builder.Build(mNotes); mNotes.SelectAll(); mNotes.SelectionColor = SystemColors.GrayText; mNotes.Select(0, 0); mNotes.ReadOnly = true; } else { builder.Append(NotesRtfHelpers.ReplaceFormattingTags(value)); builder.Build(mNotes); UIUtil.RtfLinkifyReferences(mNotes, false); NotesRtfHelpers.RtfLinkifyUrls(mNotes); } }
private void InitPlaceholdersBox() { const string VkcBreak = @"<break />"; string[] vSpecialKeyCodes = new string[] { "TAB", "ENTER", "UP", "DOWN", "LEFT", "RIGHT", "HOME", "END", "PGUP", "PGDN", "INSERT", "DELETE", "SPACE", VkcBreak, "BACKSPACE", "BREAK", "CAPSLOCK", "ESC", "WIN", "LWIN", "RWIN", "APPS", "HELP", "NUMLOCK", "PRTSC", "SCROLLLOCK", VkcBreak, "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", VkcBreak, "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE", "NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4", "NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9" }; string[] vSpecialPlaceholders = new string[] { "GROUP", "GROUP_PATH", "GROUP_NOTES", "PASSWORD_ENC", "URL:RMVSCM", "URL:SCM", "URL:HOST", "URL:PORT", "URL:PATH", "URL:QUERY", "URL:USERINFO", "URL:USERNAME", "URL:PASSWORD", // "BASE", "T-REPLACE-RX:/T/S/R/", "T-CONV:/T/C/", "C:Comment", VkcBreak, "DELAY 1000", "DELAY=200", "VKEY 13", "VKEY-NX 13", "VKEY-EX 13", "PICKCHARS", "PICKCHARS:Password:C=3", "NEWPASSWORD", "NEWPASSWORD:/Profile/", "HMACOTP", "CLEARFIELD", "APPACTIVATE " + KPRes.Title, "BEEP 800 200", VkcBreak, "APPDIR", "DB_PATH", "DB_DIR", "DB_NAME", "DB_BASENAME", "DB_EXT", "ENV_DIRSEP", "ENV_PROGRAMFILES_X86", VkcBreak, // "INTERNETEXPLORER", "FIREFOX", "OPERA", "GOOGLECHROME", // "SAFARI", VkcBreak, "DT_SIMPLE", "DT_YEAR", "DT_MONTH", "DT_DAY", "DT_HOUR", "DT_MINUTE", "DT_SECOND", "DT_UTC_SIMPLE", "DT_UTC_YEAR", "DT_UTC_MONTH", "DT_UTC_DAY", "DT_UTC_HOUR", "DT_UTC_MINUTE", "DT_UTC_SECOND" }; RichTextBuilder rb = new RichTextBuilder(); rb.AppendLine(KPRes.StandardFields, FontStyle.Bold, null, null, ":", null); rb.Append("{" + PwDefs.TitleField + "} "); rb.Append("{" + PwDefs.UserNameField + "} "); rb.Append("{" + PwDefs.PasswordField + "} "); rb.Append("{" + PwDefs.UrlField + "} "); rb.Append("{" + PwDefs.NotesField + "}"); bool bCustomInitialized = false, bFirst = true; foreach (KeyValuePair <string, ProtectedString> kvp in m_vStringDict) { if (!PwDefs.IsStandardField(kvp.Key)) { if (bCustomInitialized == false) { rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.CustomFields, FontStyle.Bold, null, null, ":", null); bCustomInitialized = true; } if (!bFirst) { rb.Append(" "); } rb.Append("{" + PwDefs.AutoTypeStringPrefix + kvp.Key + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.KeyboardKeyModifiers, FontStyle.Bold, null, null, ":", null); rb.Append(KPRes.KeyboardKeyShift + @": +, "); rb.Append(KPRes.KeyboardKeyCtrl + @": ^, "); rb.Append(KPRes.KeyboardKeyAlt + @": %"); rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.SpecialKeys, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach (string strNav in vSpecialKeyCodes) { if (strNav == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if (!bFirst) { rb.Append(" "); } rb.Append("{" + strNav + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.OtherPlaceholders, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach (string strPH in vSpecialPlaceholders) { if (strPH == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if (!bFirst) { rb.Append(" "); } rb.Append("{" + strPH + "}"); bFirst = false; } } if (SprEngine.FilterPlaceholderHints.Count > 0) { rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.PluginProvided, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach (string strP in SprEngine.FilterPlaceholderHints) { if (string.IsNullOrEmpty(strP)) { continue; } if (!bFirst) { rb.Append(" "); } rb.Append(strP); bFirst = false; } } rb.Build(m_rtbPlaceholders); LinkifyRtf(m_rtbPlaceholders); }
public void InitEx(PwEntry pe) { btn_Reload.Enabled = false; btn_Reload.Visible = false; RichTextBuilder rb = new RichTextBuilder(); string strItemSeperator = Environment.NewLine; EvAppendEntryFieldProtectedString(rb, strItemSeperator, "Title", PwDefs.TitleField, pe); EvAppendEntryFieldProtectedString(rb, strItemSeperator, "Username", PwDefs.UserNameField, pe); EvAppendEntryFieldProtectedString(rb, strItemSeperator, "URL", PwDefs.UrlField, pe); this.Text = this.Text + " - " + pe.Strings.ReadSafe(PwDefs.TitleField); string r = ""; string totpAlready = "No"; KP2faC_Website curWebsite = null; bool bPossible = false; if ((pe.Strings.Exists("otp") && pe.Strings.Get("otp") != null) || (pe.Strings.Exists("TOTP Seed") && pe.Strings.Get("TOTP Seed") != null)) { totpAlready = "Yes"; } string url = pe.Strings.ReadSafe(PwDefs.UrlField); pb_trafficlight.Image = Properties.Resources.trafficlight_orange; if (String.IsNullOrEmpty(url)) { r = "No Url set. A Url is needed to check for 2fa support"; } else { if (KP2faCheckerExt.dictKp2fac_WebsiteByDomain.Count > 0) { string prettifiedUrl = KP2faCheckerExt.prettifyUrl(url, KP2faCheckerExt.prettifyMode.AllWithoutTld); string[] domainArray = prettifiedUrl.Split('.').Reverse().ToArray(); var curDict = KP2faCheckerExt.dictKp2fac_WebsiteByDomain; for (int i = 0; i < domainArray.Length; i++) { if (curDict.ContainsKey(domainArray[i])) { if (curDict[domainArray[i]] is KP2faC_Website) { if (((KP2faC_Website)curDict[domainArray[i]]).is2faPosssible()) { if (i == domainArray.Length - 1) { r = "Yes" + r; bPossible = true; pb_trafficlight.Image = Properties.Resources.trafficlight_green; } } else { r = "No" + r; pb_trafficlight.Image = Properties.Resources.trafficlight_red; } curWebsite = (KP2faC_Website)curDict[domainArray[i]]; } else { curDict = (Dictionary <string, object>)curDict[domainArray[i]]; if (i == domainArray.Length - 1) { if (curDict.ContainsKey("*") && curDict["*"] is KP2faC_Website) { if (((KP2faC_Website)curDict["*"]).is2faPosssible()) { r = "Yes" + r; bPossible = true; pb_trafficlight.Image = Properties.Resources.trafficlight_green; } else { r = "No" + r; pb_trafficlight.Image = Properties.Resources.trafficlight_red; } curWebsite = (KP2faC_Website)curDict["*"]; } } } } else if (curDict.ContainsKey("*")) { if (curDict["*"] is KP2faC_Website) { if (((KP2faC_Website)curDict["*"]).is2faPosssible()) { r = "Yes" + r; bPossible = true; pb_trafficlight.Image = Properties.Resources.trafficlight_green; } else { r = "No" + r; pb_trafficlight.Image = Properties.Resources.trafficlight_red; } curWebsite = (KP2faC_Website)curDict["*"]; } break; } } } else { r = "Unknown. API Error!"; btn_Reload.Enabled = true; btn_Reload.Visible = true; btn_Reload.Tag = pe; } if (string.IsNullOrEmpty(r)) { r = "Dont know!"; } } EvAppendEntryFieldString(rb, strItemSeperator, "2FA already configured", totpAlready); rb.Build(rtb_Entry); rb = new RichTextBuilder(); EvAppendEntryFieldString(rb, strItemSeperator, "2FA supported", r); if (bPossible && curWebsite != null) { rb.AppendLine(); EvAppendEntryFieldString(rb, strItemSeperator, "Websitename", curWebsite.name); EvAppendEntryFieldString(rb, strItemSeperator, "2FA Options", curWebsite.getTfa()); EvAppendEntryFieldString(rb, strItemSeperator, "Documentation", curWebsite.doc); if (!String.IsNullOrEmpty(curWebsite.exception)) { EvAppendEntryFieldString(rb, strItemSeperator, "Exception", curWebsite.exception); } } else if (!bPossible && curWebsite != null) { EvAppendEntryFieldString(rb, strItemSeperator, "This is wrong?", "Give a hint! https://toasted.top/kp2fac/"); rb.AppendLine(); EvAppendEntryFieldString(rb, strItemSeperator, "Tell them to support 2FA!", " "); if (!String.IsNullOrEmpty(curWebsite.email_address)) { EvAppendEntryFieldString(rb, strItemSeperator, "Email address", curWebsite.email_address); } if (!String.IsNullOrEmpty(curWebsite.facebook)) { EvAppendEntryFieldString(rb, strItemSeperator, "Facebook", curWebsite.facebook); } if (!String.IsNullOrEmpty(curWebsite.twitter)) { EvAppendEntryFieldString(rb, strItemSeperator, "Twitter", curWebsite.twitter); } } else { rb.AppendLine(); EvAppendEntryFieldString(rb, strItemSeperator, "Is 2fa supported?", "Give a hint! https://toasted.top/kp2fac/"); } rb.Build(rtb_2FA); }
private void InitPlaceholdersBox() { const string VkcBreak = @"<break />"; string[] vSpecialKeyCodes = new string[] { "TAB", "ENTER", "UP", "DOWN", "LEFT", "RIGHT", "HOME", "END", "PGUP", "PGDN", "INSERT", "DELETE", VkcBreak, "BACKSPACE", "BREAK", "CAPSLOCK", "ESC", "HELP", "NUMLOCK", "PRTSC", "SCROLLLOCK", VkcBreak, "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", VkcBreak, "ADD", "SUBTRACT", "MULTIPLY", "DIVIDE" }; string[] vSpecialPlaceholders = new string[] { "GROUP", "GROUPPATH", "PASSWORD_ENC", "URL:RMVSCM", "C:Comment", VkcBreak, "DELAY 1000", "DELAY=200", "VKEY 65", "PICKCHARS", "PICKCHARS:Password:C=3", "NEWPASSWORD", "HMACOTP", "CLEARFIELD", VkcBreak, "APPDIR", "DB_PATH", "DB_DIR", "DB_NAME", "DB_BASENAME", "DB_EXT", "ENV_DIRSEP", VkcBreak, "DT_SIMPLE", "DT_YEAR", "DT_MONTH", "DT_DAY", "DT_HOUR", "DT_MINUTE", "DT_SECOND", "DT_UTC_SIMPLE", "DT_UTC_YEAR", "DT_UTC_MONTH", "DT_UTC_DAY", "DT_UTC_HOUR", "DT_UTC_MINUTE", "DT_UTC_SECOND" }; RichTextBuilder rb = new RichTextBuilder(); rb.AppendLine(KPRes.StandardFields, FontStyle.Bold, null, null, ":", null); rb.Append("{" + PwDefs.TitleField + "} "); rb.Append("{" + PwDefs.UserNameField + "} "); rb.Append("{" + PwDefs.PasswordField + "} "); rb.Append("{" + PwDefs.UrlField + "} "); rb.Append("{" + PwDefs.NotesField + "}"); bool bCustomInitialized = false, bFirst = true; foreach (KeyValuePair <string, ProtectedString> kvp in m_vStringDict) { if (!PwDefs.IsStandardField(kvp.Key)) { if (bCustomInitialized == false) { rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.CustomFields, FontStyle.Bold, null, null, ":", null); bCustomInitialized = true; } if (!bFirst) { rb.Append(" "); } rb.Append("{" + PwDefs.AutoTypeStringPrefix + kvp.Key + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.KeyboardKeyModifiers, FontStyle.Bold, null, null, ":", null); rb.Append(KPRes.KeyboardKeyShift + @": +, "); rb.Append(KPRes.KeyboardKeyCtrl + @": ^, "); rb.Append(KPRes.KeyboardKeyAlt + @": %"); rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.SpecialKeys, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach (string strNav in vSpecialKeyCodes) { if (strNav == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if (!bFirst) { rb.Append(" "); } rb.Append("{" + strNav + "}"); bFirst = false; } } rb.AppendLine(); rb.AppendLine(); rb.AppendLine(KPRes.OtherPlaceholders, FontStyle.Bold, null, null, ":", null); bFirst = true; foreach (string strPH in vSpecialPlaceholders) { if (strPH == VkcBreak) { rb.AppendLine(); rb.AppendLine(); bFirst = true; } else { if (!bFirst) { rb.Append(" "); } rb.Append("{" + strPH + "}"); bFirst = false; } } rb.Build(m_rtbPlaceholders); LinkifyRtf(m_rtbPlaceholders); }