}// ----------------------------------------- /// <summary> /// Quick load a `.cue` file, called when dropped and open file /// Check and prepare /// </summary> void form_quickLoadFile(string file) { dynamic o = CDCRUSH.loadQuickCUE(file); // Reset Infos and Action, unlock on valid file form_lockSection("action", true); form_set_cover(null); // Empty it out form_set_info_pre(null); form_set_crushed_size(); // Empty it out loadedCuePath = null; postCdInfo = null; numberOfTracks = 0; // Clear the status infos at next tab change FormMain.FLAG_REQUEST_STATUS_CLEAR = true; if (o == null) // Error { FormMain.sendMessage(CDCRUSH.ERROR, 3); } else { loadedCuePath = file; input_in.Text = file; form_lockSection("action", false); form_set_info_pre(o); numberOfTracks = o.tracks; FormMain.sendMessage("Loaded CUE OK.", 2); } }// -----------------------------------------
}// ----------------------------------------- // -- private void btn_RESTORE_Click(object sender, EventArgs e) { // Start the job // Note, Progress updates are automatically being handled by the main FORM bool res = CDCRUSH.restoreARC(preparedArcPath, input_out.Text, toggle_subf.Checked, toggle_single.Checked, (complete) => { FormTools.invoke(this, () => { form_lockSection("all", false); form_lockSection("action", true); // Just restored this image, why restore it again? }); if (complete) { FormMain.sendMessage("Complete", 2); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }); if (res) { form_lockSection("all", true); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }// -----------------------------------------
}// ----------------------------------------- /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_CRUSH_Click(object sender, EventArgs e) { // Start the job // Note, Progress updates are automatically being handled by the main FORM bool res = CDCRUSH.crushCD(preparedCue, input_out.Text, combo_audioq.SelectedIndex, preparedCover, info_cdtitle.Text, (complete, md5, newSize) => { FormTools.invoke(this, () => { form_lockSection("all", false); form_lockSection("action", true); form_set_info_post(new { md5, size0 = newSize }); }); if (complete) { FormMain.sendMessage("Complete", 2); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }); if (res) { form_lockSection("all", true); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); FormMain.FLAG_CLEAR_STATUS = true; } }// -----------------------------------------
}// ----------------------------------------- /// <summary> /// Quick load a `.cue` file, called when dropped and open file /// Check and prepare /// </summary> void form_quickLoadFile(string file) { dynamic o = CDCRUSH.loadQuickCUE(file); // Reset Infos and Action, unlock on valid file form_lockSection("action", true); form_set_cover(null); // will also set preparedCover form_set_info_pre(null); form_set_info_post(null); preparedCue = null; FormMain.FLAG_CLEAR_STATUS = true; if (o == null) // Error { FormMain.sendMessage(CDCRUSH.ERROR, 3); } else { preparedCue = file; input_in.Text = file; form_lockSection("action", false); form_set_info_pre(o); } }// -----------------------------------------
}// ----------------------------------------- // -- // 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); } }// -----------------------------------------
}// ----------------------------------------- // ============================================= // = EVENTS // ============================================= /// <summary> /// A file has been dropped and the ENGINE is NOT LOCKED /// </summary> /// <param name="file"></param> public void handle_dropped_file(string file) { // handle the file if (System.IO.Path.GetExtension(file).ToLower() == ".arc") { form_quickLoadFile(file); } else { FormMain.sendMessage("Unsupported file type. Drop an `.arc` file", 3); } }// -----------------------------------------
}// ----------------------------------------- // -- // 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> jobCallback = (complete, newSize) => { FormTools.invoke(this, () => { form_lockSection("all", false); form_lockSection("action", true); form_set_crushed_size(newSize); }); if (complete) { FormMain.sendMessage("Complete", 2); } else { FormMain.sendMessage(CDCRUSH.ERROR, 3); } }; // Engine request job result bool res = false; // 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(preparedCue, input_out.Text, audioQ, info_cdtitle.Text, jobCallback); } else { res = CDCRUSH.startJob_CrushCD(preparedCue, 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); FormMain.FLAG_CLEAR_STATUS = true; } }// -----------------------------------------
}// ----------------------------------------- // -- 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); } }// -----------------------------------------
}// ----------------------------------------- // ========================================== // EVENTS // ========================================== /// <summary> /// A file has been dropped and the ENGINE is NOT LOCKED /// </summary> /// <param name="file"></param> public void handle_dropped_file(string file) { // handle the file var ext = System.IO.Path.GetExtension(file).ToLower(); if (ext == ".cue") { form_quickLoadFile(file); } else if (ext == ".jpg") { form_set_cover(file); } else { FormMain.sendMessage("Unsupported file extension. Drop a .CUE file, or .JPG for a cover", 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 } }// -----------------------------------------
}// ----------------------------------------- // ========================================== // EVENTS // ========================================== /// <summary> /// A file has been dropped and the ENGINE is NOT LOCKED /// </summary> /// <param name="file"></param> public void handle_dropped_file(string file) { // handle the file var ext = System.IO.Path.GetExtension(file).ToLower(); if (ext == ".cue") { form_quickLoadFile(file); } else if (ext == ".jpg") { form_set_cover(file); } else { FormMain.sendMessage("Unsupported file extension.", 3); FormMain.FLAG_CLEAR_STATUS = true; } }// -----------------------------------------
}// ----------------------------------------- /// <summary> /// Quick load a `.cue` file, called when dropped and open file /// Check and prepare /// </summary> void form_quickLoadFile(string file) { form_prepare_init(); // Clear the status infos at next tab change FormMain.FLAG_REQUEST_STATUS_CLEAR = true; dynamic o = CDCRUSH.loadQuickCUE(file); if (o == null) // Error { FormMain.sendMessage(CDCRUSH.ERROR, 3); } else { // CUE Loaded OK, fill in form infos and unlock buttons loadedCuePath = file; input_in.Text = file; form_lockSection("action", false); form_set_cd_info(o); FormMain.sendMessage("Loaded CUE OK.", 2); } }// -----------------------------------------
}// ----------------------------------------- // -- // 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); } }// -----------------------------------------