Пример #1
0
        private void ConverterBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                MessageBox.Show(this,
                                e.Error.ToString(),
                                "Error: Conversion terminated with exception.",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else if (!(bool)e.Result)
            {
                ErrorMessenger.ShowCanNotSaveError(this);
            }

            ProgressLabel.Text    = "";
            ProgressBar.Value     = 0;
            ConvertButton.Enabled = true;
        }
Пример #2
0
        private void ResolveImagesButton_Click(object sender, EventArgs e)
        {
            try
            {
                var xlsx_path = XLSXTextBox.Text;
                if (!File.Exists(xlsx_path))
                {
                    ErrorMessenger.ShowNoFileError(this, xlsx_path);
                    return;
                }

                var columns = ImageTextBox.Lines.Where((string str) => str.Length > 0).ToArray();
                if (columns.Length < 1)
                {
                    ErrorMessenger.ShowNoColumnsError(this);
                    return;
                }

                var downloader = new ImageDownloader(
                    xlsx_path,
                    columns,
                    Properties.CRRValue,
                    Properties.ICWRValue);

                ResolveImagesButton.Enabled = false;
                StopImagesButton.Enabled    = true;

                ResolverBackgroundWorker.RunWorkerAsync(downloader);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                                ex.ToString(),
                                "Error: Can not resolve images in XLSX file.",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #3
0
        private void ConvertButton_Click(object sender, EventArgs e)
        {
            try
            {
                var xml_path = XMLTextBox.Text;
                if (!File.Exists(xml_path))
                {
                    ErrorMessenger.ShowNoFileError(this, xml_path);
                    return;
                }
                var xlsx_path = XLSXTextBox.Text;
                if (!xlsx_path.ToLower().EndsWith(".xlsx"))
                {
                    xlsx_path += ".xlsx";
                }
                try { xlsx_path = Path.GetFullPath(xlsx_path); }
                catch { ErrorMessenger.ShowBadFileNameError(this, xlsx_path); return; }

                List <TemplateNode> template;
                try { template = TemplateNode.ParseLines(TemplateTextBox.Lines); }
                catch (Exception ex) { ErrorMessenger.ShowBadTemplateError(this, ex.Message); return; }

                var converter = new Converter(xml_path, xlsx_path, template);

                ConvertButton.Enabled = false;

                ConverterBackgroundWorker.RunWorkerAsync(converter);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                                ex.ToString(),
                                "Error: Can not convert XML file.",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }