public ConnectionInfo(BaseConnectionDescriptor descriptor, string name, ConnectionTypes type, string connectionString)
 {
     Name = name;
     ConnectionDescriptor = descriptor;
     Type             = type;
     ConnectionString = connectionString;
     IsXmlFile        = false;
     ConnectionDescriptor.ConnectionString = connectionString;
 }
 public ConnectionInfo(BaseConnectionDescriptor descriptor, string name, ConnectionTypes type, string connectionString)
 {
     Name = name;
     ConnectionDescriptor = descriptor;
     Type             = type;
     ConnectionString = connectionString;
     IsXmlFile        = false;
     ConnectionDescriptor.ConnectionString = connectionString;
     StructureOptions = new MetadataStructureOptions()
     {
         AllowFavourites = true
     };
 }
        private FrameworkElement CreateSyntaxEditControl(BaseConnectionDescriptor connection)
        {
            var properties = connection.SyntaxProperties;

            if (properties == null)
            {
                return(null);
            }
            properties.PropertiesEditors.Clear();
            var propsContainer    = PropertiesFactory.GetPropertiesContainer(properties);
            var propertiesBar     = new PropertiesBar();
            var propertiesControl = (IPropertiesControl)propertiesBar;

            propertiesControl.SetProperties(propsContainer);
            return(propertiesBar);
        }
        private UserControl CreateConnectionEditControl(BaseConnectionDescriptor connection)
        {
            _metadataProperties = connection.MetadataProperties;
            if (_metadataProperties != null)
            {
                _metadataProperties.PropertiesEditors.Clear();
                var propsContainer = PropertiesFactory.GetPropertiesContainer(_metadataProperties);
                var propertiesBar  = new PropertiesBar();
                propertiesBar.EditorsOptions.NarrowEditControlsMinWidth = 160;
                propertiesBar.EditorsOptions.MultiLineEditorsMaxWidth   = 570;
                var propertiesControl = (IPropertiesControl)propertiesBar;
                propertiesControl.SetProperties(propsContainer);
                return(propertiesBar);
            }

            return(null);
        }
        public ConnectionEditWindow()
        {
            InitializeComponent();
            _connection = new MSSQLConnectionDescriptor();

            FillConnectionTypes();
            FillSyntaxTypes();

            cbConnectionType.SelectedItem        = _connection.GetDescription();
            cbLoadFromDefaultDatabase.Visibility = _connection.SyntaxProvider.IsSupportDatabases()
                ? Visibility.Visible
                : Visibility.Collapsed;
            cbLoadFromDefaultDatabase.IsChecked =
                _connection.MetadataLoadingOptions.LoadDefaultDatabaseOnly;

            UpdateConnectionPropertiesFrames();
        }
Example #6
0
        public ConnectionForm()
        {
            InitializeComponent();
            _connection = new MSSQLConnectionDescriptor();

            lbMenu.SelectedIndex = 0;

            FillConnectionTypes();
            FillSyntaxTypes();

            cbConnectionType.SelectedItem = _connection.GetDescription();
            UpdateConnectionPropertiesFrames();
            cbLoadFromDefaultDatabase.Visible = _connection.SyntaxProvider.IsSupportDatabases();
            cbLoadFromDefaultDatabase.Checked =
                _connection.MetadataLoadingOptions.LoadDefaultDatabaseOnly;

            FillImageList();
        }
        private void cbConnectionType_SelectedIndexChanged(object sender, EventArgs eventArgs)
        {
            SetShown(ShowLoadOpts, false);
            SetShown(ShowMetadataOpts, false);

            var connectionCombo = _wizardPageConnectionType.cbConnectionType;

            if (connectionCombo.SelectedIndex != -1)
            {
                var connectionName = connectionCombo.SelectedItem as string;
                if (_initialConnection != null && connectionName == _initialConnection.GetDescription())
                {
                    _connection = _initialConnection;
                }
                else
                {
                    var type = ActiveQueryBuilder.Core.Helpers.ConnectionDescriptorList[connectionCombo.SelectedIndex];
                    try
                    {
                        _connection = Activator.CreateInstance(type) as BaseConnectionDescriptor;
                    }
                    catch (Exception e)
                    {
                        var message = GetMostInnerException(e).Message;
                        MessageBox.Show(message + "\r\n \r\n" +
                                        "To fix this error you may need to install the appropriate database client software or re-compile the project from sources and add the needed assemblies to the References section.",
                                        "Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);

                        connectionCombo.SelectedIndex = _connectionIndex;
                        return;
                    }
                }

                _wizardPageConnectionType.SyntaxVisible = _connection.IsGenericSyntax();
                SelectSyntax();
            }

            _connectionIndex = connectionCombo.SelectedIndex;
        }
        private void CbConnectionType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var descriptorType = GetSelectedDescriptorType();

            if (_connection != null && _connection.GetType() == descriptorType)
            {
                return;
            }

            _connection = CreateConnectionDescriptor(descriptorType);

            if (_connection == null)
            {
                LockUI();
                return;
            }
            else
            {
                UnlockUI();
            }

            UpdateConnectionPropertiesFrames();
        }
        private FrameworkElement CreateConnectionEditControl(BaseConnectionDescriptor connection)
        {
            _metadataProperties = connection.MetadataProperties;

            if (_metadataProperties == null)
            {
                return(null);
            }

            _metadataProperties.PropertiesEditors.Clear();
            var propsContainer = PropertiesFactory.GetPropertiesContainer(_metadataProperties);
            var propertiesBar  = new PropertiesBar
            {
                EditorsOptions =
                {
                    NarrowEditControlsMinWidth = 160,
                    MultiLineEditorsMaxWidth   = 570
                }
            };
            var propertiesControl = (IPropertiesControl)propertiesBar;

            propertiesControl.SetProperties(propsContainer);
            return(propertiesBar);
        }
        public MetadataContainerLoadWindow(object owner, MetadataContainer metadataContainer, BaseConnectionDescriptor connection = null)
        {
            Debug.Assert(metadataContainer != null);

            _owner = owner;

            _pages = new List <WizardPageInfo>();

            // store reference to edited object
            EditedMetadataContainer = metadataContainer;

            _initialConnection = connection;
            Connection         = connection;

            // create new SQLContext for loading
            _temporarySqlContext = new SQLContext();
            _temporarySqlContext.Assign(EditedMetadataContainer.SQLContext);

            // create temporary MetadataContainer
            TemporaryMetadataContainer             = new MetadataContainer(_temporarySqlContext);
            _temporarySqlContext.MetadataContainer = TemporaryMetadataContainer;

            TemporaryMetadataContainer.Assign(EditedMetadataContainer);
            TemporaryMetadataContainer.LoadingOptions = new MetadataLoadingOptions();
            TemporaryMetadataContainer.LoadingOptions.Assign(EditedMetadataContainer.LoadingOptions);

            InitializeComponent();

            // set up pages

            _wizardPageWelcome = new WelcomeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageWelcome);

            _wizardPageConnectionType = new ConnectionTypeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageConnectionType);

            _wizardPageMetadataOpts = new MetadataOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageMetadataOpts);

            _wizardPageLoadOpts = new LoadOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoadOpts);

            _wizardPageFilter = new FilterWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageFilter);

            _wizardPageLoading = new LoadingWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoading);

            _pages.Add(new WizardPageInfo(ShowWelcome));
            _pages.Add(new WizardPageInfo(ShowConnection, CheckConnectionSelected));
            _pages.Add(new WizardPageInfo(ShowMetadataOpts, CheckShowMetadataOpts, true, BeforeMetadataOpts));
            _pages.Add(new WizardPageInfo(ShowLoadOpts, CheckLoadOpts, (_temporarySqlContext.SyntaxProvider != null && _temporarySqlContext.SyntaxProvider.IsSupportDatabases()), BeforeLoadOpts));
            _pages.Add(new WizardPageInfo(ShowFilter, CheckFilter));
            _pages.Add(new WizardPageInfo(ShowLoading));

            _currentPage = 0;

            _pages[_currentPage].ShowProc();

            _wizardPageMetadataOpts.bConnectionTest.Click += buttonConnectionTest_Click;
            _wizardPageConnectionType.ComboBoxConnectionType.SelectionChanged += cbConnectionType_SelectedIndexChanged;
            _wizardPageConnectionType.ComboBoxSyntaxProvider.SelectionChanged += ComboBoxSyntaxProvider_SelectedIndexChanged;

            bBack.Click += buttonBack_Click;
            bNext.Click += buttonNext_Click;

            Loaded += MetadataContainerLoadForm_Load;

            Localize();

            Loaded += MetadataContainerLoadForm_Loaded;

            var propertyLanguage =
                DependencyPropertyDescriptor.FromProperty(LanguageProperty, typeof(MetadataContainerLoadWindow));

            propertyLanguage.AddValueChanged(this, LanguagePropertyChanged);
        }
        public MetadataContainerLoadForm(MetadataContainer metadataContainer, BaseConnectionDescriptor connection = null)
        {
            Debug.Assert(metadataContainer != null);

            _pages = new List <WizardPageInfo>();

            // store reference to edited object
            EditedMetadataContainer = metadataContainer;

            _initialConnection = connection;
            _connection        = connection;

            // create new SQLContext for loading
            _temporarySQLContext = new SQLContext();
            _temporarySQLContext.Assign(EditedMetadataContainer.SQLContext);

            // create temporary MetadataContainer
            TemporaryMetadataContainer             = new MetadataContainer(_temporarySQLContext);
            _temporarySQLContext.MetadataContainer = TemporaryMetadataContainer;

            TemporaryMetadataContainer.Assign(EditedMetadataContainer);
            TemporaryMetadataContainer.LoadingOptions = new MetadataLoadingOptions();
            TemporaryMetadataContainer.LoadingOptions.Assign(EditedMetadataContainer.LoadingOptions);

            InitializeComponent();

            // set up pages

            _wizardPageWelcome = new WelcomeWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageWelcome);

            _wizardPageConnectionType = new ConnectionTypeWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageConnectionType);

            _wizardPageMetadataOpts = new MetadataOptsWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageMetadataOpts);

            _wizardPageLoadOpts = new LoadOptsWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageLoadOpts);

            _wizardPageFilter = new FilterWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageFilter);

            _wizardPageLoading = new LoadingWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageLoading);

            _pages.Add(new WizardPageInfo(ShowWelcome));
            _pages.Add(new WizardPageInfo(ShowConnection, CheckConnectionSelected));
            _pages.Add(new WizardPageInfo(ShowMetadataOpts, CheckShowMetadataOpts, true, BeforeMetadataOpts));
            _pages.Add(new WizardPageInfo(ShowLoadOpts, CheckLoadOpts, (_temporarySQLContext.SyntaxProvider != null && _temporarySQLContext.SyntaxProvider.IsSupportDatabases()), BeforeLoadOpts));
            _pages.Add(new WizardPageInfo(ShowFilter, CheckFilter));
            _pages.Add(new WizardPageInfo(ShowLoading));

            _currentPage = 0;

            _pages[_currentPage].showProc();

            _wizardPageMetadataOpts.bConnectionTest.Click += buttonConnectionTest_Click;
            _wizardPageConnectionType.cbConnectionType.SelectedIndexChanged += cbConnectionType_SelectedIndexChanged;
            _wizardPageConnectionType.cbSyntax.SelectedIndexChanged         += cbSyntax_SelectedIndexChanged;

            bBack.Click += buttonBack_Click;
            bNext.Click += buttonNext_Click;

            Load += MetadataContainerLoadForm_Load;
        }