Пример #1
0
        /// <summary>
        /// Create new instance of <see cref="ImportSeriesWizard"/>
        /// </summary>
        /// <param name="context">DataImporter</param>
        public ImportSeriesWizard(WizardContext context)
        {
            _context = context;

            // Add pages
            foreach (var page in _context.Importer.GetWizardPages(context))
            {
                Pages.Add(page);
            }

            // Wizard display options
            StartPosition = FormStartPosition.CenterParent;
            MaximizeBox   = false;
            MinimizeBox   = false;
            base.Text     = "Time Series Data Import Wizard";
        }
Пример #2
0
        void menu_Click(object sender, EventArgs e)
        {
            var importers = new List <IWizardImporter>
            {
                new CsvImporter(),
                new ExcelImporter(),
                new TxtImporter(),
                new WaterMLImporter(),
            };

            using (var dialog = new OpenFileDialog())
            {
                var filter = string.Join("|", importers.Select(item => item.Filter)) +
                             "|All files (*.*)|*.*";

                dialog.Filter             = filter;
                dialog.Title              = "Select file to import";
                dialog.CheckFileExists    = true;
                dialog.CheckPathExists    = true;
                dialog.AutoUpgradeEnabled = true;

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var fileName = dialog.FileName;
                var importer = importers.FirstOrDefault(imp => imp.CanImportFromFile(fileName)) ??
                               importers.OfType <TxtImporter>().First();
                Debug.Assert(importer != null);

                var context = new WizardContext();
                context.Importer                = importer;
                context.Settings                = importer.GetDefaultSettings();
                context.Settings.PathToFile     = fileName;
                context.Settings.SeriesSelector = SeriesControl;
                context.Settings.Map            = (Map)App.Map;

                var wizard = new ImportSeriesWizard(context);
                wizard.ShowDialog();
            }
        }