Example #1
0
        }// -----------------------------------------

        /// <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;
            }
        }// -----------------------------------------
        }// -----------------------------------------

        // --
        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);
            }
        }// -----------------------------------------
Example #3
0
        }// -----------------------------------------

        // --
        // Path must be the folder containing `ffmpeg.exe`
        void form_setFFmpegPath(string path = null)
        {
            CDCRUSH.setFFMPEGPath(path);
            info_ffmpeg.Text = CDCRUSH.FFMPEG_PATH;
            Properties.Settings.Default.ffmpegPath = CDCRUSH.FFMPEG_PATH;
            form_updateFFmpegStatus();
        }// -----------------------------------------
Example #4
0
        }// -----------------------------------------

        /// <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);
            }
        }// -----------------------------------------
Example #5
0
        }// -----------------------------------------

        // --
        private void btn_selectTemp_Click(object sender, EventArgs e)
        {
            SaveFileDialog d = new SaveFileDialog();

            d.FileName        = "TEMP_FOLDER_THIS_ONE";
            d.CheckPathExists = true;
            d.Title           = "Select Temp folder";

            if (d.ShowDialog() == DialogResult.OK)
            {
                string path;
                try{
                    path = System.IO.Path.GetDirectoryName(d.FileName);
                }catch (ArgumentException)
                {
                    return;
                }

                if (CDCRUSH.setTempFolder(path))
                {
                    info_tempFolder.Text = CDCRUSH.TEMP_FOLDER;
                    Properties.Settings.Default.tempFolder = path;             // A valid folder
                }
            }
        }// -----------------------------------------
Example #6
0
        }// -----------------------------------------

        // --
        // Load saved settings and apply them to the engine
        // Reflect the changes to the form as well
        void loadAndSetupSettings()
        {
            LOG.log("[FormMain] Loading Settings : ");

            // -- TEMP_PATH
            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.tempFolder))
            {
                LOG.log("\t tempfolder : " + Properties.Settings.Default.tempFolder);
                if (!CDCRUSH.setTempFolder(Properties.Settings.Default.tempFolder))
                {
                    // Stored temp folder is no longer valid for some reason :
                    Properties.Settings.Default.tempFolder = null;
                }
            }

            // Temp Folder Form Elements :
            info_tempFolder.Text = CDCRUSH.TEMP_FOLDER;

            // - FFMPEG_PATH
            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.ffmpegPath))
            {
                LOG.log("\t ffmpeg : " + Properties.Settings.Default.ffmpegPath);
                form_setFFmpegPath(Properties.Settings.Default.ffmpegPath);
            }

            // - MAX_TASKS
            if (Properties.Settings.Default.maxTasks > 0)
            {
                LOG.log("\t maxtasks : " + Properties.Settings.Default.maxTasks);
                CDCRUSH.MAX_TASKS = Properties.Settings.Default.maxTasks;
            }

            num_threads.Value = CDCRUSH.MAX_TASKS;
        }// -----------------------------------------
Example #7
0
        }// -----------------------------------------

        /// <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);
            }
        }// -----------------------------------------
Example #8
0
        }// -----------------------------------------

        // :: Initialize things:
        private void FormMain_Load(object sender, EventArgs e)
        {
            // -- Enable drag and drop
            FormTools.dragDropFormEnable(this, (string[] files) => {
                if (CDCRUSH.LOCKED)
                {
                    return;
                }
                if (files == null)
                {
                    return;
                }
                handle_dropped_file(files[0]);
            });

            // - Init Form Things
            FormTools.fileLoadDialogPrepare("ffmpeg", "FFmpeg.exe|ffmpeg.exe");
            form_setProgress(0);
            form_setText("Ready.", 1);

            // - Set Infos tab
            windowTitle = CDCRUSH.PROGRAM_NAME + " v" + CDCRUSH.PROGRAM_VERSION;
            this.Text   = windowTitle;

            // - Links
            info_ver.Text         = CDCRUSH.PROGRAM_VERSION;
            link_web.LinkClicked += new LinkLabelLinkClickedEventHandler((a, b) => {
                link_web.LinkVisited = true;
                System.Diagnostics.Process.Start(CDCRUSH.LINK_SOURCE);
            });

            link_donate.LinkClicked += new LinkLabelLinkClickedEventHandler((a, b) => {
                link_donate.LinkVisited = true;
                System.Diagnostics.Process.Start(CDCRUSH.LINK_DONATE);
            });

            // -- Init Engine
            if (!CDCRUSH.init())
            {
                // For some reason the engine couldn't initialize
                form_setText(CDCRUSH.ERROR, 3);
                form_lockAll(true);
                return;
            }

            // -- FFmpeg
            form_updateFFmpegStatus();

            // -- Settings tab
            loadAndSetupSettings();

            // -- Set initial tab
            tabControl1.SelectedIndex = STARTING_TAB;

            // --
                #if (!DEBUG)
            group_debug.Visible = false;
                #endif
        }// -----------------------------------------
Example #9
0
        }// -----------------------------------------

        // ------------------------------------------
        // SETTINGS PANEL
        // ------------------------------------------

        // --
        private void btn_temp_def_Click(object sender, EventArgs e)
        {
            if (CDCRUSH.setTempFolder())
            {
                info_tempFolder.Text = CDCRUSH.TEMP_FOLDER;
                Properties.Settings.Default.tempFolder = null;
            }
        }// -----------------------------------------
Example #10
0
        }// -----------------------------------------

        // --
        // 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);
            }
        }// -----------------------------------------
        }// -----------------------------------------

        // --
        // 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;
            }
        }// -----------------------------------------
Example #12
0
        }// -----------------------------------------

        // --
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            // --To cancel. e.cancel = true

            if (CDCRUSH.LOCKED)
            {
                if (!FormTools.PopupYesNo("An operation is in progress, really quit?", "Confirm"))
                {
                    e.Cancel = true;
                }
            }

            Properties.Settings.Default.Save();
            CDCRUSH.kill();
        }// -----------------------------------------
Example #13
0
        }// -----------------------------------------

        // --
        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);
            }
        }// -----------------------------------------
Example #14
0
        }// -----------------------------------------

        /// <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
            }
        }// -----------------------------------------
Example #15
0
        }// -----------------------------------------

        /// <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);
            }
        }// -----------------------------------------
Example #16
0
        }// -----------------------------------------

        // --
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Properties.Settings.Default.Save();
            CDCRUSH.kill();
        }// -----------------------------------------
Example #17
0
        }// -----------------------------------------

        // --
        // 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);
            }
        }// -----------------------------------------