private string OutputFileName(OptionSetupModel option, ErdCanvasModel canvas, TableModel table) { if (table == null) { string canvasFileName = option.OutputFileName.Replace("[[CanvasName]]", canvas.ModelSegmentControlName); string canvasFilePath = option.OutputDirectory.Replace("[[CanvasName]]", canvas.ModelSegmentControlName); if (!Directory.Exists(canvasFilePath)) { Directory.CreateDirectory(canvasFilePath); } return(Path.Combine(canvasFilePath, canvasFileName)); } string fileName = option.OutputFileName .Replace("[[TableName]]", table.TableName) .Replace("[[CanvasName]]", canvas.ModelSegmentControlName); string filePath = option.OutputDirectory .Replace("[[TableName]]", table.TableName) .Replace("[[CanvasName]]", canvas.ModelSegmentControlName); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } return(Path.Combine(filePath, fileName)); }
private void SetTab(OptionSetupModel optionModel) { BuildOption option = new BuildOption(this.canvas, this.allErdCanvasModels) { Title = optionModel.OptionModelName, OptionSetup = optionModel, ShowCloseButton = true, SelectedTable = this.selectedTable }; this.uxTabs.Items.Add(option); this.uxTabs.Content.MaxHeight = this.ActualHeight - 65; }
private void BuildOption_Loaded(object sender, RoutedEventArgs e) { try { if (base.WasFirstLoaded) { if (this.SelectedTable.TableName != this.lastLoadTableName) { this.LoadSampleScript(); } return; } if (this.OptionSetup == null) { this.OptionSetup = new OptionSetupModel(); this.OptionSetup.OptionModelName = this.Title; } this.uxOptionSetup.Items.Add(this.OptionSetup); this.optionSetup.PropertyChanged += this.OptionSetup_Changed; this.SetOptionSetup(); foreach (BuildTypeModel buildType in this.OptionSetup.BuildTypes) { this.uxBuildTypes.Items.Add(buildType); this.uxBuildTypes[buildType.BuildTypeIndex].Header = $"{buildType.BuildTypeName} = [[{buildType.BuildTypeIndex}]]"; buildType.PropertyChanged += this.BuildType_Changed; } this.LoadSampleScript(); base.WasFirstLoaded = true; } catch (Exception err) { MessageBox.Show(err.InnerExceptionMessage()); } }
public string BuildSingleFile(OptionSetupModel classOption) { if (classOption.BuildTypes.Length == 0) { return(string.Empty); } StringBuilder result = new StringBuilder(); int minIndex = classOption.BuildTypes.Min(m => m.BuildTypeIndex); BuildTypeModel body = classOption.BuildTypes.FirstOrDefault(mi => mi.BuildTypeIndex == minIndex); result.Append(body.Code); this.ExecuteIfStatment(ref result, 0); return(this.RemoveTrailingCharacters(result)); }
public string BuildSampleForeachTableScript(ErdCanvasModel sampleCanvas, List <ErdCanvasModel> allErdModels, TableModel table, OptionSetupModel classOption) { if (classOption.BuildTypes.Length == 0) { return(string.Empty); } this.ErdCanvas = sampleCanvas; this.AllErdCanvasModels = allErdModels; this.SelectedTable = table; StringBuilder result = new StringBuilder(); int minIndex = classOption.BuildTypes.Min(m => m.BuildTypeIndex); BuildTypeModel body = classOption.BuildTypes.FirstOrDefault(mi => mi.BuildTypeIndex == minIndex); result.Append(this.ReplaceParameters(body.Code)); this.BuildTypeIteration(ref result, classOption.BuildTypes); this.ExecuteIfStatment(ref result, 0); return(this.RemoveTrailingCharacters(result)); }