Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            Title = $"Keyboord usage v{AppConstants.CurrentVersion} by Kasper B. Graversen";

            var args = new CommandLineParser().ParseCommandLine();

            var style = (Style)FindResource("InformButton");

            configurationRepository = new ConfigurationRepository(new UserStateStandardConfiguraion(args));

            keyboards = configurationRepository.GetKeyboards(style);

            state = configurationRepository.LoadUserState();
            var userState = new DailySessionDecorator(state);
            var counter   = new KeysCounter(userState);

            keyPressController = new KeyPressController(
                () => WindowState == WindowState.Minimized,
                x => CurrentKey.Content       = x,
                x => KeyHistory.Text          = x,
                x => ProductiveRatio.Content  = x.ToString() + "%",
                x => DestructiveRatio.Content = x.ToString() + "%",
                x => NavigationRatio.Content  = x.ToString() + "%",
                x => MetaRatio.Content        = x.ToString() + "%",
                counter,
                null);

            listener = new KeyboardListener(counter, keyPressController);
            listener.Subscribe();

            ResizeWindow(state);

            KeyboardChooser.ItemsSource   = keyboards.Select(x => x.Name);
            KeyboardChooser.SelectedIndex = state.GetGuiConfiguration().SelectedKeyboardIndex;

            keyPressController.ForceRepaint();
        }