private void OnWindowAppeared(object sender, GwmWindowEventArgs eventArgs) { if (eventArgs.Form is not PwEntryForm pwEntryForm) { return; } var formUtil = new EntryFormUtil(pwEntryForm); var menuItem = new CreateAddressMenuItem(); menuItem.OnClick(async() => { string?description = formUtil.GetTitle(); var service = new AnonAddyService(this.accessTokenFactory); AnonAddyEntry anonAddyEntry = await service.RequestAddress(description); formUtil.PopulateUserNameFieldWith(anonAddyEntry); formUtil.AddIdFrom(anonAddyEntry); }); if (this.accessTokenFactory != null) { formUtil.Add(menuItem); } }
internal void AddIdFrom(AnonAddyEntry anonAddyEntry) { if (anonAddyEntry.Id != null) { var protectedId = new ProtectedString(false, anonAddyEntry.Id.ToString()); this.form.EntryStrings.Set("x-aa-id", protectedId); } this.form.EntryRef.Touch(true, false); }
internal void PopulateUserNameFieldWith(AnonAddyEntry anonAddyEntry) { Control?userNameControl = GetControlByKey("m_tbUserName"); if (userNameControl != null) { userNameControl.Text = anonAddyEntry.MailAddress.Address; } this.form.EntryRef.Touch(true, false); }