private void MainForm_FileOpened(object sender, FileOpenedEventArgs e) { //check to see if we've loaded our providers into the db custom data, if not load them up. dbPwDatabase = e.Database; if (!dbPwDatabase.CustomData.Exists("OpenIdProviders")) { string[] p = new string[] { "AOL", "Blogger", "BuddyPress", "Flickr", "Google", "LiveJournal", "Microsoft ", "WordPress", "Yahoo", "Facebook" }; foreach (string s in p) { OpenIdProvider provider = new OpenIdProvider() { Name = s }; providers.Add(provider); } SaveCustomData(); } else { ExtractProviders(); } tsmiOptions.Enabled = dbPwDatabase != null; }
private void SetProviderReferences(OpenIdProvider provider) { if (provider != null && !String.IsNullOrEmpty(provider.LinkedEntryUUID)) { tbUserName.Text = string.Format(@"{{REF:U@I:{0}}}", provider.LinkedEntryUUID); tbPassword.Text = string.Format(@"{{REF:P@I:{0}}}", provider.LinkedEntryUUID); tbRepeatPassword.Text = string.Format(@"{{REF:P@I:{0}}}", provider.LinkedEntryUUID); } }
private void OnWindowAdded(object sender, GwmWindowEventArgs e) { PwEntryForm pefEntryForm = (e.Form as PwEntryForm); if (pefEntryForm != null) { //check to see if it's an OpenId entry either through the flag from clicking the correct entry, or check the custom data //only do this check if we haven't already set the flag if (!IsOpenIdEntry) { IsOpenIdEntry = pefEntryForm.EntryRef.CustomData.Exists("IsOpenIdEntry") && pefEntryForm.EntryRef.CustomData.Get("IsOpenIdEntry") == "true"; } if (IsOpenIdEntry) { //find our provider OpenIdProvider provider = null; //hook up to the saved event so we can update custom data pefEntryForm.EntrySaved += EntryForm_EntrySaved; //create our controls and add to form Label lblOpenId = new Label() { Location = new Point(6, 40), Size = new Size(61, 13), Text = "OpenId Provider", }; TextBox tbOpenId = new TextBox() { Location = new Point(81, 37), Name = "m_tbOpenId", Size = new Size(373, 20), TabIndex = 5, }; tbOpenId.Leave += OnTbOpenId_Leave; string[] providerNames = providers.Select(p => p.Name).ToArray(); UIUtil.EnableAutoCompletion(tbOpenId, false, providerNames); //if editing, set the OpenID textbox value if (pefEntryForm.EditModeEx == PwEditMode.EditExistingEntry) { tbOpenId.Text = pefEntryForm.EntryRef.CustomData.Get("OpenIdProvider"); provider = providers.Where(p => p.Name.Equals(tbOpenId.Text, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault(); } Control[] tabEntryArray = pefEntryForm.Controls.Find("m_tabEntry", true); if (tabEntryArray.Length == 1) { tabEntryArray[0].Controls.Add(lblOpenId); tabEntryArray[0].Controls.Add(tbOpenId); } //hide the controls we don't want //password repeat Control[] lblPasswordRepeatArray = pefEntryForm.Controls.Find("m_lblPasswordRepeat", true); Control[] tbRepeatPasswordArray = pefEntryForm.Controls.Find("m_tbRepeatPassword", true); Control[] btnGenPwArray = pefEntryForm.Controls.Find("m_btnGenPw", true); if (lblPasswordRepeatArray.Length == 1) { lblPasswordRepeatArray[0].Visible = false; } if (tbRepeatPasswordArray.Length == 1) { tbRepeatPassword = (TextBox)tbRepeatPasswordArray[0]; tbRepeatPassword.Visible = false; } if (btnGenPwArray.Length == 1) { btnGenPwArray[0].Visible = false; } //quality Control[] lblQualityArray = pefEntryForm.Controls.Find("m_lblQuality", true); Control[] pbQualityArray = pefEntryForm.Controls.Find("m_pbQuality", true); Control[] lblQualityInfoArray = pefEntryForm.Controls.Find("m_lblQualityInfo", true); if (lblQualityArray.Length == 1) { lblQualityArray[0].Visible = false; } if (pbQualityArray.Length == 1) { pbQualityArray[0].Visible = false; } if (lblQualityInfoArray.Length == 1) { lblQualityInfoArray[0].Visible = false; } //move the ones we keep //username Control[] lblUserNameArray = pefEntryForm.Controls.Find("m_lblUserName", true); Control[] tbUserNameArray = pefEntryForm.Controls.Find("m_tbUserName", true); if (lblUserNameArray.Length == 1) { lblUserNameArray[0].Location = new Point(6, 67); } if (tbUserNameArray.Length == 1) { tbUserName = (TextBox)tbUserNameArray[0]; tbUserName.Location = new Point(81, 64); tbUserName.Enabled = false; } //password Control[] lblPasswordArray = pefEntryForm.Controls.Find("m_lblPassword", true); Control[] tbPasswordArray = pefEntryForm.Controls.Find("m_tbPassword", true); Control[] cbHidePasswordArray = pefEntryForm.Controls.Find("m_cbHidePassword", true); if (lblPasswordArray.Length == 1) { lblPasswordArray[0].Location = new Point(6, 94); } if (tbPasswordArray.Length == 1) { tbPassword = (TextBox)tbPasswordArray[0]; tbPassword.Location = new Point(81, 91); tbPassword.Enabled = false; } if (cbHidePasswordArray.Length == 1) { cbHidePasswordArray[0].Location = new Point(423, 90); cbHidePasswordArray[0].Enabled = false; } //url Control[] lblUrlArray = pefEntryForm.Controls.Find("m_lblUrl", true); Control[] tbUrlArray = pefEntryForm.Controls.Find("m_tbUrl", true); if (lblUrlArray.Length == 1) { lblUrlArray[0].Location = new Point(6, 118); } if (tbUrlArray.Length == 1) { tbUrlArray[0].Location = new Point(81, 118); } //notes Control[] lblNotesArray = pefEntryForm.Controls.Find("m_lblNotes", true); Control[] rtNotesArray = pefEntryForm.Controls.Find("m_rtNotes", true); if (lblNotesArray.Length == 1) { lblNotesArray[0].Location = new Point(6, 144); } if (rtNotesArray.Length == 1) { rtNotesArray[0].Location = new Point(81, 144); rtNotesArray[0].Height = 160; } //set the references if any SetProviderReferences(provider); //reset our flag IsOpenIdEntry = false; } } }
private void OnTbOpenId_Leave(object sender, EventArgs e) { OpenIdProvider provider = providers.Where(p => p.Name.Equals(((TextBox)sender).Text, StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault(); SetProviderReferences(provider); }