예제 #1
0
        private void updateMenu()
        {
            AnnoTier    tier        = AnnoTierStatic.Selected;
            bool        hasTier     = tier != null;
            SignalTrack track       = SignalTrackStatic.Selected;
            bool        hasTrack    = track != null;
            MediaBox    box         = MediaBoxStatic.Selected;
            bool        hasBox      = box != null;
            bool        isConnected = DatabaseHandler.IsConnected;
            bool        isConnectedAndHasSession = isConnected && DatabaseHandler.IsSession;
            bool        hasDatabaseTier          = false;

            if (isConnectedAndHasSession && hasTier && tier.AnnoList.Source.HasDatabase)
            {
                hasDatabaseTier = true;
            }
            DatabaseAuthentication authentication = DatabaseHandler.CheckAuthentication();

            // file

            control.fileSaveProjectMenu.IsEnabled     = hasTier || hasTrack || hasBox;
            control.exportSamplesMenu.IsEnabled       = hasTier && hasTrack;
            control.exportToGenie.IsEnabled           = hasTier;
            control.exportSelectedTrackMenu.IsEnabled = hasTrack;
            control.exportSelectedTierMenu.IsEnabled  = hasTier;

            // database

            control.databaseLoadSessionMenu.IsEnabled = isConnected;
            control.databasePasswordMenu.IsEnabled    = isConnected;
            control.databaseUpdateMenu.IsEnabled      = isConnected;

            control.databaseCMLMenu.IsEnabled                 = isConnected;
            control.databaseCMLCompleteStepMenu.IsEnabled     = isConnectedAndHasSession;
            control.databaseCMLExtractFeaturesMenu.IsEnabled  = isConnected && (authentication > DatabaseAuthentication.READ);
            control.databaseCMLMergeAnnotationsMenu.IsEnabled = isConnected && (authentication > DatabaseAuthentication.READ);
            control.databaseCMLTrainAndPredictMenu.IsEnabled  = isConnected && (authentication > DatabaseAuthentication.READ);

            control.databaseAdminMenu.Visibility       = isConnected && (authentication > DatabaseAuthentication.READWRITE) ? Visibility.Visible : Visibility.Collapsed;
            control.databaseManageUsersMenu.Visibility = isConnected && (authentication > DatabaseAuthentication.DBADMIN) ? Visibility.Visible : Visibility.Collapsed;


            control.fusionmenu.Visibility = (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\bayesfusion.exe") == true) ? Visibility.Visible : Visibility.Collapsed;

            // annotation
            control.annoNewMenu.IsEnabled                         = ((Time.TotalDuration > 0) == true);
            control.annoSaveAllMenu.IsEnabled                     = hasTier;
            control.annoSaveMenu.IsEnabled                        = hasTier;
            control.annoSaveAsFinishedMenu.IsEnabled              = hasTier;
            control.annoReloadMenu.IsEnabled                      = hasTier;
            control.annoReloadBackupMenu.IsEnabled                = hasDatabaseTier;
            control.annoExportMenu.IsEnabled                      = hasTier;
            control.convertSelectedTierMenu.IsEnabled             = hasTier;
            control.convertAnnoContinuousToDiscreteMenu.IsEnabled = hasTier && (tier.IsContinuous || tier.AnnoList.Scheme.Type == AnnoScheme.TYPE.FREE);
            control.removeRemainingSegmentsMenu.IsEnabled         = hasTier && tier.IsDiscreteOrFree;
            control.convertAnnoToSignalMenu.IsEnabled             = hasTier && tier.IsContinuous;
            control.convertSignalMenu.IsEnabled                   = hasTrack;
            control.XAIMenu.IsEnabled  = hasBox;
            control.XAIMenu.Visibility = control.updatePythonMenu.Visibility = (MainHandler.ENABLE_PYTHON ? Visibility.Visible : Visibility.Collapsed);
        }
예제 #2
0
        private void reloadAnnoTierFromFile(AnnoTier track)
        {
            string filename = track.AnnoList.Source.File.Path;

            if (!File.Exists(filename))
            {
                MessageTools.Error("Annotation file not found '" + filename + "'");
                return;
            }

            AnnoList anno   = AnnoList.LoadfromFile(filename);
            double   maxdur = 0;

            maxdur = anno[anno.Count - 1].Stop;

            if (anno != null && AnnoTierStatic.Selected != null)
            {
                setAnnoList(anno);
                AnnoTierStatic.Selected.Children.Clear();
                AnnoTierStatic.Selected.AnnoList.Clear();
                AnnoTierStatic.Selected.segments.Clear();
                AnnoTierStatic.Selected.AnnoList = anno;

                foreach (AnnoListItem item in anno)
                {
                    AnnoTierStatic.Selected.AddSegment(item);
                }

                AnnoTierStatic.Selected.TimeRangeChanged(MainHandler.Time);
            }

            updateTimeRange(maxdur);
            // if (maxdur > Properties.Settings.Default.DefaultZoominSeconds && Properties.Settings.Default.DefaultZoominSeconds != 0 && annos.Count != 0 && media_list.Medias.Count == 0) fixTimeRange(Properties.Settings.Default.DefaultZoominSeconds);
        }
예제 #3
0
 private void ChangeTier(bool down = true)
 {
     if (down)
     {
         for (int i = 0; i < annoTiers.Count; i++)
         {
             if (annoTiers[i] == AnnoTierStatic.Selected && i + 1 < annoTiers.Count)
             {
                 AnnoTierStatic.Select(annoTiers[i + 1]);
                 AnnoTierStatic.SelectLabel(null);
                 break;
             }
         }
     }
     else
     {
         for (int i = 0; i < annoTiers.Count; i++)
         {
             if (annoTiers[i] == AnnoTierStatic.Selected && i > 0)
             {
                 AnnoTierStatic.Select(annoTiers[i - 1]);
                 AnnoTier.SelectLabel(null);
                 break;
             }
         }
     }
 }
예제 #4
0
        private void ExportAnnoToSignal()
        {
            AnnoTier annoTier = AnnoTierStatic.Selected;

            if (annoTier.AnnoList.Scheme.Type != AnnoScheme.TYPE.CONTINUOUS)
            {
                MessageBox.Show("Selected a continious track to convert to ssi stream");
            }
            else
            {
                double sr    = 1 / annoTier.AnnoList[0].Duration;
                double from  = 0.0;
                double to    = annoTier.AnnoList[annoTier.AnnoList.Count - 1].Stop;
                int    num   = annoTier.AnnoList.Count;
                string ftype = "ASCII";
                string type  = "FLOAT";
                int    by    = sizeof(float);
                int    dim   = 1;
                int    ms    = Environment.TickCount;

                if (annoTier.AnnoList.HasChanged)
                {
                    MessageBoxResult m = MessageBoxResult.None;
                    m = MessageBox.Show("You need to save continous annotations on tier " + annoTier.AnnoList.Scheme.Name + " first", "Confirm", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    if (m == MessageBoxResult.OK)
                    {
                        exportSelectedAnnoAs();
                    }
                }

                string filename = Path.GetDirectoryName(annoTier.AnnoList.Source.File.Path) + "\\" + annoTier.AnnoList.Scheme.Name + ".stream";

                StreamWriter swheader = new StreamWriter(filename, false, System.Text.Encoding.Default);
                swheader.WriteLine("<?xml version=\"1.0\" ?>");
                swheader.WriteLine("<stream ssi-v=\"2\">");
                swheader.WriteLine("\t<info ftype=\"" + ftype + "\" sr=\"" + sr.ToString("0.000000", CultureInfo.InvariantCulture) + "\" dim=\"" + dim.ToString() + "\" byte=\"" + by.ToString() + "\" type=\"" + type + "\" />");
                swheader.WriteLine("\t<time ms=\"" + ms + "\" local=\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\" system=\"" + DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss") + "\"/>");
                swheader.WriteLine("\t<chunk from=\"" + from.ToString("0.000000", CultureInfo.InvariantCulture) + "\" to=\"" + to.ToString("0.000000", CultureInfo.InvariantCulture) + "\" byte=\"" + "0" + "\" num=\"" + num + "\"/>");

                swheader.WriteLine("</stream>");

                swheader.Close();

                StreamWriter swdata = new StreamWriter(filename + "~", false, System.Text.Encoding.Default);
                foreach (AnnoListItem i in annoTier.AnnoList)
                {
                    swdata.WriteLine(i.Label);
                }
                swdata.Close();

                MessageBoxResult mb = MessageBoxResult.None;
                mb = MessageBox.Show("Successfully converted anno to stream. Load the stream?", "Success", MessageBoxButton.YesNo);
                if (mb == MessageBoxResult.Yes)
                {
                    loadSignalFile(filename);
                }
            }
        }
예제 #5
0
        public void Remove(AnnoTier tier)
        {
            int rowIndex   = Grid.GetRow(tier.Border);
            int childIndex = 0;

            bool isLast = rowIndex == grid.RowDefinitions.Count - 1;

            // remove children:

            // splitter
            childIndex = grid.Children.IndexOf(tier.Border);
            if (!isLast)
            {
                grid.Children.RemoveAt(childIndex + 1);
            }
            // track
            childIndex = grid.Children.IndexOf(tier.Border);
            grid.Children.RemoveAt(childIndex - 2);
            // label
            childIndex = grid.Children.IndexOf(tier.Border);
            grid.Children.RemoveAt(childIndex - 1);
            // border
            childIndex = grid.Children.IndexOf(tier.Border);
            grid.Children.RemoveAt(childIndex);

            // update row indices of remaining children:

            int row = 0;

            for (int i = 0; i < grid.Children.Count; i++)
            {
                if ((i + 1) % 4 == 0)
                {
                    row++;
                }
                Grid.SetRow(grid.Children[i], row);
                if ((i + 1) % 4 == 0)
                {
                    row++;
                }
            }

            // remove rows:

            grid.RowDefinitions.RemoveAt(grid.RowDefinitions.Count - 1);
            if (!isLast)
            {
                grid.RowDefinitions.RemoveAt(grid.RowDefinitions.Count - 1);
            }

            // resize

            for (int i = 0; i < grid.RowDefinitions.Count; i += 2)
            {
                grid.RowDefinitions[i].Height = new GridLength(1, GridUnitType.Star);
            }
        }
예제 #6
0
        private void navigatorFollowAnno_Unchecked(object sender, RoutedEventArgs e)
        {
            AnnoTier.UnselectLabel();

            bool is_playing = IsPlaying();

            Stop();
            if (is_playing)
            {
                Play();
            }
        }
예제 #7
0
        private void CopyLabelToTier(bool down = true)
        {
            if (down)
            {
                if (AnnoTierStatic.Label != null)
                {
                    AnnoListItem temp = AnnoTierStatic.Label.Item;

                    for (int i = 0; i < annoTiers.Count; i++)
                    {
                        if (annoTiers[i] == AnnoTierStatic.Selected && i + 1 < annoTiers.Count)
                        {
                            AnnoTierStatic.Select(annoTiers[i + 1]);
                            if (AnnoTierStatic.Selected.IsDiscreteOrFree)
                            {
                                AnnoTier.SelectLabel(null);
                                if (!AnnoTierStatic.Selected.AnnoList.Contains(temp))
                                {
                                    AnnoTierStatic.Selected.NewAnnoCopy(temp.Start, temp.Stop, temp.Label, temp.Color);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (AnnoTierStatic.Label != null)
                {
                    AnnoListItem temp = AnnoTierStatic.Label.Item;

                    for (int i = 0; i < annoTiers.Count; i++)
                    {
                        if (annoTiers[i] == AnnoTierStatic.Selected && i > 0)
                        {
                            AnnoTierStatic.Select(annoTiers[i - 1]);
                            if (AnnoTierStatic.Selected.IsDiscreteOrFree)
                            {
                                AnnoTierStatic.SelectLabel(null);
                                if (!AnnoTierStatic.Selected.AnnoList.Contains(temp))
                                {
                                    AnnoTierStatic.Selected.NewAnnoCopy(temp.Start, temp.Stop, temp.Label, temp.Color);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
        public void UpdateRowHeight(AnnoTier tier, int height)
        {
            int rowIndex = Grid.GetRow(tier.Border);
            var r        = grid.RowDefinitions[rowIndex];

            if (height <= 0)
            {
                r.Height = new GridLength(1, GridUnitType.Star);
            }
            else
            {
                r.Height = new GridLength((double)height, GridUnitType.Pixel);
            }
        }
예제 #9
0
        private void changeAnnoTierHandler(AnnoTier tier, EventArgs e)
        {
            control.annoNameLabel.Content = tier.AnnoList.DefaultName(" #", true, true);
            setAnnoList(tier.AnnoList);
            control.annoListControl.editComboBox.Items.Clear();

            if (AnnoTierStatic.Selected != null)
            {
                if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
                {
                    control.annoListControl.editButton.Visibility   = Visibility.Collapsed;
                    control.annoListControl.editComboBox.Visibility = Visibility.Collapsed;
                    control.annoListControl.editTextBox.Visibility  = Visibility.Collapsed;
                    control.annoListControl.editComboBox.IsEnabled  = false;
                    control.annoListControl.editTextBox.IsEnabled   = false;
                }

                control.annoListControl.editComboBox.Items.Clear();
                if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.DISCRETE)
                {
                    control.annoListControl.editComboBox.IsEnabled  = true;
                    control.annoListControl.editComboBox.Visibility = Visibility.Visible;
                    control.annoListControl.editTextBox.Visibility  = Visibility.Collapsed;
                    control.annoListControl.editTextBox.IsEnabled   = false;
                    control.annoListControl.editButton.Visibility   = Visibility.Visible;

                    if (AnnoTierStatic.Selected.AnnoList.Scheme != null &&
                        AnnoTierStatic.Selected.AnnoList.Scheme.Labels != null)
                    {
                        foreach (AnnoScheme.Label lcp in AnnoTierStatic.Selected.AnnoList.Scheme.Labels)
                        {
                            control.annoListControl.editComboBox.Items.Add(lcp.Name);
                        }

                        control.annoListControl.editComboBox.SelectedIndex = 0;
                    }
                }
                else if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.FREE)
                {
                    control.annoListControl.editTextBox.Visibility  = Visibility.Visible;
                    control.annoListControl.editComboBox.Visibility = Visibility.Collapsed;
                    control.annoListControl.editButton.Visibility   = Visibility.Visible;
                    control.annoListControl.editTextBox.IsEnabled   = true;
                }
            }

            //this.view.annoNameLabel.Text = track.AnnoList.Filename;
        }
예제 #10
0
        private void databaseReload(AnnoTier tier)
        {
            Action EmptyDelegate = delegate() { };

            control.ShadowBoxText.Text   = "Reloading Annotation";
            control.ShadowBox.Visibility = Visibility.Visible;
            control.UpdateLayout();
            control.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);

            DatabaseAnno s = new DatabaseAnno();

            s.Role              = tier.AnnoList.Meta.Role;
            s.AnnoScheme        = tier.AnnoList.Scheme.Name;
            s.AnnotatorFullname = tier.AnnoList.Meta.AnnotatorFullName;
            s.Annotator         = tier.AnnoList.Meta.Annotator;

            List <DatabaseAnno> list = new List <DatabaseAnno>();

            list.Add(s);

            List <AnnoList> annos  = DatabaseHandler.LoadFromDatabase(list, Properties.Settings.Default.DatabaseName, Properties.Settings.Default.LastSessionId, Properties.Settings.Default.MongoDBUser);
            double          maxdur = 0;

            if (annos[0].Count > 0)
            {
                maxdur = annos[0][annos[0].Count - 1].Stop;
            }

            if (annos[0] != null && tier != null)
            {
                setAnnoList(annos[0]);
                tier.Children.Clear();
                tier.AnnoList.Clear();
                tier.segments.Clear();
                tier.AnnoList = annos[0];

                foreach (AnnoListItem item in annos[0])
                {
                    tier.addSegment(item);
                }

                tier.TimeRangeChanged(MainHandler.Time);
            }

            updateTimeRange(maxdur);
            // if (maxdur > Properties.Settings.Default.DefaultZoominSeconds && Properties.Settings.Default.DefaultZoominSeconds != 0 && annos.Count != 0 && media_list.Medias.Count == 0) fixTimeRange(Properties.Settings.Default.DefaultZoominSeconds);
            control.ShadowBox.Visibility = Visibility.Collapsed;
        }
예제 #11
0
        private void ReloadAnnotations()
        {
            AnnoTier track = AnnoTierStatic.Selected;

            if (track != null)
            {
                if (track.AnnoList.Source.HasFile)
                {
                    reloadAnnoTierFromFile(track);
                }
                else
                {
                    ReloadAnnoTierFromDatabase(track, false);
                }
            }
        }
예제 #12
0
        private void convertAnnoContinuousToDiscrete_Click(object sender, RoutedEventArgs e)
        {
            if (AnnoTierStatic.Selected != null)
            {
                if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
                {
                    ExportAnnoContinuousToDiscrete();
                }

                else if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.FREE)
                {
                    AnnoList newlist = AnnoList.ConvertFreetoDiscreteAnnotation(AnnoTierStatic.Selected.AnnoList);
                    AnnoTier.Unselect();
                    addAnnoTierFromList(newlist);
                }
            }
        }
예제 #13
0
        private void ApplyButton_Click(object sender, RoutedEventArgs e)
        {
            if (TierListBox.SelectedItem != null)
            {
                foreach (var tierName in TierListBox.SelectedItems)
                {
                    AnnoTier tier = handler.getAnnoTierFromName(tierName.ToString());
                    if (tier != null)
                    {
                        if (StreamListBox.SelectedItem != null)
                        {
                            string stream  = (string)StreamListBox.SelectedItem;
                            int    context = 0;
                            if (int.TryParse(ContextTextBox.Text, out context))
                            {
                                DatabaseHandler.StoreToDatabase(tier.AnnoList, handler.loadedDBmedia, false);

                                double confidence = -1.0;
                                if (ConfidenceTextBox.IsEnabled)
                                {
                                    double.TryParse(ConfidenceTextBox.Text, out confidence);
                                }
                                double minGap = 0.0;
                                if (FillGapTextBox.IsEnabled)
                                {
                                    double.TryParse(FillGapTextBox.Text, out minGap);
                                }
                                double minDur = 0.0;
                                if (RemoveLabelTextBox.IsEnabled)
                                {
                                    double.TryParse(RemoveLabelTextBox.Text, out minDur);
                                }
                                Properties.Settings.Default.CMLDefaultGap    = minGap;
                                Properties.Settings.Default.CMLDefaultConf   = confidence;
                                Properties.Settings.Default.CMLDefaultMinDur = minDur;
                                Properties.Settings.Default.Save();

                                logTextBox.Text = "";
                                logTextBox.AppendText(handler.CompleteTier(context, tier, stream, confidence, minGap, minDur));
                                //logTextBox.AppendText(File.ReadAllText("cml.log"));
                            }
                        }
                    }
                }
            }
        }
예제 #14
0
        public void addAnnoTier(AnnoList anno)
        {
            setAnnoList(anno);

            AnnoTier tier = new AnnoTier(anno);

            control.annoTierControl.Add(tier);
            control.timeLineControl.rangeSlider.OnTimeRangeChanged += tier.TimeRangeChanged;

            annoTiers.Add(tier);
            annoLists.Add(anno);

            AnnoTierStatic.Select(tier);
            tier.TimeRangeChanged(Time);

            updateNavigator();
        }
예제 #15
0
        private void removeAnnoTier()
        {
            AnnoTier at = AnnoTierStatic.Selected;

            if (at != null)
            {
                MessageBoxResult mb = MessageBoxResult.No;
                if (at.AnnoList.HasChanged)
                {
                    mb = MessageBox.Show("Save annotations on tier #" + at.Name + " first?", "Confirm", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);

                    if (mb == MessageBoxResult.Yes)
                    {
                        if (DatabaseLoaded)
                        {
                            databaseStore();
                        }
                        else
                        {
                            saveSelectedAnno();
                        }

                        at.AnnoList.HasChanged = false;
                    }
                }

                if (mb != MessageBoxResult.Cancel)
                {
                    control.annoTrackControl.annoTrackGrid.RowDefinitions[Grid.GetRow(at)].Height = new GridLength(0);
                    if (control.annoTrackControl.annoTrackGrid.Children.IndexOf(at) > 0)
                    {
                        control.annoTrackControl.annoTrackGrid.Children.RemoveAt(control.annoTrackControl.annoTrackGrid.Children.IndexOf(at) - 1);
                        control.annoTrackControl.annoTrackGrid.Children.RemoveAt(control.annoTrackControl.annoTrackGrid.Children.IndexOf(at));
                    }

                    AnnoTier.UnselectTier();
                    at.Children.Clear();
                    at.AnnoList.Clear();

                    annoTiers.Remove(at);
                    control.annoNameLabel.Content = "#NoTier";
                }
            }
        }
예제 #16
0
        private void annoList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListView grid = (ListView)sender;

            if (grid.SelectedIndex >= 0 && grid.SelectedIndex < grid.Items.Count)
            {
                AnnoListItem item = (AnnoListItem)grid.SelectedItem;
                control.annoListControl.editComboBox.SelectedItem = item.Label;

                movemedialock                   = true;
                Time.CurrentPlayPosition        = item.Start;
                Time.CurrentPlayPositionPrecise = item.Start;

                mediaList.move(item.Start);
                moveSignalCursorToSecond(item.Start);

                if (item.Start >= timeline.SelectionStop)
                {
                    float factor = (float)(((item.Start - Time.SelectionStart) / (Time.SelectionStop - Time.SelectionStart)));
                    control.timeLineControl.rangeSlider.MoveAndUpdate(true, factor);
                }
                else if (item.Stop <= timeline.SelectionStart)
                {
                    float factor = (float)(((Time.SelectionStart - item.Start)) / (Time.SelectionStop - Time.SelectionStart));
                    control.timeLineControl.rangeSlider.MoveAndUpdate(false, factor);
                }

                foreach (AnnoListItem a in AnnoTierStatic.Selected.AnnoList)
                {
                    if (a.Start == item.Start && a.Stop == item.Stop && item.Label == a.Label)
                    {
                        AnnoTier.SelectLabel(AnnoTierStatic.Selected.getSegment(a));
                        control.annoListControl.editComboBox.SelectedItem = item.Label;
                        control.annoListControl.editTextBox.Text          = item.Label;

                        break;
                    }
                }

                movemedialock = false;
            }
        }
예제 #17
0
        public AnnoTierSegment(AnnoListItem item, AnnoTier tier)
        {
            this.tier = tier;
            this.item = item;

            this.isSelected        = false;
            this.isResizeableLeft  = false;
            this.isResizeableRight = false;
            this.isMoveable        = false;

            this.Inlines.Add(item.Label == null ? "" : item.Label);
            this.FontSize     = 12;
            this.TextWrapping = TextWrapping.Wrap;
            if (item.Color != null)
            {
                Background = new SolidColorBrush(item.Color);
            }
            this.Foreground = Brushes.White;
            this.Opacity    = 0.75;

            this.TextAlignment = TextAlignment.Center;
            this.TextTrimming  = TextTrimming.WordEllipsis;

            ToolTip tt = new ToolTip();

            tt.Background = Brushes.Black;
            tt.Foreground = Brushes.White;
            if (item.Meta == null || item.Meta.ToString() == "")
            {
                tt.Content = item.Label;
            }
            else
            {
                tt.Content = item.Label + "\n\n" + item.Meta.Replace(";", "\n");
            }
            tt.StaysOpen = true;
            this.ToolTip = tt;

            item.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(item_PropertyChanged);

            update();
        }
예제 #18
0
        private void updateAnnoInfo(AnnoTier annoTier)
        {
            if (annoTier == null)
            {
                return;
            }

            AnnoList annoList = annoTier.AnnoList;

            control.annoSettingsButton.Visibility     = Visibility.Visible;
            control.annoStatusFileNameOrOIDLabel.Text = annoList.Name;
            if (annoList.Source.HasFile)
            {
                control.annoStatusFileNameOrOIDLabel.ToolTip = annoList.Source.File.Path;
            }
            else if (annoList.Source.HasDatabase)
            {
                control.annoStatusFileNameOrOIDLabel.ToolTip = annoList.Source.Database.OID;
            }
            else
            {
                control.annoStatusFileNameOrOIDLabel.ToolTip = "Not saved yet";
            }

            control.annoStatusSchemeNameLabel.Text = annoList.Scheme.Name;
            if (annoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
            {
                control.annoStatusSchemeTypeLabel.Text             = annoList.Scheme.Type.ToString();
                control.annoStatusSchemeContinuousPanel.Visibility = Visibility.Visible;
                control.annoSchemeContinuousSrLabel.Text           = annoList.Scheme.SampleRate.ToString() + " Hz";
                control.annoSchemeContinuousMinLabel.Text          = "min " + annoList.Scheme.MinScore.ToString();
                control.annoSchemeContinuousMaxLabel.Text          = "max " + annoList.Scheme.MaxScore.ToString();
            }
            else
            {
                control.annoStatusSchemeTypeLabel.Text             = annoList.Scheme.Type.ToString();
                control.annoStatusSchemeContinuousPanel.Visibility = Visibility.Collapsed;
            }
            control.annoStatusAnnotatorLabel.Text = annoList.Meta.AnnotatorFullName != "" ? annoList.Meta.AnnotatorFullName : annoList.Meta.Annotator;
            control.annoStatusRoleLabel.Text      = annoList.Meta.Role;
            control.annoCloseButton.Visibility    = playIsPlaying ? Visibility.Hidden : Visibility.Visible;
        }
예제 #19
0
        private void tierMenu_Click(object sender, RoutedEventArgs e)
        {
            AnnoTier a = AnnoTierStatic.Selected;

            if (a != null)
            {
                if (a.isDiscreteOrFree)
                {
                    control.exportAnnoContinuousToDiscreteMenu.IsEnabled = false;
                    control.exportAnnoToSignalMenu.IsEnabled             = false;
                }
                else if (!a.isDiscreteOrFree)
                {
                    control.exportAnnoContinuousToDiscreteMenu.IsEnabled = true;
                    control.exportAnnoToSignalMenu.IsEnabled             = true;
                }

                control.saveAnnoMenu.IsEnabled = true;
            }
        }
예제 #20
0
        private void MenuItemDeleteClick(object sender, RoutedEventArgs e)
        {
            if (AnnoTierStatic.Selected.isDiscreteOrFree)
            {
                if (annoDataGrid.SelectedItems.Count > 0)
                {
                    AnnoListItem[] selected = new AnnoListItem[annoDataGrid.SelectedItems.Count];
                    annoDataGrid.SelectedItems.CopyTo(selected, 0);
                    annoDataGrid.SelectedIndex = -1;

                    AnnoTier track = AnnoTierStatic.Selected;
                    foreach (AnnoListItem s in selected)
                    {
                        AnnoTierLabel segment = track.getSegment(s);
                        if (segment != null)
                        {
                            track.remSegment(segment);
                        }
                    }
                }
            }
        }
예제 #21
0
        public AnnoTier addAnnoTier(AnnoList anno)
        {
            if (this.annoTrackGrid.RowDefinitions.Count > 0)
            {
                // add splitter
                RowDefinition split_row = new RowDefinition();
                split_row.Height = new GridLength(1, GridUnitType.Auto);
                this.annoTrackGrid.RowDefinitions.Add(split_row);
                GridSplitter splitter = new GridSplitter();
                splitter.ResizeDirection     = GridResizeDirection.Rows;
                splitter.Height              = 3;
                splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                splitter.VerticalAlignment   = VerticalAlignment.Stretch;
                splitter.ShowsPreview        = true;
                Grid.SetColumnSpan(splitter, 1);
                Grid.SetColumn(splitter, 0);
                Grid.SetRow(splitter, this.annoTrackGrid.RowDefinitions.Count - 1);
                this.annoTrackGrid.Children.Add(splitter);
            }

            // add anno track
            RowDefinition row = new RowDefinition();

            row.Height = new GridLength(1, GridUnitType.Star);
            this.annoTrackGrid.RowDefinitions.Add(row);
            if (anno.Scheme.MinOrBackColor == Colors.Transparent)
            {
                anno.Scheme.MinOrBackColor = selectColor(this.annoTrackGrid.RowDefinitions.Count - 1);
            }
            AnnoTier tier = new AnnoTier(anno);

            Grid.SetColumn(tier, 0);
            Grid.SetRow(tier, this.annoTrackGrid.RowDefinitions.Count - 1);

            this.annoTrackGrid.Children.Add(tier);

            return(tier);
        }
예제 #22
0
        private void removeAnnoTier(AnnoTier tier)
        {
            if (tier != null)
            {
                MessageBoxResult mb = MessageBoxResult.No;

                if (tier.AnnoList.HasChanged)
                {
                    mb = MessageBox.Show("Save annotations on tier #" + tier.Name + " first?", "Confirm", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                    if (mb == MessageBoxResult.Yes)
                    {
                        tier.AnnoList.Save();
                    }
                }

                if (mb != MessageBoxResult.Cancel)
                {
                    control.annoTierControl.Remove(tier);

                    AnnoTierStatic.Unselect();
                    tier.Children.Clear();
                    tier.AnnoList.Clear();
                    annoTiers.Remove(tier);

                    if (annoTiers.Count > 0)
                    {
                        AnnoTierStatic.Select(annoTiers[0]);
                    }
                    else
                    {
                        clearAnnoInfo();
                        updateNavigator();
                    }
                }
            }
        }
예제 #23
0
        public void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (!this.control.annoListControl.editTextBox.IsFocused)
            {
                if (e.KeyboardDevice.IsKeyDown(Key.S) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                {
                    if (DatabaseLoaded)
                    {
                        databaseStore(true);
                    }
                    else
                    {
                        saveSelectedAnnoAs();
                    }
                }
                else if (e.KeyboardDevice.IsKeyDown(Key.S) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl))
                {
                    if (DatabaseLoaded)
                    {
                        databaseStore();
                    }
                    else
                    {
                        saveSelectedAnno();
                    }
                }
                else if (e.KeyboardDevice.IsKeyDown(Key.Delete) || e.KeyboardDevice.IsKeyDown(Key.Back))
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        AnnoTier.OnKeyDownHandler(sender, e);
                    }
                }

                if (e.KeyboardDevice.IsKeyDown(Key.R) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl))
                {
                    if (Properties.Settings.Default.DefaultDiscreteSampleRate != 0 && AnnoTierStatic.Selected.AnnoList.Scheme.SampleRate != Properties.Settings.Default.DefaultDiscreteSampleRate)
                    {
                        foreach (AnnoListItem ali in AnnoTierStatic.Selected.AnnoList)
                        {
                            if (ali.Start % (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) != 0)
                            {
                                int round = (int)(ali.Start / (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) + 0.5);
                                ali.Start = round * (1 / Properties.Settings.Default.DefaultDiscreteSampleRate);
                            }

                            if (ali.Stop % (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) != 0)
                            {
                                int round = (int)(ali.Stop / (1 / Properties.Settings.Default.DefaultDiscreteSampleRate) + 0.5);
                                ali.Stop = round * (1 / Properties.Settings.Default.DefaultDiscreteSampleRate);
                            }

                            ali.Duration = ali.Stop - ali.Start;
                        }
                        AnnoTierStatic.Selected.AnnoList.Scheme.SampleRate = Properties.Settings.Default.DefaultDiscreteSampleRate;
                    }
                }

                if (e.KeyboardDevice.IsKeyDown(Key.R) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.F5))
                {
                    AnnoTier track = AnnoTierStatic.Selected;
                    if (track != null)
                    {
                        if (DatabaseLoaded)
                        {
                            databaseReload(track);
                        }
                        else
                        {
                            reloadAnnoTier(track.AnnoList.Source.File.Path);
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.E) && !isKeyDown)
                {
                    if (AnnoTierStatic.Label != null && AnnoTierStatic.Selected.isDiscreteOrFree && isKeyDown == false)
                    {
                        UIElement container        = VisualTreeHelper.GetParent(AnnoTierStatic.Label) as UIElement;
                        Point     relativeLocation = AnnoTierStatic.Label.TranslatePoint(new Point(0, 0), container);

                        mediaList.move(MainHandler.Time.TimeFromPixel(relativeLocation.X + AnnoTierStatic.Label.Width));

                        annoCursor.X   = relativeLocation.X;
                        signalCursor.X = relativeLocation.X + AnnoTierStatic.Label.Width;

                        timeline.CurrentSelectPosition = annoCursor.X;
                        timeline.CurrentPlayPosition   = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        AnnoTierStatic.Label.select(true);
                        isKeyDown = true;
                    }
                }

                if (e.KeyboardDevice.IsKeyDown(Key.Q) && !isKeyDown)
                {
                    if (AnnoTierStatic.Label != null && AnnoTierStatic.Selected.isDiscreteOrFree && isKeyDown == false)
                    {
                        UIElement container        = VisualTreeHelper.GetParent(AnnoTierStatic.Label) as UIElement;
                        Point     relativeLocation = AnnoTierStatic.Label.TranslatePoint(new Point(0, 0), container);

                        mediaList.move(MainHandler.Time.TimeFromPixel(relativeLocation.X));

                        annoCursor.X   = relativeLocation.X + AnnoTierStatic.Label.Width;
                        signalCursor.X = relativeLocation.X;

                        timeline.CurrentSelectPosition = annoCursor.X;
                        timeline.CurrentPlayPosition   = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        AnnoTierStatic.Label.select(true);
                        isKeyDown = true;
                    }
                }

                if ((e.KeyboardDevice.IsKeyDown(Key.W) || !isKeyDown && AnnoTierStatic.Selected != null) && AnnoTierStatic.Selected.isDiscreteOrFree && !e.KeyboardDevice.IsKeyDown(Key.LeftAlt))
                {
                    if (AnnoTierStatic.Label == null)
                    {
                        AnnoTierStatic.Selected.NewAnnoKey();
                    }
                    else
                    {
                        ShowLabelBox();
                    }
                    if (AnnoTierStatic.Label != null)
                    {
                        AnnoTierStatic.Label.select(true);
                    }
                    isKeyDown = true;
                    // e.Handled = true;
                }
                else if ((e.KeyboardDevice.IsKeyDown(Key.W) || !isKeyDown && AnnoTierStatic.Selected != null) && !AnnoTierStatic.Selected.isDiscreteOrFree)
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        ShowLabelBoxCont();
                    }
                    if (AnnoTierStatic.Label != null)
                    {
                        AnnoTierStatic.Label.select(true);
                    }
                    isKeyDown = true;
                }
                if (e.KeyboardDevice.IsKeyDown(Key.Right) && e.KeyboardDevice.IsKeyDown(Key.LeftAlt) /*&& !isKeyDown*/)
                {
                    int    i   = 0;
                    double fps = 1.0 / 30.0;
                    foreach (IMedia im in mediaList.Medias)
                    {
                        if (im.IsVideo())
                        {
                            break;
                        }
                        i++;
                    }

                    if (i < mediaList.Medias.Count)
                    {
                        fps = 1.0 / mediaList.Medias[i].GetSampleRate();
                    }

                    //In case no media is loaded it takes the sr of the first loaded signal
                    else
                    {
                        if (signals.Count > 0)
                        {
                            fps = 1.0 / signals[0].rate;
                        }
                    }

                    mediaList.move(MainHandler.Time.TimeFromPixel(signalCursor.X) + fps);

                    if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                    {
                        annoCursor.X = annoCursor.X + MainHandler.Time.PixelFromTime(fps);
                    }
                    else
                    {
                        signalCursor.X = signalCursor.X + MainHandler.Time.PixelFromTime(fps);
                    }

                    timeline.CurrentSelectPosition      = annoCursor.X;
                    timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X);
                    timeline.CurrentPlayPositionPrecise = MainHandler.Time.TimeFromPixel(signalCursor.X);

                    if (AnnoTierStatic.Label != null)
                    {
                        double start = annoCursor.X;
                        double end   = signalCursor.X;

                        if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                        {
                            start = signalCursor.X;
                            end   = annoCursor.X;
                        }
                        if (end > start)
                        {
                            AnnoTierStatic.Label.resize_right(MainHandler.Time.PixelFromTime(fps));
                        }
                        else
                        {
                            AnnoTierStatic.Label.resize_left(MainHandler.Time.PixelFromTime(fps));
                        }
                        AnnoTierStatic.Label.select(true);
                    }

                    isKeyDown = true;
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.Left) && e.KeyboardDevice.IsKeyDown(Key.LeftAlt) /* && !isKeyDown*/)
                {
                    int    i   = 0;
                    double fps = 1.0 / 30.0;
                    foreach (IMedia im in mediaList.Medias)
                    {
                        if (im.IsVideo())
                        {
                            break;
                        }
                        i++;
                    }

                    if (i < mediaList.Medias.Count)
                    {
                        fps = 1.0 / mediaList.Medias[i].GetSampleRate();
                    }

                    mediaList.move(MainHandler.Time.TimeFromPixel(signalCursor.X) - fps);
                    if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                    {
                        annoCursor.X = annoCursor.X - MainHandler.Time.PixelFromTime(fps);
                    }
                    else
                    {
                        signalCursor.X = signalCursor.X - MainHandler.Time.PixelFromTime(fps);
                    }

                    timeline.CurrentSelectPosition      = annoCursor.X;
                    timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X);
                    timeline.CurrentPlayPositionPrecise = MainHandler.Time.TimeFromPixel(signalCursor.X);

                    double start = annoCursor.X;
                    double end   = signalCursor.X;

                    if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                    {
                        start = signalCursor.X;
                        end   = annoCursor.X;
                    }

                    if (AnnoTierStatic.Label != null)
                    {
                        if (end > start)
                        {
                            AnnoTierStatic.Label.resize_right(-MainHandler.Time.PixelFromTime(fps));
                        }
                        else
                        {
                            AnnoTierStatic.Label.resize_left(-MainHandler.Time.PixelFromTime(fps));
                        }
                        AnnoTierStatic.Label.select(true);
                    }

                    isKeyDown = true;
                    e.Handled = true;
                }
                else if (!e.KeyboardDevice.IsKeyDown(Key.LeftAlt))
                {
                    AnnoTier.OnKeyDownHandler(sender, e);
                }
            }
        }
예제 #24
0
        public void OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (!this.control.annoListControl.editTextBox.IsFocused)
            {
                if (e.KeyboardDevice.IsKeyDown(Key.Space))
                {
                    handlePlay();

                    e.Handled = true;
                }


                if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && e.KeyboardDevice.IsKeyDown(Key.L))
                {
                    if (AnnoTierStatic.Selected != null && Properties.Settings.Default.CMLDefaultStream != null)
                    {
                        DatabaseHandler.StoreToDatabase(AnnoTierStatic.Selected.AnnoList, loadedDBmedia, false);
                        CompleteTier(Properties.Settings.Default.CMLContext, AnnoTierStatic.Selected, Properties.Settings.Default.CMLDefaultStream, Properties.Settings.Default.CMLDefaultConf, Properties.Settings.Default.CMLDefaultGap, Properties.Settings.Default.CMLDefaultMinDur);
                    }

                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.D0) || e.KeyboardDevice.IsKeyDown(Key.NumPad0))
                {
                    if (AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.DISCRETE || AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.FREE)
                    {
                        string label = "GARBAGE";
                        if (AnnoTierStatic.Label != null)
                        {
                            AnnoTierStatic.Label.Item.Label      = label;
                            AnnoTierStatic.Label.Item.Color      = Colors.Black;
                            AnnoTierStatic.Label.Item.Confidence = 1.0;
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.D1) || e.KeyboardDevice.IsKeyDown(Key.D2) || e.KeyboardDevice.IsKeyDown(Key.D3) || e.KeyboardDevice.IsKeyDown(Key.D4) ||
                    e.KeyboardDevice.IsKeyDown(Key.D5) || e.KeyboardDevice.IsKeyDown(Key.D6) || e.KeyboardDevice.IsKeyDown(Key.D7) || e.KeyboardDevice.IsKeyDown(Key.D8) || e.KeyboardDevice.IsKeyDown(Key.D9) ||
                    e.KeyboardDevice.IsKeyDown(Key.NumPad1) || e.KeyboardDevice.IsKeyDown(Key.NumPad2) || e.KeyboardDevice.IsKeyDown(Key.NumPad3) || e.KeyboardDevice.IsKeyDown(Key.NumPad4) || e.KeyboardDevice.IsKeyDown(Key.NumPad5) ||
                    e.KeyboardDevice.IsKeyDown(Key.NumPad6) || e.KeyboardDevice.IsKeyDown(Key.NumPad7) || e.KeyboardDevice.IsKeyDown(Key.NumPad8) || e.KeyboardDevice.IsKeyDown(Key.NumPad9))
                {
                    int index = 0;
                    if (e.Key - Key.D1 < 10 && AnnoTierStatic.Selected.AnnoList.Scheme.Labels != null && AnnoTierStatic.Selected.AnnoList.Scheme.Labels.Count > 0)
                    {
                        index = Math.Min(AnnoTierStatic.Selected.AnnoList.Scheme.Labels.Count - 1, e.Key - Key.D1);
                    }
                    else if (AnnoTierStatic.Selected.AnnoList.Scheme.Labels != null)
                    {
                        index = Math.Min(AnnoTierStatic.Selected.AnnoList.Scheme.Labels.Count - 1, e.Key - Key.NumPad1);
                    }

                    if (index >= 0 && AnnoTierStatic.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.DISCRETE)
                    {
                        string label = AnnoTierStatic.Selected.AnnoList.Scheme.Labels.ElementAt(index).Name;
                        if (AnnoTierStatic.Label != null)
                        {
                            AnnoTierStatic.Label.Item.Label      = label;
                            AnnoTierStatic.Selected.DefaultLabel = label;

                            foreach (AnnoScheme.Label lp in AnnoTierStatic.Selected.AnnoList.Scheme.Labels)
                            {
                                if (label == lp.Name)
                                {
                                    AnnoTierStatic.Label.Item.Color      = lp.Color;
                                    AnnoTierStatic.Label.Item.Confidence = 1.0;
                                    AnnoTierStatic.Selected.DefaultColor = lp.Color;

                                    break;
                                }
                            }
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.Right) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl))
                {
                    if (AnnoTierStatic.Label != null && AnnoTierStatic.Selected.isDiscreteOrFree && isKeyDown == false /*&& AnnoTierStatic.Label == null*/)
                    {
                        UIElement container        = VisualTreeHelper.GetParent(AnnoTierStatic.Label) as UIElement;
                        Point     relativeLocation = AnnoTierStatic.Label.TranslatePoint(new Point(0, 0), container);

                        mediaList.move(MainHandler.Time.TimeFromPixel(relativeLocation.X + AnnoTierStatic.Label.Width));

                        if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                        {
                            annoCursor.X = relativeLocation.X + AnnoTierStatic.Label.Width;
                        }
                        else
                        {
                            signalCursor.X = relativeLocation.X + AnnoTierStatic.Label.Width;
                        }

                        timeline.CurrentSelectPosition      = annoCursor.X;
                        timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        timeline.CurrentPlayPositionPrecise = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        AnnoTierStatic.Label.select(true);
                        isKeyDown = true;
                    }
                    e.Handled = true;
                }

                else if (e.KeyboardDevice.IsKeyDown(Key.Right) && !e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && !e.KeyboardDevice.IsKeyDown(Key.LeftAlt) && !isKeyDown)
                {
                    isKeyDown = true;
                    if (AnnoTier.Selected != null)
                    {
                        AnnoTier.Selected.Focus();
                    }
                    int    i   = 0;
                    double fps = 1.0 / 25.0;
                    foreach (IMedia im in mediaList.Medias)
                    {
                        if (im.IsVideo())
                        {
                            break;
                        }
                        i++;
                    }

                    if (i < mediaList.Medias.Count)
                    {
                        fps = 1.0 / mediaList.Medias[i].GetSampleRate();
                    }

                    mediaList.move(MainHandler.Time.TimeFromPixel(signalCursor.X) + fps);
                    timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X) + fps;
                    timeline.CurrentPlayPositionPrecise = MainHandler.Time.TimeFromPixel(signalCursor.X) + fps;
                    double pos = MainHandler.Time.PixelFromTime(timeline.CurrentPlayPosition);
                    signalCursor.X = pos;


                    if (Time.CurrentPlayPosition >= Time.SelectionStop && control.navigator.followplaybox.IsChecked == true)
                    {
                        double factor = (((timeline.CurrentPlayPosition - timeline.SelectionStart) / (timeline.SelectionStop - timeline.SelectionStart)));
                        control.timeLineControl.rangeSlider.followmedia = true;
                        control.timeLineControl.rangeSlider.MoveAndUpdate(true, factor);

                        if (timeline.SelectionStop - timeline.SelectionStart < 1)
                        {
                            timeline.SelectionStart = timeline.SelectionStop - 1;
                        }
                        signalCursor.X = 1;
                    }
                    else if (control.navigator.followplaybox.IsChecked == false)
                    {
                        control.timeLineControl.rangeSlider.followmedia = false;
                    }



                    double time = Time.TimeFromPixel(pos);
                    control.signalPositionLabel.Text     = FileTools.FormatSeconds(time);
                    control.annoTrackControl.currenttime = Time.TimeFromPixel(pos);
                    e.Handled = true;
                }



                if (e.KeyboardDevice.IsKeyDown(Key.Left) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl))
                {
                    if (AnnoTierStatic.Label != null && AnnoTierStatic.Selected.isDiscreteOrFree && isKeyDown == false /*&& AnnoTierStatic.Label == null*/)
                    {
                        UIElement container        = VisualTreeHelper.GetParent(AnnoTierStatic.Label) as UIElement;
                        Point     relativeLocation = AnnoTierStatic.Label.TranslatePoint(new Point(0, 0), container);

                        mediaList.move(MainHandler.Time.TimeFromPixel(relativeLocation.X));

                        if (e.KeyboardDevice.IsKeyDown(Key.LeftShift))
                        {
                            annoCursor.X = relativeLocation.X;
                        }
                        else
                        {
                            signalCursor.X = relativeLocation.X;
                        }

                        timeline.CurrentSelectPosition      = annoCursor.X;
                        timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        timeline.CurrentPlayPositionPrecise = MainHandler.Time.TimeFromPixel(signalCursor.X);
                        AnnoTierStatic.Label.select(true);
                        isKeyDown = true;
                    }
                    e.Handled = true;
                }

                else if (e.KeyboardDevice.IsKeyDown(Key.Left) && !e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && !e.KeyboardDevice.IsKeyDown(Key.LeftAlt) && !isKeyDown)
                {
                    isKeyDown = true;
                    if (AnnoTier.Selected != null)
                    {
                        AnnoTier.Selected.Focus();
                    }
                    int    i   = 0;
                    double fps = 1.0 / 25.0;
                    foreach (IMedia im in mediaList.Medias)
                    {
                        if (im.IsVideo())
                        {
                            break;
                        }
                        i++;
                    }

                    if (i < mediaList.Medias.Count)
                    {
                        fps = 1.0 / mediaList.Medias[i].GetSampleRate();
                    }

                    mediaList.move(MainHandler.Time.TimeFromPixel(signalCursor.X) - fps);
                    timeline.CurrentPlayPosition        = MainHandler.Time.TimeFromPixel(signalCursor.X) - fps;
                    timeline.CurrentPlayPositionPrecise = timeline.CurrentPlayPosition;
                    double pos = MainHandler.Time.PixelFromTime(timeline.CurrentPlayPosition);
                    signalCursor.X = pos;



                    if (Time.CurrentPlayPosition < Time.SelectionStart && Time.SelectionStart > 0 && control.navigator.followplaybox.IsChecked == true)
                    {
                        double factor = (((timeline.SelectionStop - timeline.CurrentPlayPosition) / (timeline.SelectionStop - timeline.SelectionStart)));
                        control.timeLineControl.rangeSlider.followmedia = true;
                        control.timeLineControl.rangeSlider.MoveAndUpdate(false, factor);

                        if (timeline.SelectionStop - timeline.SelectionStart < 1)
                        {
                            timeline.SelectionStart = timeline.SelectionStop - 1;
                        }
                        signalCursor.X = MainHandler.Time.PixelFromTime(MainHandler.Time.SelectionStop);
                    }
                    else if (control.navigator.followplaybox.IsChecked == false)
                    {
                        control.timeLineControl.rangeSlider.followmedia = false;
                    }



                    double time = Time.TimeFromPixel(pos);
                    if (time != 0)
                    {
                        control.signalPositionLabel.Text     = FileTools.FormatSeconds(time);
                        control.annoTrackControl.currenttime = Time.TimeFromPixel(pos);
                    }

                    e.Handled = true;
                }



                if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && !isKeyDown)
                {
                    if (AnnoTierStatic.Selected != null && !AnnoTierStatic.Selected.isDiscreteOrFree)
                    {
                        AnnoTierStatic.Selected.ContinuousAnnoMode();
                    }
                    isKeyDown = true;
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.T) && e.KeyboardDevice.IsKeyDown(Key.Down))
                {
                    for (int i = 0; i < annoTiers.Count; i++)
                    {
                        if (annoTiers[i] == AnnoTierStatic.Selected && i + 1 < annoTiers.Count)
                        {
                            AnnoTier.SelectTier(annoTiers[i + 1]);
                            AnnoTier.SelectLabel(null);
                            break;
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.T) && e.KeyboardDevice.IsKeyDown(Key.Up))
                {
                    for (int i = 0; i < annoTiers.Count; i++)
                    {
                        if (annoTiers[i] == AnnoTierStatic.Selected && i > 0)
                        {
                            AnnoTier.SelectTier(annoTiers[i - 1]);
                            AnnoTier.SelectLabel(null);
                            break;
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.C) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && AnnoTierStatic.Selected != null && AnnoTierStatic.Selected.isDiscreteOrFree)
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        temp_segment = AnnoTierStatic.Label;
                        AnnoTierStatic.Label.select(false);
                    }

                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.X) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && AnnoTierStatic.Selected != null && AnnoTierStatic.Selected.isDiscreteOrFree)
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        temp_segment = AnnoTierStatic.Label;
                        AnnoTier.OnKeyDownHandler(sender, e);
                    }

                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.V) && e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && AnnoTierStatic.Selected != null && AnnoTierStatic.Selected.isDiscreteOrFree)
                {
                    if (AnnoTierStatic.Selected != null)
                    {
                        double start = Time.TimeFromPixel(annoCursor.X);
                        if (temp_segment != null)
                        {
                            AnnoTierStatic.Selected.NewAnnoCopy(start, start + temp_segment.Item.Duration, temp_segment.Item.Label, temp_segment.Item.Color, temp_segment.Item.Confidence);
                        }
                    }

                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && e.KeyboardDevice.IsKeyDown(Key.Z))
                {
                    if (AnnoTierStatic.Selected != null)
                    {
                        AnnoTierStatic.Selected.UnDoObject.Undo(1);
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) && e.KeyboardDevice.IsKeyDown(Key.Y))
                {
                    if (AnnoTierStatic.Selected != null)
                    {
                        AnnoTierStatic.Selected.UnDoObject.Redo(1);
                    }

                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.LeftAlt) && e.KeyboardDevice.IsKeyDown(Key.Down))
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        AnnoListItem temp = AnnoTierStatic.Label.Item;

                        for (int i = 0; i < annoTiers.Count; i++)
                        {
                            if (annoTiers[i] == AnnoTierStatic.Selected && i + 1 < annoTiers.Count)
                            {
                                AnnoTier.SelectTier(annoTiers[i + 1]);
                                AnnoTier.SelectLabel(null);
                                if (!AnnoTierStatic.Selected.AnnoList.Contains(temp))
                                {
                                    AnnoTierStatic.Selected.NewAnnoCopy(temp.Start, temp.Stop, temp.Label, temp.Color);
                                }

                                break;
                            }
                        }
                    }
                    e.Handled = true;
                }

                if (e.KeyboardDevice.IsKeyDown(Key.LeftAlt) && e.KeyboardDevice.IsKeyDown(Key.Up))
                {
                    if (AnnoTierStatic.Label != null)
                    {
                        AnnoListItem temp = AnnoTierStatic.Label.Item;

                        for (int i = 0; i < annoTiers.Count; i++)
                        {
                            if (annoTiers[i] == AnnoTierStatic.Selected && i > 0)
                            {
                                AnnoTier.SelectTier(annoTiers[i - 1]);
                                AnnoTier.SelectLabel(null);
                                if (!AnnoTierStatic.Selected.AnnoList.Contains(temp))
                                {
                                    AnnoTierStatic.Selected.NewAnnoCopy(temp.Start, temp.Stop, temp.Label, temp.Color);
                                }
                                break;
                            }
                        }
                    }
                    e.Handled = true;
                }
            }
        }
예제 #25
0
        public void Add(AnnoTier tier)
        {
            for (int i = 0; i < grid.RowDefinitions.Count; i += 2)
            {
                grid.RowDefinitions[i].Height = new GridLength(1, GridUnitType.Star);
            }

            if (grid.RowDefinitions.Count > 0)
            {
                // add splitter
                RowDefinition split = new RowDefinition();
                split.Height = new GridLength(1, GridUnitType.Auto);
                grid.RowDefinitions.Add(split);
                GridSplitter splitter = new GridSplitter();
                splitter.Background          = Defaults.Brushes.Splitter;
                splitter.ResizeDirection     = GridResizeDirection.Rows;
                splitter.Height              = 5;
                splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                splitter.VerticalAlignment   = VerticalAlignment.Stretch;
                splitter.ShowsPreview        = true;
                Grid.SetColumnSpan(splitter, 1);
                Grid.SetColumn(splitter, 0);
                Grid.SetRow(splitter, grid.RowDefinitions.Count - 1);
                grid.Children.Add(splitter);
            }

            // add anno tier
            RowDefinition row = new RowDefinition();

            row.Height = new GridLength(1, GridUnitType.Star);
            grid.RowDefinitions.Add(row);

            Grid.SetColumn(tier, 0);
            Grid.SetRow(tier, grid.RowDefinitions.Count - 1);
            grid.Children.Add(tier);

            Label label = new Label();

            label.Content = " " + tier.AnnoList.Scheme.Name;
            if (tier.AnnoList.Meta.Role != "")
            {
                label.Content += "." + tier.AnnoList.Meta.Role;
            }
            if (tier.AnnoList.Meta.AnnotatorFullName != "")
            {
                label.Content += " (" + tier.AnnoList.Meta.AnnotatorFullName + ")";
            }
            label.HorizontalAlignment = HorizontalAlignment.Left;
            label.VerticalAlignment   = VerticalAlignment.Center;
            label.Foreground          = Brushes.Black;
            Color color = Defaults.Colors.Highlight;

            color.A                = 128;
            label.Background       = new SolidColorBrush(color);
            label.IsHitTestVisible = false;
            Grid.SetColumn(label, 0);
            Grid.SetRow(label, grid.RowDefinitions.Count - 1);
            grid.Children.Add(label);

            Border border = new Border();

            border.BorderThickness  = new Thickness(Defaults.SelectionBorderWidth, 0, 0, 0);
            border.BorderBrush      = Defaults.Brushes.Highlight;
            border.IsHitTestVisible = false;
            Grid.SetColumn(border, 0);
            Grid.SetRow(border, grid.RowDefinitions.Count - 1);
            grid.Children.Add(border);

            tier.Border = border;
        }
예제 #26
0
        private void annoTierControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (control.navigator.askforlabels.IsChecked == true)
            {
                AnnoTier.askForLabel = true;
            }
            else
            {
                AnnoTier.askForLabel = false;
            }



            if (e.LeftButton == MouseButtonState.Pressed && !Keyboard.IsKeyDown(Key.LeftShift))
            {
                if (AnnoTierStatic.Selected != null)
                {
                    AnnoTierStatic.Selected.LeftMouseButtonDown(e);
                }
                if (AnnoTierStatic.Label != null)

                {
                    AnnoTierStatic.Label.isMoveable = true;
                }
                geometricCompare.Clear();
            }

            else if (e.RightButton == MouseButtonState.Pressed && !Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                if (AnnoTierStatic.Label != null)
                {
                    AnnoTierStatic.Label.select(false);
                }

                if (AnnoTierStatic.Selected != null && (AnnoTierStatic.Selected.AnnoList.Scheme.Type != AnnoScheme.TYPE.CONTINUOUS || isMouseButtonDown == false))
                {
                    foreach (AnnoTier a in annoTiers)
                    {
                        if (a.IsMouseOver)
                        {
                            AnnoTier.SelectLabel(null);
                            AnnoTier.Select(a);
                            break;
                        }
                    }
                }

                if (AnnoTierStatic.Selected != null)
                {
                    AnnoTierStatic.Selected.RightMouseButtonDown(e);
                }
                isMouseButtonDown = true;
            }
            else if (e.RightButton == MouseButtonState.Pressed && Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                try
                {
                    AnnoList al = ((AnnoTier)Mouse.DirectlyOver).AnnoList;
                    if (al.ID != AnnoTierStatic.Selected.AnnoList.ID)
                    {
                        geometricCompare.Add(al);
                    }
                }
                catch { }
            }

            if (AnnoTierStatic.Selected != null)
            {
                if (AnnoTierStatic.Selected.IsDiscreteOrFree || (!AnnoTierStatic.Selected.IsDiscreteOrFree && Keyboard.IsKeyDown(Key.LeftShift)))
                {
                    double pos = e.GetPosition(control.signalAndAnnoGrid).X;
                    annoCursor.X = pos;
                    Time.CurrentSelectPosition = pos;

                    annoCursor.Visibility = Visibility.Visible;
                    double time = Time.TimeFromPixel(pos);
                    control.annoPositionLabel.Text = FileTools.FormatSeconds(time);
                }
                else
                {
                    double pos = e.GetPosition(control.signalAndAnnoGrid).X;
                    annoCursor.X = 0;
                    double time = Time.TimeFromPixel(pos);
                    annoCursor.Visibility          = Visibility.Hidden;
                    control.annoPositionLabel.Text = FileTools.FormatSeconds(time);
                }
            }

            else
            {
                double pos = e.GetPosition(control.signalAndAnnoGrid).X;
                annoCursor.X = 0;
                double time = Time.TimeFromPixel(pos);
                annoCursor.Visibility          = Visibility.Hidden;
                control.annoPositionLabel.Text = FileTools.FormatSeconds(time);
            }
        }
예제 #27
0
        private void annoTrackGrid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (control.navigator.askforlabels.IsChecked == true)
            {
                AnnoTier.askForLabel = true;
            }
            else
            {
                AnnoTier.askForLabel = false;
            }

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (AnnoTierStatic.Label != null)
                {
                    AnnoTierStatic.Label.isMoveable = true;
                    AnnoTierStatic.Selected.LeftMouseButtonDown(e);
                }
            }

            if (e.RightButton == MouseButtonState.Pressed)
            {
                if (AnnoTierStatic.Label != null)
                {
                    AnnoTierStatic.Label.select(false);
                }

                if (AnnoTierStatic.Selected != null && (AnnoTierStatic.Selected.AnnoList.Scheme.Type != AnnoScheme.TYPE.CONTINUOUS || isMouseButtonDown == false))
                {
                    foreach (AnnoTier a in annoTiers)
                    {
                        if (a.IsMouseOver)
                        {
                            AnnoTier.SelectLabel(null);
                            AnnoTier.SelectTier(a);
                            break;
                        }
                    }
                }

                if (AnnoTierStatic.Selected != null)
                {
                    AnnoTierStatic.Selected.RightMouseButtonDown(e);
                }
                isMouseButtonDown = true;
            }

            if (AnnoTierStatic.Selected != null)
            {
                if (AnnoTierStatic.Selected.isDiscreteOrFree || (!AnnoTierStatic.Selected.isDiscreteOrFree && Keyboard.IsKeyDown(Key.LeftShift)))
                {
                    double pos = e.GetPosition(control.trackGrid).X;
                    annoCursor.X = pos;
                    Time.CurrentSelectPosition = pos;

                    annoCursor.Visibility = Visibility.Visible;
                    double time = Time.TimeFromPixel(pos);
                    control.annoPositionLabel.Text = FileTools.FormatSeconds(time);
                }
                else
                {
                    annoCursor.X = 0;
                    double time = Time.TimeFromPixel(0);
                    annoCursor.Visibility          = Visibility.Hidden;
                    control.annoPositionLabel.Text = FileTools.FormatSeconds(time);
                }
            }
        }
예제 #28
0
        private void ExportAnnoContinuousToDiscrete()
        {
            if (AnnoTierStatic.Selected != null && !AnnoTierStatic.Selected.IsDiscreteOrFree)
            {
                Dictionary <string, UserInputWindow.Input> input = new Dictionary <string, UserInputWindow.Input>();
                input["labels"] = new UserInputWindow.Input()
                {
                    Label = "Class labels (separated by ;)", DefaultValue = Properties.Settings.Default.ConvertToDiscreteClasses
                };
                input["thresholds"] = new UserInputWindow.Input()
                {
                    Label = "Upper thresholds (separated by ;)", DefaultValue = Properties.Settings.Default.ConvertToDiscreteThreshs
                };
                input["offset"] = new UserInputWindow.Input()
                {
                    Label = "Optional offset (s)", DefaultValue = Properties.Settings.Default.ConvertToDiscreteDelays
                };
                UserInputWindow dialog = new UserInputWindow("Convert to discrete annotation", input);
                dialog.ShowDialog();

                List <string> classes         = new List <string>();
                List <double> upperThresholds = new List <double>();
                double        offset          = 0.0;

                if (dialog.DialogResult == true)
                {
                    Properties.Settings.Default.ConvertToDiscreteClasses = dialog.Result("labels");
                    Properties.Settings.Default.ConvertToDiscreteThreshs = dialog.Result("thresholds");
                    Properties.Settings.Default.ConvertToDiscreteDelays  = dialog.Result("offset");
                    Properties.Settings.Default.Save();


                    string[] labels = dialog.Result("labels").Split(';');
                    for (int i = 0; i < labels.Length; i++)
                    {
                        classes.Add(labels[i]);
                    }

                    string[] thresholds = dialog.Result("thresholds").Split(';');
                    for (int i = 0; i < thresholds.Length; i++)
                    {
                        double thresh = -1;
                        double.TryParse(thresholds[i], out thresh);
                        if (thresh > -1)
                        {
                            upperThresholds.Add(thresh);
                        }
                        else
                        {
                            MessageTools.Warning("Could not parse input");
                        }
                    }

                    if (thresholds.Length == labels.Length - 1)
                    {
                        upperThresholds.Add(1.0);
                    }
                    else if (thresholds.Length == labels.Length + 1)
                    {
                        classes.Add("REST");
                    }
                    else if (thresholds.Length != labels.Length)
                    {
                        MessageBox.Show("Number of labels does not match number of threshholds");
                    }

                    double.TryParse(dialog.Result("offset"), out offset);
                }
                Mouse.SetCursor(Cursors.No);

                AnnoList discretevalues = new AnnoList();
                discretevalues.Scheme         = new AnnoScheme();
                discretevalues.Scheme.Type    = AnnoScheme.TYPE.DISCRETE;
                discretevalues.Meta.Role      = AnnoTier.Selected.AnnoList.Meta.Role;
                discretevalues.Meta.Annotator = AnnoTier.Selected.AnnoList.Meta.Annotator;
                discretevalues.Scheme.Name    = AnnoTier.Selected.AnnoList.Scheme.Name;

                foreach (string label in classes)
                {
                    AnnoScheme.Label item = new AnnoScheme.Label(label, System.Windows.Media.Colors.Black);
                    discretevalues.Scheme.Labels.Add(item);
                }

                AnnoScheme.Label garbage = new AnnoScheme.Label("GARBAGE", Colors.Black);
                discretevalues.Scheme.Labels.Add(garbage);

                double lowThres  = -Double.MaxValue;
                double highThres = 1.0;

                foreach (AnnoListItem ali in AnnoTierStatic.Selected.AnnoList)
                {
                    double val = ali.Score;

                    for (int i = 0; i < classes.Count; i++)
                    {
                        highThres = upperThresholds[i];
                        if (i > 0)
                        {
                            lowThres = upperThresholds[i - 1];
                        }
                        else
                        {
                            lowThres = -Double.MaxValue;
                        }

                        if (val > lowThres && val <= highThres)
                        {
                            if (!(discretevalues.Count > 0 && discretevalues[discretevalues.Count - 1].Label == classes[i]))
                            {
                                AnnoListItem newItem = new AnnoListItem(ali.Start + offset, ali.Duration, classes[i], "", discretevalues.Scheme.GetColorForLabel(classes[i]));
                                if (newItem.Start < 0.0)
                                {
                                    newItem.Duration = ali.Duration + offset + newItem.Start;
                                    newItem.Start    = 0.0;
                                    newItem.Stop     = newItem.Duration;
                                }
                                if (newItem.Duration > 0.0)
                                {
                                    discretevalues.Add(newItem);
                                }
                            }
                            else
                            {
                                discretevalues[discretevalues.Count - 1].Stop = discretevalues[discretevalues.Count - 1].Stop + ali.Duration;
                            }
                            break;
                        }
                    }
                }

                AnnoTier.Unselect();
                addAnnoTierFromList(discretevalues);

                Mouse.SetCursor(System.Windows.Input.Cursors.Arrow);
            }
            else
            {
                MessageBox.Show("Tier is already discrete");
            }
        }
예제 #29
0
        public void ReloadAnnoTierFromDatabase(AnnoTier tier, bool loadBackup)
        {
            if (tier == null || tier.AnnoList == null)
            {
                return;
            }

            if (loadBackup && tier.AnnoList.Source.Database.DataBackupOID == AnnoSource.DatabaseSource.ZERO)
            {
                MessageTools.Warning("No backup exists");
                return;
            }

            Action EmptyDelegate = delegate() { };

            control.ShadowBoxText.Text   = "Reloading Annotation";
            control.ShadowBox.Visibility = Visibility.Visible;
            control.UpdateLayout();
            control.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);

            DatabaseAnnotation annotation = new DatabaseAnnotation();

            annotation.Role              = tier.AnnoList.Meta.Role;
            annotation.Scheme            = tier.AnnoList.Scheme.Name;
            annotation.AnnotatorFullName = tier.AnnoList.Meta.AnnotatorFullName;
            annotation.Annotator         = tier.AnnoList.Meta.Annotator;
            annotation.Session           = DatabaseHandler.SessionName;

            AnnoList annoList = DatabaseHandler.LoadAnnoList(annotation, loadBackup);
            double   maxdur   = 0;

            if (annoList != null && annoList.Count > 0 && annoList.Scheme.Type == AnnoScheme.TYPE.DISCRETE || annoList.Scheme.Type == AnnoScheme.TYPE.FREE)
            {
                maxdur = annoList[annoList.Count - 1].Stop;

                setAnnoList(annoList);
                tier.Children.Clear();
                tier.AnnoList.Clear();
                tier.segments.Clear();
                tier.AnnoList = annoList;

                foreach (AnnoListItem item in annoList)
                {
                    tier.AddSegment(item);
                }

                tier.TimeRangeChanged(Time);
                updateTimeRange(maxdur);

                tier.AnnoList.HasChanged = false;
            }

            else if (annoList != null && annoList.Count > 0 && annoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
            {
                maxdur = annoList[annoList.Count - 1].Stop;

                setAnnoList(annoList);
                tier.AnnoList.Clear();
                tier.AnnoList = annoList;
                tier.TimeRangeChanged(Time);
                updateTimeRange(maxdur);
                AnnoTier.Selected.TimeRangeChanged(MainHandler.Time);

                tier.AnnoList.HasChanged = false;
            }

            control.ShadowBox.Visibility = Visibility.Collapsed;
        }
예제 #30
0
        private void annoStatsButton_Click(object sender, RoutedEventArgs e)
        {
            if (AnnoTier.Selected != null && AnnoTier.Selected.AnnoList.Scheme.Type == AnnoScheme.TYPE.CONTINUOUS)
            {
                Signal temp = new Signal();

                AnnoTier annoTier = AnnoTierStatic.Selected;

                double sr    = 1 / annoTier.AnnoList[0].Duration;
                double from  = 0.0;
                double to    = annoTier.AnnoList[annoTier.AnnoList.Count - 1].Stop;
                int    num   = annoTier.AnnoList.Count;
                string ftype = "ASCII";
                string type  = "FLOAT";
                int    by    = sizeof(float);
                int    dim   = 1;
                int    ms    = Environment.TickCount;

                var filename = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), annoTier.AnnoList.Scheme.Name + ".stream");


                try
                {
                    StreamWriter swheader = new StreamWriter(filename, false, System.Text.Encoding.Default);
                    swheader.WriteLine("<?xml version=\"1.0\" ?>");
                    swheader.WriteLine("<stream ssi-v=\"2\">");
                    swheader.WriteLine("\t<info ftype=\"" + ftype + "\" sr=\"" + sr.ToString("0.000000", CultureInfo.InvariantCulture) + "\" dim=\"" + dim.ToString() + "\" byte=\"" + by.ToString() + "\" type=\"" + type + "\" />");
                    swheader.WriteLine("\t<time ms=\"" + ms + "\" local=\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\" system=\"" + DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss") + "\"/>");
                    swheader.WriteLine("\t<chunk from=\"" + from.ToString("0.000000", CultureInfo.InvariantCulture) + "\" to=\"" + to.ToString("0.000000", CultureInfo.InvariantCulture) + "\" byte=\"" + "0" + "\" num=\"" + num + "\"/>");

                    swheader.WriteLine("</stream>");
                    swheader.Close();

                    StreamWriter swdata = new StreamWriter(filename + "~", false, System.Text.Encoding.Default);
                    foreach (AnnoListItem i in annoTier.AnnoList)
                    {
                        swdata.WriteLine(i.Score);
                    }
                    swdata.Close();

                    temp = Signal.LoadStreamFile(filename);
                    try
                    {
                        File.Delete(filename);
                        File.Delete(filename + "~");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    //temp.

                    SignalStatsWindow ssw = new SignalStatsWindow(temp, 0, true);
                    Time.OnTimelineChanged   += ssw.timeRangeChanged;
                    ssw.Topmost               = true;
                    ssw.WindowStartupLocation = WindowStartupLocation.Manual;
                    ssw.Show();

                    if (ssw.DialogResult == false)
                    {
                        Time.OnTimelineChanged -= ssw.timeRangeChanged;
                    }
                }

                catch (Exception x)
                {
                    MessageBox.Show(x.ToString());
                }
            }
        }