Beispiel #1
0
        private void GeneratePreview()
        {
            if (_isLoading)
            {
                return;
            }

            // update configuration
            _hiConfigs.NarratorToUppercase = checkBoxNames.Checked;
            _hiConfigs.MoodsToUppercase    = checkBoxMoods.Checked;
            _hiConfigs.RemoveExtraSpaces   = checkBoxRemoveSpaces.Checked;
            _hiConfigs.SingleLineNarrator  = checkBoxSingleLineNarrator.Checked;
            _hiConfigs.Style = ((ComboBoxItem)comboBoxStyle.SelectedItem).Style;

            listViewFixes.BeginUpdate();
            listViewFixes.Items.Clear();

            _fixedTexts = new Dictionary <string, string>();

            foreach (Paragraph p in _subtitle.Paragraphs)
            {
                var  text             = p.Text;
                bool containsMood     = false;
                bool containsNarrator = false;

                // Remove Extra Spaces inside brackets ( foobar ) to (foobar)
                string beforeChanges = text;
                if (checkBoxRemoveSpaces.Checked)
                {
                    _hearingImpaired.RemoveExtraSpacesInsideTag(text);
                }
                // (Moods and feelings)
                if (checkBoxMoods.Checked)
                {
                    beforeChanges = text;
                    text          = _hearingImpaired.MoodsToUppercase(text);
                    if (beforeChanges != text)
                    {
                        text         = text.FixExtraSpaces();
                        containsMood = true;
                    }
                }
                // Narrator:
                if (checkBoxNames.Checked)
                {
                    beforeChanges    = text;
                    text             = _hearingImpaired.NarratorToUppercase(text);
                    containsNarrator = !beforeChanges.Equals(text, StringComparison.Ordinal);
                }

                if (containsMood || containsNarrator)
                {
                    _fixedTexts.Add(p.ID, text);
                    string oldText = HtmlUtils.RemoveTags(p.Text, true);
                    text = HtmlUtils.RemoveTags(text, true);
                    AddFixToListView(p, oldText, text, containsMood, containsNarrator);
                }
            }

            int totalConvertParagraphs = _fixedTexts.Count;

            groupBox1.ForeColor = totalConvertParagraphs <= 0 ? Color.Red : Color.Green;
            groupBox1.Text      = string.Format("Total Found: {0}", totalConvertParagraphs);

            /*this.listViewFixes.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
             * this.listViewFixes.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);*/
            //Application.DoEvents();
            listViewFixes.EndUpdate();
            Refresh();
        }
Beispiel #2
0
        private void GeneratePreview(Subtitle sub)
        {
            if (_list == null)
            {
                _list = new List <string>();
            }
            else
            {
                _list.Clear();
            }

            listBox1.Items.Clear();
            for (int i = 0; i < sub.Paragraphs.Count; i++)
            {
                var p    = sub.Paragraphs[i];
                var text = p.Text;
                text = text.Replace('[', '(').Replace(']', ')');
                var idx = text.IndexOf('(');
                if (idx < 0)
                {
                    continue;
                }

                var noTagLines = HtmlUtils.RemoveTags(text).Replace(Environment.NewLine, "\n").Split('\n');

                // single line (Sighs)
                if (noTagLines.Length == 1)
                {
                    if (IsStartEndBraces(noTagLines[0], idx))
                    {
                        continue;
                    }

                    FindNamesInText(text, idx);
                }
                else
                {
                    //- (SKIPPER) Flaps.
                    //- KOWALSKI:  Check.

                    //(LIVELY AFRICAN
                    //TRIBAL THEME PLAYS)

                    //(CLICKING) (SNARLING)

                    //- (CLICKING) UASOIDUFA;
                    //- Oh! (LAUGHS) (SQUEALS)

                    //- (SKIPPER) initiate warp drive.
                    //- (WHIRRING)

                    for (int k = 0; k < noTagLines.Length; k++)
                    {
                        var noTagLine = noTagLines[k];
                        idx = noTagLine.IndexOf('(');
                        if (idx < 0)
                        {
                            continue;
                        }
                        if (IsStartEndBraces(noTagLine, idx))
                        {
                            if (k > 0) // continue is second line starts and ends with '(' & ')'
                            {
                                continue;
                            }
                            if (k == 0 && noTagLine.StartsWith("-", StringComparison.Ordinal)) // Continue if it's dialog
                            {
                                continue;
                            }
                        }
                        FindNamesInText(noTagLine, idx);
                    }
                }
            }
            if (listBox1.Items.Count > 0)
            {
                this.label1.Text = "Total found names: " + listBox1.Items.Count;;
            }
        }
Beispiel #3
0
        private void AddDash(DialogueType dialogueStyle)
        {
            string text = textBox1.Text.Trim();

            if (text.Replace(Environment.NewLine, string.Empty).Length != text.Length)
            {
                string temp = string.Empty;
                // TODO: REMOVE

                /*
                 * if (num < 1)
                 * {
                 *  if (!string.IsNullOrEmpty(text))
                 *  {
                 *      temp = Utilities.RemoveHtmlTags(text).Trim();
                 *
                 *      if (temp.StartsWith("-"))
                 *      {
                 *          text = Regex.Replace(text, @"\B-\B", string.Empty);
                 *          text = Regex.Replace(text, Environment.NewLine + @"\B-\B", Environment.NewLine);
                 *      }
                 *  }
                 * }*/
                switch (dialogueStyle)
                {
                case DialogueType.SingleDash:
                    // removes the first dash
                    temp = HtmlUtils.RemoveTags(text).Trim();
                    var val = text.Substring(0, text.IndexOf(Environment.NewLine));
                    if (HtmlUtils.RemoveTags(val).Trim().Length > 2 && val.StartsWith("-"))
                    {
                        int index = text.IndexOf("-");
                        text = text.Remove(index, 1);
                        if (text.Length > index && text[index] == 0x20)
                        {
                            text = text.Remove(index, 1);
                        }
                    }

                    // add a new dash
                    if (!temp.Contains(Environment.NewLine + "-"))
                    {
                        text          = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
                        textBox1.Text = text;
                    }
                    break;

                case DialogueType.DoubleDash:
                    temp = HtmlUtils.RemoveTags(text);
                    if (!temp.StartsWith("-"))
                    {
                        text = text.Insert(0, "- ");
                    }

                    if (!temp.Contains(Environment.NewLine + "-"))
                    {
                        text = text.Replace(Environment.NewLine, Environment.NewLine + "- ");
                    }
                    textBox1.Text = text;
                    break;
                }
            }
        }