예제 #1
0
 private void AppendText(WordGroupCollection collect, StringBuilder sb)
 {
     foreach (WordGroup wg in collect)
     {
         sb.Append(wg.Text);
     }
 }
예제 #2
0
 private bool[] getEnterStatus(WordGroupCollection coll)
 {
     bool[] r = new bool[coll.Count];
     for (int i = 0; i < r.Length; i++)
     {
         r[i] = coll[i].ActiveOffset <= 0;
     }
     return(r);
 }
예제 #3
0
 private bool[] getExitStatus(WordGroupCollection coll, float nextLineTime)
 {
     next_line_time = nextLineTime;
     bool[] r = new bool[coll.Count];
     for (int i = 0; i < r.Length; i++)
     {
         r[i] = coll[i].isActive(nextLineTime);
     }
     return(r);
 }
예제 #4
0
        private void AppendMetadata(WordGroupCollection collect, StringBuilder sb)
        {
            bool first = true;

            foreach (WordGroup group in collect)
            {
                int wordcount = StringInfo.ParseCombiningCharacters(group.Text).Length;
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.Append("|");
                }
                sb.Append(group.ActiveOffset);
                if (wordcount != 1)
                {
                    sb.Append(",");
                    sb.Append(wordcount);
                }
            }
        }
예제 #5
0
        //只会加入必要的组
        private void HandleGroupCollection(LineCommand parentCmd, WordGroupCollection coll, bool isTranslate, bool[] enterStatus, bool[] exitStatus)
        {
            int i = 0;

            foreach (var gp in coll)
            {
                if ((!enterStatus[i]) && exitStatus[i])
                {
                    FlagCommand x;

                    if (commandList.ContainsKey(gp.ActiveTime))
                    {
                        x = commandList[gp.ActiveTime];
                        if (x is LineCommand)
                        {
                            throw new Exception("duplicate timeline(crash between line and group)");
                        }
                    }
                    else
                    {
                        x = new GroupCommand()
                        {
                            ParentLine = parentCmd
                        };
                        commandList.Add(gp.ActiveTime, x);
                    }
                    (x as GroupCommand).gpList.Add(new GroupInfos()
                    {
                        group       = gp,
                        id          = i,
                        isTranslate = isTranslate
                    });
                }
                i++;
            }
        }
예제 #6
0
        //需要使用StringInfo来编码
        public void ToWordGroupCollection(string cleartext, WordGroupCollection collection)
        {
            var strEnum = StringInfo.GetTextElementEnumerator(cleartext);

            StringBuilder sb = new StringBuilder();

            foreach (MetaPair pair in metalist)
            {
                //get string
                for (int i = 0; i < pair.count && strEnum.MoveNext(); i++)
                {
                    sb.Append(strEnum.GetTextElement());
                }
                if (sb.Length == 0)
                {
                    break;
                }
                WordGroup group = new WordGroup();
                group.ActiveOffset = pair.activeTime;
                group.Text         = sb.ToString();
                collection.Add(group);

                sb.Clear();
            }
            while (strEnum.MoveNext())
            {
                sb.Append(strEnum.GetTextElement());
            }
            if (sb.Length > 0)
            {
                WordGroup group = new WordGroup();
                group.ActiveOffset = 0;
                group.Text         = sb.ToString();
                collection.Add(group);
            }
        }