示例#1
0
 private void New()
 {
     using (var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ"))
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             var arr = form.FormatOk.Split('Æ');
             if (arr.Length == 6)
             {
                 string name = arr[0];
                 int    i    = 1;
                 while (NameExists(name))
                 {
                     form.FormatOk = form.FormatOk.Remove(0, name.Length);
                     name          = arr[0] + " (" + i + ")";
                     form.FormatOk = name + form.FormatOk;
                     i++;
                 }
                 _templates.Add(form.FormatOk);
                 ShowTemplates(_templates);
                 listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
             }
         }
     }
     SaveTemplates();
 }
示例#2
0
        internal static string GenerateCustomText(Subtitle subtitle, Subtitle translation, string title, string templateString)
        {
            var arr = templateString.Split('Æ');
            var sb  = new StringBuilder();

            sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[1]));
            string template = ExportCustomTextFormat.GetParagraphTemplate(arr[2]);

            for (int i = 0; i < subtitle.Paragraphs.Count; i++)
            {
                Paragraph p     = subtitle.Paragraphs[i];
                string    start = ExportCustomTextFormat.GetTimeCode(p.StartTime, arr[3]);
                string    end   = ExportCustomTextFormat.GetTimeCode(p.EndTime, arr[3]);
                string    text  = ExportCustomTextFormat.GetText(p.Text, arr[4]);

                string translationText = string.Empty;
                if (translation != null && translation.Paragraphs != null && translation.Paragraphs.Count > 0)
                {
                    var trans = Utilities.GetOriginalParagraph(i, p, translation.Paragraphs);
                    if (trans != null)
                    {
                        translationText = trans.Text;
                    }
                }
                string paragraph = ExportCustomTextFormat.GetParagraph(template, start, end, text, translationText, i, p.Actor, p.Duration, arr[3]);
                sb.Append(paragraph);
            }
            sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[5]));
            return(sb.ToString());
        }
示例#3
0
        private void New()
        {
            var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ");

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _templates.Add(form.FormatOK);
                ShowTemplates(_templates);
                listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
            }
            SaveTemplates();
        }
示例#4
0
        private string GenerateText(Subtitle subtitle, Subtitle translation, string title)
        {
            if (listViewTemplates.SelectedItems.Count != 1)
            {
                return(string.Empty);
            }

            if (title == null)
            {
                title = string.Empty;
            }
            else
            {
                title = System.IO.Path.GetFileNameWithoutExtension(title);
            }

            try
            {
                int idx = listViewTemplates.SelectedItems[0].Index;
                var arr = _templates[idx].Split('Æ');
                var sb  = new StringBuilder();
                sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[1]));
                string template = ExportCustomTextFormat.GetParagraphTemplate(arr[2]);
                for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
                {
                    Paragraph p     = _subtitle.Paragraphs[i];
                    string    start = ExportCustomTextFormat.GetTimeCode(p.StartTime, arr[3]);
                    string    end   = ExportCustomTextFormat.GetTimeCode(p.EndTime, arr[3]);
                    string    text  = ExportCustomTextFormat.GetText(p.Text, arr[4]);

                    string translationText = string.Empty;
                    if (translation != null && translation.Paragraphs != null && translation.Paragraphs.Count > 0)
                    {
                        var trans = Utilities.GetOriginalParagraph(idx, p, translation.Paragraphs);
                        if (trans != null)
                        {
                            translationText = trans.Text;
                        }
                    }

                    string paragraph = ExportCustomTextFormat.GetParagraph(template, start, end, text, translationText, i, p.Duration, arr[3]);
                    sb.Append(paragraph);
                }
                sb.Append(ExportCustomTextFormat.GetHeaderOrFooter(title, subtitle, arr[5]));
                return(sb.ToString());
            }
            catch (Exception exception)
            {
                return(exception.Message);
            }
        }
示例#5
0
 private void buttonNew_Click(object sender, EventArgs e)
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ");
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates.Add(form.FormatOK);
             ShowTemplates(_templates);
             listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
         }
     }
     SaveTemplates();
 }
示例#6
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         int idx  = listViewTemplates.SelectedItems[0].Index;
         var form = new ExportCustomTextFormat(_templates[idx]);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates[idx] = form.FormatOK;
             ShowTemplates(_templates);
             if (idx < listViewTemplates.Items.Count)
             {
                 listViewTemplates.Items[idx].Selected = true;
             }
         }
     }
 }
示例#7
0
 private void Edit()
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         int idx  = listViewTemplates.SelectedItems[0].Index;
         var form = new ExportCustomTextFormat(_templates[idx]);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates[idx] = form.FormatOk;
             ShowTemplates(_templates);
             if (idx < listViewTemplates.Items.Count)
             {
                 listViewTemplates.Items[idx].Selected = true;
             }
         }
     }
 }
 private void Edit()
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         int idx = listViewTemplates.SelectedItems[0].Index;
         using (var form = new ExportCustomTextFormat(_templates[idx]))
         {
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 _templates[idx] = form.FormatOk;
                 SaveTemplates();
                 ShowTemplates(_templates);
                 if (idx < listViewTemplates.Items.Count)
                     listViewTemplates.Items[idx].Selected = true;
             }
         }
     }
 }
 private void New()
 {
     using (var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ"))
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             var arr = form.FormatOk.Split('Æ');
             if (arr.Length == 6)
             {
                 string name = arr[0];
                 int i = 1;
                 while (NameExists(name))
                 {
                     form.FormatOk = form.FormatOk.Remove(0, name.Length);
                     name = arr[0] + " (" + i + ")";
                     form.FormatOk = name +  form.FormatOk;
                     i++;
                 }
                 _templates.Add(form.FormatOk);
                 ShowTemplates(_templates);
                 listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
             }
         }
     }
     SaveTemplates();
 }
 private void New()
 {
     using (var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ"))
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates.Add(form.FormatOk);
             ShowTemplates(_templates);
             listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
         }
     }
     SaveTemplates();
 }
示例#11
0
 private void buttonNew_Click(object sender, EventArgs e)
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         var form = new ExportCustomTextFormat("NewÆÆ{number}\r\n{start} --> {end}\r\n{text}\r\n\r\nÆhh:mm:ss,zzzÆ[Do not modify]Æ");
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates.Add(form.FormatOK);
             ShowTemplates(_templates);
             listViewTemplates.Items[listViewTemplates.Items.Count - 1].Selected = true;
         }
     }
     SaveTemplates();
 }
示例#12
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     if (listViewTemplates.SelectedItems.Count == 1)
     {
         int idx = listViewTemplates.SelectedItems[0].Index;
         var form = new ExportCustomTextFormat(_templates[idx]);
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             _templates[idx] = form.FormatOK;
             ShowTemplates(_templates);
             if (idx < listViewTemplates.Items.Count)
                 listViewTemplates.Items[idx].Selected = true;
         }
     }
 }