Exemple #1
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;

            fastColoredTextBox5.Text = CodeMaker.MakeDbConfig(applicationSettings.Connections, checkBox4.Checked);
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var diagResult = folderBrowserDialog.ShowDialog();

            if (diagResult == DialogResult.OK)
            {
                try
                {
                    string folder  = folderBrowserDialog.SelectedPath;
                    var    content = CodeMaker.MakeDbConfig(applicationSettings.Connections, checkBox4.Checked);
                    WriteToFile(folder, "db.config", content, true);
                    toolStripStatusLabel.Text = @"Generated db.config files successfully.";
                }
                catch (Exception ex)
                {
                    toolStripStatusLabel.Text = @"Generated db.config files failed.:" + ex.Message;
                }
            }
        }
Exemple #3
0
        private void LoadApplicationSettings()
        {
            applicationSettings = ApplicationSettings.Load();
            if (applicationSettings != null)
            {
                // Display all previous connections
                connectionNameComboBox.DataSource    = applicationSettings.Connections;
                connectionNameComboBox.DisplayMember = "Name";
                fastColoredTextBox5.Text             = CodeMaker.MakeDbConfig(applicationSettings.Connections, checkBox4.Checked);
                // Set the last used connection
                var lastUsedConnection =
                    applicationSettings.Connections.FirstOrDefault(connection => connection.Id == applicationSettings.LastUsedConnection);
                _currentConnection = lastUsedConnection ?? applicationSettings.Connections.FirstOrDefault();
                connectionNameComboBox.SelectedItem = _currentConnection;

                DomainNmespaceTextBox.Text              = applicationSettings.NameSpace;
                IReposityNamespaceTextBox.Text          = applicationSettings.NameSpaceMap;
                ReposityNamespaceTextBox.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;
                DomainFolderTextBox.Text                = applicationSettings.FolderPath;
                IReposityFolderTextBox.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;
            }
            LoadMySetting();
        }