Beispiel #1
0
        private void NewAccount()
        {
            // User entered info
            var dialog = new TextDialog();

            if (dialog.ShowDialog() == true && dialog.AccountText != "" && dialog.PasswordText != "")
            {
                account = dialog.AccountText;
                string password = dialog.PasswordText;
                string aviUrl   = htmlAviScrape(dialog.UrlText);

                // If the auto login checkbox was checked, update settings file and global variables.
                if (dialog.AutoLogAccountIndex == true)
                {
                    settingsFile.Write("SelectedAcc", (encryptedAccounts.Count + 1).ToString(), "AutoLog");
                    settingsFile.Write("Selected", "True", "AutoLog");
                    settingsFile.Write("Recent", "False", "AutoLog");
                    selected    = true;
                    recent      = false;
                    selectedAcc = encryptedAccounts.Count + 1;
                }

                try
                {
                    // Encrypt info before saving to file
                    ePassword = StringCipher.Encrypt(password, eKey);

                    encryptedAccounts.Add(new Account()
                    {
                        Name = dialog.AccountText, Password = ePassword, ProfUrl = dialog.UrlText, AviUrl = aviUrl, Description = dialog.DescriptionText
                    });

                    Utils.Serialize(encryptedAccounts);

                    RefreshWindow();
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    var itemToRemove = encryptedAccounts.Single(r => r.Name == dialog.AccountText);
                    encryptedAccounts.Remove(itemToRemove);

                    Utils.Serialize(encryptedAccounts);

                    NewAccount();
                }
            }
        }
Beispiel #2
0
        private void editEntry(object butt)
        {
            Button button = butt as Button;
            int    index  = Int32.Parse(button.Tag.ToString());

            var dialog = new TextDialog();

            dialog.AccountText     = decryptedAccounts[index].Name;
            dialog.PasswordText    = decryptedAccounts[index].Password;
            dialog.UrlText         = decryptedAccounts[index].ProfUrl;
            dialog.DescriptionText = decryptedAccounts[index].Description;

            // Reload slected boolean
            if (settingsFile.Read("Selected", "AutoLog") == "True")
            {
                selected = true;
            }
            else
            {
                selected = false;
            }

            if (selected == true && selectedAcc == index)
            {
                dialog.autoLogCheckBox.IsChecked = true;
            }

            if (dialog.ShowDialog() == true)
            {
                string aviUrl = htmlAviScrape(dialog.UrlText);

                // If the auto login checkbox was checked, update settings file and global variables.
                if (dialog.AutoLogAccountIndex == true)
                {
                    settingsFile.Write("SelectedAcc", button.Tag.ToString(), "AutoLog");
                    settingsFile.Write("Selected", "True", "AutoLog");
                    settingsFile.Write("Recent", "False", "AutoLog");
                    selected    = true;
                    recent      = false;
                    selectedAcc = index;
                }
                else
                {
                    settingsFile.Write("SelectedAcc", "-1", "AutoLog");
                    settingsFile.Write("Selected", "False", "AutoLog");
                    selected    = false;
                    selectedAcc = -1;
                }

                try
                {
                    // Encrypt info before saving to file
                    ePassword = StringCipher.Encrypt(dialog.PasswordText, eKey);

                    encryptedAccounts[index].Name        = dialog.AccountText;
                    encryptedAccounts[index].Password    = ePassword;
                    encryptedAccounts[index].ProfUrl     = dialog.UrlText;
                    encryptedAccounts[index].AviUrl      = aviUrl;
                    encryptedAccounts[index].Description = dialog.DescriptionText;

                    Utils.Serialize(encryptedAccounts);
                    RefreshWindow();
                }
                catch (Exception m)
                {
                    MessageBox.Show(m.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    editEntry(butt);
                }
            }
        }