Пример #1
0
        // Ok Go
        private void f_run_Click(object sender, EventArgs e)
        {
            m_filesChecked = 0;
            f_filesResults.Items.Clear();

            FileSystem fs = new FileSystem();
            fs.RootPath = f_rootPath.Text;

            // create thread based on functionality

            if (f_deleteAll.Checked == false && f_deleteImages.Checked == false)
                myThread = new ThreadMessage(fs.RunStandardizor);

            else if (f_deleteAll.Checked == true && f_deleteImages.Checked == false)
                myThread = new ThreadMessage(fs.RunDeleteAll);

            else if (f_deleteAll.Checked == false && f_deleteImages.Checked == true)
                myThread = new ThreadMessage(fs.RunDeleteImages);

            else
            {
                MessageBox.Show("Choice of what to delete is ambiguous.", "Delete Error");
                return;
            }

            // sunscribe to file system for computation updates
            // subscribe to thread class for cancel events

            FileSystem.Progress += new FileSystem.ComputationEvent(FileBrowser_ProgressUpdate);
            myThread.ThreadUpdate += new ThreadMessage.ThreadEventHandler(FileBrowser_ProgressUpdate);

            myThread.LaunchThread();

            /*
                        // non-thread test

                        Cursor.Current = Cursors.WaitCursor;

                        FileSystem.ProcessParams p = new FileSystem.ProcessParams();
                        p.RootFolder = f_rootPath.Text;
                        FileSystem.RunRecursive(p, fs.Standardize);

                        Cursor.Current = Cursors.Default;
            */
        }
Пример #2
0
        /// <summary>
        /// "Ok Go" button: validate form input and launch appropriate thread.
        /// </summary>
        private void f_run_Click(object sender, EventArgs e)
        {
            // prepare members for computation

            m_filesChecked = 0;
            f_filesResults.Items.Clear();

            // validate data from form

            m_rootPath = f_rootFolder.Text;

            if (Directory.Exists(m_rootPath) == false)
            {
                f_rootFolder.Text = "ERROR";
                return;
            }

            MainSelector.SetLastFolder(m_rootPath);

            // create thread based on file type and function type

            if (f_fileType.Text == TYPE_IMAGE)
            {
                myThread = new ThreadMessage(RunImagePropChange);
                ImageProcessor.Progress += new ImageProcessor.ComputationEvent(FileBrowser_ProgressUpdate);
            }

            else if (f_fileType.Text == TYPE_MUSIC)
            {
                myThread = new ThreadMessage(RunMusicPropChange);
                MusicProcessor.MusicCoverPath = Properties.Settings.Default.MusicCoverPath;
                MusicProcessor.Progress += new MusicProcessor.ComputationEvent(FileBrowser_ProgressUpdate);
            }

            else
                return;

            // subscribe to the thread to get cancelations

            myThread.ThreadUpdate += new ThreadMessage.ThreadEventHandler(FileBrowser_ProgressUpdate);

            // launch the computation thread

            myThread.LaunchThread();
        }
Пример #3
0
        // Change OK button
        private void f_change_Click(object sender, EventArgs e)
        {
            // proceed if the input is valid

            this.RootPath = f_rootPath.Text;
            this.ChangeFrom = f_textChangeFrom.Text;
            this.ChangeTo = f_textChangeTo.Text;

            if (Directory.Exists(RootPath) == false || string.IsNullOrEmpty(ChangeFrom) == true)
            {
                MessageBox.Show("Invalid input fields.", "Change Text Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // change file names in thread

            myThread = new ThreadMessage(CallChangeText);

            FileSystem.Progress += new FileSystem.ComputationEvent(FileSystem_Progress);

            myThread.LaunchThread();
        }