예제 #1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_aceOvr == null)
            {
                throw new InvalidOperationException();
            }
            m_aceTmp = m_aceOvr.CloneDeep();

            GlobalWindowManager.AddWindow(this);

            this.Icon = AppIcons.Default;
            this.Text = KPRes.UrlOverrides;

            UIUtil.SetExplorerTheme(m_lvOverrides, false);

            int nWidth = m_lvOverrides.ClientSize.Width - UIUtil.GetVScrollBarWidth();

            m_lvOverrides.Columns.Add(KPRes.Scheme, nWidth / 4);
            m_lvOverrides.Columns.Add(KPRes.UrlOverride, (nWidth * 3) / 4);

            m_bEnfSch = AppConfigEx.IsOptionEnforced(Program.Config.Integration, "UrlSchemeOverrides");
            m_bEnfAll = AppConfigEx.IsOptionEnforced(Program.Config.Integration, "UrlOverride");

            UpdateOverridesList(false, false);

            m_cbOverrideAll.Checked = (m_strUrlOverrideAll.Length > 0);
            m_tbOverrideAll.Text    = m_strUrlOverrideAll;

            UIUtil.AccSetName(m_tbOverrideAll, m_cbOverrideAll);

            EnableControlsEx();
        }
예제 #2
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_pd == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         KeePass.Properties.Resources.B48x48_Binary, KPRes.XmlReplace,
                                         KPRes.XmlReplaceDesc);

            this.Icon = AppIcons.Default;
            this.Text = KPRes.XmlReplace;

            m_imgWarning = UIUtil.IconToBitmap(SystemIcons.Warning,
                                               DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_picWarning.Image = m_imgWarning;

            UIUtil.AccSetName(m_picWarning, KPRes.Warning);

            FontUtil.AssignDefaultBold(m_rbRemove);
            FontUtil.AssignDefaultBold(m_rbReplace);

            m_rbReplace.Checked   = true;
            m_rbInnerText.Checked = true;

            EnableControlsEx();
        }
예제 #3
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            GlobalWindowManager.AddWindow(this);

            string strTitle = (m_bEditing ? KPRes.TriggerEdit : KPRes.TriggerAdd);
            string strDesc  = (m_bEditing ? KPRes.TriggerEditDesc : KPRes.TriggerAddDesc);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Run, strTitle, strDesc);
            this.Text = strTitle;
            this.Icon = AppIcons.Default;

            m_lvEvents.SmallImageList     = m_ilIcons;
            m_lvConditions.SmallImageList = m_ilIcons;
            m_lvActions.SmallImageList    = m_ilIcons;

            Debug.Assert((m_lvEvents.Width == m_lvConditions.Width) &&
                         (m_lvEvents.Width == m_lvActions.Width));
            int nColWidth = ((m_lvEvents.ClientSize.Width - UIUtil.GetVScrollBarWidth()) / 2);

            m_lvEvents.Columns.Add(KPRes.Event, nColWidth);
            m_lvEvents.Columns.Add(string.Empty, nColWidth);
            m_lvConditions.Columns.Add(KPRes.Condition, nColWidth);
            m_lvConditions.Columns.Add(string.Empty, nColWidth);
            m_lvActions.Columns.Add(KPRes.Action, nColWidth);
            m_lvActions.Columns.Add(string.Empty, nColWidth);

            m_tbName.Text = m_trigger.Name;
            UIUtil.SetMultilineText(m_tbComments, m_trigger.Comments);
            m_cbEnabled.Checked            = m_trigger.Enabled;
            m_cbInitiallyOn.Checked        = m_trigger.InitiallyOn;
            m_cbTurnOffAfterAction.Checked = m_trigger.TurnOffAfterAction;

            UIUtil.AccSetName(m_btnEventMoveUp, KPRes.MoveUp);
            UIUtil.AccSetName(m_btnEventMoveDown, KPRes.MoveDown);
            UIUtil.AccSetName(m_btnConditionMoveUp, KPRes.MoveUp);
            UIUtil.AccSetName(m_btnConditionMoveDown, KPRes.MoveDown);
            UIUtil.AccSetName(m_btnActionMoveUp, KPRes.MoveUp);
            UIUtil.AccSetName(m_btnActionMoveDown, KPRes.MoveDown);

            UpdateListsEx(false);
            EnableControlsEx();
            UIUtil.SetFocus(m_tbName, this);
        }
예제 #4
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_pwDatabase == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }
            if (m_pgStorage == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         KeePass.Properties.Resources.B48x48_Wizard, KPRes.TanWizard,
                                         KPRes.TanWizardDesc);

            this.Icon = AppIcons.Default;
            this.Text = KPRes.TanWizard;

            Debug.Assert(!m_lblToGroup.AutoSize);             // For RTL support
            if (!string.IsNullOrEmpty(m_pgStorage.Name))
            {
                m_lblToGroup.Text += ": " + StrUtil.EncodeMenuText(
                    m_pgStorage.Name) + ".";
            }
            else
            {
                m_lblToGroup.Text += ".";
            }

            m_tbTanChars.Text = Program.Config.Defaults.TanCharacters;

            UIUtil.AccSetName(m_numTANsIndex, m_cbNumberTans);

            EnableControlsEx();
        }
예제 #5
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_triggers == null)
            {
                Debug.Assert(false); return;
            }

            GlobalWindowManager.AddWindow(this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Make_KDevelop, KPRes.Triggers,
                                         KPRes.TriggersDesc);
            this.Text = KPRes.Triggers;
            this.Icon = AppIcons.Default;

            int nWidth = (m_lvTriggers.ClientSize.Width - UIUtil.GetVScrollBarWidth() - 1);

            m_lvTriggers.Columns.Add(KPRes.Triggers, nWidth);

            m_lvTriggers.SmallImageList = m_ilIcons;

            m_cbEnableTriggers.Checked = m_triggers.Enabled;
            UpdateTriggerListEx(false);

            EcasTriggerSystem ts    = Program.TriggerSystem;
            EcasTriggerSystem tsCfg = Program.Config.Application.TriggerSystem;

            if (object.ReferenceEquals(m_triggersInOut, ts) &&
                AppConfigEx.IsOptionEnforced(tsCfg, "Enabled"))
            {
                m_cbEnableTriggers.Enabled = false;
            }

            UIUtil.AccSetName(m_btnMoveUp, KPRes.MoveUp);
            UIUtil.AccSetName(m_btnMoveDown, KPRes.MoveDown);
        }
예제 #6
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if ((m_pbData == null) || (m_pwDatabase == null))
            {
                throw new InvalidOperationException();
            }

            m_bInitializing = true;

            GlobalWindowManager.AddWindow(this);

            // Callable from KPScript without parent form
            Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen);

            this.Icon = AppIcons.Default;
            this.Text = KPRes.GenericCsvImporter;

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Binary, KPRes.GenericCsvImporter,
                                         KPRes.CsvImportDesc);

            // FontUtil.AssignDefaultBold(m_grpSyntax);
            // FontUtil.AssignDefaultBold(m_grpSem);

            UIUtil.SetExplorerTheme(m_lvFields, false);
            UIUtil.SetExplorerTheme(m_lvImportPreview, false);

            foreach (StrEncodingInfo seiEnum in StrUtil.Encodings)
            {
                m_cmbEnc.Items.Add(seiEnum.Name);
            }

            StrEncodingInfo seiGuess = BinaryDataClassifier.GetStringEncoding(
                m_pbData, out m_uStartOffset);

            int iSel = 0;

            if (seiGuess != null)
            {
                iSel = Math.Max(m_cmbEnc.FindStringExact(seiGuess.Name), 0);
            }
            m_cmbEnc.SelectedIndex = iSel;

            string[] vChars = new string[] { ",", ";", ".", ":", "\"", @"'",
                                             StrCharTab, StrCharNewLine };
            foreach (string strChar in vChars)
            {
                m_cmbFieldSep.Items.Add(strChar);
                m_cmbRecSep.Items.Add(strChar);
                m_cmbTextQual.Items.Add(strChar);
            }
            m_cmbFieldSep.SelectedIndex = 0;
            m_cmbRecSep.SelectedIndex   = 7;
            m_cmbTextQual.SelectedIndex = 4;

            m_lvFields.Columns.Add(KPRes.Field);

            AddCsvField(CsvFieldType.Title, null, null);
            AddCsvField(CsvFieldType.UserName, null, null);
            AddCsvField(CsvFieldType.Password, null, null);
            AddCsvField(CsvFieldType.Url, null, null);
            AddCsvField(CsvFieldType.Notes, null, null);

            for (int i = (int)CsvFieldType.First; i < (int)CsvFieldType.Count; ++i)
            {
                m_cmbFieldType.Items.Add(CsvFieldToString((CsvFieldType)i));
            }
            m_cmbFieldType.SelectedIndex = (int)CsvFieldType.Group;

            m_cmbFieldFormat.Text = string.Empty;

            UIUtil.AccSetName(m_btnFieldMoveUp, KPRes.MoveUp);
            UIUtil.AccSetName(m_btnFieldMoveDown, KPRes.MoveDown);

            m_bInitializing = false;

            UpdateTextPreview();
            UpdateImportPreview();
            GuessCsvStructure();

            ProcessResize();
            EnableControlsEx();
        }
예제 #7
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_pwGroup == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }
            if (m_pwDatabase == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            string strTitle = (m_bCreatingNew ? KPRes.AddGroup : KPRes.EditGroup);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Folder_Txt, strTitle,
                                         (m_bCreatingNew ? KPRes.AddGroupDesc : KPRes.EditGroupDesc));
            this.Icon = AppIcons.Default;
            this.Text = strTitle;

            UIUtil.ConfigureToolTip(m_ttRect);
            UIUtil.SetToolTip(m_ttRect, m_btnIcon, KPRes.SelectIcon, true);
            UIUtil.SetToolTip(m_ttRect, m_btnAutoTypeEdit, KPRes.ConfigureKeystrokeSeq, true);

            UIUtil.AccSetName(m_dtExpires, m_cbExpires);
            UIUtil.AccSetName(m_tbDefaultAutoTypeSeq, m_rbAutoTypeOverride);

            m_tbName.Text = m_pwGroup.Name;

            m_pwIconIndex    = m_pwGroup.IconId;
            m_pwCustomIconID = m_pwGroup.CustomIconUuid;

            if (!m_pwCustomIconID.Equals(PwUuid.Zero))
            {
                UIUtil.SetButtonImage(m_btnIcon, DpiUtil.GetIcon(
                                          m_pwDatabase, m_pwCustomIconID), true);
            }
            else
            {
                UIUtil.SetButtonImage(m_btnIcon, m_ilClientIcons.Images[
                                          (int)m_pwIconIndex], true);
            }

            UIUtil.SetMultilineText(m_tbNotes, m_pwGroup.Notes);

            if (m_pwGroup.Expires)
            {
                m_dtExpires.Value   = TimeUtil.ToLocal(m_pwGroup.ExpiryTime, true);
                m_cbExpires.Checked = true;
            }
            else             // Does not expire
            {
                m_dtExpires.Value   = DateTime.Now.Date;
                m_cbExpires.Checked = false;
            }
            m_cgExpiry.Attach(m_cbExpires, m_dtExpires);

            TagUtil.MakeInheritedTagsLink(m_linkTagsInh, m_pwGroup.ParentGroup, this);
            m_tbTags.Text = StrUtil.TagsToString(m_pwGroup.Tags, true);
            TagUtil.MakeTagsButton(m_btnTags, m_tbTags, m_ttRect, m_pwGroup.ParentGroup,
                                   ((m_pwDatabase != null) ? m_pwDatabase.RootGroup : null));

            m_tbUuid.Text = m_pwGroup.Uuid.ToHexString() + ", " +
                            Convert.ToBase64String(m_pwGroup.Uuid.UuidBytes);

            PwGroup pgParent = m_pwGroup.ParentGroup;

            bool bParentSearching = ((pgParent != null) ?
                                     pgParent.GetSearchingEnabledInherited() :
                                     PwGroup.DefaultSearchingEnabled);

            UIUtil.MakeInheritableBoolComboBox(m_cmbEnableSearching,
                                               m_pwGroup.EnableSearching, bParentSearching);

            bool bParentAutoType = ((pgParent != null) ?
                                    pgParent.GetAutoTypeEnabledInherited() :
                                    PwGroup.DefaultAutoTypeEnabled);

            UIUtil.MakeInheritableBoolComboBox(m_cmbEnableAutoType,
                                               m_pwGroup.EnableAutoType, bParentAutoType);

            m_tbDefaultAutoTypeSeq.Text = m_pwGroup.GetAutoTypeSequenceInherited();

            if (m_pwGroup.DefaultAutoTypeSequence.Length == 0)
            {
                m_rbAutoTypeInherit.Checked = true;
            }
            else
            {
                m_rbAutoTypeOverride.Checked = true;
            }

            UIUtil.SetButtonImage(m_btnAutoTypeEdit,
                                  Properties.Resources.B16x16_Wizard, true);

            m_sdCustomData = m_pwGroup.CustomData.CloneDeep();
            UIUtil.StrDictListInit(m_lvCustomData);
            UIUtil.StrDictListUpdate(m_lvCustomData, m_sdCustomData, false);

            EnableControlsEx();

            ThreadPool.QueueUserWorkItem(delegate(object state)
            {
                try
                {
                    string[] vSeq = m_pwDatabase.RootGroup.GetAutoTypeSequences(true);
                    // Do not append, because long suggestions hide the start
                    UIUtil.EnableAutoCompletion(m_tbDefaultAutoTypeSeq,
                                                false, vSeq); // Invokes
                }
                catch (Exception) { Debug.Assert(false); }
            });

            UIUtil.SetFocus(m_tbName, this);

            switch (m_gftInit)
            {
            case GroupFormTab.Properties:
                m_tabMain.SelectedTab = m_tabProperties; break;

            case GroupFormTab.AutoType:
                m_tabMain.SelectedTab = m_tabAutoType; break;

            case GroupFormTab.CustomData:
                m_tabMain.SelectedTab = m_tabCustomData; break;

            default: break;
            }
        }
예제 #8
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            // The password text box should not be focused by default
            // in order to avoid a Caps Lock warning tooltip bug;
            // https://sourceforge.net/p/keepass/bugs/1807/
            Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused);

            GlobalWindowManager.AddWindow(this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_KGPG_Sign, KPRes.CreateMasterKey,
                                         m_ioInfo.GetDisplayName());
            this.Icon = AppIcons.Default;
            this.Text = KPRes.CreateMasterKey;

            FontUtil.SetDefaultFont(m_cbPassword);
            FontUtil.AssignDefaultBold(m_cbPassword);
            FontUtil.AssignDefaultBold(m_cbKeyFile);
            FontUtil.AssignDefaultBold(m_cbUserAccount);

            m_imgKeyFileWarning = UIUtil.IconToBitmap(SystemIcons.Warning,
                                                      DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));
            m_imgAccWarning           = (Image)m_imgKeyFileWarning.Clone();
            m_picKeyFileWarning.Image = m_imgKeyFileWarning;
            m_picAccWarning.Image     = m_imgAccWarning;

            UIUtil.ConfigureToolTip(m_ttRect);
            UIUtil.SetToolTip(m_ttRect, m_tbRepeatPassword, KPRes.PasswordRepeatHint, false);
            UIUtil.SetToolTip(m_ttRect, m_btnSaveKeyFile, KPRes.KeyFileCreate, false);
            UIUtil.SetToolTip(m_ttRect, m_btnOpenKeyFile, KPRes.KeyFileUseExisting, false);

            UIUtil.AccSetName(m_tbPassword, m_cbPassword);
            UIUtil.AccSetName(m_cmbKeyFile, m_cbKeyFile);
            UIUtil.AccSetName(m_picKeyFileWarning, KPRes.Warning);
            UIUtil.AccSetName(m_picAccWarning, KPRes.Warning);

            Debug.Assert(!m_lblIntro.AutoSize);             // For RTL support
            if (!m_bCreatingNew)
            {
                m_lblIntro.Text = KPRes.ChangeMasterKeyIntroShort;
            }

            m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblRepeatPassword,
                                 m_tbRepeatPassword, m_lblEstimatedQuality, m_pbPasswordQuality,
                                 m_lblQualityInfo, m_ttRect, this, true, false);

            m_cmbKeyFile.Items.Add(KPRes.NoKeyFileSpecifiedMeta);
            foreach (KeyProvider prov in Program.KeyProviderPool)
            {
                m_cmbKeyFile.Items.Add(prov.Name);
            }

            m_cmbKeyFile.SelectedIndex = 0;

            m_cbPassword.Checked = true;
            UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyCreationFlags,
                                   m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword);

            if (WinUtil.IsWindows9x || NativeLib.IsUnix())
            {
                UIUtil.SetChecked(m_cbUserAccount, false);
                UIUtil.SetEnabled(m_cbUserAccount, false);
                UIUtil.SetEnabled(m_lblWindowsAccDesc, false);
                UIUtil.SetEnabled(m_lblWindowsAccDesc2, false);
            }

            EnableUserControls();
            // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown
        }
예제 #9
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_pgRoot == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            string strTitle = KPRes.SearchTitle;
            string strDesc  = KPRes.SearchDesc2;

            if ((m_pgRoot.ParentGroup != null) && !string.IsNullOrEmpty(m_pgRoot.Name))
            {
                strTitle += " (" + KPRes.SelectedGroup + ")";
                strDesc   = KPRes.Group + ": '" + m_pgRoot.Name + "'.";
            }

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_XMag, strTitle, strDesc);
            this.Icon = AppIcons.Default;
            this.Text = KPRes.SearchTitle;

            UIUtil.SetButtonImage(m_btnProfileAdd,
                                  Properties.Resources.B16x16_FileSaveAs, false);
            UIUtil.SetButtonImage(m_btnProfileDelete,
                                  Properties.Resources.B16x16_EditDelete, true);

            UIUtil.SetText(m_cbDerefData, m_cbDerefData.Text + " (" + KPRes.Slow + ")");

            UIUtil.ConfigureToolTip(m_ttMain);
            UIUtil.SetToolTip(m_ttMain, m_btnProfileAdd, KPRes.ProfileSaveDesc, false);
            UIUtil.SetToolTip(m_ttMain, m_btnProfileDelete, KPRes.ProfileDeleteDesc, false);

            UIUtil.AccSetName(m_btnProfileAdd, KPRes.ProfileSave);
            UIUtil.AccSetName(m_btnProfileDelete, KPRes.ProfileDelete);

            SearchParameters sp = (!string.IsNullOrEmpty(m_strInitProfile) ?
                                   Program.Config.Search.FindProfile(m_strInitProfile) : null);

            Debug.Assert(string.IsNullOrEmpty(m_strInitProfile) || (sp != null));
            UpdateProfilesList((sp != null) ? sp.Name : ProfileCustom);
            SetSearchParameters(sp ?? Program.Config.Search.LastUsedProfile);

            m_tbSearch.TextChanged         += this.OnProfilePropertyChanged;
            m_rbModeSimple.CheckedChanged  += this.OnProfilePropertyChanged;
            m_rbModeRegular.CheckedChanged += this.OnProfilePropertyChanged;
            m_rbModeXPath.CheckedChanged   += this.OnProfilePropertyChanged;

            CheckBox[] v = new CheckBox[] {
                m_cbTitle, m_cbUserName, m_cbPassword, m_cbUrl, m_cbNotes,
                m_cbStringsOther, m_cbStringName, m_cbTags, m_cbUuid,
                m_cbGroupPath, m_cbGroupName, m_cbHistory,
                m_cbCaseSensitive, m_cbExcludeExpired, m_cbIgnoreGroupSettings,
                m_cbDerefData
            };
            foreach (CheckBox cb in v)
            {
                cb.CheckedChanged += this.OnProfilePropertyChanged;
            }

            UpdateUIState();
            m_tbSearch.SelectAll();
        }
예제 #10
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            m_bInitializing = true;

            // The password text box should not be focused by default
            // in order to avoid a Caps Lock warning tooltip bug;
            // https://sourceforge.net/p/keepass/bugs/1807/
            Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused);

            GlobalWindowManager.AddWindow(this);
            // if(m_bRedirectActivation) Program.MainForm.RedirectActivationPush(this);

            string strBannerTitle = (!string.IsNullOrEmpty(m_strCustomTitle) ?
                                     m_strCustomTitle : KPRes.EnterCompositeKey);
            string strBannerDesc = m_ioInfo.GetDisplayName();             // Compacted by banner

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_KGPG_Key2, strBannerTitle, strBannerDesc);
            this.Icon = AppIcons.Default;

            FontUtil.SetDefaultFont(m_cbPassword);
            FontUtil.AssignDefaultBold(m_cbPassword);
            FontUtil.AssignDefaultBold(m_cbKeyFile);
            FontUtil.AssignDefaultBold(m_cbUserAccount);

            UIUtil.ConfigureToolTip(m_ttRect);
            UIUtil.SetToolTip(m_ttRect, m_btnOpenKeyFile, KPRes.KeyFileSelect, true);

            UIUtil.AccSetName(m_tbPassword, m_cbPassword);
            UIUtil.AccSetName(m_cmbKeyFile, m_cbKeyFile);

            PwInputControlGroup.ConfigureHideButton(m_cbHidePassword, m_ttRect);

            string strStart = (!string.IsNullOrEmpty(m_strCustomTitle) ?
                               m_strCustomTitle : KPRes.OpenDatabase);
            string strNameEx = UrlUtil.GetFileName(m_ioInfo.Path);

            if (!string.IsNullOrEmpty(strNameEx))
            {
                this.Text = strStart + " - " + strNameEx;
            }
            else
            {
                this.Text = strStart;
            }

            // Must be set manually due to possible object override
            m_tbPassword.TextChanged += this.ProcessTextChangedPassword;

            // m_cmbKeyFile.OrderedImageList = m_lKeyFileImages;
            AddKeyFileSuggPriv(KPRes.NoKeyFileSpecifiedMeta, true);

            // Enable protection before possibly setting a text
            m_cbHidePassword.Checked = true;
            OnCheckedHidePassword(sender, e);             // 'Checked' may have been true already

            // Do not directly compare with Program.CommandLineArgs.FileName,
            // because this may be a relative path instead of an absolute one
            string strCmdLineFile = Program.CommandLineArgs.FileName;

            if ((strCmdLineFile != null) && (Program.MainForm != null))
            {
                strCmdLineFile = Program.MainForm.IocFromCommandLine().Path;
            }
            if ((strCmdLineFile != null) && strCmdLineFile.Equals(m_ioInfo.Path,
                                                                  StrUtil.CaseIgnoreCmp))
            {
                string str;

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.Password];
                if (str != null)
                {
                    m_cbPassword.Checked = true;
                    m_tbPassword.Text    = str;
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordEncrypted];
                if (str != null)
                {
                    m_cbPassword.Checked = true;
                    m_tbPassword.Text    = StrUtil.DecryptString(str);
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordStdIn];
                if (str != null)
                {
                    ProtectedString ps = KeyUtil.ReadPasswordStdIn(true);
                    if (ps != null)
                    {
                        m_cbPassword.Checked = true;
                        m_tbPassword.TextEx  = ps;
                    }
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.KeyFile];
                if (str != null)
                {
                    m_cbKeyFile.Checked = true;
                    AddKeyFileSuggPriv(str, true);
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PreSelect];
                if (str != null)
                {
                    m_cbKeyFile.Checked = true;
                    AddKeyFileSuggPriv(str, true);
                }
            }

            Debug.Assert(m_cmbKeyFile.Text.Length != 0);

            m_btnExit.Enabled = m_bCanExit;
            m_btnExit.Visible = m_bCanExit;

            ulong uKpf = Program.Config.UI.KeyPromptFlags;

            UIUtil.ApplyKeyUIFlags(uKpf, m_cbPassword, m_cbKeyFile,
                                   m_cbUserAccount, m_cbHidePassword);

            if ((uKpf & (ulong)AceKeyUIFlags.DisableKeyFile) != 0)
            {
                UIUtil.SetEnabled(m_cmbKeyFile, m_cbKeyFile.Checked);
                UIUtil.SetEnabled(m_btnOpenKeyFile, m_cbKeyFile.Checked);
            }

            if (((uKpf & (ulong)AceKeyUIFlags.CheckPassword) != 0) ||
                ((uKpf & (ulong)AceKeyUIFlags.UncheckPassword) != 0))
            {
                m_bPwStatePreset = true;
            }
            if (((uKpf & (ulong)AceKeyUIFlags.CheckUserAccount) != 0) ||
                ((uKpf & (ulong)AceKeyUIFlags.UncheckUserAccount) != 0))
            {
                m_bUaStatePreset = true;
            }

            EnableUserControls();

            m_bInitializing = false;

            // E.g. command line options have higher priority
            m_bCanModKeyFile = (m_cmbKeyFile.SelectedIndex == 0);

            m_aKeyAssoc = Program.Config.Defaults.GetKeySources(m_ioInfo);
            if (m_aKeyAssoc != null)
            {
                if (m_aKeyAssoc.Password && !m_bPwStatePreset)
                {
                    m_cbPassword.Checked = true;
                }

                if (m_aKeyAssoc.KeyFilePath.Length > 0)
                {
                    AddKeyFileSuggPriv(m_aKeyAssoc.KeyFilePath, null);
                }

                if (m_aKeyAssoc.UserAccount && !m_bUaStatePreset)
                {
                    m_cbUserAccount.Checked = true;
                }
            }

            foreach (KeyProvider prov in Program.KeyProviderPool)
            {
                AddKeyFileSuggPriv(prov.Name, null);
            }

            // Local, but thread will continue to run anyway
            Thread th = new Thread(new ThreadStart(this.AsyncFormLoad));

            th.Start();
            // ThreadPool.QueueUserWorkItem(new WaitCallback(this.AsyncFormLoad));

            this.BringToFront();
            this.Activate();
            // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown
        }
예제 #11
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            // Can be invoked by tray command; don't use CenterParent
            Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen);

            ++m_uBlockUIUpdate;

            GlobalWindowManager.AddWindow(this);

            m_strAdvControlText = m_tabAdvanced.Text;

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_KGPG_Gen, KPRes.PasswordOptions,
                                         KPRes.PasswordOptionsDesc);
            this.Icon = AppIcons.Default;

            UIUtil.SetButtonImage(m_btnProfileAdd,
                                  Properties.Resources.B16x16_FileSaveAs, false);
            UIUtil.SetButtonImage(m_btnProfileRemove,
                                  Properties.Resources.B16x16_EditDelete, true);

            FontUtil.AssignDefaultBold(m_rbStandardCharSet);
            FontUtil.AssignDefaultBold(m_rbPattern);
            FontUtil.AssignDefaultBold(m_rbCustom);
            FontUtil.AssignDefaultMono(m_tbPreview, true);

            UIUtil.ConfigureToolTip(m_ttMain);
            UIUtil.SetToolTip(m_ttMain, m_btnProfileAdd, KPRes.ProfileSaveDesc, false);
            UIUtil.SetToolTip(m_ttMain, m_btnProfileRemove, KPRes.ProfileDeleteDesc, false);
            UIUtil.SetToolTip(m_ttMain, m_btnCustomOpt, KPRes.Options, true);

            UIUtil.AccSetName(m_btnProfileAdd, KPRes.ProfileSave);
            UIUtil.AccSetName(m_btnProfileRemove, KPRes.ProfileDelete);

            using (RtlAwareResizeScope r = new RtlAwareResizeScope(
                       m_cbUpperCase, m_cbLowerCase, m_cbDigits, m_cbMinus,
                       m_cbUnderline, m_cbSpace, m_cbSpecial, m_cbBrackets,
                       m_cbLatin1S, m_cbNoRepeat, m_cbExcludeLookAlike,
                       m_lblExcludeChars, m_lblSecRedInfo))
            {
                m_cbUpperCase.Text        += " (A, B, C, ...)";
                m_cbLowerCase.Text        += " (a, b, c, ...)";
                m_cbDigits.Text           += " (0, 1, 2, ...)";
                m_cbMinus.Text            += " (-)";
                m_cbUnderline.Text        += " (_)";
                m_cbSpace.Text            += " ( )";
                m_cbSpecial.Text          += @" (!, $, %, &&, ...)";
                m_cbBrackets.Text         += @" ([, ], {, }, (, ), <, >)";
                m_cbLatin1S.Text          += " (\u00C4, \u00B5, \u00B6, ...)";
                m_cbNoRepeat.Text         += " *";
                m_cbExcludeLookAlike.Text += " (l|1I, O0) *";
                m_lblExcludeChars.Text    += " *";
                m_lblSecRedInfo.Text       = "* " + m_lblSecRedInfo.Text;
            }

            SetCharSetTT(m_cbUpperCase, PwCharSet.UpperCase, 2);
            SetCharSetTT(m_cbLowerCase, PwCharSet.LowerCase, 2);
            SetCharSetTT(m_cbDigits, PwCharSet.Digits, 2);
            SetCharSetTT(m_cbSpecial, PwCharSet.Special, 2);
            SetCharSetTT(m_cbLatin1S, PwCharSet.Latin1S, 4);

            m_cmbCustomAlgo.Items.Add(NoCustomAlgo);
            foreach (CustomPwGenerator pwg in Program.PwGeneratorPool)
            {
                m_cmbCustomAlgo.Items.Add(pwg.Name);
            }
            SelectCustomGenerator((m_optInitial != null) ?
                                  m_optInitial.CustomAlgorithmUuid : null, null);
            if (m_optInitial != null)
            {
                CustomPwGenerator pwg = GetPwGenerator();
                if (pwg != null)
                {
                    m_dictCustomOptions[pwg] = m_optInitial.CustomAlgorithmOptions;
                }
            }

            m_cmbProfiles.Items.Add(CustomMeta);

            if (m_optInitial != null)
            {
                m_cmbProfiles.Items.Add(DeriveFromPrevious);
                SetGenerationOptions(m_optInitial);
            }

            m_rbStandardCharSet.CheckedChanged   += this.UpdateUIProc;
            m_rbPattern.CheckedChanged           += this.UpdateUIProc;
            m_rbCustom.CheckedChanged            += this.UpdateUIProc;
            m_numGenChars.ValueChanged           += this.UpdateUIProc;
            m_cbUpperCase.CheckedChanged         += this.UpdateUIProc;
            m_cbLowerCase.CheckedChanged         += this.UpdateUIProc;
            m_cbDigits.CheckedChanged            += this.UpdateUIProc;
            m_cbMinus.CheckedChanged             += this.UpdateUIProc;
            m_cbUnderline.CheckedChanged         += this.UpdateUIProc;
            m_cbSpace.CheckedChanged             += this.UpdateUIProc;
            m_cbSpecial.CheckedChanged           += this.UpdateUIProc;
            m_cbBrackets.CheckedChanged          += this.UpdateUIProc;
            m_cbLatin1S.CheckedChanged           += this.UpdateUIProc;
            m_tbCustomChars.TextChanged          += this.UpdateUIProc;
            m_tbPattern.TextChanged              += this.UpdateUIProc;
            m_cbPatternPermute.CheckedChanged    += this.UpdateUIProc;
            m_cbNoRepeat.CheckedChanged          += this.UpdateUIProc;
            m_cbExcludeLookAlike.CheckedChanged  += this.UpdateUIProc;
            m_tbExcludeChars.TextChanged         += this.UpdateUIProc;
            m_cmbCustomAlgo.SelectedIndexChanged += this.UpdateUIProc;

            m_cmbProfiles.Items.Add(AutoGeneratedMeta);

            m_cmbProfiles.SelectedIndex = ((m_optInitial == null) ? 0 : 1);

            foreach (PwProfile ppw in PwGeneratorUtil.GetAllProfiles(true))
            {
                m_cmbProfiles.Items.Add(ppw.Name);

                if ((ppw.GeneratorType == PasswordGeneratorType.Custom) &&
                    !string.IsNullOrEmpty(ppw.CustomAlgorithmUuid))
                {
                    CustomPwGenerator pwg = Program.PwGeneratorPool.Find(new
                                                                         PwUuid(Convert.FromBase64String(ppw.CustomAlgorithmUuid)));
                    if (pwg != null)
                    {
                        m_dictCustomOptions[pwg] = ppw.CustomAlgorithmOptions;
                    }
                }
            }

            if (m_optInitial == null)
            {
                // int nIndex = m_cmbProfiles.FindString(Program.Config.PasswordGenerator.LastUsedProfile.Name);
                // if(nIndex >= 0) m_cmbProfiles.SelectedIndex = nIndex;
                SetGenerationOptions(Program.Config.PasswordGenerator.LastUsedProfile);
            }

            if (!m_bCanAccept)
            {
                m_btnOK.Visible  = false;
                m_btnCancel.Text = KPRes.Close;

                m_tabPreview.Text    = KPRes.Generate;
                m_lblPreview.Visible = false;
                UIUtil.SetChecked(m_cbEntropy, false);
                m_cbEntropy.Enabled = false;
            }

            // Debug.Assert(this.ShowInTaskbar == false);
            // if(m_bForceInTaskbar) this.ShowInTaskbar = true;

            --m_uBlockUIUpdate;
            EnableControlsEx(false);
        }
예제 #12
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            Debug.Assert(m_pwDatabase != null); if (m_pwDatabase == null)
            {
                throw new InvalidOperationException();
            }

            m_bInitializing = true;

            GlobalWindowManager.AddWindow(this);

            IOConnectionInfo ioc     = m_pwDatabase.IOConnectionInfo;
            string           strDisp = ioc.GetDisplayName();

            string strDesc = KPRes.DatabaseSettingsDesc;

            if (!string.IsNullOrEmpty(strDisp))
            {
                strDesc = strDisp;
            }

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Ark, KPRes.DatabaseSettings, strDesc);
            this.Icon = AppIcons.Default;

            FontUtil.AssignDefaultItalic(m_lblHeaderCpAlgo);
            FontUtil.AssignDefaultItalic(m_lblHeaderCp);
            FontUtil.AssignDefaultItalic(m_lblHeaderPerf);

            FontUtil.AssignDefaultBold(m_rbNone);
            FontUtil.AssignDefaultBold(m_rbGZip);

            UIUtil.ConfigureToolTip(m_ttRect);
            UIUtil.SetToolTip(m_ttRect, m_btnKdf1Sec, KPRes.KdfParams1Sec, false);

            UIUtil.AccSetName(m_btnColor, KPRes.SelectColor);
            UIUtil.AccSetName(m_numHistoryMaxItems, m_cbHistoryMaxItems);
            UIUtil.AccSetName(m_numHistoryMaxSize, m_cbHistoryMaxSize);
            UIUtil.AccSetName(m_numKeyRecDays, m_cbKeyRec);
            UIUtil.AccSetName(m_numKeyForceDays, m_cbKeyForce);

            m_tbDbName.PromptText = KPRes.DatabaseNamePrompt;
            m_tbDbDesc.PromptText = KPRes.DatabaseDescPrompt;

            if (m_bCreatingNew)
            {
                this.Text = KPRes.ConfigureOnNewDatabase3;
            }
            else
            {
                this.Text = KPRes.DatabaseSettings;
            }

            m_tbDbName.Text = m_pwDatabase.Name;
            UIUtil.SetMultilineText(m_tbDbDesc, m_pwDatabase.Description);
            m_tbDefaultUser.Text = m_pwDatabase.DefaultUserName;

            m_clr = m_pwDatabase.Color;
            bool bClr = !UIUtil.ColorsEqual(m_clr, Color.Empty);

            if (bClr)
            {
                m_clr = AppIcons.RoundColor(m_clr);
                UIUtil.OverwriteButtonImage(m_btnColor, ref m_imgColor,
                                            UIUtil.CreateColorBitmap24(m_btnColor, m_clr));
            }
            m_cbColor.Checked = bClr;

            for (int inx = 0; inx < CipherPool.GlobalPool.EngineCount; ++inx)
            {
                m_cmbEncAlgo.Items.Add(CipherPool.GlobalPool[inx].DisplayName);
            }

            if (m_cmbEncAlgo.Items.Count > 0)
            {
                int nIndex = CipherPool.GlobalPool.GetCipherIndex(m_pwDatabase.DataCipherUuid);
                m_cmbEncAlgo.SelectedIndex = ((nIndex >= 0) ? nIndex : 0);
            }

            Debug.Assert(m_cmbKdf.Items.Count == 0);
            foreach (KdfEngine kdf in KdfPool.Engines)
            {
                m_cmbKdf.Items.Add(kdf.Name);
            }

            m_numKdfIt.Minimum = ulong.MinValue;
            m_numKdfIt.Maximum = ulong.MaxValue;

            m_numKdfMem.Minimum = ulong.MinValue;
            m_numKdfMem.Maximum = ulong.MaxValue;

            Debug.Assert(m_cmbKdfMem.Items.Count == 0);
            Debug.Assert(!m_cmbKdfMem.Sorted);
            m_cmbKdfMem.Items.Add("B");
            m_cmbKdfMem.Items.Add("KB");
            m_cmbKdfMem.Items.Add("MB");
            m_cmbKdfMem.Items.Add("GB");

            m_numKdfPar.Minimum = uint.MinValue;
            m_numKdfPar.Maximum = uint.MaxValue;

            SetKdfParameters(m_pwDatabase.KdfParameters);

            // m_lbMemProt.Items.Add(KPRes.Title, m_pwDatabase.MemoryProtection.ProtectTitle);
            // m_lbMemProt.Items.Add(KPRes.UserName, m_pwDatabase.MemoryProtection.ProtectUserName);
            // m_lbMemProt.Items.Add(KPRes.Password, m_pwDatabase.MemoryProtection.ProtectPassword);
            // m_lbMemProt.Items.Add(KPRes.Url, m_pwDatabase.MemoryProtection.ProtectUrl);
            // m_lbMemProt.Items.Add(KPRes.Notes, m_pwDatabase.MemoryProtection.ProtectNotes);

            // m_cbAutoEnableHiding.Checked = m_pwDatabase.MemoryProtection.AutoEnableVisualHiding;
            // m_cbAutoEnableHiding.Checked = false;

            if (m_pwDatabase.Compression == PwCompressionAlgorithm.None)
            {
                m_rbNone.Checked = true;
            }
            else if (m_pwDatabase.Compression == PwCompressionAlgorithm.GZip)
            {
                m_rbGZip.Checked = true;
            }
            else
            {
                Debug.Assert(false);
            }

            InitRecycleBinTab();
            InitAdvancedTab();

            m_bInitializing = false;
            EnableControlsEx();
            UIUtil.SetFocus(m_tbDbName, this);
        }
예제 #13
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            ++m_uUIAutoBlocked;

            // The password text box should not be focused by default
            // in order to avoid a Caps Lock warning tooltip bug;
            // https://sourceforge.net/p/keepass/bugs/1807/
            Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused);

            GlobalWindowManager.AddWindow(this);
            // if(m_bRedirectActivation) Program.MainForm.RedirectActivationPush(this);

            string strBannerTitle = (!string.IsNullOrEmpty(m_strCustomTitle) ?
                                     m_strCustomTitle : KPRes.EnterCompositeKey);
            string strBannerDesc = m_ioInfo.GetDisplayName();             // Compacted by banner

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_KGPG_Key2, strBannerTitle, strBannerDesc);
            this.Icon = AppIcons.Default;

            string strStart = (!string.IsNullOrEmpty(m_strCustomTitle) ?
                               m_strCustomTitle : KPRes.OpenDatabase);
            string strName = UrlUtil.GetFileName(m_ioInfo.Path);

            if (!string.IsNullOrEmpty(strName))
            {
                this.Text = strStart + " - " + strName;
            }
            else
            {
                this.Text = strStart;
            }

            FontUtil.SetDefaultFont(m_cbPassword);
            // FontUtil.AssignDefaultBold(m_cbPassword);
            // FontUtil.AssignDefaultBold(m_cbKeyFile);
            // FontUtil.AssignDefaultBold(m_cbUserAccount);

            UIUtil.ConfigureToolTip(m_ttRect);
            UIUtil.SetToolTip(m_ttRect, m_btnOpenKeyFile, KPRes.KeyFileSelect, true);

            UIUtil.AccSetName(m_tbPassword, m_cbPassword);
            UIUtil.AccSetName(m_cmbKeyFile, m_cbKeyFile);

            PwInputControlGroup.ConfigureHideButton(m_cbHidePassword, m_ttRect);

            // Enable protection before possibly setting a text
            m_cbHidePassword.Checked = true;
            OnHidePasswordCheckedChanged(null, EventArgs.Empty);

            // Must be set manually due to possible object override
            m_tbPassword.TextChanged += this.OnPasswordTextChanged;

            // m_cmbKeyFile.OrderedImageList = m_lKeyFileImages;
            AddKeyFileItem(KPRes.NoKeyFileSpecifiedMeta, true);

            Debug.Assert(!AnyComponentOn());

            // Do not directly compare with Program.CommandLineArgs.FileName,
            // because this may be a relative path instead of an absolute one
            string strCmdLineFile = Program.CommandLineArgs.FileName;

            if (!string.IsNullOrEmpty(strCmdLineFile) && (Program.MainForm != null))
            {
                strCmdLineFile = Program.MainForm.IocFromCommandLine().Path;
            }
            if (!string.IsNullOrEmpty(strCmdLineFile) && strCmdLineFile.Equals(
                    m_ioInfo.Path, StrUtil.CaseIgnoreCmp))
            {
                string str;

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.Password];
                if (str != null)
                {
                    m_cbPassword.Checked = true;
                    m_tbPassword.Text    = str;
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordEncrypted];
                if (str != null)
                {
                    m_cbPassword.Checked = true;
                    m_tbPassword.Text    = StrUtil.DecryptString(str);
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordStdIn];
                if (str != null)
                {
                    ProtectedString ps = KeyUtil.ReadPasswordStdIn(true);
                    if (ps != null)
                    {
                        m_cbPassword.Checked = true;
                        m_tbPassword.TextEx  = ps;
                    }
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.KeyFile];
                if (!string.IsNullOrEmpty(str))
                {
                    AddKeyFileItem(str, true);
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PreSelect];
                if (!string.IsNullOrEmpty(str))
                {
                    AddKeyFileItem(str, true);
                }

                str = Program.CommandLineArgs[AppDefs.CommandLineOptions.UserAccount];
                if (str != null)
                {
                    m_cbUserAccount.Checked = true;
                }
            }

            AceKeyAssoc a = Program.Config.Defaults.GetKeySources(m_ioInfo);

            if ((a != null) && !AnyComponentOn())
            {
                if (a.Password)
                {
                    m_cbPassword.Checked = true;
                }

                if (!string.IsNullOrEmpty(a.KeyFilePath))
                {
                    AddKeyFileItem(a.KeyFilePath, true);
                }
                if (!string.IsNullOrEmpty(a.KeyProvider))
                {
                    AddKeyFileItem(a.KeyProvider, true);
                }

                if (a.UserAccount)
                {
                    m_cbUserAccount.Checked = true;
                }
            }

            foreach (KeyProvider kp in Program.KeyProviderPool)
            {
                AddKeyFileItem(kp.Name, false);
            }

            UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyPromptFlags,
                                   m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword);

            if (!m_cbPassword.Enabled && !m_cbPassword.Checked)
            {
                m_tbPassword.Text = string.Empty;
                UIUtil.SetEnabledFast(false, m_tbPassword, m_cbHidePassword);
            }

            if (!m_cbKeyFile.Enabled && !m_cbKeyFile.Checked)
            {
                UIUtil.SetEnabledFast(false, m_cmbKeyFile, m_btnOpenKeyFile);
            }

            if (WinUtil.IsWindows9x || NativeLib.IsUnix())
            {
                UIUtil.SetChecked(m_cbUserAccount, false);
                UIUtil.SetEnabled(m_cbUserAccount, false);
            }

            m_btnExit.Enabled = m_bCanExit;
            m_btnExit.Visible = m_bCanExit;

            --m_uUIAutoBlocked;
            UpdateUIState();

            // Local, but thread will continue to run anyway
            Thread th = new Thread(new ThreadStart(this.OnFormLoadAsync));

            th.Start();
            // ThreadPool.QueueUserWorkItem(new WaitCallback(this.OnFormLoadAsync));

            this.BringToFront();
            this.Activate();
            // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown
        }