예제 #1
0
 //打开文件
 private void LoadUST_Click(object sender, EventArgs e)
 {
     UST ust_load = new UST();
     OpenFileDialog Open = new OpenFileDialog();
     Open.Filter = "UTAU工程文件|*.ust";
     Open.ShowDialog();
     if (Open.FileName != "")
     {
         ust_load.FileName = Open.FileName;
         ust_load.SafeFileName = Open.SafeFileName;
         StreamReader USTReader = new StreamReader(Open.OpenFile(), Encoding.GetEncoding("Shift-JIS"));
         bool USTValid = ust_load.USTLoad(USTReader);
         USTReader.Close();
         if (Encoding.Default != Encoding.GetEncoding("Shift-JIS"))
         {
             string buffer = File.ReadAllText(Open.FileName, Encoding.Default);
             int Start = buffer.IndexOf("VoiceDir=");
             int End = buffer.IndexOf("\r\n", Start);
             ust_load.VoiceDir = buffer.Substring(Start, End - Start).Remove(0, 9);
         }
         if (USTValid)
         {
             ust = ust_load;
             groupBox_USTProperties.Enabled = true;
             groupBox_SongProperties.Enabled = true;
             groupBox_LyricsType.Enabled = true;
             groupBox_NoteProperties.Enabled = true;
             DoLyricTrans.Enabled = true;
             textBox_ProjectName.Text = ust.ProjectName;
             textBox_OutFile.Text = ust.OutFile;
             string VoiceDirBuf = ust.VoiceDir;
             try
             {
                 if (ust.VoiceDir.Substring(0, 7) == "%VOICE%")
                 {
                     VoiceDirBuf = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase.Substring(0, System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase.Length - 1) + "\\voice\\" + ust.VoiceDir.Remove(0, 7);
                     if (VoicePaths.IndexOf(VoiceDirBuf) == -1)
                     {
                         VoiceDirBuf = ExtraVoiceDir + "\\" + ust.VoiceDir.Remove(0, 7);
                     }
                 }
             }
             catch { }
             VoiceSelBox.SelectedIndex = VoicePaths.IndexOf(VoiceDirBuf);
             textBox_VoiceDir.Text = ust.VoiceDir;
             textBox_Tool1.Text = ust.Tool1;
             textBox_Tool2.Text = ust.Tool2;
             textBox_Flags.Text = ust.Flags;
             textBox_BPM.Text = ust.BPM;
             textBox_PitchShift.Text = ust.PitchShift.ToString();
             PitchModeBox.SelectedIndex = ust.PitchMode - 1;
             VibratoBox.SelectedIndex = 0;
             Save.Enabled = true;
             SaveAs.Enabled = true;
             SetDefault.Enabled = true;
         }
         else
         {
             LoadingFailed LoadingFailedDlg = new LoadingFailed();
             LoadingFailedDlg.Show();
             ust_load = null;
             GC.Collect();
         }
         USTReader.Close();
     }
 }
예제 #2
0
        //打开文件
        private void LoadUST_Click(object sender, EventArgs e)
        {
            UST            ust_load = new UST();
            OpenFileDialog Open     = new OpenFileDialog();

            Open.Filter = "UTAU工程文件|*.ust";
            Open.ShowDialog();
            if (Open.FileName != "")
            {
                ust_load.FileName     = Open.FileName;
                ust_load.SafeFileName = Open.SafeFileName;
                StreamReader USTReader = new StreamReader(Open.OpenFile(), Encoding.GetEncoding("Shift-JIS"));
                bool         USTValid  = ust_load.USTLoad(USTReader);
                USTReader.Close();
                if (Encoding.Default != Encoding.GetEncoding("Shift-JIS"))
                {
                    string buffer = File.ReadAllText(Open.FileName, Encoding.Default);
                    int    Start  = buffer.IndexOf("VoiceDir=");
                    int    End    = buffer.IndexOf("\r\n", Start);
                    ust_load.VoiceDir = buffer.Substring(Start, End - Start).Remove(0, 9);
                }
                if (USTValid)
                {
                    ust = ust_load;
                    groupBox_USTProperties.Enabled  = true;
                    groupBox_SongProperties.Enabled = true;
                    groupBox_LyricsType.Enabled     = true;
                    groupBox_NoteProperties.Enabled = true;
                    DoLyricTrans.Enabled            = true;
                    textBox_ProjectName.Text        = ust.ProjectName;
                    textBox_OutFile.Text            = ust.OutFile;
                    string VoiceDirBuf = ust.VoiceDir;
                    try
                    {
                        if (ust.VoiceDir.Substring(0, 7) == "%VOICE%")
                        {
                            VoiceDirBuf = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase.Substring(0, System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase.Length - 1) + "\\voice\\" + ust.VoiceDir.Remove(0, 7);
                            if (VoicePaths.IndexOf(VoiceDirBuf) == -1)
                            {
                                VoiceDirBuf = ExtraVoiceDir + "\\" + ust.VoiceDir.Remove(0, 7);
                            }
                        }
                    }
                    catch { }
                    VoiceSelBox.SelectedIndex  = VoicePaths.IndexOf(VoiceDirBuf);
                    textBox_VoiceDir.Text      = ust.VoiceDir;
                    textBox_Tool1.Text         = ust.Tool1;
                    textBox_Tool2.Text         = ust.Tool2;
                    textBox_Flags.Text         = ust.Flags;
                    textBox_BPM.Text           = ust.BPM;
                    textBox_PitchShift.Text    = ust.PitchShift.ToString();
                    PitchModeBox.SelectedIndex = ust.PitchMode - 1;
                    VibratoBox.SelectedIndex   = 0;
                    Save.Enabled       = true;
                    SaveAs.Enabled     = true;
                    SetDefault.Enabled = true;
                }
                else
                {
                    LoadingFailed LoadingFailedDlg = new LoadingFailed();
                    LoadingFailedDlg.Show();
                    ust_load = null;
                    GC.Collect();
                }
                USTReader.Close();
            }
        }