コード例 #1
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();
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        private void lvExpiringPasswordsItem_onDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo lvHit = lvExpiringPasswords.HitTest(e.Location);
            ListViewItem        lvi   = lvHit.Item;
            PwListItem          pli   = (lvi.Tag as PwListItem);
            PwEntry             pe    = pli.Entry;

            if (pe == null || pdb == null || il_icons == null)
            {
                return;                                                // Do not assert
            }
            pe.CreationTime         = DateTime.Parse("20.12.2019");
            pe.LastModificationTime = DateTime.Parse("20.12.2019");
            this.Close();

            PwDatabase  pwDb  = pdb;
            PwEntryForm pForm = new PwEntryForm();

            pForm.InitEx(pe, PwEditMode.EditExistingEntry, pwDb, il_icons,
                         false, false);

            DialogResult dr   = pForm.ShowDialog();
            bool         bMod = ((dr == DialogResult.OK) && pForm.HasModifiedEntry);

            UIUtil.DestroyForm(pForm);

            bool bUpdImg = pwDb.UINeedsIconUpdate;
            PwObjectList <PwEntry> pwEntries = new PwObjectList <PwEntry>();

            pwEntries.Add(pe);
            MainForm mf = Program.MainForm;

            mf.SelectEntries(pwEntries, true, true);
            mf.RefreshEntriesList();
            mf.UpdateUI(false, null, bUpdImg, null, false, null, bMod);

            if (Program.Config.Application.AutoSaveAfterEntryEdit && bMod)
            {
                mf.SaveDatabase(pwDb, null);
            }
        }
コード例 #4
0
        private static void CreateEntry(PwEntry peTemplate)
        {
            if (peTemplate == null)
            {
                Debug.Assert(false); return;
            }

            PwDatabase pd = Program.MainForm.ActiveDatabase;

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

            PwGroup pgContainer = Program.MainForm.GetSelectedGroup();

            if (pgContainer == null)
            {
                pgContainer = pd.RootGroup;
            }

            PwEntry pe = peTemplate.CloneDeep();

            pe.Uuid         = new PwUuid(true);
            pe.CreationTime = pe.LastModificationTime = pe.LastAccessTime = DateTime.Now;

            if (EntryTemplates.EntryCreating != null)
            {
                EntryTemplates.EntryCreating(null, new TemplateEntryEventArgs(
                                                 peTemplate.CloneDeep(), pe));
            }

            PwEntryForm pef = new PwEntryForm();

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

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

                if (EntryTemplates.EntryCreated != null)
                {
                    EntryTemplates.EntryCreated(null, new TemplateEntryEventArgs(
                                                    peTemplate.CloneDeep(), pe));
                }

                // Program.MainForm.UpdateEntryList(null, true);
                // Program.MainForm.UpdateUIState(true);
                Program.MainForm.UpdateUI(false, null, pd.UINeedsIconUpdate, null,
                                          true, null, true);
            }
            else
            {
                Program.MainForm.UpdateUI(false, null, pd.UINeedsIconUpdate, null,
                                          pd.UINeedsIconUpdate, null, false);
            }
        }