示例#1
0
        public MainViewModel()
        {
            this.Compose();
            TextStreamModel textStreamModel = new TextStreamModel();

            this.KeyboardViewModel          = new KeyboardViewModel(textStreamModel);
            this.TextStreamViewModel        = new TextStreamViewModel(textStreamModel);
            this.TypingStatsViewModel       = new TypingStatsViewModel();
            this.TextStreamManagerViewModel = new TextStreamManagerViewModel();
            textStreamModel.TextExpected   += new EventHandler <TextEventArgs>(this.TypingStatsViewModel.OnTextExpected);

            ITextProvider defaultProvider = null;

            foreach (ITextProvider provider in this.TextProviders)
            {
                TextStreamProviderViewModel providerViewmodel = new TextStreamProviderViewModel(provider);
                this.TextStreamManagerViewModel.TextStreamProviders.Add(providerViewmodel);
                if (provider is SimpleTextProvider)
                {
                    defaultProvider = provider;
                }
            }
            this.TextStreamManagerViewModel.CurrentTextStreamProvider = this.TextStreamManagerViewModel.TextStreamProviders.First();

            defaultProvider.Refresh();
            ITextSource defaultTextSource = defaultProvider.Sources.First();

            if (defaultTextSource != null)
            {
                this.TextStreamViewModel.Text = defaultTextSource.Text;
            }
        }