public SpeakerManagerViewModel(SpeakerCollection documentSpeakers, SpeakerCollection localSpeakers, SpeakersApi api, SpeakersManager window) { _window = window; _api = api; if (_api != null) { _loadingTimer = new System.Timers.Timer(1000); _loadingTimer.AutoReset = false; _loadingTimer.Elapsed += _loadingTimer_Elapsed; } this._document = documentSpeakers; this._local = localSpeakers; _showOnline = Settings.Default.SpeakerManagerShowOnline; _showLocal = Settings.Default.SpeakerManagerShowLocal; _showDocument = Settings.Default.SpeakerManagerShowDocument; this.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { switch (e.PropertyName) { case "ShowLocal": Settings.Default.SpeakerManagerShowLocal = this.ShowLocal; break; case "ShowDocument": Settings.Default.SpeakerManagerShowLocal = this.ShowDocument; break; case "ShowOnline": Settings.Default.SpeakerManagerShowLocal = this.ShowOnline; break; } }; ReloadSpeakers(); }
public OnlineTranscriptionWindow(SpeakersApi speakersApi) { InitializeComponent(); this._api = speakersApi; }
public OnlineTranscriptionWindow(SpeakersApi speakersApi) { InitializeComponent(); this._api = speakersApi; }
private async Task LoadOnlineSource(string path) { Settings.Default.FeatureEnabler.DbMerging = false; Settings.Default.FeatureEnabler.LocalEdit = false; Settings.Default.FeatureEnabler.PhoneticEditation = false; Settings.Default.FeatureEnabler.QuickExport = false; Settings.Default.FeatureEnabler.QuickNavigation = false; Settings.Default.FeatureEnabler.VideoFrame = false; Settings.Default.FeatureEnabler.LocalSpeakers = false; _api = new SpeakersApi(path, this); if (await _api.TryLogin() == true) { if (_api.Info.API2) { _api = new SpeakersApi2(path, this); await _api.TryLogin(); } LoadOnlineSetting(); } else Close(); }
private bool TryLoadTranscription(string fileName, bool listing = false) { fileName = System.IO.Path.GetFullPath(fileName); TranscriptionIsLoading = true; if (!listing) ImportTranscriptions = false; var ext = System.IO.Path.GetExtension(fileName); if (ext == ".tlst") //list of transcriptions { TranscriptionList = new ObservableCollection<FileInfo>(File.ReadAllLines(fileName).Select(l => new FileInfo(l))); TranscriptionIndex = 0; fileName = TranscriptionList[TranscriptionIndex].FullName; } else if (ext == ".ilst") { TranscriptionList = new ObservableCollection<FileInfo>(File.ReadAllLines(fileName).Select(l => new FileInfo(l))); TranscriptionIndex = 0; fileName = TranscriptionList[TranscriptionIndex].FullName; ImportTranscriptions = true; } else if (!listing) { var dir = new DirectoryInfo(System.IO.Path.GetDirectoryName(fileName)); TranscriptionList = new ObservableCollection<FileInfo>(dir.GetFiles("*" + ext)); TranscriptionIndex = TranscriptionList.ToList().FindIndex(f => f.FullName == fileName); } else if (listing) //moving through list { TranscriptionIndex = TranscriptionList.ToList().FindIndex(f => f.FullName == fileName); } else return false; WPFTranscription trans; if (ImportTranscriptions) { trans = ImportTranscription(TranscriptionList[TranscriptionIndex].FullName); } else { trans = WPFTranscription.Deserialize(fileName); } if (trans != null) { if (trans.IsOnline) { _api = new SpeakersApi(trans.OnlineInfo.OriginalURL.ToString(), this); _api.Trans = trans; _api.Info = trans.OnlineInfo; LoadOnlineSetting();//contains LoadTranscription(....); } else { LoadTranscription(trans); } TranscriptionIsLoading = false; return true; } TranscriptionIsLoading = false; return false; }
private async void Window_Loaded(object sender, RoutedEventArgs e) { LoadSpeakersDatabase(); foreach (var item in SpeakersDatabase) item.PinnedToDocument = false; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); InitCommands(); LoadPlugins(); if (Settings.Default.FeatureEnabler.Spellchecking) { //asynchronous spellcecking vocabluary load Thread t = new Thread( delegate() { SpellChecker.LoadVocabulary(); } ) { Name = "Spellchecking_Load" }; t.Start(); } //TODO: move to xaml? phoneticTranscription.Text = ""; phoneticTranscription.buttonSpeaker.Visibility = Visibility.Collapsed; phoneticTranscription.checkBox1.Visibility = Visibility.Collapsed; phoneticTranscription.stackPanelAttributes.Visibility = Visibility.Collapsed; phoneticTranscription.textbegin.Visibility = Visibility.Collapsed; phoneticTranscription.textend.Visibility = Visibility.Collapsed; phoneticTranscription.DisableAutomaticElementVisibilityChanges = true; phoneticTranscription.EditPhonetics = true; phoneticTranscription.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; phoneticTranscription.editor.Style = null; phoneticTranscription.editor.OverridesDefaultStyle = false; phoneticTranscription.editor.TextArea.TextView.LineTransformers.Remove(Element.DefaultSpellchecker); PedalsInit(); string path = null; bool import = false; bool online = false; if (App.Startup_ARGS != null && App.Startup_ARGS.Length > 0) { if (App.Startup_ARGS[0] == "-i") { import = true; path = App.Startup_ARGS[1]; } else if (App.Startup_ARGS[0] == "-urlapi") { online = true; path = App.Startup_ARGS[1]; } else path = App.Startup_ARGS[0]; } if (path == null) { await NewTranscription(); } else { if (online) { if (path.StartsWith("trsx://")) path = path.Substring(7); if (path.StartsWith("trsx:")) path = path.Substring(5); await LoadOnlineSource(path); } else if (import) { await NewTranscription(); CommandImportFile.Execute(path, this); } else { await OpenTranscription(false, path); #if MINIMAL Transcription.MediaURI = @"http://demo.ite.tul.cz/audio_cro/51b5752ca802563ad80020d1.mp4"; _api = new SpeakersApi2("https://demo.ite.tul.cz/speechlab/cro_1968_1988_trsx07/api/speakers?", this); _api.Info = new OnlineTranscriptionInfo() { TrsxUploadURL = new Uri("https://demo.ite.tul.cz/speechlab/cro_1968_1988_trsx07/api/speakers"), SpeakerAPI_URL = new Uri("https://demo.ite.tul.cz/speechlab/cro_1968_1988_trsx07/api/speakers"), }; _api.LoadTranscription(Transcription); await _api.UpdateTranscriptionSpeakers(); LoadOnlineSetting(); #endif } } VirtualizingListBox.RequestTimePosition += delegate(out TimeSpan value) { value = waveform1.CaretPosition; }; VirtualizingListBox.RequestPlaying += delegate(out bool value) { value = Playing; }; VirtualizingListBox.RequestPlayPause += delegate() { CommandPlayPause.Execute(null, null); }; }
private void LoadOnlineSource(string path) { Settings.Default.FeatureEnabler.DbMerging = false; Settings.Default.FeatureEnabler.LocalEdit = false; Settings.Default.FeatureEnabler.PhoneticEditation = false; Settings.Default.FeatureEnabler.QuickExport = false; Settings.Default.FeatureEnabler.QuickNavigation = false; Settings.Default.FeatureEnabler.VideoFrame = false; Settings.Default.FeatureEnabler.LocalSpeakers = false; _api = new SpeakersApi(path, this); if (_api.TryLogin(this) == true) { LoadOnlineSetting(); } else Close(); }