Ejemplo n.º 1
0
        /// <summary>
        /// Get's the passwords for all the browser's
        /// </summary>
        private void DisplayPassword()
        {
            Chrome chrome = new Chrome();
            IE ie = new IE();
            // List of users/passes
            SortableBindingList<LoginVisible> loginArray = new SortableBindingList<LoginVisible>();
            // Variables
            const string chromeBrowser = "Chrome";
            const string IEBrowser = "IE";

            // For each url in getpasswords, add a password
            foreach (var url in chrome.GetPasswords())
            {
                loginArray.Add(new LoginVisible(url.UserName, url.Url, url.Password, url.visitDate, chromeBrowser));
            }
            foreach (var url in Firefox.getPasswords())
            {
                loginArray.Add(url);
            }
            foreach (var url in ie.GetIEPassword())
            {
                loginArray.Add(url);
            }

            // If the "show Passwords" checkbox is not checked, don't show the passwords
            if (Settings.Default.showFullPassword == false)
            {
                // New list to hold values
                SortableBindingList<LoginVisible> loginArrayNew = new SortableBindingList<LoginVisible>();
                foreach (LoginVisible url in loginArray)
                {
                    // Number of digits to replace
                    int length = url.Password.Length;
                    //Add a new login with DOTS instead of the password
                    loginArrayNew.Add(new LoginVisible(url.UserName, url.Url,
                                                       url.Password.Replace(url.Password,
                                                                            string.Concat(Enumerable.Repeat("\u25CF",
                                                                                                            length))),
                                                       url.visitDate, url.Browser));
                }
                // Sets the dataGridView source to logins
                dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataSource = this.loginBindingSource;
                dataGridView1.DataSource = loginArrayNew;
            }
            else
            {
                // Sets the dataGridView source to logins
                dataGridView1.AutoGenerateColumns = true;
                this.dataGridView1.DataSource = this.loginBindingSource;
                dataGridView1.DataSource = loginArray;
            }
        }