public static bool UpdateSchemeDialog(ref AnnoScheme scheme) { Window dialog = null; if (scheme.Type == AnnoScheme.TYPE.FREE) { dialog = new AnnoTierNewFreeSchemeWindow(ref scheme); } else if (scheme.Type == AnnoScheme.TYPE.DISCRETE) { dialog = new AnnoTierNewDiscreteSchemeWindow(ref scheme); } else if (scheme.Type == AnnoScheme.TYPE.CONTINUOUS) { dialog = new AnnoTierNewContinuousSchemeWindow(ref scheme); } else if (scheme.Type == AnnoScheme.TYPE.POINT) { dialog = new AnnoTierNewPointSchemeWindow(ref scheme); } else { return(false); } dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); return(dialog.DialogResult.Value); }
private void ResampleScheme_Click(object sender, RoutedEventArgs e) { if (SchemesBox.SelectedItem != null) { string name = (string)SchemesBox.SelectedItem; AnnoScheme oldScheme = DatabaseHandler.GetAnnotationScheme(name); AnnoScheme newScheme = DatabaseHandler.GetAnnotationScheme(name); if (newScheme.Type != AnnoScheme.TYPE.CONTINUOUS) { MessageBox.Show("Only continuous annotations can be resampled"); return; } newScheme.Name = newScheme.Name + "_resampled"; AnnoTierNewContinuousSchemeWindow window = new AnnoTierNewContinuousSchemeWindow(ref newScheme); window.ShowDialog(); if (window.DialogResult == true) { if (DatabaseHandler.AddScheme(newScheme)) { List <DatabaseAnnotation> existingAnnos = DatabaseHandler.GetAnnotations(oldScheme); if (existingAnnos.Count > 0) { AnnoList al_t = DatabaseHandler.LoadAnnoList(existingAnnos[0].Id); double old_sr = al_t.Scheme.SampleRate; double factor = 0; if (old_sr > newScheme.SampleRate) { factor = old_sr / newScheme.SampleRate; } else if (old_sr < newScheme.SampleRate) { factor = newScheme.SampleRate / old_sr; } else { factor = 1; } if (factor % 1 != 0) { MessageBox.Show("New samplerate must be a number divisible by old samplerate."); return; } foreach (DatabaseAnnotation anno in existingAnnos) { AnnoList al = DatabaseHandler.LoadAnnoList(anno.Id); DatabaseHandler.resampleAnnotationtoNewScheme(al, newScheme, al_t.Scheme); } GetSchemes(); } else { MessageBox.Show("Scheme created, but no existing Annotations found, nothing was converted."); } } } } }
private void navigatorNewAnno_Click(object sender, RoutedEventArgs e) { if (Time.TotalDuration > 0) { AnnoTierNewSchemeWindow dialog = new AnnoTierNewSchemeWindow(); dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog.ShowDialog(); if (dialog.DialogResult == true) { AnnoScheme.TYPE annoType = dialog.Result(); if (DatabaseLoaded) { databaseAddNewAnnotation(annoType); } else { if (annoType == AnnoScheme.TYPE.FREE) { AnnoTierNewFreeSchemeWindow dialog2 = new AnnoTierNewFreeSchemeWindow(); dialog2.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog2.ShowDialog(); if (dialog2.DialogResult == true) { AnnoScheme annoScheme = dialog2.Result; AnnoList annoList = new AnnoList() { Scheme = annoScheme }; addAnnoTier(annoList); } } else if (annoType == AnnoScheme.TYPE.DISCRETE) { AnnoTierNewDiscreteSchemeWindow dialog2 = new AnnoTierNewDiscreteSchemeWindow(); dialog2.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog2.ShowDialog(); if (dialog2.DialogResult == true) { AnnoList annoList = dialog2.GetAnnoList(); addAnnoTier(annoList); } } else if (annoType == AnnoScheme.TYPE.CONTINUOUS) { double defaultSr = 25.0; foreach (IMedia m in mediaList.Medias) { if (m.IsVideo()) { defaultSr = m.GetSampleRate(); break; } } AnnoTierNewContinuousSchemeWindow.Input input = new AnnoTierNewContinuousSchemeWindow.Input() { SampleRate = defaultSr, MinScore = 0.0, MaxScore = 1.0, MinColor = Colors.LightBlue, MaxColor = Colors.Red }; AnnoTierNewContinuousSchemeWindow dialog2 = new AnnoTierNewContinuousSchemeWindow(input); dialog2.WindowStartupLocation = WindowStartupLocation.CenterScreen; dialog2.ShowDialog(); if (dialog2.DialogResult == true) { AnnoScheme annoScheme = dialog2.Result; AnnoList annoList = new AnnoList() { Scheme = annoScheme }; addAnnoTier(annoList); } } } } } else { MessageTools.Warning("Nothing to annotate, load some data first."); } }