abstract internal string ToText(Subtitle subtitle, string title);
Exemple #2
0
        public PluginForm(Subtitle subtitle, string name, string description)
        {
            InitializeComponent();

            //SetControlColor(this);
            gradientBrush = new LinearGradientBrush(ClientRectangle, color, Color.White, 0f);

            Text = $@"{name} - v{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(2)}";

            _subtitle      = subtitle;
            labelDesc.Text = "Description: " + description;

            LoadConfigurations();
            FormClosed += (s, e) =>
            {
                // update config
                //_hiConfigs.NarratorToUppercase = checkBoxNames.Checked;
                //_hiConfigs.MoodsToUppercase = checkBoxMoods.Checked;
                //_hiConfigs.RemoveExtraSpaces = checkBoxRemoveSpaces.Checked;
                //_hiConfigs.Style = (HIStyle)Enum.Parse(typeof(HIStyle), comboBoxStyle.SelectedValue.ToString());
                //_hiConfigs.Style = ((ComboBoxItem)comboBoxStyle.SelectedItem).Style;
                // TypeConverter converter = TypeDescriptor.GetConverter(typeof(HIStyle));

                SaveConfigurations();
            };


            Resize += delegate
            {
                listViewFixes.Columns[listViewFixes.Columns.Count - 1].Width = -2;
            };

            linkLabel1.DoubleClick += LinkLabel1_DoubleClick;

            // force layout
            OnResize(EventArgs.Empty);

            InitComboBoxHIStyle();
            UpdateUIFromConfigs(_hiConfigs);

            _isLoading = false;
            GeneratePreview();

            /*
             * this.KeyDown += (s, e) =>
             * {
             *  if (e.KeyCode == Keys.Escape)
             *      this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
             * };
             */

            buttonNext.Click += (sender, e) =>
            {
                if (listViewFixes.Items.Count == 0 || listViewFixes.SelectedItems.Count == 0)
                {
                    return;
                }

                ListViewItem lvi     = listViewFixes.SelectedItems[0];
                int          nextIdx = lvi.Index + 1;
                // handle boundary
                if (nextIdx == listViewFixes.Items.Count)
                {
                    nextIdx = 0;
                }

                lvi.Selected = false;
                listViewFixes.Select();
                listViewFixes.Items[nextIdx].EnsureVisible();
                listViewFixes.Items[nextIdx].Selected = true;
            };

            buttonPrev.Click += (sender, e) =>
            {
                if (listViewFixes.Items.Count == 0 || listViewFixes.SelectedItems.Count == 0)
                {
                    return;
                }

                ListViewItem lvi    = listViewFixes.SelectedItems[0];
                int          preIdx = lvi.Index - 1;
                // handle boundary
                if (preIdx < 0)
                {
                    preIdx = listViewFixes.Items.Count - 1;
                }

                lvi.Selected = false;
                listViewFixes.Select();
                listViewFixes.Items[preIdx].EnsureVisible();
                listViewFixes.Items[preIdx].Selected = true;
            };

            // donate handler
            pictureBoxDonate.Click += (s, e) =>
            {
                Process.Start(StringUtils.DonateUrl);
            };
        }
 abstract internal void LoadSubtitle(Subtitle subtitle, List <string> lines, string fileName);
Exemple #4
0
        private void ReadLine(Subtitle subtitle, string line, string next)
        {
            switch (_expecting)
            {
            case ExpectingLine.Number:
                if (Utilities.IsInteger(line))
                {
                    _paragraph.Number = int.Parse(line);
                    _expecting        = ExpectingLine.TimeCodes;
                }
                else if (line.Trim().Length > 0)
                {
                    _errorCount++;
                }
                break;

            case ExpectingLine.TimeCodes:
                if (TryReadTimeCodesLine(line, _paragraph))
                {
                    _paragraph.Text = string.Empty;
                    _expecting      = ExpectingLine.Text;
                }
                else if (line.Trim().Length > 0)
                {
                    _errorCount++;
                    _expecting = ExpectingLine.Number;     // lets go to next paragraph
                }
                break;

            case ExpectingLine.Text:
                if (line.Trim().Length > 0)
                {
                    if (_paragraph.Text.Length > 0)
                    {
                        _paragraph.Text += Environment.NewLine;
                    }
                    _paragraph.Text += RemoveBadChars(line).TrimEnd().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
                }
                else if (IsText(next))
                {
                    if (_paragraph.Text.Length > 0)
                    {
                        _paragraph.Text += Environment.NewLine;
                    }
                    _paragraph.Text += RemoveBadChars(line).TrimEnd().Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);
                }
                else if (string.IsNullOrEmpty(line) && string.IsNullOrEmpty(_paragraph.Text))
                {
                    _paragraph.Text = string.Empty;
                    if (!string.IsNullOrEmpty(next) && (Utilities.IsInteger(next) || _regexTimeCodes.IsMatch(next)))
                    {
                        subtitle.Paragraphs.Add(_paragraph);
                        _paragraph = new Paragraph();
                        _expecting = ExpectingLine.Number;
                    }
                }
                else
                {
                    subtitle.Paragraphs.Add(_paragraph);
                    _paragraph = new Paragraph();
                    _expecting = ExpectingLine.Number;
                }
                break;
            }
        }