Exemplo n.º 1
0
        public RootViewModel(
            IServerResponseService serverResponseService,
            IFileProcessService fileProcessService,
            IConfigurationService _configurationService,
            IRecordService recordService)
        {
            _recordService = recordService;
            _recordService.RecordStopped += delegate { IsTranscribingInProgress = false; };
            _recordService.InfoMessage   += delegate(object _sender, string message) { InfoMessage = message; };
            _recordService.RecordLevel   += delegate(object _sender, float level) { RecordLevel = level; };

            _fontSizes        = new int[] { 8, 12, 14, 16, 18, 20, 22, 24, 26 };
            _selectedFontSize = _fontSizes[3];

            _transportService              = Mvx.IoCProvider.Resolve <ITransportService>();
            _transportService.InfoMessage += delegate(object _sender, string message) { InfoMessage = message; };

            _configurationService = new ConfigurationService();

            _fileProcessService = fileProcessService;
            _fileProcessService.PercentageTranscribed += UpdatePercentageTranscribed;
            _fileProcessService.InfoMessage           += delegate(object _sender, string message) { InfoMessage = message; };

            _serverResponseService = serverResponseService;
            _serverResponseService.HandledServerResponse += delegate(object _sender, string resp) { Transcription = resp; };
            _serverResponseService.InfoMessage           += delegate(object _sender, string message) { InfoMessage = message; };

            ToggleTranscriptionCommand = new MvxCommand(StartTranscribing);
            ClearTextCommand           = new MvxCommand(_serverResponseService.Clear);
            TranscribeFileCommand      = new MvxAsyncCommand(TranscribeFile);

            AvailableLanguages = _configurationService.GetLanguages().ToArray();
            if (AvailableLanguages.Count() != 0)
            {
                SelectedLanguage = AvailableLanguages.Where(x => x.Key.ToLower() == "russian").FirstOrDefault();
            }
        }