Пример #1
0
        /// ------------------------------------------------------------------------------------
        public ManualSegmenterDlg(ManualSegmenterDlgViewModel viewModel, int segmentToHighlight)
            : base(viewModel)
        {
            Logger.WriteEvent("ManualSegmenterDlg constructor. ComponentFile = {0}; segmentToHighlight = ", viewModel.ComponentFile, segmentToHighlight);
            InitializeComponent();
            _tableLayoutButtons.BackColor = Settings.Default.BarColorEnd;
            Opacity = 0D;

            viewModel.AllowDeletionOfOralAnnotations = AllowDeletionOfOralAnnotations;

            Controls.Remove(toolStripButtons);
            _tableLayoutOuter.Controls.Add(toolStripButtons);
            _tableLayoutOuter.Resize += HandleTableLayoutOuterResize;

            _tableLayoutButtons.Controls.Add(_pictureIcon, 0, 0);
            _tableLayoutButtons.SetRowSpan(_pictureIcon, 3);
            _pictureIcon.Anchor = AnchorStyles.Left | AnchorStyles.Right;
            _tableLayoutButtons.Controls.Add(_labelInfo, 1, 0);
            _tableLayoutButtons.SetRowSpan(_labelInfo, 3);
            _tableLayoutButtons.ColumnStyles[0].SizeType = SizeType.AutoSize;
            _tableLayoutButtons.ColumnStyles[1].SizeType = SizeType.Percent;

            _origAddSegBoundaryButtonText = _buttonAddSegmentBoundary.Text;

            _buttonStopOriginal.Click += delegate { _waveControl.Stop(); };

            if (segmentToHighlight > 0)
            {
                Shown += delegate {
                    var endOfPreviousSegment = ViewModel.GetEndOfSegment(segmentToHighlight - 1);
                    _waveControl.SetCursor(endOfPreviousSegment);
                    _waveControl.EnsureTimeIsVisible(endOfPreviousSegment);
                };
            }
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        public static string ShowDialog(ComponentFile file, EditorBase parent, int segmentToHighlight)
        {
            Exception error;
            string    msg;

            using (var viewModel = new ManualSegmenterDlgViewModel(file))
                using (var dlg = new ManualSegmenterDlg(viewModel, segmentToHighlight))
                {
                    try
                    {
                        if (dlg.ShowDialog(parent) != DialogResult.OK || !viewModel.WereChangesMade)
                        {
                            viewModel.DiscardChanges();
                            return(null);
                        }

                        Analytics.Track("Changes made using Manual Segmentation");

                        var annotationFile = file.GetAnnotationFile();

                        if (!viewModel.TimeTier.Segments.Any())
                        {
                            if (annotationFile != null)
                            {
                                annotationFile.Delete();
                                parent.RefreshComponentFiles(file.FileName, null);
                            }
                            return(null);
                        }

                        var eafFile = AnnotationFileHelper.Save(file.PathToAnnotatedFile, viewModel.Tiers);

                        if (annotationFile == null)
                        {
                            return(eafFile);
                        }

                        error = annotationFile.TryLoadAndReturnException();
                        if (error == null)
                        {
                            WaitCursor.Show();
                            try
                            {
                                annotationFile.AssociatedComponentFile.GenerateOralAnnotationFile(viewModel.Tiers,
                                                                                                  parent, ComponentFile.GenerateOption.ClearAndRegenerateOnDemand);
                            }
                            finally
                            {
                                WaitCursor.Hide();
                            }
                            return(eafFile);
                        }

                        msg = LocalizationManager.GetString(
                            "DialogBoxes.Transcription.ManualSegmenterDlg.SavingSegmentsErrorMsg",
                            "There was an error while trying to save segments for the file '{0}'.");
                    }
                    catch (Exception e)
                    {
                        error = e;
                        msg   = LocalizationManager.GetString(
                            "DialogBoxes.Transcription.ManualSegmenterDlg.GeneralSegmentingErrorMsg",
                            "There was an error segmenting the file '{0}'.");
                    }
                }

            ErrorReport.NotifyUserOfProblem(error, msg, file.PathToAnnotatedFile);
            return(null);
        }