public void ExportProgressCallback(CWExporter.eExportState state, string data)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(delegate() { ExportProgressCallback(state, data); }));
            }
            else
            {
                switch (state)
                {
                    case CWExporter.eExportState.Start:
                        progressExport.Value = 0;
                        break;

                    case CWExporter.eExportState.Progress:
                        progressExport.Value = int.Parse(data);
                        break;

                    case CWExporter.eExportState.End:
                        progressExport.Value = 100;
                        break;

                    case CWExporter.eExportState.Close:
                        ShowMessage(data);
                        Hide();
                        break;
                }
            }
        }
 public void RegisterExporter(CWExporter exporter)
 {
     Exporters.Add(exporter);
     comboExportType.Items.Add(exporter.Description);
     exporter.ExportProgress += new CWExporter.ExportProgressDeledgate(ExportProgressCallback);
 }
        private void buttExport_Click(object sender, EventArgs e)
        {
            if (m_thread != null)
                return;

            if (comboExportType.SelectedIndex < 0)
            {
                MessageBox.Show("Select export type first", "Attention");
                return;
            }

            m_exporter = Exporters[comboExportType.SelectedIndex];

            string errMsg = m_exporter.ValidateExport();
            if (errMsg != null)
            {
                ShowMessage(errMsg);
                return;
            }

            try
            {
                SaveFileDialog sf = new SaveFileDialog();
                sf.Filter = string.Format("{0}(*.{1})|*.{1}|All files (*.*)|*.*", m_exporter.Description, m_exporter.FileExtension);
                if (sf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    m_filename = sf.FileName;
                    m_stream = new FileStream(sf.FileName, FileMode.Create);
                    m_thread = new Thread(new ThreadStart(ExportingThread));
                    m_exporter.CancelExport = false;
                    m_thread.Start();
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
                if (m_stream != null)
                {
                    m_stream.Close();
                    File.Delete(m_filename);
                }
                m_stream = null;
            }
        }