예제 #1
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="toCopy"></param>
 public TranscriptionSection(TranscriptionSection toCopy)
     : this()
 {
     this.Begin = toCopy.Begin;
     this.End = toCopy.End;
     this.Name = toCopy.Name;
     if (toCopy.Paragraphs != null)
     {
         this.Paragraphs = new VirtualTypeList<TranscriptionParagraph>(this, this._children);
         for (int i = 0; i < toCopy.Paragraphs.Count; i++)
         {
             this.Paragraphs.Add(new TranscriptionParagraph(toCopy.Paragraphs[i]));
         }
     }
 }
예제 #2
0
        public async Task<bool> NewTranscription()
        {
            if (!await TrySaveUnsavedChanges())
                return false;

            var source = new WPFTranscription();
            source.BeginUpdate(false);
            var c = new TranscriptionChapter(Properties.Strings.DefaultChapterText);
            var s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
            var p = new TranscriptionParagraph();
            p.Add(new TranscriptionPhrase());
            c.Add(s);
            s.Add(p);
            source.Add(c);
            Transcription = source;
            SynchronizeSpeakers();
            VirtualizingListBox.ActiveTransctiption = p;

            TranscriptionList.Clear();
            source.ClearUndo();
            source.EndUpdate();

            Transcription.Saved = true;
            return true;
        }
예제 #3
0
 private void CNewChapter(object sender, ExecutedRoutedEventArgs e)
 {
     TranscriptionChapter c = new TranscriptionChapter(Properties.Strings.DefaultChapterText);
     TranscriptionSection s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
     TranscriptionParagraph p = new TranscriptionParagraph();
     p.Add(new TranscriptionPhrase());
     Transcription.Add(c);
     c.Add(s);
     s.Add(p);
     VirtualizingListBox.ActiveTransctiption = c;
 }
예제 #4
0
        private void CInsertNewSection(object sender, ExecutedRoutedEventArgs e)
        {
            if (VirtualizingListBox.ActiveTransctiption != null)
            {
                if (VirtualizingListBox.ActiveTransctiption.IsParagraph)
                {
                    TranscriptionParagraph p = (TranscriptionParagraph)VirtualizingListBox.ActiveTransctiption;
                    int idx = p.ParentIndex;
                    TranscriptionSection sec = (TranscriptionSection)p.Parent;
                    TranscriptionSection s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
                    for (int i = idx; i < sec.Children.Count; i++)
                        s.Add(sec[i]);

                    sec.Children.RemoveRange(idx, sec.Children.Count - idx);

                    sec.Parent.Insert(sec.ParentIndex + 1, s);
                    VirtualizingListBox.ActiveTransctiption = s;

                    VirtualizingListBox.Reset();
                }
                else if (VirtualizingListBox.ActiveTransctiption.IsSection)
                {
                    var s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
                    s.Children.AddRange(VirtualizingListBox.ActiveTransctiption.Children);
                    VirtualizingListBox.ActiveTransctiption.Children.Clear();
                    VirtualizingListBox.ActiveTransctiption.Parent.Insert(VirtualizingListBox.ActiveTransctiption.ParentIndex, s);
                    VirtualizingListBox.ActiveTransctiption = s;
                    VirtualizingListBox.Reset();
                }
                else if (VirtualizingListBox.ActiveTransctiption.IsChapter)
                {
                    var s = new TranscriptionSection(Properties.Strings.DefaultSectionText);
                    VirtualizingListBox.ActiveTransctiption.Insert(0, s);
                    VirtualizingListBox.ActiveTransctiption = s;
                    VirtualizingListBox.Reset();
                }
            }
        }
예제 #5
0
        public static TranscriptionSection DeserializeV2(XElement e, bool isStrict)
        {
            TranscriptionSection tsec = new TranscriptionSection();
            tsec.Name = e.Attribute("name").Value;
            tsec.Elements = e.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value);
            tsec.Elements.Remove("name");
            foreach (var p in e.Elements(isStrict ? "paragraph" : "pa").Select(p => (TranscriptionElement)TranscriptionParagraph.DeserializeV2(p, isStrict)))
                tsec.Add(p);

            return tsec;
        }
예제 #6
0
        public static bool Import(Stream input, Transcription storage)
        {
            XDocument doc = XDocument.Load(input);
            var root = doc.Element("NanovoidSegmentation");

            var mediums = root.Elements("Medium").ToArray();

            XElement medium = null;
            if (mediums.Length > 1)
            {
                SelectFile sf = new SelectFile(mediums.Select(m => m.Attribute("url") != null ? Path.GetFileName(m.Attribute("url").Value) : "name not specified").ToList());
                sf.Title = "Select Medium";
                if (sf.ShowDialog() == true)
                {
                    medium = mediums[sf.SelectedIndex];
                }
                else return false;
            }
            else
                medium = mediums.First();

            var segmentations = medium.Elements("Segmentation").ToArray();

            XElement segmentation = null;
            if (segmentations.Length > 1)
            {
                var lst = segmentations.Select(s => string.Join(" ", s.Attributes().Select(a => a.Name + ":" + a.Value))).ToList();
                SelectFile sf = new SelectFile(lst);
                sf.Title = "Select segmentation";
                if (sf.ShowDialog() == true)
                {
                    segmentation = segmentations[sf.SelectedIndex];
                }
                else return false;
            }
            else
                segmentation = segmentations.First();

            TimeSpan unitlen = new TimeSpan((long)(TimeSpan.FromSeconds(1).Ticks * XmlConvert.ToDouble(segmentation.Attribute("tres").Value)));
            //segmentations.Elements("Segment");

            Transcription tr = storage;
            TranscriptionChapter ch = new TranscriptionChapter();
            ch.Text = segmentation.Attribute("type").Value;

            TranscriptionSection sec = new TranscriptionSection();
            sec.Text = segmentation.Attribute("label").Value;

            tr.MediaURI = medium.Attribute("url")!=null?medium.Attribute("url").Value:"";

            var idss = segmentation.Element("Identities");
            if (idss != null)
            {
                var ids = idss.Elements("Id");
                if (ids != null && ids.Count() > 0)
                {
                    var speakers = ids.Select(i => new Speaker() { ID = XmlConvert.ToInt32(i.Attribute("id").Value), Surname = i.Attribute("label").Value });
                    tr.Speakers = new SpeakerCollection(speakers);
                }
            }

            var segments = segmentation.Element("Segments").Elements("Segment");

            var paragraphs = MakeParagraphs(segments, unitlen);

            foreach (var p in paragraphs)
                sec.Add(p);

            ch.Add(sec);
            tr.Add(ch);

               tr.AssingSpeakersByID(); //added in newer version

            return true;
        }