Пример #1
0
        private void ConnectSyllableWithNext_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedListBox?.SelectedItem == null)
            {
                return;
            }

            int         selectedIndex = SelectedListBox.SelectedIndex;
            RomajiLyric selected      = (RomajiLyric)SelectedListBox.SelectedItem;
            LyricLine   selectedLine  = (LyricLine)SelectedListBox.ItemsSource;

            if (selected == null || selectedIndex + 1 >= SelectedListBox.Items.Count)
            {
                return;
            }

            Vocal       selectedVocal = selected.Vocal;
            RomajiLyric next          = (RomajiLyric)SelectedListBox.Items[selectedIndex + 1];

            var undoAction = new UndoConnectSyllables(selectedIndex, new RomajiLyric(selected), next, selectedLine);

            UndoStack.Push(undoAction);

            if (selectedVocal.Lyric.EndsWith("-"))
            {
                selectedVocal.Lyric = selectedVocal.Lyric.Substring(0, selectedVocal.Lyric.Length - 1);
            }

            selectedVocal.Lyric += next.Vocal.Lyric;
            selectedVocal.Length = (float)Math.Round(selectedVocal.Length + next.Vocal.Length, 3, MidpointRounding.AwayFromZero);

            selectedLine.Remove(next);

            MatchRomajiToSymbols();
        }
Пример #2
0
        private void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog
            {
                Filter       = "XML Files|*.xml",
                AddExtension = true,
                FileName     = "PART JVOCALS_RS2.xml"
            };

            try
            {
                if (dialog.ShowDialog() == true)
                {
                    VocalsFile vocals = new VocalsFile();
                    foreach (LyricLine line in LyricLines)
                    {
                        foreach (RomajiLyric lyric in line)
                        {
                            Vocal  currentVocal = lyric.Vocal;
                            string romaji       = lyric.Vocal.Lyric;
                            string japanese     = lyric.Japanese?.Content;

                            // Use the original file contents for any unmatched syllables
                            if (string.IsNullOrEmpty(japanese))
                            {
                                japanese = romaji;
                            }
                            // Connect all Japanese characters, but skip words already in romaji
                            else if (!romaji.Equals(japanese, StringComparison.OrdinalIgnoreCase))
                            {
                                if (romaji.EndsWith("+"))
                                {
                                    japanese += "+";
                                }
                                else
                                {
                                    japanese += "-";
                                }
                            }

                            vocals.Add(new Vocal
                            {
                                Length = currentVocal.Length,
                                Lyric  = japanese,
                                Note   = currentVocal.Note,
                                Time   = currentVocal.Time
                            });
                        }
                    }

                    XmlHelper.Serialize(dialog.FileName, vocals);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    "Saving file failed: " + Environment.NewLine + ex.Message,
                    "Error Saving File",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);
            }
        }