using Caliburn.Micro; using friaLabbar.Models; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media; namespace friaLabbar.ViewModels { public class PasswordCrackerViewModel { private List passwordPool = new List() {"BELOW", "PLANT", "WHICH", "WORLD", "WATER", "THESE", "THERE", "HOUSE", "WOULD", "WRITE", "ABOUT", "LEARN" }; private PasswordCracker pwCracker; public BindableCollection PossiblePasswords { get; set; } public BindableCollection AllPasswords { get; set; } public PasswordCrackerViewModel() { pwCracker = new PasswordCracker(passwordPool); pwCracker.PositionalCharacters[0].Text = "WHLXAS"; pwCracker.PositionalCharacters[1].Text = "ORHEQZT"; pwCracker.PositionalCharacters[4].Text = "EDQZP"; IEnumerable pp = pwCracker.AllPasswords; PossiblePasswords = new BindableCollection(pwCracker.PositionalCharacters); AllPasswords = new BindableCollection(pwCracker.AllPasswords); } } public class PasswordToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is Boolean) { if ((Boolean)value) { return Brushes.Gray; } else { return Brushes.Red; } } return Brushes.White; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } public class PasswordCharacterToColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Brush color = Brushes.White; if (value is CharacterState) { switch ((CharacterState)value) { case CharacterState.Possible: color = Brushes.Green; break; case CharacterState.Impossible: color = Brushes.Red; break; case CharacterState.Unknown: color = Brushes.White; break; } } return color; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }