Esempio n. 1
0
        private void LoadApplicationSettings()
        {
            applicationSettings = ApplicationSettings.Load();
            if (applicationSettings != null)
            {
                // Display all previous connections
                connectionNameComboBox.DataSource = applicationSettings.Connections;
                connectionNameComboBox.DisplayMember = "Name";

                // Set the last used connection
                var lastUsedConnection =
                    applicationSettings.Connections.FirstOrDefault(connection => connection.Id == applicationSettings.LastUsedConnection);
                _currentConnection = lastUsedConnection ?? applicationSettings.Connections.FirstOrDefault();
                connectionNameComboBox.SelectedItem = _currentConnection;

                nameSpaceTextBox.Text = applicationSettings.NameSpace;
                namespaceMapTextBox.Text = applicationSettings.NameSpaceMap;
                assemblyNameTextBox.Text = applicationSettings.AssemblyName;
                cSharpRadioButton.Checked = applicationSettings.Language == Language.CSharp;
                vbRadioButton.Checked = applicationSettings.Language == Language.VB;
                noValidationRadioButton.Checked = applicationSettings.ValidationStyle == ValidationStyle.None;
                nhibernateValidationRadioButton.Checked = applicationSettings.ValidationStyle == ValidationStyle.Nhibernate;
                dataAnnotationsRadioButton.Checked = applicationSettings.ValidationStyle == ValidationStyle.Microsoft;
                autoPropertyRadioBtn.Checked = applicationSettings.IsAutoProperty;
                folderTextBox.Text = applicationSettings.FolderPath;
                domainFolderTextBox.Text = applicationSettings.DomainFolderPath;
                textBoxInheritence.Text = applicationSettings.InheritenceAndInterfaces;
                comboBoxForeignCollection.Text = applicationSettings.ForeignEntityCollectionType;
                textBoxClassNamePrefix.Text = applicationSettings.ClassNamePrefix;
                EnableInflectionsCheckBox.Checked = applicationSettings.EnableInflections;
                wcfDataContractCheckBox.Checked = applicationSettings.GenerateWcfContracts;
                partialClassesCheckBox.Checked = applicationSettings.GeneratePartialClasses;
                useLazyLoadingCheckBox.Checked = applicationSettings.UseLazy;
                includeLengthAndScaleCheckBox.Checked = applicationSettings.IncludeLengthAndScale;
                includeForeignKeysCheckBox.Checked = applicationSettings.IncludeForeignKeys;
                nameAsForeignTableCheckBox.Checked = applicationSettings.NameFkAsForeignTable;
                includeHasManyCheckBox.Checked = applicationSettings.IncludeHasMany;

                fluentMappingOption.Checked = applicationSettings.IsFluent;
                entityFrameworkRadionBtn.Checked = applicationSettings.IsEntityFramework;
                castleMappingOption.Checked = applicationSettings.IsCastle;
                byCodeMappingOption.Checked = applicationSettings.IsByCode;

                if (applicationSettings.FieldPrefixRemovalList == null)
                    applicationSettings.FieldPrefixRemovalList = new List<string>();

                fieldPrefixListBox.Items.AddRange(applicationSettings.FieldPrefixRemovalList.ToArray());
                removeFieldPrefixButton.Enabled = false;

                prefixRadioButton.Checked = !string.IsNullOrEmpty(applicationSettings.Prefix);
                prefixTextBox.Text = applicationSettings.Prefix;
                camelCasedRadioButton.Checked = (applicationSettings.FieldNamingConvention == FieldNamingConvention.CamelCase);
                pascalCasedRadioButton.Checked = (applicationSettings.FieldNamingConvention == FieldNamingConvention.PascalCase);
                sameAsDBRadioButton.Checked = (applicationSettings.FieldNamingConvention == FieldNamingConvention.SameAsDatabase);

                sameAsDBRadioButton.Checked = (!prefixRadioButton.Checked && !pascalCasedRadioButton.Checked &&
                                               !camelCasedRadioButton.Checked);

                generateInFoldersCheckBox.Checked = applicationSettings.GenerateInFolders;

                SetCodeControlFormatting(applicationSettings);
            }
            else
            {
                // Default application settings
                autoPropertyRadioBtn.Checked = true;
                pascalCasedRadioButton.Checked = true;
                cSharpRadioButton.Checked = true;
                byCodeMappingOption.Checked = true;
                includeForeignKeysCheckBox.Checked = true;
                nameAsForeignTableCheckBox.Checked = true;
                includeHasManyCheckBox.Checked = false;
                useLazyLoadingCheckBox.Checked = true;

                comboBoxForeignCollection.Text = "IList";

                CaptureApplicationSettings();
            }

            if (!prefixRadioButton.Checked)
            {
                prefixLabel.Visible = prefixTextBox.Visible = false;
            }
        }
Esempio n. 2
0
        private void ConnectionNameSelectedIndexChanged(object sender, EventArgs e)
        {
            if (connectionNameComboBox.SelectedItem == null) return;

            _currentConnection = (Connection) connectionNameComboBox.SelectedItem;

            pOracleOnlyOptions.Hide();

            if (_currentConnection.Type == ServerType.Oracle)
                pOracleOnlyOptions.Show();
        }
Esempio n. 3
0
 private void OnConnectionDialogLoad(object sender, EventArgs e)
 {
     // If no connection has been passed in create a new one
     if (Connection == null)
     {
         Connection = CreateNewConnection();
     }
 }
Esempio n. 4
0
        private void ConnectionButtonClick(object sender, EventArgs e)
        {
            // Belt and braces
            if (applicationSettings == null)
            {
                LoadApplicationSettings();
            }

            var connectionDialog = new ConnectionDialog();

            // Edit current connection
            if (_currentConnection != null)
            {
                connectionDialog.Connection = _currentConnection;
            }

            var result = connectionDialog.ShowDialog();
            switch (result)
            {
                case DialogResult.OK:
                    // Add or Update Connection
                    _currentConnection = connectionDialog.Connection;
                    var connectionToUpdate = applicationSettings.Connections.FirstOrDefault(connection => connection.Id == _currentConnection.Id);

                    if (connectionToUpdate == null)
                    {
                        // Add new connection
                        applicationSettings.Connections.Add(_currentConnection);
                    }

                    break;
                case DialogResult.Abort:
                    // Delete Connection
                    applicationSettings.Connections.Remove(_currentConnection);
                    _currentConnection = null;
                    break;
            }

            // Refresh data connections drop down
            connectionNameComboBox.DataSource = null;
            connectionNameComboBox.DataSource = applicationSettings.Connections;
            connectionNameComboBox.DisplayMember = "Name";
            connectionNameComboBox.SelectedItem = _currentConnection;
        }
Esempio n. 5
0
 private void OnAddButtonClick(object sender, EventArgs e)
 {
     Connection = CreateNewConnection();
 }