}// ----------------------------------------- // -- // Event Clicked Compressed Button private void btn_CRUSH_Click(object sender, EventArgs e) { // Get a valid audio parameters tuple Tuple <int, int> audioQ = Tuple.Create(combo_audio_c.SelectedIndex, combo_audio_q.SelectedIndex); // Since I can fire 2 jobs from here, have a common callback Action <bool, int, CueReader> jobCallback = (complete, newSize, cd) => { FormTools.invoke(this, () => { form_lockSection("all", false); form_set_crushed_size(newSize); postCdInfo = cd; // Either null or full info if (complete) { FormMain.sendMessage("Complete", 2); btn_chksm.Enabled = true; } else { FormMain.sendProgress(0); FormMain.sendMessage(CDCRUSH.ERROR, 3); } }); }; // Reset the message color, incase it was red FormMain.sendMessage("", 1); // Engine request job result bool res = false; // Fix progress reporting. HACKY WAY :-/ CDCRUSH.HACK_CD_TRACKS = numberOfTracks; // Either compress to an archive, or just convert // Note : Progress updates are automatically being handled by the main FORM if (chk_encodedCue.Checked) { res = CDCRUSH.startJob_ConvertCue(loadedCuePath, input_out.Text, audioQ, info_cdtitle.Text, jobCallback); } else { res = CDCRUSH.startJob_CrushCD(loadedCuePath, input_out.Text, audioQ, preparedCover, info_cdtitle.Text, combo_data_c.SelectedIndex + 1, jobCallback); } // -- Is everything ok? if (res) { form_lockSection("all", true); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }// -----------------------------------------
}// ----------------------------------------- // -- private void btn_RESTORE_Click(object sender, EventArgs e) { // -- FormMain.sendMessage("", 1); // Send the nuber of tracks for proper progress reporting CDCRUSH.HACK_CD_TRACKS = loadedCDInfo.tracks.length; // Start the job // Note, Progress updates are automatically being handled by the main FORM bool res = CDCRUSH.startJob_RestoreCD( loadedArcPath, input_out.Text, toggle_subf.Checked, combo_method.SelectedIndex, (complete) => { FormTools.invoke(this, () => { form_lockSection("all", false); if (complete) { // DEVNOTE: Should I lock the button in case user presses it again? // I don't think so right? // form_lockSection("action", true); FormMain.sendMessage("Complete", 2); } else { // job update-fail won't push progress, do it manually FormMain.sendProgress(0); FormMain.sendMessage(CDCRUSH.ERROR, 3); } // Make progress bar and status message clear after FormMain.FLAG_REQUEST_STATUS_CLEAR = true; }); }); if (res) { form_lockSection("all", true); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }// -----------------------------------------
}// ----------------------------------------- /// <summary> /// Quick load an .arc file and display info about the CD loaded /// If FILE is unsupported it will notify user about error /// </summary> void form_quickLoadFile(string file) { // - Action <object> onLoad = (o) => { FormTools.invoke(this, () => { FormMain.sendProgress(0); form_lockSection("all", false); if (o == null) { LOG.log("QuickLoad ERROR - " + CDCRUSH.ERROR); FormMain.sendMessage(CDCRUSH.ERROR, 3); form_lockSection("action", true); return; } // This file will be restored when the button is clicked loadedArcPath = file; input_in.Text = file; form_setCdInfo(o); form_setCoverImage((o as dynamic).cover); // Note: Cover file may not exist FormMain.sendMessage("Loaded Info OK.", 2); btn_RESTORE.Focus(); }); }; // -- // Clear the status infos at next tab change FormMain.FLAG_REQUEST_STATUS_CLEAR = true; if (CDCRUSH.loadQuickInfo(file, onLoad)) { // Waiting to load quick info : Lock Form form_lockSection("all", true); FormMain.sendMessage("Reading Information ..", 1); FormMain.sendProgress(-1); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); onLoad(null); // hacky way to have one codebase for errors } }// -----------------------------------------
}// ----------------------------------------- // -- // Event Clicked Compressed Button private void btn_CRUSH_Click(object sender, EventArgs e) { // Common callback for all job types Action <bool, CrushParams> jobCallback = (complete, jobdata) => { FormTools.invoke(this, () => { form_lockSection("all", false); form_set_crushed_size(jobdata.crushedSize); postCdInfo = jobdata.cd; // Either null or full info if (complete) { FormMain.sendMessage("Complete", 2); btn_chksm.Enabled = true; } else { FormMain.sendProgress(0); FormMain.sendMessage(CDCRUSH.ERROR, 3); } // Make progress bar and status message clear after FormMain.FLAG_REQUEST_STATUS_CLEAR = true; }); }; // Reset the message color, incase it was red FormMain.sendMessage("", 1); // Fix progress reporting. HACKY WAY :-/ CDCRUSH.HACK_CD_TRACKS = numberOfTracks; // Either compress to an archive, or just convert // Note : Progress updates are automatically being handled by the main FORM // This TUPLE will hold (CODECID, QUALITY INDEX) Tuple <string, int> audioQ = Tuple.Create(AudioMaster.codecs[combo_audio_c.SelectedIndex], combo_audio_q.SelectedIndex); bool res = CDCRUSH.startJob_Convert_Crush( combo_method.SelectedIndex, loadedCuePath, input_out.Text, audioQ, combo_data_c.SelectedIndex, info_cdtitle.Text, preparedCover, jobCallback ); // -- Check preliminary Job Status if (res) { form_lockSection("all", true); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }// -----------------------------------------