Esempio n. 1
0
        /// <summary>
        /// Asks for file name(s) and imports the file(s) into one or multiple worksheets. After the user chooses one or multiple files, one of the chosen files is used for analysis.
        /// The result of the structure analysis of this file is then presented to the user. The user may change some of the options and starts a re-analysis. Finally, the import options
        /// are confirmed by the user and the import process can start.
        /// </summary>
        /// <param name="dataTable">The data table to import to. Can be null if <paramref name="toMultipleWorksheets"/> is set to <c>true</c>.</param>
        /// <param name="toMultipleWorksheets">If true, multiple files are imported into multiple worksheets. New worksheets were then created automatically.</param>
        /// <param name="vertically">If <c>toMultipleWorksheets</c> is false, and this option is true, the data will be exported vertically (in the same columns) instead of horizontally.</param>
        public static void ShowImportAsciiDialogAndOptions(this DataTable dataTable, bool toMultipleWorksheets, bool vertically)
        {
            var options = new Altaxo.Gui.OpenFileOptions();

            options.AddFilter("*.csv;*.dat;*.txt", "Text files (*.csv;*.dat;*.txt)");
            options.AddFilter("*.*", "All files (*.*)");
            options.FilterIndex      = 0;
            options.RestoreDirectory = true;
            options.Multiselect      = true;

            if (Current.Gui.ShowOpenFileDialog(options) && options.FileNames.Length > 0)
            {
                var analysisOptions = dataTable.GetPropertyValue(AsciiDocumentAnalysisOptions.PropertyKeyAsciiDocumentAnalysisOptions, null);
                if (!ShowAsciiImportOptionsDialog(options.FileName, analysisOptions, out var importOptions))
                {
                    return;
                }

                if (toMultipleWorksheets)
                {
                    AsciiImporter.ImportFilesIntoSeparateNewTables(Main.ProjectFolder.RootFolder, options.FileNames, true, importOptions);
                }
                else
                {
                    if (vertically)
                    {
                        AsciiImporter.ImportFromMultipleAsciiFilesVertically(dataTable, options.FileNames, true, importOptions);
                    }
                    else
                    {
                        AsciiImporter.ImportFromMultipleAsciiFilesHorizontally(dataTable, options.FileNames, true, importOptions);
                    }
                }
            }
        }
Esempio n. 2
0
        public override void Run(Altaxo.Gui.Worksheet.Viewing.WorksheetController ctrl)
        {
            _table = ctrl.DataTable;

            var script = _table.GetPropertyValue <FileImportScript>("Temp\\FileImportScript") ?? new FileImportScript();

            object[] args = new object[] { script, new Altaxo.Gui.Scripting.ScriptExecutionHandler(EhScriptExecution) };

            if (Current.Gui.ShowDialog(args, "File import script of " + _table.Name))
            {
                _table.PropertyBag.SetValue <FileImportScript>("Temp\\FileImportScript", (FileImportScript)args[0]);
            }

            _table = null;
        }
Esempio n. 3
0
		private static AsciiDocumentAnalysisOptions GetDefaultAsciiDocumentAnalysisOptions(DataTable dataTable)
		{
			AsciiDocumentAnalysisOptions result = null;
			if (null != dataTable)
				result = dataTable.GetPropertyValue(AsciiDocumentAnalysisOptions.PropertyKeyAsciiDocumentAnalysisOptions, null);
			if (null == result)
				result = Current.PropertyService.GetValue(AsciiDocumentAnalysisOptions.PropertyKeyAsciiDocumentAnalysisOptions, Main.Services.RuntimePropertyKind.UserAndApplicationAndBuiltin);
			return result;
		}