| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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<string> passwordPool = new List<string>()
- {"BELOW", "PLANT", "WHICH", "WORLD", "WATER", "THESE", "THERE", "HOUSE", "WOULD", "WRITE", "ABOUT", "LEARN" };
-
- private PasswordCracker pwCracker;
- public BindableCollection<PositionalPasswordCharacter> PossiblePasswords { get; set; }
- public BindableCollection<PossiblePassword> 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<PossiblePassword> pp = pwCracker.AllPasswords;
- PossiblePasswords = new BindableCollection<PositionalPasswordCharacter>(pwCracker.PositionalCharacters);
- AllPasswords = new BindableCollection<PossiblePassword>(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();
- }
- }
- }
|