Ejemplo n.º 1
0
        private void InitializeApplication()
        {
            _projectDefinition = ProjectDefinition.LoadDefaultProject();
            _patternProject    = new PatternProject();
            _recentProjects    = new RecentProjects(mnuReopen, mnuReopenRecentFile_Click);
            Reload_ProjectDefinition();

            // refresh presentation
            Refresh_Form(true);

            // recent projects list
            InitializeRecentMenu();

            // Modified
            SetModified(false);
        }
Ejemplo n.º 2
0
        private void UiAction_NewProject()
        {
            using (var frmNew = new frmProjectDetails(frmProjectDetails.FormEditMode.New)) {
                frmNew.ProjectInstance = ProjectDefinition.LoadDefaultProject();
                if (frmNew.ShowDialog() == DialogResult.OK)
                {
                    _projectDefinaton = frmNew.ProjectInstance;
                    _patternProject   = PatternProject.ReadFromFile(
                        Common.AppVarPathMakeAbsolute(_projectDefinaton.CodeGenSettings.CodeGenPatternFile));
                    Refresh_Form(true);

                    SetModified(true);
                    _currentProject_Opened = false;
                    // Reload everything
                }
            }
        }
        private void InitializeProjectModel()
        {
            if (ProjectInstance == null)
            {
                // load default settings
                ProjectInstance = ProjectDefinition.LoadDefaultProject();
            }

            ProjectInstance.ProjectName = txtProjectName.Text;
            ProjectInstance.CodeGenSettings.DefaultNamespace = txtNamespace.Text;
            ProjectInstance.GenerationPath = txtGenerationPath.Text;
            ProjectInstance.CodeGenSettings.CodeGenPatternFile = txtPatternfile.Text;

            ProjectInstance.CodeGenSettings.GenerateTablesForeignKeys  = chkGenForeignKey.Checked;
            ProjectInstance.CodeGenSettings.GenerateColumnsDescription = chkGenDescription.Checked;

            ProjectInstance.CodeGenSettings.GenerateConstraintKeys = chkTableConstraintKeys.Checked;

            ProjectInstance.RenamingOptions.UnderlineWordDelimiter     = chkRenUnderlineWordDelimiter.Checked;
            ProjectInstance.RenamingOptions.RemoveUnderline.Enabled    = chkRenRemUnderline.Checked;
            ProjectInstance.RenamingOptions.RemoveUnderline.Tables     = chkRenUnderlineTables.Checked;
            ProjectInstance.RenamingOptions.RemoveUnderline.Properties = chkRenUnderlineProps.Checked;

            ProjectInstance.RenamingOptions.CaseChange.Enabled    = chkRenamingCase.Checked;
            ProjectInstance.RenamingOptions.CaseChange.Tables     = chkRenCaseTables.Checked;
            ProjectInstance.RenamingOptions.CaseChange.Properties = chkRenCaseProps.Checked;
            ProjectInstance.RenamingOptions.CaseChangeMode        = (ProjectRenaming.CaseChangeType)cmbRenamingCase.SelectedValue;

            if (pagerDatabaseProvider.SelectedTab == tabSQLServer)
            {
                ProjectInstance.DbSettions.ServerName           = txtSqlHost.Text;
                ProjectInstance.DbSettions.DatabaseName         = txtSqlDbName.Text;
                ProjectInstance.DbSettions.SqlUsername          = txtSqlUsername.Text;
                ProjectInstance.DbSettions.SqlPassword          = txtSqlPassword.Text;
                ProjectInstance.DbSettions.UseSqlAuthentication = rbtnSqlAuthentication.Checked;
                ProjectInstance.DbSettions.ConnectTimeout       = Convert.ToInt32(txtSqlConnectTimeout.Text);
                ProjectInstance.DbSettions.DatabaseProvider     = DatabaseProvider.SQLServer;
            }
            else if (pagerDatabaseProvider.SelectedTab == tabSQLite)
            {
                ProjectInstance.DbSettions.ServerName = txtSQLiteDatabaseName.Text;
                try {
                    ProjectInstance.DbSettions.DatabaseName = Path.GetFileNameWithoutExtension(txtSQLiteDatabaseName.Text);
                }
                catch { }
                ProjectInstance.DbSettions.SqlUsername          = "";
                ProjectInstance.DbSettions.SqlPassword          = txtSQLitePassword.Text;
                ProjectInstance.DbSettions.UseSqlAuthentication = false;
                ProjectInstance.DbSettions.ConnectTimeout       = Convert.ToInt32(txtSQLiteConnectTimeout.Text);
                ProjectInstance.DbSettions.DatabaseProvider     = DatabaseProvider.SQLite;
            }
            else if (pagerDatabaseProvider.SelectedTab == tabSqlCe)
            {
                ProjectInstance.DbSettions.ServerName = txtSqlCeDatabaseName.Text;
                try {
                    ProjectInstance.DbSettions.DatabaseName = Path.GetFileNameWithoutExtension(txtSqlCeDatabaseName.Text);
                }
                catch { }
                ProjectInstance.DbSettions.SqlUsername = "";
                ProjectInstance.DbSettions.SqlPassword = txtSqlCePassword.Text;
                if (string.IsNullOrEmpty(txtSqlCePassword.Text))
                {
                    ProjectInstance.DbSettions.UseSqlAuthentication = false;
                }
                else
                {
                    ProjectInstance.DbSettions.UseSqlAuthentication = true;
                }

                ProjectInstance.DbSettions.ConnectTimeout   = -1;
                ProjectInstance.DbSettions.DatabaseProvider = DatabaseProvider.SqlCe4;
            }
            else if (pagerDatabaseProvider.SelectedTab == tabOracle)
            {
                ProjectInstance.DbSettions.ServerName     = txtOrclDataSource.Text;
                ProjectInstance.DbSettions.ConnectTimeout = Convert.ToInt32(txtOrclConnectTimeout.Text);

                ProjectInstance.DbSettions.UseSqlAuthentication = rbtnOrclSpecificUsernamePass.Checked;

                ProjectInstance.DbSettions.DatabaseName        = txtOrclDbName.Text;
                ProjectInstance.DbSettions.SqlUsername         = txtOrclUsername.Text;
                ProjectInstance.DbSettions.SqlPassword         = txtOrclPassword.Text;
                ProjectInstance.DbSettions.OracleUseSysdbaRole = chkOrclUserRoleSYSDBA.Checked;

                ProjectInstance.DbSettions.DatabaseProvider = DatabaseProvider.Oracle;
            }
            else if (pagerDatabaseProvider.SelectedTab == tabPostgres)
            {
                ProjectInstance.DbSettions.ServerName   = txtPgHost.Text;
                ProjectInstance.DbSettions.DatabaseName = txtPgDbName.Text;
                ProjectInstance.DbSettions.SqlUsername  = txtPgUsername.Text;
                ProjectInstance.DbSettions.SqlPassword  = txtPgPassword.Text;
                ProjectInstance.DbSettions.SchemaName   = txtPgSchema.Text;

                ProjectInstance.DbSettions.DatabaseProvider = DatabaseProvider.Npgsql;
            }
            else if (pagerDatabaseProvider.SelectedTab == tabMySQL)
            {
                ProjectInstance.DbSettions.ServerName   = txtMysqlHost.Text;
                ProjectInstance.DbSettions.DatabaseName = txtMysqlDbName.Text;
                ProjectInstance.DbSettions.SqlUsername  = txtMysqlUsername.Text;
                ProjectInstance.DbSettions.SqlPassword  = txtMysqlPassword.Text;

                ProjectInstance.DbSettions.DatabaseProvider = DatabaseProvider.MySql;
            }

            ProjectInstance.DbSettions.SuffixForTables = txtSuffixForTables.Text;
            ProjectInstance.DbSettions.SuffixForViews  = txtSuffixForViews.Text;

            ProjectInstance.DbSettions.PrefixForTables = txtPrefixForTables.Text;
            ProjectInstance.DbSettions.PrefixForViews  = txtPrefixForViews.Text;

            ProjectInstance.DbSettions.IgnoredPrefixes.Clear();
            foreach (var item in lstIgnoredPrefixes.Items)
            {
                ProjectInstance.DbSettions.IgnoredPrefixes.Add(item.ToString());
            }

            ProjectInstance.DbSettions.IgnoredSuffixes.Clear();
            foreach (var item in lstIgnoredSuffixes.Items)
            {
                ProjectInstance.DbSettions.IgnoredSuffixes.Add(item.ToString());
            }
        }