コード例 #1
0
ファイル: ChangeAction.cs プロジェクト: Ttxman/NanoTrans
 public ChangeAction(ChangeType changeType, TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
 {
     _changeType = changeType;
     _changedElement = changedElement;
     _changeTranscriptionIndex = changeIndex;
     _changeAbsoluteIndex = changeAbsoluteIndex;
 }
コード例 #2
0
ファイル: ChangeAction.cs プロジェクト: Ttxman/NanoTrans
 public ReplaceAction(TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
     : base(ChangeType.Replace, changedElement, changeIndex, changeAbsoluteIndex)
 {
 }
コード例 #3
0
 public abstract void Insert(TranscriptionIndex index, TranscriptionElement value);
コード例 #4
0
 public override bool Remove(TranscriptionElement value)
 {
     throw new NotSupportedException();
 }
コード例 #5
0
 public override void Insert(int index, TranscriptionElement data)
 {
     throw new NotSupportedException();
 }
コード例 #6
0
 public override void Insert(TranscriptionIndex index, TranscriptionElement value)
 {
     ValidateIndexOrThrow(index);
     if (index.IsSectionIndex)
     {
         if (index.IsParagraphIndex)
             Sections[index.Sectionindex].Insert(index, value);
         else
             Sections.Insert(index.Sectionindex,(TranscriptionSection)value);
     }
     else
     {
         throw new IndexOutOfRangeException("index");
     }
 }
コード例 #7
0
ファイル: Window1.xaml.cs プロジェクト: Ttxman/NanoTrans
 void _transcription_ContentChanged(object sender, TranscriptionElement.TranscriptionElementChangedEventArgs e)
 {
     if (e.ActionsTaken.Any(a => !(a.ChangedElement is TranscriptionPhrase)))
         waveform1.InvalidateSpeakers();
 }
コード例 #8
0
 public MyTranscriptionElementEventArgs(TranscriptionElement value)
 {
     Value = value;
 }
コード例 #9
0
 public Element GetVisualForTransctiption(TranscriptionElement el)
 {
     return listbox.ItemContainerGenerator.ContainerFromItem(el).VisualFindChild<Element>();
 }
コード例 #10
0
 private void ColorizeBackground(TranscriptionElement focused)
 {
     var all = listbox.VisualFindChildren<Element>();
     foreach (var elem in all)
     {
         if (elem.ValueElement == focused)
         {
             elem.Background = Settings.Default.ActiveParagraphBackground;
         }
         else
         {
             if (elem.ValueElement is TranscriptionSection)
                 elem.Background = Settings.Default.SectionBackground;
             else if (elem.ValueElement is TranscriptionChapter)
                 elem.Background = Settings.Default.ChapterBackground;
             else
                 elem.Background = null;
         }
     }
 }
コード例 #11
0
        public Element SetActiveTranscription(TranscriptionElement el)
        {
            ActivatingTranscription = true;
            if (el == null)
                return null;

            if (el == _activeTranscription)
                return listbox.ItemContainerGenerator.ContainerFromItem(el).VisualFindChild<Element>();

            _activeTranscription = el;
            _activetransctiptionSelectionLength = -1;
            _activetransctiptionSelectionStart = -1;

            foreach (Element ee in listbox.VisualFindChildren<Element>())
            {
                if (ee.ValueElement != el)
                {
                    ee.editor.Select(0, 0);
                }
            }

            listbox.ScrollIntoView(el);
            ListBoxItem cont = listbox.ItemContainerGenerator.ContainerFromItem(el) as ListBoxItem;
            if (cont == null)
            {
                listbox.UpdateLayout();
                listbox.ScrollIntoView(el);
                cont = listbox.ItemContainerGenerator.ContainerFromItem(el) as ListBoxItem;
            }

            if (cont != null)
            {
                var elm = cont.VisualFindChild<Element>();
                listbox.SelectedItem = el;

                //events may not be active yet
                if (elm.Background != Settings.Default.ActiveParagraphBackground)
                {
                    elm.editor.Focus();
                    ColorizeBackground(el);
                }
                ActivatingTranscription = false;
                return elm;
            }
            ActivatingTranscription = false;
            return null;
        }
コード例 #12
0
        public virtual bool Replace(TranscriptionElement oldelement, TranscriptionElement newelement)
        {
            int index = _children.IndexOf(oldelement);
            if (index >= 0)
            {
                var oi = oldelement.TranscriptionIndex;
                var oa = oldelement.AbsoluteIndex;

                newelement._Parent = this;
                newelement._ParentIndex = oldelement._ParentIndex;

                oldelement._Parent = null;
                oldelement._ParentIndex = -1;

                _children[index] = newelement;

                OnContentChanged(new ReplaceAction(oldelement, oi, oa));
                return true;
            }
            return false;
        }
コード例 #13
0
 public virtual bool Remove(TranscriptionElement value)
 {
     RemoveAt(_children.IndexOf(value));
     return true;
 }
コード例 #14
0
        public virtual void Insert(int index, TranscriptionElement data)
        {
            if (index < 0 || index > Children.Count)
                throw new IndexOutOfRangeException();

            _children.Insert(index, data);
            data._Parent = this;
            for (int i = index; i < _children.Count; i++)
            {
                _children[i]._ParentIndex = i;
            }

            OnContentChanged(new InsertAction(data, data.TranscriptionIndex, data.AbsoluteIndex));
        }
コード例 #15
0
ファイル: ChangeAction.cs プロジェクト: Ttxman/NanoTrans
 public TextAction(TranscriptionElement changedelement, TranscriptionIndex changeIndex, int changeAbsoluteIndex, string oldtstring)
     : base(ChangeType.Modify, changedelement, changeIndex, changeAbsoluteIndex)
 {
     _oldtstring = oldtstring;
 }
コード例 #16
0
 private void FixPosSetFor(TranscriptionElement elm)
 {
     _FixPosElm = elm;
     var prevc = listbox.ItemContainerGenerator.ContainerFromItem(elm) as ListBoxItem;
     _FixPosElmPos = prevc.TransformToAncestor(_scrollViewer).Transform(new Point(0, 0));
 }
コード例 #17
0
        private void ScrollToItem(TranscriptionElement elm)
        {
            if (_scrollViewer == null)
                return;

            listbox.SelectedItem = elm;
            listbox.ScrollIntoView(listbox.Items[listbox.SelectedIndex]);
            if (elm == Transcription.Last())
            {
                _scrollViewer.ScrollToBottom();
            }
            else
            {
                var all = listbox.VisualFindChildren<Element>();
                var visible = all.Where(itm => listbox.VisualIsVisibleChild(itm));

                Action scroll = new Action(() =>
                    {
                        all = listbox.VisualFindChildren<Element>();
                        visible = all.Where(itm => listbox.VisualIsVisibleChild(itm));
                        var element = all.First(itm => itm.ValueElement == elm);
                        var position = element.TransformToAncestor(_scrollViewer).Transform(new Point(0, element.ActualHeight));
                        _scrollViewer.ScrollToVerticalOffset(position.Y);
                        _scrollViewer.UpdateLayout();
                    });

                if (visible.Any(itm => itm.ValueElement == elm))
                    _scrollViewer.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, scroll);
            }
        }
コード例 #18
0
        void val_ContentChanged(object sender, TranscriptionElement.TranscriptionElementChangedEventArgs e)
        {
            Element el = this;

            //phrase changes
            if (el.ValueElement is TranscriptionParagraph && e.ActionsTaken.Any(a => a.ChangedElement.Parent != null && a.ChangedElement.Parent == el.ValueElement))
                el.TextualContentChanged();

            if (el == null || el.ValueElement == null || !e.ActionsTaken.Any(a => a.ChangedElement == el.ValueElement))
                return;

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.TextAction))
                el.TextualContentChanged();

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.BeginAction))
                el.BeginChanged(el, new EventArgs());

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.BeginAction))
                el.BeginChanged(el, new EventArgs());

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.EndAction))
                el.EndChanged(el, new EventArgs());

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.ParagraphSpeakerAction))
                el.RefreshSpeakerInfos();

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.ParagraphLanguageAction))
                el.textBlockLanguage.GetBindingExpression(TextBlock.TextProperty).UpdateTarget();

            if (e.ActionsTaken.Any(a => a is NanoTrans.Core.ParagraphAttibutesAction))
                el.RepaintAttributes();
        }
コード例 #19
0
        private void SetCaretIn(TranscriptionElement elm, int position)
        {
            if (ActiveTransctiption != elm)
                ActiveTransctiption = elm;

            listbox.ScrollIntoView(elm);
            var n = listbox.ItemContainerGenerator.ContainerFromItem(elm).VisualFindChild<Element>();
            if (!n.IsFocused)
                n.Focus();
            n.SetCaretOffset(position);
        }
コード例 #20
0
ファイル: Window1.xaml.cs プロジェクト: Ttxman/NanoTrans
 public int NormalizePhonetics(TranscriptionElement aElement, int aIndexNormalizace)
 {
     throw new NotImplementedException();
 }
コード例 #21
0
        public override void Insert(TranscriptionIndex index, TranscriptionElement value)
        {
            ValidateIndexOrThrow(index);
            if (!index.IsPhraseIndex)
                throw new IndexOutOfRangeException("index");

            Phrases.Insert(index.PhraseIndex,(TranscriptionPhrase)value);
        }
コード例 #22
0
 public override void Add(TranscriptionElement data)
 {
     throw new NotSupportedException();
 }
コード例 #23
0
ファイル: ChangeAction.cs プロジェクト: Ttxman/NanoTrans
 public InsertAction(TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
     : base(ChangeType.Add, changedElement, changeIndex, changeAbsoluteIndex)
 {
 }
コード例 #24
0
 public override void Insert(TranscriptionIndex index, TranscriptionElement value)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
ファイル: ChangeAction.cs プロジェクト: Ttxman/NanoTrans
 public BeginAction(TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex, TimeSpan oldtime)
     : base(ChangeType.Modify, changedElement, changeIndex,changeAbsoluteIndex)
 {
     _oldtime = oldtime;
 }
コード例 #26
0
 public override bool Replace(TranscriptionElement oldelement, TranscriptionElement newelement)
 {
     throw new NotSupportedException();
 }
コード例 #27
0
 public virtual void Add(TranscriptionElement data)
 {
     _children.Add(data);
     data._Parent = this;
     data._ParentIndex = _children.Count - 1;
     OnContentChanged(new InsertAction(data, data.TranscriptionIndex, data.AbsoluteIndex));
 }