Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            var appSettings = ApplicationSettings.Load();

            if (appSettings != null)
            {
                serverTypeComboBox.SelectedItem = appSettings.ServerType;
                connStrTextBox.Text             = appSettings.ConnectionString;
                nameSpaceTextBox.Text           = appSettings.NameSpace;
                assemblyNameTextBox.Text        = appSettings.AssemblyName;
                fluentMappingOption.Checked     = appSettings.IsFluent;
                cSharpRadioButton.Checked       = appSettings.Language == Language.CSharp;
                autoPropertyRadioBtn.Checked    = appSettings.IsAutoProperty;
                folderTextBox.Text              = appSettings.FolderPath;
                textBoxInheritence.Text         = appSettings.InheritenceAndInterfaces;
                comboBoxForeignCollection.Text  = appSettings.ForeignEntityCollectionType;
                textBoxClassNamePrefix.Text     = appSettings.ClassNamePrefix;
                wcfDataContractCheckBox.Checked = appSettings.GenerateWcfContracts;
                partialClassesCheckBox.Checked  = appSettings.GeneratePartialClasses;

                fluentMappingOption.Checked  = appSettings.IsFluent;
                nhFluentMappingStyle.Checked = appSettings.IsNhFluent;
                castleMappingOption.Checked  = appSettings.IsCastle;
                byCodeMappingOption.Checked  = appSettings.IsByCode;

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

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

                generateInFoldersCheckBox.Checked = appSettings.GenerateInFolders;
            }
            else
            {
                autoPropertyRadioBtn.Checked   = true;
                sameAsDBRadioButton.Checked    = true;
                cSharpRadioButton.Checked      = true;
                fluentMappingOption.Checked    = true;
                comboBoxForeignCollection.Text = "IList";
            }
            if (!prefixRadioButton.Checked)
            {
                prefixLabel.Visible = prefixTextBox.Visible = false;
            }
        }
Exemple #2
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;
                wcfDataContractCheckBox.Checked       = applicationSettings.GenerateWcfContracts;
                partialClassesCheckBox.Checked        = applicationSettings.GeneratePartialClasses;
                useLazyLoadingCheckBox.Checked        = applicationSettings.UseLazy;
                includeLengthAndScaleCheckBox.Checked = applicationSettings.IncludeLengthAndScale;
                includeForeignKeysCheckBox.Checked    = applicationSettings.IncludeForeignKeys;

                fluentMappingOption.Checked = applicationSettings.IsFluent;
                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;
                useLazyLoadingCheckBox.Checked     = true;

                comboBoxForeignCollection.Text = "IList";

                CaptureApplicationSettings();
            }

            if (!prefixRadioButton.Checked)
            {
                prefixLabel.Visible = prefixTextBox.Visible = false;
            }
        }