public ImportXlsSheetControl(string filePath, XlsSheetMeta xlsSheetMeta)
        {
            InitializeComponent();
            _filePath  = filePath;
            _sheetMeta = xlsSheetMeta;

            _grid = new ReoGridControl();
            ReoGridUtil.InitGrid(_grid, readOnly: true);
            _gridLoadControl = new LoadingContainerControl {
                ContainedControl = _grid, Dock = DockStyle.Fill
            };
            _previewPanel.Controls.Add(_gridLoadControl);

            _columnsControl = new ImportColumnsControl {
                Dock = DockStyle.Fill
            };
            _columnsControl.SetFixedColumnWidths();
            _columnsLoadControl = new LoadingContainerControl {
                ContainedControl = _columnsControl, Dock = DockStyle.Fill
            };
            _columnsPanel.Controls.Add(_columnsLoadControl);
            Bind.OnChange(new Slot[] { _columnsControl.Change }, (sender, e) => ValueChanged?.Invoke(this, EventArgs.Empty));

            _sheetOptions            = new XlsSheetOptions();
            _propGrid.SelectedObject = _sheetOptions;
        }
Beispiel #2
0
    public ImportCsvForm(string filePath, DatabaseSchema schema, NotebookManager manager)
    {
        InitializeComponent();
        _filePath       = filePath;
        _databaseSchema = schema;
        _manager        = manager;

        _optionsControl = new ImportCsvOptionsControl(schema)
        {
            AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink
        };
        _optionsPanel.Controls.Add(_optionsControl);

        _columnsControl = new ImportColumnsControl(allowDetectTypes: true)
        {
            Dock = DockStyle.Fill
        };
        _columnsLoadControl = new LoadingContainerControl {
            ContainedControl = _columnsControl, Dock = DockStyle.Fill
        };
        _columnsPanel.Controls.Add(_columnsLoadControl);

        _inputPreviewControl = new ImportCsvPreviewControl {
            Dock = DockStyle.Fill
        };
        _inputPreviewLoadControl = new LoadingContainerControl {
            ContainedControl = _inputPreviewControl, Dock = DockStyle.Fill
        };
        _originalFilePanel.Controls.Add(_inputPreviewLoadControl);

        Ui ui = new(this, 170, 45);

        ui.Init(_table);
        ui.Init(_outerSplit, 0.48);
        ui.InitHeader(_originalFileLabel);
        ui.Init(_lowerSplit, 0.52);
        ui.InitHeader(_optionsLabel);
        ui.InitHeader(_columnsLabel);
        ui.Init(_buttonFlow1);
        ui.MarginTop(_buttonFlow1);
        ui.Init(_previewButton);
        ui.Init(_buttonFlow2);
        ui.MarginTop(_buttonFlow2);
        ui.Init(_okBtn);
        ui.Init(_cancelBtn);

        Load += async(sender, e) => {
            ValidateOptions();
            await UpdateControls(inputChange : true);

            _optionsControl.SelectTableCombo();
        };

        var o = _optionsControl;

        Bind.OnChange(new Slot[] { o.TargetTableName },
                      async(sender, e) => {
            ValidateOptions();
            await UpdateControls(columnsChange: true);
        });
        Bind.OnChange(new Slot[] { o.FileEncoding },
                      async(sender, e) => await UpdateControls(inputChange: true));
        Bind.OnChange(new Slot[] { o.IfTableExists, o.SkipLines, o.HasColumnHeaders, o.Separator },
                      async(sender, e) => await UpdateControls(columnsChange: true));
        Bind.BindAny(new[] { _columnsLoadControl.IsOverlayVisible, _inputPreviewLoadControl.IsOverlayVisible },
                     x => _okBtn.Enabled = !x);

        Text = $"Import {Path.GetFileName(_filePath)}";
        o.TargetTableName.Value = Path.GetFileNameWithoutExtension(_filePath);
    }