private void btnOK_Click()
        {
            var errorList = MetadataEditor.ValidateBeforeApply();

            if (errorList.Count == 0)
            {
                ApplyChanges();
                DialogResult = true;
                return;
            }

            var form   = new ErrorListForm("Warning", Helpers.Localizer.GetString("strErrorsFound", Helpers.ConvertLanguageFromNative(Language), LocalizableConstantsInternal.strErrorsFound), errorList, true);
            var result = form.ShowDialog();

            if (result != true)
            {
                return;
            }

            ApplyChanges();
            DialogResult = true;
        }
        public MetadataEditorStandalone()
        {
            InitializeComponent();

            CreateAndBindCommands();

            foreach (Type type in ActiveQueryBuilder.Core.Helpers.SyntaxProviderList)
            {
                if (type == typeof(AutoSyntaxProvider))
                {
                    continue;
                }

                var syntax = Activator.CreateInstance(type) as BaseSyntaxProvider;

                if (syntax != null)
                {
                    cbSyntaxProvider.Items.Add(syntax);
                }
            }

            MetadataEditor.OpenContainerLoadFormIfNotConnected = true;
            MetadataEditor.LoadStart  += LoadStart;
            MetadataEditor.LoadFinish += LoadFinish;
            MetadataEditor.LoadStep   += LoadStep;

            cbSyntaxProvider.SelectionChanged += CbSyntaxProvider_SelectedIndexChanged;
            tsmiLoadFromDatabase.Click        += loadFromDatabaseToolStripMenuItem_Click;


            UpdateLocalization();

            _originalContext = new SQLContext()
            {
                SyntaxProvider = new MSSQLSyntaxProvider()
            };
            _originalContext.MetadataContainer.LoadingOptions.OfflineMode = true;
            _originalContext.MetadataContainer.ImportFromXML("Northwind.xml");

            _sqlContext = new SQLContext();
            _sqlContext.Assign(_originalContext);

            if (_sqlContext.SyntaxProvider == null)
            {
                _sqlContext.SyntaxProvider = new GenericSyntaxProvider();
            }

            _sqlContext.SyntaxProviderChanged += SqlContext_SyntaxProviderChanged;

            foreach (var item in cbSyntaxProvider.Items)
            {
                if (item.GetType() != _sqlContext.SyntaxProvider.GetType())
                {
                    continue;
                }

                cbSyntaxProvider.SelectionChanged -= CbSyntaxProvider_SelectedIndexChanged;
                try
                {
                    cbSyntaxProvider.SelectedItem = item;
                    break;
                }
                finally
                {
                    cbSyntaxProvider.SelectionChanged += CbSyntaxProvider_SelectedIndexChanged;
                }
            }

            MetadataEditor.Init(_sqlContext);
        }
 private void loadFromDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     MetadataEditor.ShowContainerLoadForm();
 }