using System.Windows;

namespace FSI.BT.Tools.Global.Commands
{
    /// <summary>
    /// Shows the main window.
    /// </summary>
    public class LoginCommand : CommandBase<LoginCommand>
    {
        public override void Execute(object parameter)
        {
            Lib.Guis.AutoPw.FrmMain frmMain = new Lib.Guis.AutoPw.FrmMain()
            {
                CloseAtLostFocus = false,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
            };
            frmMain.ShowDialog();
            
            Global.Vars.UserRights = 
            Vars.AdminRights = frmMain.PwOk;

            if (frmMain.PwOk)
            {
                Vars.Log.Info("Admin-Passowrt wurde korrekt eingegben.");
            }
            else
            {
                Vars.Log.Info("Anmeldung wurde vom Benutzer abgebrochen.");
            }
        }

        public override bool CanExecute(object parameter)
        {
            return true;
        }
    }
}