Ejemplo n.º 1
0
        public void Sort()
        {
            ScriptLine scriptLine = GetFirstLine();
            ScriptLine source     = scriptLine.NextByTime;

            while (source != null)
            {
                ScriptLine nextByTime = source.NextByTime;
                ScriptLine target     = null;
                for (; scriptLine != null && scriptLine.Offset > source.Offset; scriptLine = scriptLine.PrevByTime)
                {
                    target = scriptLine;
                }
                if (target != null)
                {
                    MoveLine(target, source);
                    if (source.PrevByTime == null)
                    {
                        m_list = source;
                    }
                }
                source = nextByTime;
                if (source != null)
                {
                    scriptLine = source.PrevByTime;
                }
            }
            UpdateCharacterLinks();
        }
Ejemplo n.º 2
0
        public ScriptLine Insert(string character, MidiTime offset)
        {
            ScriptLine scriptLine1 = new ScriptLine();

            scriptLine1.Character = character;
            scriptLine1.Offset    = offset;
            ScriptLine scriptLine2 = GetFirstLine();

            while (scriptLine2.NextByTime != null && scriptLine2.Offset < offset)
            {
                scriptLine2 = scriptLine2.NextByTime;
            }
            if (scriptLine2.Offset >= offset)
            {
                scriptLine1.NextByTime = scriptLine2;
                scriptLine1.PrevByTime = scriptLine2.PrevByTime;
                if (scriptLine1.PrevByTime != null)
                {
                    scriptLine1.PrevByTime.NextByTime = scriptLine1;
                }
                else
                {
                    m_list = scriptLine1;
                }
                scriptLine2.PrevByTime = scriptLine1;
            }
            else
            {
                scriptLine1.PrevByTime = scriptLine2;
                scriptLine2.NextByTime = scriptLine1;
            }
            UpdateCharacterLinks();
            return(scriptLine1);
        }
Ejemplo n.º 3
0
 public ScriptLineBox(ScriptLine sl, float fontsize)
     : this(sl)
 {
     _mCharacterbox.Font = new Font("Franklin Gothic Medium", fontsize, FontStyle.Regular, GraphicsUnit.Point, 0);
     m_linebox.Font      = _mCharacterbox.Font;
     _mTimebox.Font      = new Font("Franklin Gothic Medium", fontsize, FontStyle.Regular, GraphicsUnit.Point, 0);
 }
Ejemplo n.º 4
0
        private void UpdateCharacterLinks()
        {
            Dictionary <string, ScriptLine> dictionary = new Dictionary <string, ScriptLine>(StringComparer.CurrentCultureIgnoreCase);

            for (ScriptLine scriptLine = GetFirstLine(); scriptLine != null; scriptLine = scriptLine.NextByTime)
            {
                if (scriptLine.Character != null)
                {
                    if (dictionary.ContainsKey(scriptLine.Character))
                    {
                        dictionary[scriptLine.Character].NextByCharacter = scriptLine;
                        scriptLine.PrevByCharacter       = dictionary[scriptLine.Character];
                        dictionary[scriptLine.Character] = scriptLine;
                    }
                    else
                    {
                        scriptLine.PrevByCharacter = null;
                        dictionary.Add(scriptLine.Character, scriptLine);
                    }
                }
            }
            foreach (ScriptLine scriptLine in dictionary.Values)
            {
                scriptLine.NextByCharacter = null;
            }
            m_characters = new string[dictionary.Count];
            dictionary.Keys.CopyTo(m_characters, 0);
            Array.Sort(m_characters);
        }
Ejemplo n.º 5
0
 public ScriptLineBox(ScriptLine sl)
 {
     LinkedLine = sl;
     InitializeControl();
     _mCharacterbox.Text = $"{LinkedLine.Character}:";
     m_linebox.Text      = LinkedLine.Line;
     _mTimebox.Text      = LinkedLine.Offset.ToString().Substring(3, 5);
 }
Ejemplo n.º 6
0
        public ScriptLine GetFirstLine(string character)
        {
            ScriptLine scriptLine = m_list;

            while (scriptLine != null && scriptLine.Character != character)
            {
                scriptLine = scriptLine.NextByTime;
            }
            return(scriptLine);
        }
Ejemplo n.º 7
0
        public ScriptLine GetNearestLineAfter(MidiTime time)
        {
            ScriptLine scriptLine = m_list;

            while (scriptLine != null && scriptLine.Offset < time)
            {
                scriptLine = scriptLine.NextByTime;
            }
            return(scriptLine);
        }
Ejemplo n.º 8
0
        public ScriptLine GetNearestLine(MidiTime time)
        {
            ScriptLine scriptLine = m_list;

            for (ScriptLine nextByTime = m_list.NextByTime; nextByTime != null && scriptLine.Offset < time; nextByTime = nextByTime.NextByTime)
            {
                if (Math.Abs(time.Difference(nextByTime.Offset)) < Math.Abs(time.Difference(scriptLine.Offset)))
                {
                    scriptLine = nextByTime;
                }
            }
            return(scriptLine);
        }
Ejemplo n.º 9
0
        public ScriptLine GetNearestLineAfter(string character, MidiTime time)
        {
            ScriptLine scriptLine = m_list;

            while (scriptLine != null && scriptLine.Character != character)
            {
                scriptLine = scriptLine.NextByTime;
            }
            while (scriptLine != null && scriptLine.Offset < time)
            {
                scriptLine = scriptLine.NextByCharacter;
            }
            return(scriptLine);
        }
Ejemplo n.º 10
0
        public ScriptLine GetFirstUnrecordedLine(string character)
        {
            ScriptLine scriptLine = GetFirstLine(character);

            while (scriptLine != null && scriptLine.IsDone)
            {
                scriptLine = scriptLine.NextByCharacter;
            }
            if (scriptLine == null)
            {
                scriptLine = GetFirstLine(character);
            }
            return(scriptLine);
        }
Ejemplo n.º 11
0
        public ScriptLine GetFirstUnrecordedLine()
        {
            ScriptLine scriptLine = m_list;

            while (scriptLine != null && scriptLine.IsDone)
            {
                scriptLine = scriptLine.NextByTime;
            }
            if (scriptLine == null)
            {
                scriptLine = m_list;
            }
            return(scriptLine);
        }
Ejemplo n.º 12
0
 public void LineCount(string charname, out int LinesDone, out int LinesLeft)
 {
     LinesDone = 0;
     LinesLeft = 0;
     for (ScriptLine scriptLine = GetFirstLine(charname); scriptLine != null; scriptLine = scriptLine.NextByCharacter)
     {
         if (scriptLine.IsDone)
         {
             ++LinesDone;
         }
         else
         {
             ++LinesLeft;
         }
     }
 }
Ejemplo n.º 13
0
 public void LineCount(out int LinesDone, out int LinesLeft)
 {
     LinesDone = 0;
     LinesLeft = 0;
     for (ScriptLine scriptLine = GetFirstLine(); scriptLine != null; scriptLine = scriptLine.NextByTime)
     {
         if (scriptLine.IsDone)
         {
             ++LinesDone;
         }
         else
         {
             ++LinesLeft;
         }
     }
 }
Ejemplo n.º 14
0
 private void MoveLine(ScriptLine target, ScriptLine source)
 {
     if (source.PrevByTime != null)
     {
         source.PrevByTime.NextByTime = source.NextByTime;
     }
     if (source.NextByTime != null)
     {
         source.NextByTime.PrevByTime = source.PrevByTime;
     }
     if (target.PrevByTime != null)
     {
         target.PrevByTime.NextByTime = source;
     }
     source.PrevByTime = target.PrevByTime;
     source.NextByTime = target;
     target.PrevByTime = source;
 }
Ejemplo n.º 15
0
        public ScriptLine GetNearestLine(string character, MidiTime time)
        {
            ScriptLine scriptLine1 = m_list;

            while (scriptLine1 != null && scriptLine1.Character != character)
            {
                scriptLine1 = scriptLine1.NextByTime;
            }
            ScriptLine scriptLine2 = scriptLine1;

            for (ScriptLine nextByCharacter = scriptLine1.NextByCharacter; nextByCharacter != null && scriptLine2.Offset < time; nextByCharacter = nextByCharacter.NextByCharacter)
            {
                time.Difference(nextByCharacter.Offset);
                time.Difference(scriptLine2.Offset);
                if (Math.Abs(time.Difference(nextByCharacter.Offset)) < Math.Abs(time.Difference(scriptLine2.Offset)))
                {
                    scriptLine2 = nextByCharacter;
                }
            }
            return(scriptLine2);
        }
Ejemplo n.º 16
0
 public ScriptLineBox(ScriptLine sl, float fontsize, string longestcharname)
     : this(sl, fontsize)
 {
     m_longestchar = longestcharname;
 }
Ejemplo n.º 17
0
 public ScriptLineCollection(ScriptLine list)
 {
     m_list = list;
 }