Ejemplo n.º 1
0
        private async void ButtonExport_Click(object sender, RoutedEventArgs e)
        {
            if (Parameters.SubtitleList.Count != 0)
            {
                try
                {
                    List <SubtitleItem> subtitleListChanged = CopyList(Parameters.SubtitleList);

                    if (ComboBoxMath.SelectedIndex == 0) //add
                    {
                        if (ComboBoxTime.SelectedIndex == 0)
                        {
                            Exporter.Add(subtitleListChanged, int.Parse(TextBoxInput.Text));
                        }                                                                                                         //add milliseconds
                        if (ComboBoxTime.SelectedIndex == 1)
                        {
                            Exporter.Add(subtitleListChanged, int.Parse(TextBoxInput.Text) * 1000);
                        }                                                                                                                //add seconds
                        if (ComboBoxTime.SelectedIndex == 2)
                        {
                            Exporter.Add(subtitleListChanged, int.Parse(TextBoxInput.Text) * 60000);
                        }                                                                                                                 //add minutes
                        if (ComboBoxTime.SelectedIndex == 3)
                        {
                            Exporter.Add(subtitleListChanged, int.Parse(TextBoxInput.Text) * 3600000);
                        }                                                                                                                   //add hours
                    }

                    if (ComboBoxMath.SelectedIndex == 1) //subtract
                    {
                        if (ComboBoxTime.SelectedIndex == 0)
                        {
                            Exporter.Subtract(subtitleListChanged, int.Parse(TextBoxInput.Text));
                        }                                                                                                              //subtract milliseconds
                        if (ComboBoxTime.SelectedIndex == 1)
                        {
                            Exporter.Subtract(subtitleListChanged, int.Parse(TextBoxInput.Text) * 1000);
                        }                                                                                                                     //subtract seconds
                        if (ComboBoxTime.SelectedIndex == 2)
                        {
                            Exporter.Subtract(subtitleListChanged, int.Parse(TextBoxInput.Text) * 60000);
                        }                                                                                                                      //subtract minutes
                        if (ComboBoxTime.SelectedIndex == 3)
                        {
                            Exporter.Subtract(subtitleListChanged, int.Parse(TextBoxInput.Text) * 3600000);
                        }                                                                                                                        //subtract hours
                    }

                    await Exporter.Export(Parameters.FileName, subtitleListChanged);
                }
                catch (Exception)
                {
                    await Dialogs.ErrorDialog("Exporing aborted", "The value you entered isn't a numeric value or a whole number. Please try again.");
                }
            }

            else
            {
                await Dialogs.ErrorDialog("Exporting aborted", "Please load a subtitle file first.");
            }
        }