private void button_ToMacros_Click(object sender, EventArgs e) { if ((index_song_selected = combo_SongName.SelectedIndex) == -1) { return; } if ((index_diff_selected = combo_difficulty.SelectedIndex) == -1) { return; } name_save = textb_SongName.Text + "_" + diffs[index_diff_selected].shortName + ".cfg"; if (MessageBox.Show( "The current difficulty is \"" + diffs[index_diff_selected].displayName + "\". Sure?", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } button_ToMacros.Enabled = false; button_Save.Enabled = false; button_FromMacros.Enabled = false; output_000.Text = "Processing..."; try { Converter_NotesMacro.ConvertMacro( ref js_macro, text_Score.Lines, textb_SongName.Text, ref diffs[index_diff_selected]); } catch (Exception err) { output_000.Text += "\r\n" + err.ToString(); button_ToMacros.Enabled = true; } MessageBox.Show("Done."); output_000.Text += "Done."; button_ToMacros.Enabled = true; button_Save.Enabled = true; }
private void button_Download_Click(object sender, EventArgs e) { if ((index_song_selected = combo_SongName.SelectedIndex) == -1) { return; } if ((index_diff_selected = combo_difficulty.SelectedIndex) == -1) { return; } button_Download.Enabled = false; button_Save.Enabled = false; button_FromMacros.Enabled = false; name_save = songs[index_song_selected].fullName + "_" + diffs[index_diff_selected].shortName + ".cfg"; output_000.Text = ""; Task t = new Task(() => { try { HttpWebRequest xhr = (HttpWebRequest)WebRequest.Create("https://million.hyrorre.com/musics/" + songs[index_song_selected].urlName + "/" + diffs[index_diff_selected].urlName); xhr.Method = "GET"; Invoke(new Action(() => { output_000.Text += "Connecting... "; })); HttpWebResponse xhrr = xhr.GetResponse() as HttpWebResponse; Invoke(new Action(() => { output_000.Text += "Success.\r\nProcessingText..."; })); StreamReader sr = new StreamReader(xhrr.GetResponseStream()); string string_sr = sr.ReadToEnd(); sr.Close(); Match m_u = Regex.Match(string_sr, "(?<=<div id=\"score_str\">)[^<]*"); if (!m_u.Success) { throw new Exception("Notes information is not found."); } string_sr = Regex.Replace(m_u.Value, """, "\""); Invoke(new Action(() => { output_000.Text += "Success.\r\nParsingJSON..."; })); js_notes = JsonConvert.DeserializeObject <Js_notes_OBJ>(string_sr); Invoke(new Action(() => { if (checkBox_tempo.Checked) { js_notes.Conductors[0].Tempo = (int)numericUpDown_tempo.Value; } else { numericUpDown_tempo.Value = js_notes.Conductors[0].Tempo; } })); Converter_NotesMacro.ConvertMacro( ref js_macro, ref js_notes, ref songs[index_song_selected], ref diffs[index_diff_selected]); Invoke(new Action(() => { output_000.Text += "Success."; button_Save.Enabled = true; button_Download.Enabled = true; button_FromMacros.Enabled = true; })); } catch (Exception err) { Invoke(new Action(() => { output_000.Text += "\r\n" + err.ToString(); })); button_Download.Enabled = true; } }); t.Start(); }