Exemplo n.º 1
0
        private static KeePassLib.Translation.KPFormCustomization ReadKPFormCustomization(XmlReader xr)
        {
            KeePassLib.Translation.KPFormCustomization o = new KeePassLib.Translation.KPFormCustomization();

            while(xr.MoveToNextAttribute())
            {
                switch(xr.LocalName)
                {
                    case "FullName":
                        o.FullName = xr.Value;
                        break;
                    default:
                        Debug.Assert(false);
                        break;
                }
            }

            if(SkipEmptyElement(xr)) return o;

            Debug.Assert(xr.NodeType == XmlNodeType.Element);
            xr.ReadStartElement();
            xr.MoveToContent();

            while(true)
            {
                XmlNodeType nt = xr.NodeType;
                if((nt == XmlNodeType.EndElement) || (nt == XmlNodeType.None)) break;
                if(nt != XmlNodeType.Element) { Debug.Assert(false); continue; }

                switch(xr.LocalName)
                {
                    case "Window":
                        o.Window = ReadKPControlCustomization(xr);
                        break;
                    case "ChildControls":
                        o.Controls = ReadListOfKPControlCustomization(xr);
                        break;
                    default:
                        Debug.Assert(false);
                        xr.Skip();
                        break;
                }

                xr.MoveToContent();
            }

            Debug.Assert(xr.NodeType == XmlNodeType.EndElement);
            xr.ReadEndElement();
            return o;
        }
Exemplo n.º 2
0
        public void Init(PCAInitData pcadata, Action <object, CancelEventArgs> eProfilesOpening)
        {
            #region Translations
            Text = PluginTranslate.PluginName;
            tbURL2.PromptText     = PluginTranslate.URL2Hint;
            gPasswords.Text       = PluginTranslate.ChangePassword;;
            lOldPassword.Text     = PluginTranslate.OldPW;
            lNewPassword.Text     = PluginTranslate.NewPW;
            bCancel.Text          = KPRes.Cancel;
            bChangePassword.Text  = PluginTranslate.ButtonChangePW;
            bOldPasswordCopy.Text = bNewPasswordCopy.Text = KPRes.Copy;
            bSequence.Text        = bOldPasswordType.Text = bNewPasswordType.Text = KPRes.AutoType;
            gSequence.Text        = PluginTranslate.PCASequence;
            bSequenceEdit.Text    = KPRes.EditCmd;
            bSequenceEdit.Width   = bNewPasswordCopy.Width = bOldPasswordCopy.Width = Math.Max(bNewPasswordCopy.Width, bSequenceEdit.Width);
            bSequence.Left        = bOldPasswordType.Left = bNewPasswordType.Left = bOldPasswordCopy.Left + bOldPasswordCopy.Width + 10;
            KeePassLib.Translation.KPFormCustomization kpfc = Program.Translation.Forms.Find(x => x.FullName == typeof(PwEntryForm).FullName);
            if (kpfc != null)
            {
                kpfc.ApplyTo(this);
                m_cbExpires.Text         = StrUtil.RemoveAccelerator(m_cbExpires.Text);
                m_lblPasswordRepeat.Text = StrUtil.RemoveAccelerator(m_lblPasswordRepeat.Text);
                m_lblQuality.Text        = StrUtil.RemoveAccelerator(m_lblQuality.Text);
            }
            if (!m_lblQuality.Text.EndsWith(":"))
            {
                m_lblQuality.Text += ":";
            }
            #endregion

            m_OnProfilesOpening = eProfilesOpening;
            m_pcadata           = pcadata;

            m_peCtxEntry         = new PwEntry(true, true);
            m_peCtxEntry.Strings = m_pcadata.Strings;

            InitSequences();
            rtbSequence.Text = m_pcadata.PCASequence;

            #region Handle SecureTextBoxEx
            SecureTextBoxEx.InitEx(ref tbPasswordOld);
            SecureTextBoxEx.InitEx(ref tbPasswordNew);
            SecureTextBoxEx.InitEx(ref tbPasswordNewRepeat);

            tbPasswordOld.TextEx   = pcadata.OldPassword;
            tbPasswordOld.ReadOnly = true;

            ToolTip ttPwGen = new ToolTip();
            #endregion

            SprEngine.FilterPlaceholderHints.Add(Config.PlaceholderOldPW);
            SprEngine.FilterPlaceholderHints.Add(Config.PlaceholderNewPW);

            #region password profile button - context menu, integration of PasswordProfileSync, ...
            ttPwGen.SetToolTip(GeneratePW, KPRes.GeneratePassword);
            GeneratePW.Image = UIUtil.CreateDropDownImage(Config.ScaleImage((Image)Program.Resources.GetObject("B16x16_Key_New")));

            bChangePassword.Image = Config.ScaleImage(Resources.pca);

            //Password profile dropdown
            UpdateProfilesContextMenu();
            #endregion

            Program.Translation.ApplyTo("KeePass.Forms.PwEntryForm.m_ctxDefaultTimes", m_ctxDefaultTimes.Items);
            bExpiry.Image = UIUtil.CreateDropDownImage(Config.ScaleImage((Image)Program.Resources.GetObject("B16x16_History")));
            InitExpiryDate();

            #region Show entry title - shortened if required
            string title = m_pcadata.Title;
            string user = m_pcadata.User;
            bool   titleShortened = false, userShortened = false;
            while ((title.Length + user.Length) > 60)
            {
                if (title.Length > 30)
                {
                    title          = title.Substring(0, title.Length - 1);
                    titleShortened = true;
                }
                else
                {
                    user          = user.Substring(0, user.Length - 1);
                    userShortened = true;
                }
            }
            if (titleShortened)
            {
                title += "...";
            }
            if (userShortened)
            {
                user += "...";
            }
            if (string.IsNullOrEmpty(user))
            {
                lEntry.Text = string.Format(PluginTranslate.EntryInfoNoUsername, KPRes.Entry, title);
            }
            else
            {
                lEntry.Text = string.Format(PluginTranslate.EntryInfo, KPRes.Entry, title, user);
            }
            #endregion

            Tools.GlobalWindowManager(this);
        }