private void UiAction_SelectNewPattern() { var codeGenFile = Common.AppVarPathMakeAbsolute(_projectDefinition.CodeGenSettings.CodeGenPatternFile); dlgOpenPattern.FileName = codeGenFile; dlgOpenPattern.InitialDirectory = Path.GetDirectoryName(codeGenFile); if (dlgOpenPattern.ShowDialog() == DialogResult.OK) { string projectFile = dlgOpenPattern.FileName; try { _patternProject = PatternProject.ReadFromFile(projectFile); var prjRelativePath = Common.AppVarPathMakeRelative(projectFile); _projectDefinition.CodeGenSettings.CodeGenPatternFile = prjRelativePath; Refresh_PatternProjectsCombo(); SetModified(true); } catch (Exception) { MessageBox.Show("Failed to open the selected pattern!", "Pattern project", MessageBoxButtons.OK, MessageBoxIcon.Stop); } Refresh_PatternsList(true); } }
private void Reload_ProjectDefinition(string patternProjectFile) { _patternProject = PatternProject.ReadFromFile(patternProjectFile); // realod combo Refresh_PatternProjectsCombo(); }
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 } } }
/// <summary> /// Reads pattern projects list /// </summary> private void Refresh_PatternProjectsList() { string patPrjExt = "*" + AppConfig.PatternProjectExtension; try { string[] projectFiles = Directory.GetFiles(AppConfig.PatternProjectsDirectory, patPrjExt, SearchOption.AllDirectories); _patternProjectsList.Clear(); foreach (var project in projectFiles) { try { // load the pattern PatternProject patPrj = PatternProject.ReadFromFile(project); // add to list _patternProjectsList.Add(patPrj); } catch (Exception) { // failed! // TODO: notify user about failed pattern } } // sort patterns list _patternProjectsList.Sort((x, y) => string.Compare(x.Name, y.Name)); //_patternProjectsList.Sort(new Comparison<PatternProject>((x, y) => string.Compare(x.Name, y.Name))); //// sort patterns list //_patternProjectsList.Sort(new Comparison<PatternProject>(delegate(PatternProject x, PatternProject y) //{ // return string.Compare(x.Name, y.Name); //})); // pattern projects Refresh_PatternProjectsCombo(); } catch (Exception ex) { throw new Exception("Failed to read pattern projects list.", ex); } }