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);
    }
        }                                                      // the ultimate result of this form

        public ImportXlsBookForm(string filePath, DatabaseSchema schema, NotebookManager manager)
        {
            InitializeComponent();
            _filePath       = filePath;
            _databaseSchema = schema;
            _manager        = manager;

            _dockPanel = DockPanelUtil.CreateDockPanel(showWindowListButton: true);
            _dockPanel.DockTopPortion = 150;
            _dockPanelContainer.Controls.Add(_dockPanel);

            Text = $"Import {Path.GetFileName(filePath)}";

            // left pane - sheet names
            {
                _sheetsControl = new ImportXlsSheetsControl();
                _sheetsControl.ValueChanged += SheetsControl_ValueChanged;
                _sheetsLoadControl           = new LoadingContainerControl {
                    ContainedControl = _sheetsControl
                };
                var dc = new UserControlDockContent("Worksheets", _sheetsLoadControl, DockAreas.DockTop)
                {
                    CloseButtonVisible = false
                };
                dc.Show(_dockPanel, DockState.DockTop);
            }

            // import script panel
            {
                _sqlControl     = new SqlTextControl(readOnly: true);
                _sqlLoadControl = new LoadingContainerControl {
                    ContainedControl = _sqlControl
                };
                _sqlDockContent = new UserControlDockContent("Import Script", _sqlLoadControl)
                {
                    CloseButton        = false,
                    CloseButtonVisible = false,
                    ControlBox         = false,
                    Icon = Properties.Resources.ScriptIco
                };
            }

            // import preview panel
            {
                _outputPreviewControl = new ImportMultiTablePreviewControl();
                _outputPreviewControl.GeneratePreview += OutputPreviewControl_GeneratePreview;
                _outputPreviewLoadControl              = new LoadingContainerControl {
                    ContainedControl = _outputPreviewControl
                };
                _outputPreviewDockContent = new UserControlDockContent("Preview", _outputPreviewLoadControl)
                {
                    CloseButton        = false,
                    CloseButtonVisible = false,
                    ControlBox         = false,
                    Icon = Properties.Resources.TableImportIco
                };
            }

            // dummy panel shown while loading worksheet tabs
            {
                _sheetInitialLoadControl = new LoadingContainerControl {
                    ContainedControl = new Panel()
                };
                var dc = new UserControlDockContent("Loading...", _sheetInitialLoadControl)
                {
                    CloseButton        = false,
                    CloseButtonVisible = false,
                    ControlBox         = false,
                    Icon = Properties.Resources.TableSheetIco
                };
                dc.Show(_dockPanel);
                _sheetInitialLoadDockContent = dc;
            }
        }