Example #1
0
 override public bool Execute(string[] args)
 {
     if (string.IsNullOrWhiteSpace(Passwordfile.SharedSecret))
     {
         MessageBox.Show("Password not set. Use 'Open Password' command to set password.");
     }
     else
     {
         if (args.Length > 1)
         {
             string         name = args[1];
             PasswordsModel data = Passwordfile.ReadFile();
             if (data != null)
             {
                 if (data.Passwords != null)
                 {
                     string password = data.Passwords.Where(o => o.Name.ToLower() == name.ToLower()).Select(o => o.Password).FirstOrDefault();
                     if (string.IsNullOrWhiteSpace(password))
                     {
                         MessageBox.Show("Password not found.");
                     }
                     else
                     {
                         Clipboard.SetText(password, TextDataFormat.Text);
                     }
                 }
             }
             else
             {
                 MessageBox.Show("Password not set. Use 'Open Password' command to set password.");
             }
         }
     }
     return(true); // hide command window
 }
Example #2
0
        override public bool Execute(string[] args)
        {
            if (string.IsNullOrWhiteSpace(Passwordfile.SharedSecret))
            {
                MessageBox.Show("Password not set. Use 'Open Password' command to set password.");
            }
            else
            {
                if (args.Length > 2)
                {
                    PasswordModel pw = new PasswordModel();
                    pw.Name     = args[1];
                    pw.Password = args[2];
                    if (args.Length > 3)
                    {
                        pw.UserName = args[3];
                        if (args.Length > 4)
                        {
                            pw.Url = args[4];
                            if (args.Length > 5)
                            {
                                pw.Email = args[5];
                            }
                        }
                    }

                    PasswordsModel data = Passwordfile.ReadFile();
                    if (data == null)
                    {
                        data = new PasswordsModel();
                    }
                    if (data.Passwords != null)
                    {
                        data.Passwords.Add(pw);
                    }
                    Passwordfile.SaveFile(data);
                }
            }
            return(true); // hide command window
        }