Ejemplo n.º 1
0
        private SplitContainerControl createColumnMetaDataControl(ImportDataColumn col, bool swapPanels)
        {
            if (col.MetaData == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(col.Source))
            {
                return(null);
            }
            var colMetaDataControl = new MetaDataEditControl(col.MetaData)
            {
                Tag = col, AutoAcceptChanges = true
            };

            Controls.Add(colMetaDataControl);
            colMetaDataControl.OnCopyMetaData       += onCopyMetaDataColumnControlPanel;
            colMetaDataControl.OnIsDataValidChanged += onIsValidChangedColumnControlPanel;
            colMetaDataControl.OnMetaDataChanged    += onMetaDataChangedColumnControlPanel;
            if (col.MetaData.Rows.Count > 0)
            {
                col.SetColumnUnitDependingOnMetaData();
                reflectMetaDataChangesForColumn(col);
            }

            var newSplitter = new SplitContainerControl();

            Controls.Add(newSplitter);

            newSplitter.BeginInit();
            newSplitter.Horizontal = false;
            newSplitter.FixedPanel = SplitFixedPanel.Panel1;
            newSplitter.AlwaysScrollActiveControlIntoView = true;
            newSplitter.Panel2.Controls.Add(colMetaDataControl);
            colMetaDataControl.Dock        = DockStyle.Fill;
            newSplitter.Panel2.Name        = col.ColumnName;
            newSplitter.Panel2.Text        = col.GetCaptionForColumn();
            newSplitter.Panel2.ShowCaption = true;
            newSplitter.Panel2.BorderStyle = BorderStyles.Simple;
            newSplitter.Panel2.MinSize     = PANEL_MIN_SIZE;
            newSplitter.Panel2.Height      = (col.MetaData.Columns.Count + 2) * PANEL_ROW_HEIGHT;
            newSplitter.CollapsePanel      = SplitCollapsePanel.Panel2;
            if (swapPanels)
            {
                newSplitter.SwapPanels();
            }
            newSplitter.SplitterPosition = PANEL_ROW_HEIGHT;
            newSplitter.EndInit();

            return(newSplitter);
        }
Ejemplo n.º 2
0
        private void cleanMemory()
        {
            _gridPresenter.CopyMetaDataColumnControlEvent -= onCopyMetaDataColumnControl;
            _gridPresenter.SetUnitEvent -= onSetUnitClick;

            if (_metaDataControl != null)
            {
                _metaDataControl.OnCopyMetaData       -= onCopyMetaDataTableControl;
                _metaDataControl.OnBroadCastMetaData  -= onBroadCastMetaDataTableControl;
                _metaDataControl.OnIsDataValidChanged -= metaDataControlOnIsDataValidChanged;
            }
            _gridPresenter.MetaDataChangedEvent -= rePlot;
            _gridPresenter?.Clear();
            _metaDataControl?.Dispose();
            _metaDataControl = null;
            CleanUpHelper.ReleaseControls(Controls);
            Controls.Clear();
        }
Ejemplo n.º 3
0
        public EditMetaDataView(MetaDataTable data)
        {
            InitializeComponent();

            Text           = Captions.Importer.PleaseEnterMetaDataInformation;
            btnOK.Click   += onOkClick;
            btnCopy.Click += onCopyClick;

            int rowIndex = data.Rows.Count > 0 ? 0 : -1;

            _metaDataControl = new MetaDataEditControl(data, rowIndex, false);
            panelControl.Controls.Add(_metaDataControl);
            _metaDataControl.Dock = DockStyle.Fill;

            _metaDataControl.OnIsDataValidChanged += onIsDataValidChanged;
            enableButtons();
            if (ParentForm != null)
            {
                Icon = ParentForm.Icon;
            }
        }
Ejemplo n.º 4
0
        private void buildControl()
        {
            var cursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                Controls.Clear();
                _gridPresenter.Edit(Table);
                if (Table.MetaData != null)
                {
                    var splitter = new SplitContainerControl();
                    Controls.Add(splitter);
                    splitter.Dock = DockStyle.Fill;
                    splitter.AlwaysScrollActiveControlIntoView = true;

                    var panel = splitter.Panel1;
                    SplitContainerControl newSplitter = null;
                    for (var i = Table.Columns.Count - 1; i >= 0; i--)
                    {
                        var col = Table.Columns.ItemByIndex(i);
                        if (col.MetaData == null)
                        {
                            continue;
                        }
                        newSplitter = createColumnMetaDataControl(col, false);
                        if (newSplitter == null)
                        {
                            continue;
                        }
                        panel.Controls.Add(newSplitter);
                        newSplitter.Dock = DockStyle.Fill;
                        panel            = newSplitter.Panel1;
                    }

                    if (newSplitter != null)
                    {
                        panel = newSplitter.Panel1;
                    }

                    _metaDataControl = new MetaDataEditControl(Table.MetaData)
                    {
                        AutoAcceptChanges = true
                    };
                    Controls.Add(_metaDataControl);
                    panel.Name        = "Meta Data";
                    panel.Text        = Captions.Importer.MetaData;
                    panel.ShowCaption = false;
                    panel.MinSize     = PANEL_MIN_SIZE;
                    panel.Width       = PANEL_MIN_WIDTH;
                    panel.Height      = (Table.MetaData.Columns.Count + 2) * PANEL_ROW_HEIGHT;
                    panel.Controls.Add(_metaDataControl);
                    _metaDataControl.Dock                  = DockStyle.Fill;
                    _metaDataControl.OnCopyMetaData       += onCopyMetaDataTableControl;
                    _metaDataControl.OnBroadCastMetaData  += onBroadCastMetaDataTableControl;
                    _metaDataControl.OnIsDataValidChanged += metaDataControlOnIsDataValidChanged;

                    splitter.SplitterPosition = PANEL_MIN_WIDTH;

                    splitter.Panel2.Name    = "Data";
                    splitter.Panel2.Text    = Captions.Importer.Data;
                    splitter.Panel2.MinSize = PANEL_MIN_SIZE;

                    var datasplitter = new SplitContainerControl {
                        Dock = DockStyle.Fill, Horizontal = false
                    };
                    datasplitter.Panel1.FillWith(_gridPresenter.View);
                    datasplitter.Panel1.Padding = new Padding(10, 12, 10, 10);
                    datasplitter.Panel2.FillWith(_presenter.View);
                    datasplitter.Panel2.Padding = new Padding(10);
                    datasplitter.CollapsePanel  = SplitCollapsePanel.Panel2;
                    rePlot();

                    UnitChanged += (sender, args) => rePlot();
                    _gridPresenter.MetaDataChangedEvent += rePlot;
                    splitter.Panel2.Controls.Add(datasplitter);
                }
                else
                {
                    var metaDataExists = false;
                    foreach (ImportDataColumn col in Table.Columns)
                    {
                        metaDataExists = (col.MetaData != null && !string.IsNullOrEmpty(col.Source));
                        if (metaDataExists)
                        {
                            break;
                        }
                    }
                    if (metaDataExists)
                    {
                        var splitter = new SplitContainerControl();
                        Controls.Add(splitter);
                        splitter.Dock          = DockStyle.Fill;
                        splitter.Horizontal    = true;
                        splitter.CollapsePanel = SplitCollapsePanel.Panel1;
                        splitter.Panel2.FillWith(_gridPresenter.View);
                        splitter.Panel2.MinSize = PANEL_MIN_SIZE;

                        var panel = splitter.Panel1;
                        panel.Width = PANEL_MIN_WIDTH;
                        splitter.SplitterPosition = panel.Width;
                        SplitContainerControl newSplitter = null;
                        foreach (ImportDataColumn col in Table.Columns)
                        {
                            if (col.MetaData == null)
                            {
                                continue;
                            }
                            newSplitter = createColumnMetaDataControl(col, true);
                            if (newSplitter == null)
                            {
                                continue;
                            }
                            panel.Controls.Add(newSplitter);
                            newSplitter.Dock = DockStyle.Fill;
                            panel            = newSplitter.Panel2;
                        }
                        if (newSplitter != null)
                        {
                            newSplitter.Collapsed = true;
                        }
                    }
                    else
                    {
                        this.FillWith(_gridPresenter.View);
                    }
                }
                PerformLayout();
            }
            finally
            {
                Cursor.Current = cursor;
            }
        }