コード例 #1
0
        private void m_BtnMerge_Click ( object sender, EventArgs e )
            {
            try
                {
                if (m_lbDTBfiles.Items.Count >= 2)
                    {
                    m_StatusLabel.Text = "Merging all DTBs in listbox. ";
                    if (m_txtDirectoryPath.Text == "")
                        {
                        MessageBox.Show ( "Output Directory Path cannot be empty, Please select the output Directory Path",
                                        "Select Directory", MessageBoxButtons.OK, MessageBoxIcon.Error );
                        m_BtnOutputDirectory.Focus ();
                        m_StatusLabel.Text = "Click Browse button to select the Directory to save the merged files..";
                        return;
                        }
                    if (m_txtDirectoryPath.Text.Length > 0)
                        {
                        if (!m_bgWorker.IsBusy)
                            {
                            m_bgWorker.RunWorkerAsync ();
                            }
                        else
                            {
                            MessageBox.Show ( " Please be patient, earlier task is in progress " );
                            return;
                            }
                        if (m_bgWorker.IsBusy)
                            {
                            progress = new ProgressDialogDTB ();
                            progress.FormClosing += new FormClosingEventHandler ( ProgressDialog_FormClosing );
                            progress.ShowDialog ( this );
                            }

                        while (m_bgWorker.IsBusy)
                            {
                            Application.DoEvents ();
                            }
                        }
                    }
                else
                    {
                    MessageBox.Show ( "Either there are no files or only one file in the Listbox to merge. Minimum 2 files are needed for merging. Please add some files in Listbox.Click Add button.", "Listbox Empty", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
                    m_btnAdd.Focus ();
                    }

                }
            catch (Exception ex)
                {
                MessageBox.Show ( ex.ToString () );
                }
            }//m_BtnMerge_Click
コード例 #2
0
            }//ProgressDialog_FormClosing

        private void m_bgWorker_RunWorkerCompleted ( object sender, AsyncCompletedEventArgs e )
            {
            if (progress != null)
                {
                progress.Close ();
                progress = null;
                }

            if (e.Error == null)
                {
                if (m_Merger != null && !m_Merger.IsCancelled)
                    {
                    m_StatusLabel.Text = "Files have been merged and placed in the given directory path. ";
                    m_BtnValidateOutput.Enabled = true;
                    MessageBox.Show ( "Files have been merged and put in the respective directory " + m_txtDirectoryPath.Text + " .", "Files Merged in Directory", MessageBoxButtons.OK, MessageBoxIcon.Information );
                    }
                }
            if (e.Error != null)
                {
                MessageBox.Show ( e.Error.Message );
                m_StatusLabel.Text = "Failed in merging the DTBs";
                }
            }//m_bgWorker_RunWorkerCompleted