public static TranscriptionChapter DeserializeV2(XElement c, bool isStrict)
        {
            TranscriptionChapter chap = new TranscriptionChapter();
            chap.Name = c.Attribute("name").Value;
            chap.Elements = c.Attributes().ToDictionary(a => a.Name.ToString(), a => a.Value);
            chap.Elements.Remove("name");
            foreach (var s in c.Elements(isStrict ? "section" : "se").Select(s => (TranscriptionElement)TranscriptionSection.DeserializeV2(s, isStrict)))
                chap.Add(s);

            return chap;
        }
Exemple #2
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;
 }
Exemple #3
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;
        }
Exemple #4
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;
        }