Exemplo n.º 1
0
 // passing
 public void SelectPasswordItem(PasswordItem selectedItem)
 {
     // 获取到了当前被选择的 PasswordItem
     SelectedPassword = new PasswordItem();
     SelectedPassword = selectedItem;
     Switcher.SelectPasswordItem();
 }
Exemplo n.º 2
0
        // some functions contains discard

        // passing
        /// <summary>
        /// 将添加的密码项添加到已存在的 Tag 中去,此时该密码项
        /// 的密码已在库中密文存储,在列表中明文存在
        /// </summary>
        /// <param name="passwordItem"></param>
        /// <param name="tagName"></param>
        public void AddPasswordToTagList(PasswordItem passwordItem, string tagName)
        {
            foreach (Tag td in TagList)
            {
                if (td.TagName.Equals(tagName))
                {
                    td.PasswordItems.Add(passwordItem);
                }
            }
        }
Exemplo n.º 3
0
        public void Search(string queryStr)
        {
            PasswordItem passwordItem = DbHelper.SearchPasswordByName(queryStr);

            if (passwordItem == null)
            {
                // null 需要提示窗口
                WarningView wv = new WarningView("have no this guys");
                wv.ShowDialog();
            }
            else
            {
                passwordItem.Password = Encryptor.AESDecrypt(passwordItem.Password, KeyPassword);
                SelectPasswordItem(passwordItem);
            }
        }
Exemplo n.º 4
0
        public MainWindowModel(string key)
        {
            Switcher     = new ComponentSwitcher();
            PasswordForm = new PasswordItem();
            KeyPassword  = Encryptor.HashedKeyByMD5(key);
            SetUserFavicon();
            UpdateTagList();

            // Commands
            CloseCommand              = new RelayCommand(Close);
            ShowAddNewPwFormCommand   = new RelayCommand(ShowAddNewPwForm);
            AddNewPasswordCommand     = new RelayCommand(AddNewPassword);
            SelectPasswordItemCommand = new RelayCommand <PasswordItem>(t => SelectPasswordItem(t));
            CopyCommand               = new RelayCommand <string>(t => Copy(t));
            OpenWeblinkCommand        = new RelayCommand(OpenWeblink);
            UpdateCommand             = new RelayCommand(Update);
            UpdateOKCommand           = new RelayCommand(UpdateOK);
            DeletePasswordItemCommand = new RelayCommand(DeletePasswordItem);
            SearchCommand             = new RelayCommand <string>(t => Search(t));
            AboutCommand              = new RelayCommand(About);
            OpenCSVFileCommand        = new RelayCommand(OpenCSVFile);
        }
Exemplo n.º 5
0
        public void AddNewPassword()
        {
            if (string.IsNullOrEmpty(Title))
            {
                WindowToolTip = "Please fill the title";
                return;
            }
            if (string.IsNullOrEmpty(AddPassword))
            {
                WindowToolTip = "Please enter the password!";
            }
            if (!Website.StartsWith("https://"))
            {
                Website = "https://" + Website;
            }
            if (AvatarHashTable.ContainsKey(Title.ToLower()))
            {
                Avatar = (string)AvatarHashTable[Title.ToLower()];
            }
            else
            {
                Avatar = "asset/default.png";
            }

            //对密码加密
            string encryptedPassword = Encryptor.AESEncrypt(AddPassword, KeyPassword);

            db.InsertNewPw(Title, Account, encryptedPassword, Website, Avatar);

            PasswordItem passwordItem = new PasswordItem(Title, Account, AddPassword, Website, Avatar);

            AddAPwItemToPwList(passwordItem);

            ClearAddNewPwForm();
            DefaultVisibility      = "Visible";
            AddNewPwFormVisibility = "Hidden";
        }
Exemplo n.º 6
0
 // curd
 public void AddAPwItemToPwList(PasswordItem item)
 {
     PasswordLists.Add(item);
 }