コード例 #1
0
        public EntryTemplateManager(IPluginHost host, PwEntryForm form)
        {
            m_host              = host;
            this.form           = form;
            our_page            = new TabPage("Template");
            our_page.AutoScroll = true;

            form_tab_control = get_control_from_form(form, "m_tabMain") as TabControl;
            Debug.Assert(form_tab_control != null);
            form_tab_control.Selecting += main_tabs_control_Selecting;
            _entry_is_template          = form.EntryStrings.Get("_etm_template") != null;
            ProtectedString str = form.EntryStrings.Get("_etm_template_uuid");

            entry_is_child = str != null;
            if (entry_is_child)
            {
                child_template_uuid = str.ReadString();
            }
            form.EntrySaving += form_EntrySaving;
            our_page.UseVisualStyleBackColor = true;
            form_tab_control.TabPages.Insert(0, our_page);
            if (entry_is_child || entry_is_template)
            {
                form_tab_control.SelectTab(0);
            }
        }
コード例 #2
0
        private void form_Shown(object sender, EventArgs e)
        {
            PwEntryForm form = sender as PwEntryForm;

            new EntryTemplateManager(m_host, form);
            //form_Resize(sender, e);
        }
コード例 #3
0
        void form_Resize(object sender, EventArgs e)
        {
            PwEntryForm form = sender as PwEntryForm;

            TabControl tabControl = null;

            foreach (Control c in form.Controls)
            {
                if (c is TabControl)
                {
                    tabControl = c as TabControl;
                    break;
                }
            }
            if (tabControl == null)
            {
                return;
            }

            TabPage tmplPage = tabControl.TabPages[0];

            if (tmplPage.Text != "Template")
            {
                return;
            }
            EntryTemplateManager.SetBaseSizes(tmplPage);
            foreach (Control c in tmplPage.Controls)
            {
                EntryTemplateManager.UpdateControlSize(c);
            }
        }
コード例 #4
0
        public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                                      CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
        {
            KeePassRPCPlugin = keePassRPCPlugin;
            _entry           = entry;
            InitializeComponent();
            _pwEntryForm = pwEntryForm;
            _strings     = strings;
            string json = strings.ReadSafe("KPRPC JSON");

            if (string.IsNullOrEmpty(json))
            {
                _conf = new EntryConfig();
            }
            else
            {
                try
                {
                    _conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
                }
                catch (Exception)
                {
                    MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KeePassRPC JSON config' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this.", "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
コード例 #5
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     pwEntryForm = ParentForm as PwEntryForm;
     if (pwEntryForm != null)
     {
         IntialSettings =
             pwEntryForm.EntryRef.GetKeeAgentSettings();
         CurrentSettings = (EntrySettings)IntialSettings.Clone();
         entrySettingsBindingSource.DataSource = CurrentSettings;
         keyLocationPanel.KeyLocationChanged  += delegate {
             UpdateKeyInfoDelayed();
         };
         pwEntryForm.FormClosing += delegate {
             while (delayedUpdateKeyInfoTimer.Enabled)
             {
                 Application.DoEvents();
             }
         };
     }
     else
     {
         Debug.Fail("Don't have settings to bind to");
     }
     // replace the confirm constraint checkbox if the global confirm option is enabled
     if (ext.Options.AlwaysConfirm)
     {
         confirmConstraintCheckBox.ReplaceWithGlobalConfirmMessage();
     }
     UpdateControlStates();
 }
コード例 #6
0
 /// <summary>
 /// Event handler for when a new window is created. Checks if this is a password entry window and, if so, attaches to the "shown" event.
 /// </summary>
 /// <param name="sender">The object which triggered the event.</param>
 /// <param name="e">The event arguments.</param>
 private void WindowCreated(object sender, GwmWindowEventArgs e)
 {
     if (e.Form is PwEntryForm)
     {
         PwEntryForm pwEntryForm = (PwEntryForm)e.Form;
         pwEntryForm.Shown += this.PasswordEntryFormShown;
     }
 }
コード例 #7
0
        /// <summary>
        /// Default contructor.
        /// </summary>
        /// <param name="entryForm">The password entry form.</param>
        /// <param name="passwordEntryManager">The manager used for interacting with the open password entry.</param>
        public RunAsOptions(PwEntryForm entryForm, PasswordEntryManager passwordEntryManager)
        {
            InitializeComponent();

            this.passwordEntryManager = passwordEntryManager;

            this.LoadSettings();
            entryForm.EntrySaving += this.Container_EntrySaving;
        }
コード例 #8
0
        /// <summary>
        /// Event handler for when a password entry window is shown. Adds the "Run As" tab.
        /// </summary>
        /// <param name="sender">The object which triggered the event.</param>
        /// <param name="e">The event arguments.</param>
        private void PasswordEntryFormShown(object sender, System.EventArgs e)
        {
            PwEntryForm form = (PwEntryForm)sender;

            PasswordEntryManager passwordEntryManager = new PasswordEntryManager(this.host.Database, form);

            RunAsTab runAsTab = new RunAsTab((PwEntryForm)sender, passwordEntryManager);

            runAsTab.EntryIconUpdated += this.RunAsTab_EntryIconUpdated;
        }
コード例 #9
0
        private void CustomOptionMenuItem_Click(object sender, EventArgs e)
        {
            // Getting a reference to the password entry form
            ToolStripMenuItem customOptionMenuItem = sender as ToolStripMenuItem;
            CustomDateOption  option    = customOptionMenuItem.Tag as CustomDateOption;
            PwEntryForm       entryForm = ((ContextMenuStrip)(((ToolStripMenuItem)sender).Owner)).SourceControl.TopLevelControl as PwEntryForm;

            // Set the expiration date.
            entryForm.SetExpireIn(option.Years, option.Months, option.Days);
        }
コード例 #10
0
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                               CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry           = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings     = strings;
     _conf        = entry.GetKPRPCConfig(strings);
 }
コード例 #11
0
        void GlobalWindowManager_WindowAdded(object sender, GwmWindowEventArgs e)
        {
            PwEntryForm form = e.Form as PwEntryForm;

            if (form == null)
            {
                return;
            }
            form.Shown += form_Shown;
        }
コード例 #12
0
        void form_Resize(object sender, EventArgs e)
        {
            // on form resize, change edits and bottom button widths;
            // also reposition right side buttons

            PwEntryForm form = sender as PwEntryForm;

            TabControl tabControl = null;

            foreach (Control c in form.Controls)
            {
                if (c is TabControl)
                {
                    tabControl = c as TabControl;
                    break;
                }
            }
            if (tabControl == null)
            {
                return;
            }

            TabPage tmplPage = tabControl.TabPages[0];

            if (tmplPage.Text != "Template")
            {
                return;
            }

            foreach (Control c in tmplPage.Controls)
            {
                if (!(c is Label))
                {
                    if (c is CheckBox)
                    {
                        c.Left = tmplPage.Width - ((c.Width + 55) / 2);
                    }
                    else if (c is Button)
                    {
                        if ((c as Button).Text == "Remove As Template Child")
                        {
                            c.Width = tmplPage.Width - c.Left - 55;
                        }
                        else
                        {
                            c.Left = tmplPage.Width - ((c.Width + 55) / 2);
                        }
                    }
                    else
                    {
                        c.Width = tmplPage.Width - c.Left - 55;
                    }
                }
            }
        }
コード例 #13
0
        public void WindowAddedHandler(object sender, GwmWindowEventArgs e)
        {
            PwEntryForm form = e.Form as PwEntryForm;

            if (form == null)
            {
                return;
            }

            form.EntrySaved += prov.EntrySaved;
        }
コード例 #14
0
 private void write_entry(PwEntryForm form, IEnumerable <EntryTemplate> to_add)
 {
     erase_entry_template_items(form.EntryStrings);
     foreach (EntryTemplate t in to_add)
     {
         form.EntryStrings.Set("_etm_title_" + t.fieldName, new ProtectedString(false, t.title));
         form.EntryStrings.Set("_etm_type_" + t.fieldName, new ProtectedString(false, t.type));
         form.EntryStrings.Set("_etm_position_" + t.fieldName, new ProtectedString(false, t.position.ToString()));
         form.EntryStrings.Set("_etm_options_" + t.fieldName, new ProtectedString(false, t.options ?? ""));
     }
 }
コード例 #15
0
 public KeeEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                            CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry           = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings     = strings;
     _dbConf      = KeePassRPCPlugin._host.Database.GetKPRPCConfig();
     _conf        = entry.GetKPRPCConfig(strings, _dbConf.DefaultMatchAccuracy);
 }
コード例 #16
0
ファイル: KeePassRPCExt.cs プロジェクト: nhom4git/KeeFox
        void editEntryFormShown(object sender, EventArgs e)
        {
            PwEntryForm               form             = sender as PwEntryForm;
            PwEntry                   entry            = null;
            TabControl                mainTabControl   = null;
            CustomListViewEx          advancedListView = null;
            ProtectedStringDictionary strings          = null;

            //This might not work, but might as well use the feature if possible.
            try
            {
                // reflection doesn't seem to be needed for 2.10 and above
                entry   = form.EntryRef;
                strings = form.EntryStrings;

                Control[] cs = form.Controls.Find("m_tabMain", true);
                if (cs.Length == 0)
                {
                    return;
                }
                mainTabControl = cs[0] as TabControl;

                Control[] cs2 = form.Controls.Find("m_lvStrings", true);
                if (cs2.Length == 0)
                {
                    return;
                }
                advancedListView = cs2[0] as CustomListViewEx;
            }
            catch
            {
                // that's life, just move on.
                return;
            }

            if (entry == null)
            {
                return;
            }

            lock (_lockRPCClientManagers)
            {
                //TODO2: Only consider managers of client types that have at least one valid client already authorised
                foreach (KeePassRPCClientManager manager in _RPCClientManagers.Values)
                {
                    if (manager.Name != "Null")
                    {
                        manager.AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings);
                    }
                }
            }
        }
コード例 #17
0
        public void EntrySaved(object sender, EventArgs e)
        {
            PwEntryForm form = sender as PwEntryForm;

            form.EntryRef.Touched -= PwdTouchedHandler;
            form.EntryRef.Touched += PwdTouchedHandler;

            //only touch newly created entries, updated entries are touched by KeePass
            if (form.EntryRef.UsageCount <= 1)
            {
                form.EntryRef.Touch(true);
            }
        }
コード例 #18
0
ファイル: SearchWindow.cs プロジェクト: amnore/AutoTypeSearch
        private void EditEntry(SearchResult searchResult)
        {
            using (var entryForm = new PwEntryForm())
            {
                mMainForm.MakeDocumentActive(mMainForm.DocumentManager.FindDocument(searchResult.Database));

                entryForm.InitEx(searchResult.Entry, PwEditMode.EditExistingEntry, searchResult.Database, mMainForm.ClientIcons, false, false);

                ShowForegroundDialog(entryForm);

                mMainForm.UpdateUI(false, null, searchResult.Database.UINeedsIconUpdate, null, true, null, entryForm.HasModifiedEntry);
            }
        }
コード例 #19
0
        private void miItem_Edit(object sender, EventArgs e)
        {
            ToolStripMenuItem Item   = (ToolStripMenuItem)sender;
            PwEntry           Entry  = (PwEntry)Item.Tag;
            PwEntryForm       myForm = new PwEntryForm();

            myForm.InitEx(Entry, PwEditMode.EditExistingEntry, Host.MainWindow.DocumentManager.ActiveDatabase, Host.MainWindow.ClientIcons, false, true);

            if ((myForm.ShowDialog() == DialogResult.OK))
            {
                Host.MainWindow.UpdateUI(false, null, Host.MainWindow.DocumentManager.ActiveDatabase.UINeedsIconUpdate, null, true, null, true);
            }
            Host.MainWindow.RefreshEntriesList();
        }
コード例 #20
0
        /// <summary>
        /// Find the tab container.
        /// </summary>
        /// <param name="container">The password entry form.</param>
        /// <returns>The tab container with the name defined in <see cref="TAB_CONTAINER_NAME"/>.</returns>
        private TabControl GetTabContainer(PwEntryForm container)
        {
            Control[] matchedControls = container.Controls.Find(TAB_CONTAINER_NAME, true);
            if (matchedControls.Length == 0)
            {
                throw new System.Exception("Tab container not found.");
            }

            if (!(matchedControls[0] is TabControl))
            {
                throw new System.Exception("The control which was found is not a TabControl.");
            }

            return((TabControl)matchedControls[0]);
        }
コード例 #21
0
ファイル: PEDCalcExt.cs プロジェクト: Rookiestyle/PEDCalc
 private void OnWindowAdded(object sender, GwmWindowEventArgs e)
 {
     if (!Configuration.Active)
     {
         return;
     }
     if (!(e.Form is PwEntryForm))
     {
         return;
     }
     m_pweForm              = (PwEntryForm)e.Form;
     m_pweForm.Shown       += OnFormShown;
     m_pweForm.FormClosed  += OnFormClosed;
     m_pweForm.EntrySaving += OnEntrySaving;
 }
コード例 #22
0
        private void EntryForm_EntrySaved(object sender, EventArgs e)
        {
            PwEntryForm pefEntryForm = (sender as PwEntryForm);

            if (pefEntryForm != null)
            {
                Control[] tbOpenIdArray = pefEntryForm.Controls.Find("m_tbOpenId", true);

                if (tbOpenIdArray.Length == 1)
                {
                    pefEntryForm.EntryRef.CustomData.Set("IsOpenIdEntry", "true");
                    pefEntryForm.EntryRef.CustomData.Set("OpenIdProvider", tbOpenIdArray[0].Text);
                    pefEntryForm.EntryRef.Touch(true, false);
                }
            }
        }
コード例 #23
0
        public void EntrySaved(object sender, EventArgs e)
        {
            PwEntryForm form = sender as PwEntryForm;

            if (PluginOptions.AutoCheck == false)
            {
                return;
            }

            form.EntryRef.Touched -= PwdTouchedHandler;
            form.EntryRef.Touched += PwdTouchedHandler;

            bulkCheck = false;

            form.EntryRef.Touch(true);
        }
コード例 #24
0
ファイル: KeePassRPCExt.cs プロジェクト: icts-ca/keepassrpc
        void editEntryFormShown(object sender, EventArgs e)
        {
            PwEntryForm               form             = sender as PwEntryForm;
            PwEntry                   entry            = null;
            TabControl                mainTabControl   = null;
            CustomListViewEx          advancedListView = null;
            ProtectedStringDictionary strings          = null;

            //This might not work, but might as well use the feature if possible.
            try
            {
                // reflection doesn't seem to be needed for 2.10 and above
                entry   = form.EntryRef;
                strings = form.EntryStrings;

                Control[] cs = form.Controls.Find("m_tabMain", true);
                if (cs.Length == 0)
                {
                    return;
                }
                mainTabControl = cs[0] as TabControl;

                Control[] cs2 = form.Controls.Find("m_lvStrings", true);
                if (cs2.Length == 0)
                {
                    return;
                }
                advancedListView = cs2[0] as CustomListViewEx;
            }
            catch
            {
                // that's life, just move on.
                return;
            }

            if (entry == null)
            {
                return;
            }

            lock (_lockRPCClientManagers)
            {
                _lockRPCClientManagers.HeldBy = Thread.CurrentThread.ManagedThreadId;
                _RPCClientManagers["general"].AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings);
            }
        }
コード例 #25
0
        private void HandleColorButtonClicked(object sender, EventArgs e)
        {
            if (sender == null)
            {
                Debug.Assert(false); return;
            }
            ColorMenuItem mi = (sender as ColorMenuItem);

            if (mi == null)
            {
                Debug.Assert(false); return;
            }

            m_clr = mi.Color;
            UIUtil.SetButtonImage(m_btnColor, PwEntryForm.CreateColorButtonImage(
                                      m_btnColor, m_clr), false);
        }
コード例 #26
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="container">The password entry form.</param>
        /// <param name="passwordEntryManager">The manager used for interacting with the open password entry.</param>
        internal RunAsTab(PwEntryForm container, PasswordEntryManager passwordEntryManager)
            : base(TAB_TITLE)
        {
            this.passwordEntryManager = passwordEntryManager;

            // Find the tab container and add this tab page to it.
            TabControl tabContainer = this.GetTabContainer(container);

            tabContainer.Controls.Add(this);

            // Add the run as options to this tab page.
            RunAsOptions optionsControl = new RunAsOptions(container, this.passwordEntryManager);

            optionsControl.EntryIconUpdated += this.OptionsControl_EntryIconUpdated;
            optionsControl.Dock              = DockStyle.Fill;
            this.Controls.Add(optionsControl);
        }
コード例 #27
0
        private static void CreateEntry(EntryTemplate et)
        {
            if (Program.MainForm.ActiveDatabase.IsOpen == false)
            {
                Debug.Assert(false);
                return;
            }

            PwGroup pgContainer = Program.MainForm.GetSelectedGroup();

            if (pgContainer == null)
            {
                pgContainer = Program.MainForm.ActiveDatabase.RootGroup;
            }

            PwEntry pe = new PwEntry(true, true);

            // pe.Strings.Set(PwDefs.TitleField, new ProtectedString(
            //	Program.MainForm.Database.MemoryProtection.ProtectTitle,
            //	et.Name));

            foreach (EntryTemplateItem eti in et.Items)
            {
                pe.Strings.Set(eti.Name, new ProtectedString(eti.Protected, string.Empty));
            }

            PwEntryForm pef = new PwEntryForm();

            pef.InitEx(pe, PwEditMode.AddNewEntry, Program.MainForm.ActiveDatabase,
                       Program.MainForm.ClientIcons, true);

            if (pef.ShowDialog() == DialogResult.OK)
            {
                pgContainer.AddEntry(pe, true);

                // Program.MainForm.UpdateEntryList(null, true);
                // Program.MainForm.UpdateUIState(true);
                Program.MainForm.UpdateUI(false, null, false, null, true, null, true);
            }
            else
            {
                Program.MainForm.UpdateUI(false, null, false, null, false, null, false);
            }
        }
コード例 #28
0
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     if (sender is PwGeneratorForm)
     {
         ProfileClicked(sender, new ToolStripItemClickedEventArgs(new ToolStripMenuItem(m_pwgForm.SelectedProfile.Name)));
         List <PwProfile> dbProfiles = Program.Config.PasswordGenerator.UserProfiles.GetDBProfiles();
         bool             changed    = false;
         UpdateDBProfiles(m_profiles, dbProfiles, out changed);
         if (changed)
         {
             m_host.MainWindow.UpdateUI(false, null, false, null, false, null, true);
         }
     }
     else if (sender is PwEntryForm)
     {
         m_pweForm = null;
     }
     m_pwgForm = null;
 }
コード例 #29
0
        private void OnEditEntryFormShown(object sender, EventArgs args)
        {
            PwEntryForm form  = (PwEntryForm)sender;
            PwEntry     entry = form.EntryRef;

            // Extract gui objects
            Control[] cs = form.Controls.Find("m_tabMain", true);
            if (cs.Length == 0)
            {
                return;
            }
            TabControl mainTabControl = (TabControl)cs[0];

            // Attach my userControl to the window
            TabPage kpTabPage = new TabPage("AutoChange");

            kpTabPage.Controls.Add(new PwEditTab());
            mainTabControl.TabPages.Add(kpTabPage);
        }
コード例 #30
0
        public EntryPageOverride(PwEntryForm form)
        {
            this.form      = form;
            this.entryPage = FindControl <TabPage>(form, "m_tabEntry");
            if (this.entryPage != null)
            {
                this.notesLabel = FindControl <Label>(this.entryPage, "m_lblNotes");
                this.notesCtrl  = FindControl <CustomRichTextBoxEx>(this.entryPage, "m_rtNotes");
                if (this.notesLabel != null && this.notesCtrl != null)
                {
                    sshMenuStrip = CreateSSHMenuStrip();

                    notesLocation      = notesCtrl.Location;
                    notesHeight        = notesCtrl.Height;
                    notesLabelLocation = notesLabel.Location;
                    Update();
                }
            }
        }