Example #1
0
 public void Add(Dogagan_Record rec)
 {
     if (String.IsNullOrEmpty(rec.Speaker))
     {
         rec.Speaker = "0";
     }
     _records.Add(rec);
     //Console.WriteLine("Speaker:"+rec.Speaker + ":"+rec.Transcript);
 }
Example #2
0
        /// <summary>
        /// 指定のログファイルを読み込む
        /// </summary>
        /// <param name="logPath"></param>
        /// <returns>読み込み成功したらtrue</returns>
        public static bool LoadSRTFile(string logPath)
        {
            Console.WriteLine("srtファイル読み込み開始");

            //改行コードがCRLFでないと正しくパースできないので、事前にチェックして変換、上書きする
            if (ReplaceLF2CRLF(logPath) == false)
            {
                return(false);                                  //falseなら中断
            }
            //読み込み処理
            SubRipFile subs = SubRipFile.Load(logPath);

            foreach (SubRipEntry sub in subs.Entries)
            {
                //Console.WriteLine(sub.OrderId);         //通し番号
                //Console.WriteLine(sub.Duration.Start);  //INタイムコード
                //Console.WriteLine(sub.Duration.End);    //OUTタイムコード
                //Console.WriteLine(sub.Text);            //字幕テキスト
                //Console.WriteLine(sub.Duration.Start.ToString());

                Dogagan_Record rec            = new Dogagan_Record();
                char[]         delimiterChars = { ':', ',' };
                string[]       tc             = sub.Duration.Start.ToString().Split(delimiterChars);

                //タイムコードを変換&整合性チェック
                int  hour, min, sec;
                bool isIntTc0 = int.TryParse(tc[0], out hour);
                bool isIntTc1 = int.TryParse(tc[1], out min);
                bool isIntTc2 = int.TryParse(tc[2], out sec);
                if (!isIntTc0 || !isIntTc1 || !isIntTc2)
                {
                    MessageBox.Show("タイムコード形式が不正な行があり、ログ読み込みを中断します。\r" + sub.ToString());
                    return(false);
                }
                else
                {
                    rec.TimeStamp = hour * 3600 + min * 60 + sec;
                }
                rec.Transcript = sub.Text;
                AppModel.Records.Add(rec);
                rec.Renew();
            }

            AppModel.MainWindow.ListBox_Records.DataContext = AppModel.Records.Records;
            AppModel.MainWindow.MI_Replace.IsEnabled        = true;

            AppModel.CurrentLogFilePath = logPath;
            return(true);
        }
Example #3
0
        public static bool LoadTXTFile(string logPath)
        {
            //読み込み処理
            string line = "";

            using (StreamReader sr = new StreamReader(logPath, Encoding.GetEncoding("Shift_JIS")))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        string[] fields = line.Split('\t');
                        //Console.WriteLine("code:" + fields[0] + " text:" + fields[1]);
                        Dogagan_Record rec = new Dogagan_Record();
                        string[]       tc  = fields[0].Split(':');

                        //タイムコードを変換&整合性チェック
                        int  hour, min, sec;
                        bool isIntTc0 = int.TryParse(tc[0], out hour);
                        bool isIntTc1 = int.TryParse(tc[1], out min);
                        bool isIntTc2 = int.TryParse(tc[2], out sec);
                        if (!isIntTc0 || !isIntTc1 || !isIntTc2)
                        {
                            MessageBox.Show("タイムコード形式が不正な行があり、ログ読み込みを中断します。\r" + line);
                            return(false);
                        }
                        else
                        {
                            rec.TimeStamp = hour * 3600 + min * 60 + sec;
                        }
                        rec.Transcript = fields[1];
                        AppModel.Records.Add(rec);
                        rec.Renew();
                    }
                }

                //foreach(var rec in AppModel.Records.Records)
                //{
                //    Console.WriteLine("tc:"+rec.TimeStamp + " text:"+rec.Transcript);
                //}
                AppModel.MainWindow.ListBox_Records.DataContext = AppModel.Records.Records;
                AppModel.MainWindow.MI_Replace.IsEnabled        = true;
            }
            AppModel.CurrentLogFilePath = logPath;
            return(true);
        }
Example #4
0
        /// <summary>
        /// 指定のログファイルを読み込む
        /// </summary>
        /// <param name="logPath"></param>
        /// <returns>読み込み成功したらtrue</returns>
        public static bool LoadDGGFile(string logPath)
        {
            AppModel.CurrentLogFilePath = logPath;
            //読み込み処理
            string line = "";

            using (StreamReader sr = new StreamReader(logPath, Encoding.GetEncoding("UTF-8")))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    if (!String.IsNullOrEmpty(line))
                    {
                        string[]       fields = line.Split('\t');
                        Dogagan_Record rec    = new Dogagan_Record();

                        //タイムコードを変換&整合性チェック
                        float ts;
                        bool  isFloat = float.TryParse(fields[0], out ts);
                        if (!isFloat)
                        {
                            MessageBox.Show("タイムコード形式が不正な行があり、ログ読み込みを中断します。\r" + line);
                            return(false);
                        }
                        else
                        {
                            rec.TimeStamp = ts;
                        }
                        rec.Transcript = fields[1];
                        rec.Speaker    = fields[2];
                        AppModel.Records.Add(rec);
                        rec.Renew();
                    }
                }

                //foreach(var rec in AppModel.Records.Records)
                //{
                //    Console.WriteLine("tc:"+rec.TimeStamp + " text:"+rec.Transcript);
                //}
                AppModel.MainWindow.ListBox_Records.DataContext = AppModel.Records.Records;
                AppModel.MainWindow.MI_Replace.IsEnabled        = true;
            }
            AppModel.CurrentLogFilePath = logPath;
            return(true);
        }
Example #5
0
 /// <summary>
 /// レコードを削除
 /// </summary>
 /// <param name="rec">削除したいレコード</param>
 public void Delete(Dogagan_Record item)
 {
     _records.Remove(item);
     AppModel.IsCurrentFileDirty = true;
 }