Ejemplo n.º 1
0
        private void btOK_Click(object sender, RoutedEventArgs e)
        {
            if (isGT)
            {
                string from = ((ComboBoxItem)cbFrom.SelectedItem).Tag.ToString();
                string to   = ((ComboBoxItem)cbTo.SelectedItem).Tag.ToString();
                suggestion        = SharedClasses.GetGoogleTranslation(subtitle, from, to);
                this.DialogResult = true;
                this.Close();
            }

            if (isWarning)
            {
                this.DialogResult = true;
                this.Close();
            }

            this.Close();
        }
Ejemplo n.º 2
0
        private void Menu_Save(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtTranslate.Text) || string.IsNullOrWhiteSpace(txtTranslate.Text))
            {
                loadedSubs.Rows[currentDialog]["Translation"] = txtTranslate.Text.Trim();
            }

            string         openFile   = lblOpenFile.Content.ToString();
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Filter       = "Subtitle TranStation Project (*.tra)|*.tra";
            saveDialog.AddExtension = true;
            saveDialog.FileName     = Path.GetFileNameWithoutExtension(lblOpenFile.Content.ToString());

            if (saveDialog.ShowDialog() == true)
            {
                if (SharedClasses.SaveProject(saveDialog.OpenFile(), subScript))
                {
                    string       message     = String.Format("The translation project has been saved successfully.", fileName);
                    DialogWindow errorDialog = new DialogWindow();
                    errorDialog.DialogTitle = "Exporting Subtitles";
                    errorDialog.Message     = message;
                    errorDialog.Type        = DialogWindow.InfoType;
                    errorDialog.Owner       = this;
                    errorDialog.Width       = 400;
                    errorDialog.Height      = 120;
                    errorDialog.Show();
                }
                else
                {
                    string       errorMsg    = String.Format("An error ocurred while saving the translation project, please try again.", fileName);
                    DialogWindow errorDialog = new DialogWindow();
                    errorDialog.DialogTitle = "Exporting Subtitles";
                    errorDialog.Message     = errorMsg;
                    errorDialog.Type        = DialogWindow.ErrorType;
                    errorDialog.Owner       = this;
                    errorDialog.Width       = 400;
                    errorDialog.Height      = 120;
                    errorDialog.Show();
                }
            }
        }
Ejemplo n.º 3
0
        private void Menu_Open(object sender, RoutedEventArgs e)
        {
            OpenFileDialog filedialog = new OpenFileDialog();

            filedialog.Filter = "All files (*.*)|*.*|SubRip Subtitles (*.srt)|*.srt|Subtitle TranStation Project (*.tra)|*.tra";
            if (filedialog.ShowDialog() == true)
            {
                subScript = SharedClasses.CheckSubFile(filedialog.FileName);

                if (subScript != null)
                {
                    loadedSubs    = subScript.Tables["Dialogue"];
                    fileName      = filedialog.FileName;
                    currentDialog = 0;
                    UpdateCurrentDialog(loadedSubs, currentDialog, fileName);
                    fileOpened           = true;
                    exportMenu.IsEnabled = true;
                }
            }
        }
Ejemplo n.º 4
0
        private void UpdateCurrentDialog(DataTable loadedSubs, int currentDialog, string fileName)
        {
            lblOpenFile.Content  = System.IO.Path.GetFileName(fileName);
            lblDialogNum.Content = String.Format("{0} of {1}", (currentDialog + 1), loadedSubs.Rows.Count);
            if (loadedSubs.Columns.Contains("Name"))
            {
                if (!string.IsNullOrEmpty(loadedSubs.Rows[currentDialog]["Name"].ToString()))
                {
                    lblCharacter.Content = loadedSubs.Rows[currentDialog]["Name"];
                }
            }
            lblStartTime.Content = String.Format("Start: {0}", loadedSubs.Rows[currentDialog]["Start"].ToString());
            lblEndTime.Content   = String.Format("End: {0}", loadedSubs.Rows[currentDialog]["End"].ToString());

            string htmlDialog = SharedClasses.VisualDialogue(loadedSubs.Rows[currentDialog]["Text"].ToString());

            txtDialog.NavigateToString(htmlDialog);
            txtDialog.Visibility = Visibility.Visible;
            txtTranslate.Text    = loadedSubs.Rows[currentDialog]["Translation"].ToString();
        }
Ejemplo n.º 5
0
        private void Menu_Export(object sender, RoutedEventArgs e)
        {
            string         newFile      = String.Empty;
            SaveFileDialog exportDialog = new SaveFileDialog();

            exportDialog.Filter       = "SubRip Subtitles (*.srt) | *.srt|SubStation Alpha Subtitles (*.ass)|*.ass";
            exportDialog.AddExtension = true;
            exportDialog.FileName     = Path.GetFileNameWithoutExtension(lblOpenFile.Content.ToString());
            if (exportDialog.ShowDialog() == true)
            {
                try
                {
                    SharedClasses.ExportTranslation(exportDialog.FileName,
                                                    exportDialog.OpenFile(),
                                                    subScript);

                    string       message     = String.Format("The subtitles has been exported successfully.", fileName);
                    DialogWindow errorDialog = new DialogWindow();
                    errorDialog.DialogTitle = "Exporting Subtitles";
                    errorDialog.Message     = message;
                    errorDialog.Type        = DialogWindow.InfoType;
                    errorDialog.Owner       = this;
                    errorDialog.Width       = 400;
                    errorDialog.Height      = 120;
                    errorDialog.Show();
                }
                catch (Exception)
                {
                    string       errorMsg    = String.Format("An error ocurred exporting the subtitles, please try again.", fileName);
                    DialogWindow errorDialog = new DialogWindow();
                    errorDialog.DialogTitle = "Exporting Subtitles";
                    errorDialog.Message     = errorMsg;
                    errorDialog.Type        = DialogWindow.ErrorType;
                    errorDialog.Owner       = this;
                    errorDialog.Width       = 400;
                    errorDialog.Height      = 120;
                    errorDialog.Show();
                }
            }
        }