Ejemplo n.º 1
0
        private void batchExportXMSBTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.Description         = "Select a directory containing MSBT files:";
            fbd.ShowNewFolderButton = false;
            fbd.SelectedPath        = Settings.Default.XMSBTDirectory;

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.XMSBTDirectory = fbd.SelectedPath;

                if (Directory.Exists(fbd.SelectedPath))
                {
                    DirectoryInfo dir       = new DirectoryInfo(fbd.SelectedPath);
                    FileInfo[]    files     = dir.GetFiles("*.msbt");
                    bool          overwrite = true;
                    string        result    = "";

                    if (dir.GetFiles("*.xmsbt").Length > 0)
                    {
                        overwrite = MessageBox.Show("Is it OK to overwrite XMSBT files in the directory?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
                    }

                    if (files.Length > 0)
                    {
                        foreach (FileInfo file in files)
                        {
                            try
                            {
                                MSBT msbt = new MSBT(file.FullName);
                                msbt.ExportXMSBT(file.FullName.Substring(0, file.FullName.Length - 4) + "xmsbt", overwrite);
                            }
                            catch (Exception ex)
                            {
                                result = ex.Message;
                            }
                        }

                        if (result.Length == 0)
                        {
                            result = "Successfully batch exported files to XMSBT.";
                        }
                    }
                    else
                    {
                        result = "There are no MSBT files to export in the selected directory.";
                    }

                    MessageBox.Show(result, "XMSBT Batch Export Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            Settings.Default.Save();
            Settings.Default.Reload();
        }
Ejemplo n.º 2
0
        private void exportXMSBTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName         = _msbt.File.Name.Substring(0, _msbt.File.Name.Length - 4) + "xmsbt";
            sfd.Title            = "Save XMSBT As...";
            sfd.Filter           = "XMSBT (*.xmsbt)|*.xmsbt";
            sfd.InitialDirectory = Settings.Default.XMSBTDirectory;
            sfd.AddExtension     = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.XMSBTDirectory = new FileInfo(sfd.FileName).DirectoryName;

                string result = _msbt.ExportXMSBT(sfd.FileName);

                MessageBox.Show(result, "XMSBT Export Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Settings.Default.Save();
            Settings.Default.Reload();
        }