/// <summary> /// Print all match results. /// </summary> /// <param name="settings">Export settings</param> /// <returns>print document as a string</returns> /// <history> /// [Curtis_Beard] 04/10/2015 CHG: move printing exporting here /// </history> public static string PrintAll(ExportSettings settings) { StringBuilder document = new StringBuilder(); foreach (var match in settings.Grep.MatchResults) { document.AppendLine("----------------------------------------------------------------------"); document.AppendLine(match.File.FullName); document.AppendLine("----------------------------------------------------------------------"); for (int i = 0; i < match.Matches.Count; i++) { var matchLine = match.Matches[i]; if (matchLine.LineNumber > -1) { document.AppendLine(string.Format("{0}: {1}", matchLine.LineNumber, matchLine.Line)); } else { document.AppendLine(string.Empty); } } document.AppendLine(string.Empty); } return document.ToString(); }
private static void ResolveFluentMethod(ExportSettings settings) { if (string.IsNullOrEmpty(_parameters.ConfigurationMethod)) return; var methodPath = _parameters.ConfigurationMethod; var path = new Stack<string>(methodPath.Split('.')); var method = path.Pop(); var fullQualifiedType = string.Join(".", path.Reverse()); foreach (var sourceAssembly in settings.SourceAssemblies) { var type = sourceAssembly.GetType(fullQualifiedType, false); if (type != null) { var constrMethod = type.GetMethod(method); if (constrMethod != null && constrMethod.IsStatic) { var pars = constrMethod.GetParameters(); if (pars.Length == 1 && pars[0].ParameterType == typeof(ConfigurationBuilder)) { settings.ConfigurationMethod = builder => constrMethod.Invoke(null, new object[] { builder }); break; } } } } }
public ExportEventArgs(ExportType type, IExportElement document, bool sendByEmail, string fileName) { Settings = new ExportSettings(); SetTitle(fileName); ExportType = type; SendByEmail = sendByEmail; ExportDocument(document); }
public ExportEventArgs(string document, string title) { Settings = new ExportSettings(); Document = document; Title = title; ExportType = ExportType.Html; SendByEmail = false; }
private static void ExportMesh(Mesh mesh, MeshRenderer meshRenderer, Transform gotrans, ExportSettings settings, List <PipelineData> storePipelines = null) { bool addedCullGroup = false; if (settings.autoAddCullNodes) { CullData culldata = new CullData(); Vector3 center = meshRenderer.bounds.center - gotrans.position; CoordSytemConverter.Convert(ref center); culldata.center = NativeUtils.ToNative(center); culldata.radius = meshRenderer.bounds.size.magnitude * 0.5f; GraphBuilderInterface.unity2vsg_AddCullGroupNode(culldata); addedCullGroup = true; } // Material[] materials = meshRenderer.sharedMaterials; if (mesh != null && mesh.isReadable && mesh.vertexCount > 0 && mesh.GetIndexCount(0) > 0) { int meshid = mesh.GetInstanceID(); MeshInfo meshInfo = MeshConverter.GetOrCreateMeshInfo(mesh); int subMeshCount = mesh.subMeshCount; // shader instance id, Material Data, sub mesh indicies Dictionary <int, Dictionary <MaterialInfo, List <int> > > meshMaterials = new Dictionary <int, Dictionary <MaterialInfo, List <int> > >(); for (int matindex = 0; matindex < materials.Length && matindex < subMeshCount; matindex++) { Material mat = materials[matindex]; if (mat == null) { continue; } MaterialInfo matdata = MaterialConverter.GetOrCreateMaterialData(mat); int matshaderid = matdata.shaderStages.id; if (!meshMaterials.ContainsKey(matshaderid)) { meshMaterials.Add(matshaderid, new Dictionary <MaterialInfo, List <int> >()); } if (!meshMaterials[matshaderid].ContainsKey(matdata)) { meshMaterials[matshaderid].Add(matdata, new List <int>()); } meshMaterials[matshaderid][matdata].Add(matindex); } if (subMeshCount > 1) { // create mesh data, if the mesh has already been created we only need to pass the ID to the addGeometry function foreach (int shaderkey in meshMaterials.Keys) { List <MaterialInfo> mds = new List <MaterialInfo>(meshMaterials[shaderkey].Keys); if (mds.Count == 0) { continue; } // add stategroup and pipeline for shader GraphBuilderInterface.unity2vsg_AddStateGroupNode(); PipelineData pipelineData = NativeUtils.CreatePipelineData(meshInfo); //WE NEED INFO ABOUT THE SHADER SO WE CAN BUILD A PIPLE LINE pipelineData.descriptorBindings = NativeUtils.WrapArray(mds[0].descriptorBindings.ToArray()); pipelineData.shaderStages = mds[0].shaderStages.ToNative(); pipelineData.useAlpha = mds[0].useAlpha; pipelineData.id = NativeUtils.ToNative(NativeUtils.GetIDForPipeline(pipelineData)); storePipelines.Add(pipelineData); if (GraphBuilderInterface.unity2vsg_AddBindGraphicsPipelineCommand(pipelineData, 1) == 1) { GraphBuilderInterface.unity2vsg_AddCommandsNode(); VertexBuffersData vertexBuffersData = MeshConverter.GetOrCreateVertexBuffersData(meshInfo); GraphBuilderInterface.unity2vsg_AddBindVertexBuffersCommand(vertexBuffersData); IndexBufferData indexBufferData = MeshConverter.GetOrCreateIndexBufferData(meshInfo); GraphBuilderInterface.unity2vsg_AddBindIndexBufferCommand(indexBufferData); foreach (MaterialInfo md in mds) { BindDescriptors(md, false); foreach (int submeshIndex in meshMaterials[shaderkey][md]) { DrawIndexedData drawIndexedData = MeshConverter.GetOrCreateDrawIndexedData(meshInfo, submeshIndex); GraphBuilderInterface.unity2vsg_AddDrawIndexedCommand(drawIndexedData); } } GraphBuilderInterface.unity2vsg_EndNode(); // step out of commands node for descriptors and draw indexed commands } GraphBuilderInterface.unity2vsg_EndNode(); // step out of stategroup node for shader } } else { List <int> sids = new List <int>(meshMaterials.Keys); if (sids.Count > 0) { List <MaterialInfo> mds = new List <MaterialInfo>(meshMaterials[sids[0]].Keys); if (mds.Count > 0) { // add stategroup and pipeline for shader GraphBuilderInterface.unity2vsg_AddStateGroupNode(); PipelineData pipelineData = NativeUtils.CreatePipelineData(meshInfo); //WE NEED INFO ABOUT THE SHADER SO WE CAN BUILD A PIPLE LINE pipelineData.descriptorBindings = NativeUtils.WrapArray(mds[0].descriptorBindings.ToArray()); pipelineData.shaderStages = mds[0].shaderStages.ToNative(); pipelineData.useAlpha = mds[0].useAlpha; pipelineData.id = NativeUtils.ToNative(NativeUtils.GetIDForPipeline(pipelineData)); storePipelines.Add(pipelineData); if (GraphBuilderInterface.unity2vsg_AddBindGraphicsPipelineCommand(pipelineData, 1) == 1) { BindDescriptors(mds[0], true); VertexIndexDrawData vertexIndexDrawData = MeshConverter.GetOrCreateVertexIndexDrawData(meshInfo); GraphBuilderInterface.unity2vsg_AddVertexIndexDrawNode(vertexIndexDrawData); GraphBuilderInterface.unity2vsg_EndNode(); // step out of vertex index draw node } GraphBuilderInterface.unity2vsg_EndNode(); // step out of stategroup node } } } } else { string reason = mesh == null ? "mesh is null." : (!mesh.isReadable ? "mesh '" + mesh.name + "' is not readable. Please enabled read/write in the models import settings." : "mesh '" + mesh.name + "' has an unknown error."); NativeLog.WriteLine("ExportMesh: Unable to export mesh for gameobject " + gotrans.gameObject.name + ", " + reason); } if (addedCullGroup) { GraphBuilderInterface.unity2vsg_EndNode(); } }
private static void ExportTerrainMesh(Terrain terrain, ExportSettings settings, List <PipelineData> storePipelines = null) { TerrainConverter.TerrainInfo terrainInfo = TerrainConverter.CreateTerrainInfo(terrain, settings); if (terrainInfo == null || ((terrainInfo.diffuseTextureDatas.Count == 0 || terrainInfo.maskTextureDatas.Count == 0) && terrainInfo.customMaterial == null)) { return; } // add stategroup and pipeline for shader GraphBuilderInterface.unity2vsg_AddStateGroupNode(); PipelineData pipelineData = new PipelineData(); pipelineData.hasNormals = 1; pipelineData.uvChannelCount = 1; pipelineData.useAlpha = 0; if (terrainInfo.customMaterial == null) { pipelineData.descriptorBindings = NativeUtils.WrapArray(terrainInfo.descriptorBindings.ToArray()); ShaderStagesInfo shaderStagesInfo = MaterialConverter.GetOrCreateShaderStagesInfo(terrainInfo.shaderMapping.shaders.ToArray(), string.Join(",", terrainInfo.shaderDefines.ToArray()), terrainInfo.shaderConsts.ToArray()); pipelineData.shaderStages = shaderStagesInfo.ToNative(); pipelineData.id = NativeUtils.ToNative(NativeUtils.GetIDForPipeline(pipelineData)); storePipelines.Add(pipelineData); if (GraphBuilderInterface.unity2vsg_AddBindGraphicsPipelineCommand(pipelineData, 1) == 1) { if (terrainInfo.diffuseTextureDatas.Count > 0) { DescriptorImageData layerDiffuseTextureArray = MaterialConverter.GetOrCreateDescriptorImageData(terrainInfo.diffuseTextureDatas.ToArray(), 0); GraphBuilderInterface.unity2vsg_AddDescriptorImage(layerDiffuseTextureArray); } if (terrainInfo.diffuseScales.Count > 0) { DescriptorVectorArrayUniformData scalesDescriptor = new DescriptorVectorArrayUniformData(); scalesDescriptor.binding = 2; scalesDescriptor.value = NativeUtils.WrapArray(terrainInfo.diffuseScales.ToArray()); GraphBuilderInterface.unity2vsg_AddDescriptorBufferVectorArray(scalesDescriptor); } DescriptorVectorUniformData sizeDescriptor = new DescriptorVectorUniformData(); sizeDescriptor.binding = 3; sizeDescriptor.value = NativeUtils.ToNative(terrainInfo.terrainSize); GraphBuilderInterface.unity2vsg_AddDescriptorBufferVector(sizeDescriptor); if (terrainInfo.maskTextureDatas.Count > 0) { DescriptorImageData layerMaskTextureArray = MaterialConverter.GetOrCreateDescriptorImageData(terrainInfo.maskTextureDatas.ToArray(), 1); GraphBuilderInterface.unity2vsg_AddDescriptorImage(layerMaskTextureArray); } GraphBuilderInterface.unity2vsg_CreateBindDescriptorSetCommand(1); GraphBuilderInterface.unity2vsg_AddVertexIndexDrawNode(MeshConverter.GetOrCreateVertexIndexDrawData(terrainInfo.terrainMesh)); GraphBuilderInterface.unity2vsg_EndNode(); // step out of vertex index draw node } } else { pipelineData.descriptorBindings = NativeUtils.WrapArray(terrainInfo.customMaterial.descriptorBindings.ToArray()); pipelineData.shaderStages = terrainInfo.customMaterial.shaderStages.ToNative(); pipelineData.id = NativeUtils.ToNative(NativeUtils.GetIDForPipeline(pipelineData)); storePipelines.Add(pipelineData); if (GraphBuilderInterface.unity2vsg_AddBindGraphicsPipelineCommand(pipelineData, 1) == 1) { BindDescriptors(terrainInfo.customMaterial, true); GraphBuilderInterface.unity2vsg_AddVertexIndexDrawNode(MeshConverter.GetOrCreateVertexIndexDrawData(terrainInfo.terrainMesh)); GraphBuilderInterface.unity2vsg_EndNode(); // step out of vertex index draw node } } GraphBuilderInterface.unity2vsg_EndNode(); // step out of stategroup node }
/// <summary> /// Save results to a text file /// </summary> /// <param name="settings">Export settings</param> /// <history> /// [Curtis_Beard] 09/06/2006 Created /// [Andrew_Radford] 20/09/2009 Extracted from main form code-behind /// [Curtis_Beard] 01/31/2012 CHG: output some basic search information, make divider same length as filename /// [Curtis_Beard] 02/12/2014 CHG: handle file search only better, add search options to output /// [Curtis_Beard] 10/27/2014 CHG: 85, remove leading white space /// [Curtis_Beard] 11/11/2014 ADD: export all filteritems /// [Curtis_Beard] 12/03/2014 CHG: use grepIndexes instead of ListView /// [Curtis_Beard] 04/08/2015 CHG: update export delegate with settings class /// </history> public static void SaveResultsAsText(ExportSettings settings) { // Open the file using (var writer = new StreamWriter(settings.Path, false, System.Text.Encoding.UTF8)) { StringBuilder builder = new StringBuilder(); int totalHits = 0; bool isFileSearch = string.IsNullOrEmpty(settings.Grep.SearchSpec.SearchText); // loop through File Names list for (int i = 0; i < settings.GrepIndexes.Count; i++) { var _hit = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); totalHits += _hit.HitCount; // write info to a file if (isFileSearch || settings.Grep.SearchSpec.ReturnOnlyFileNames) { builder.AppendLine(_hit.File.FullName); } else { builder.AppendLine(new string('-', _hit.File.FullName.Length)); builder.AppendLine(_hit.File.FullName); builder.AppendLine(new string('-', _hit.File.FullName.Length)); for (int j = 0; j < _hit.Matches.Count; j++) { string line = _hit.Matches[j].Line; if (settings.RemoveLeadingWhiteSpace) { line = line.TrimStart(); } if (settings.ShowLineNumbers && _hit.Matches[j].LineNumber > -1) { line = string.Format("{0}: {1}", _hit.Matches[j].LineNumber, line); } builder.AppendLine(line); } builder.AppendLine(); } } // output basic search information as a header writer.WriteLine("AstroGrep Results"); writer.WriteLine("-------------------------------------------------------"); if (!isFileSearch) { writer.WriteLine(string.Format("{0} was found {1} time{2} in {3} file{4}", settings.Grep.SearchSpec.SearchText, totalHits, totalHits > 1 ? "s" : "", settings.Grep.MatchResults.Count, settings.Grep.MatchResults.Count > 1 ? "s" : "")); writer.WriteLine(""); } writer.WriteLine(""); // output options writer.WriteLine("Search Options"); writer.WriteLine("-------------------------------------------------------"); writer.WriteLine("Search Paths: {0}", string.Join(", ", settings.Grep.SearchSpec.StartDirectories)); writer.WriteLine("File Types: {0}", settings.Grep.FileFilterSpec.FileFilter); writer.WriteLine("Regular Expressions: {0}", settings.Grep.SearchSpec.UseRegularExpressions.ToString()); writer.WriteLine("Case Sensitive: {0}", settings.Grep.SearchSpec.UseCaseSensitivity.ToString()); writer.WriteLine("Whole Word: {0}", settings.Grep.SearchSpec.UseWholeWordMatching.ToString()); writer.WriteLine("Subfolders: {0}", settings.Grep.SearchSpec.SearchInSubfolders.ToString()); writer.WriteLine("Show File Names Only: {0}", settings.Grep.SearchSpec.ReturnOnlyFileNames.ToString()); writer.WriteLine("Negation: {0}", settings.Grep.SearchSpec.UseNegation.ToString()); writer.WriteLine("Line Numbers: {0}", settings.ShowLineNumbers.ToString()); writer.WriteLine("Remove Leading White Space: {0}", settings.RemoveLeadingWhiteSpace.ToString()); writer.WriteLine("Context Lines: {0}", settings.Grep.SearchSpec.ContextLines.ToString()); // filter items if (settings.Grep.FileFilterSpec.FilterItems != null) { writer.WriteLine("Exclusions:"); foreach (FilterItem item in settings.Grep.FileFilterSpec.FilterItems) { string option = item.ValueOption.ToString(); if (item.ValueOption == FilterType.ValueOptions.None) { option = string.Empty; } writer.WriteLine("\t{0} -> {1}: {2} {3}", item.FilterType.Category, item.FilterType.SubCategory, item.Value, option); } } writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine("Results"); if (isFileSearch || settings.Grep.SearchSpec.ReturnOnlyFileNames) { writer.WriteLine("-------------------------------------------------------"); } // output actual results writer.Write(builder.ToString()); } }
/// <summary> /// Builds an action from parsed data /// </summary> /// <param name="template">Template to export</param> /// <param name="parsedData">Parsed data</param> /// <param name="data">Dialog data</param> /// <param name="nextStep">Next step in the dialog</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Action string</returns> public override async Task <string> BuildActionFromParsedData(ExportTemplate template, CodeActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { string actionCode = await FillPlaceholders(template, errorCollection, parsedData, flexFieldObject, data, nextStep, exportSettings, stepRenderer); actionCode = BuildFinalScriptCode(actionCode); return(actionCode); }
/// <summary> /// Builds an action from parsed data /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="data">Dialog data</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <returns>Action string</returns> public override async Task <string> BuildActionFromParsedData(ShowFloatingTextAboveObjectActionRenderer.FloatingTextActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings) { ExportTemplate actionTemplate = await GetExportTemplate(project); IFlexFieldExportable valueObject = await GetValueObject(project, parsedData, flexFieldObject, errorCollection); if (valueObject == null) { return(string.Empty); } string actionCode = actionTemplate.Code; actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_FloatingText).Replace(actionCode, parsedData.FloatingText); actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_FloatingText_LangKey).Replace(actionCode, m => { return(_languageKeyGenerator.GetDialogTextLineKey(flexFieldObject.Id, valueObject.Name, GetLanguageKeyType(), data.Id, parsedData.FloatingText).Result); }); ExportObjectData flexFieldExportData = new ExportObjectData(); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType()); _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection); actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result; return(actionCode); }
/// <summary> /// Save results to a html file /// </summary> /// <param name="settings">Export settings</param> /// <history> /// [Curtis_Beard] 09/06/2006 Created /// [Andrew_Radford] 20/09/2009 Extracted from main form code-behind /// [Curtis_Beard] 01/31/2012 CHG: make divider same length as filename /// [Curtis_Beard] 10/30/2012 CHG: add total in hits in file /// [Curtis_Beard] 02/12/2014 CHG: handle file search only better /// [Curtis_Beard] 10/27/2014 CHG: 85, remove leading white space /// [Curtis_Beard] 12/03/2014 CHG: use grepIndexes instead of ListView /// [Curtis_Beard] 04/08/2015 CHG: update export delegate with settings class /// </history> public static void SaveResultsAsHTML(ExportSettings settings) { using (var writer = new StreamWriter(settings.Path, false, System.Text.Encoding.UTF8)) { var allSections = new System.Text.StringBuilder(); string repeater; StringBuilder lines; string template = HTMLHelper.GetContents("Output.html"); string css = HTMLHelper.GetContents("Output.css"); int totalHits = 0; bool isFileSearch = string.IsNullOrEmpty(settings.Grep.SearchSpec.SearchText); if (settings.Grep.SearchSpec.ReturnOnlyFileNames || isFileSearch) template = HTMLHelper.GetContents("Output-fileNameOnly.html"); css = HTMLHelper.ReplaceCssHolders(css); template = template.Replace("%%style%%", css); template = template.Replace("%%title%%", "AstroGrep Results"); int rStart = template.IndexOf("[repeat]"); int rStop = template.IndexOf("[/repeat]") + "[/repeat]".Length; string repeat = template.Substring(rStart, rStop - rStart); string repeatSection = repeat; repeatSection = repeatSection.Replace("[repeat]", string.Empty); repeatSection = repeatSection.Replace("[/repeat]", string.Empty); // loop through File Names list for (int i = 0; i < settings.GrepIndexes.Count; i++) { var hitObject = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); lines = new StringBuilder(); repeater = repeatSection; string fileLine = string.Format("{0} (Total: {1})", hitObject.File.FullName, hitObject.HitCount); repeater = repeater.Replace("%%file%%", fileLine); repeater = repeater.Replace("%%filesep%%", new string('-', fileLine.Length)); totalHits += hitObject.HitCount; for (int j = 0; j < hitObject.Matches.Count; j++) { string line = hitObject.Matches[j].Line; if (settings.RemoveLeadingWhiteSpace) { line = line.TrimStart(); } if (settings.ShowLineNumbers && hitObject.Matches[j].LineNumber > -1) { line = string.Format("{0}: {1}", hitObject.Matches[j].LineNumber, line); } lines.Append(HTMLHelper.GetHighlightLine(line, settings.Grep)); } repeater = repeater.Replace("%%lines%%", lines.ToString()); allSections.Append(repeater); } template = template.Replace(repeat, allSections.ToString()); template = HTMLHelper.ReplaceSearchOptions(template, settings.Grep, totalHits, settings.ShowLineNumbers, settings.RemoveLeadingWhiteSpace); // write out template to the file writer.WriteLine(template); } }
/// <summary> /// Builds an action from parsed data /// </summary> /// <param name="template">Template to export</param> /// <param name="parsedData">Parsed data</param> /// <param name="data">Dialog data</param> /// <param name="nextStep">Next step in the dialog</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Action string</returns> public override async Task <string> BuildActionFromParsedData(ExportTemplate template, MoveNpcActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { KortistoNpc foundNpc = await GetNpc(parsedData, flexFieldObject); if (foundNpc == null) { errorCollection.AddDialogNpcNotFoundError(); return(string.Empty); } KartaMapNamedMarkerQueryResult markerResult = await GetMarker(parsedData); if (markerResult == null) { errorCollection.AddDialogMarkerNotFoundError(); return(string.Empty); } string directContinueFunction = string.Empty; if (data.Children != null) { ExportDialogDataChild directStep = data.Children.FirstOrDefault(c => c.NodeChildId == DirectContinueFunctionNodeId); directContinueFunction = directStep != null ? directStep.Child.DialogStepFunctionName : string.Empty; } return(await FillPlaceholders(template, errorCollection, parsedData, foundNpc, markerResult.MarkerName, directContinueFunction, flexFieldObject, data, nextStep, exportSettings, stepRenderer)); }
/// <summary> /// /// </summary> /// <example> /// entityId;entityLogicalName;Type;LCID1;LCID2;...;LCODX /// </example> /// <param name="entities"></param> /// <param name="languages"></param> /// <param name="sheet"></param> public void Export(List <EntityMetadata> entities, List <int> languages, ExcelWorksheet sheet, ExportSettings settings) { var line = 0; var cell = 0; AddHeader(sheet, languages); foreach (var entity in entities.OrderBy(e => e.LogicalName)) { if (!entity.MetadataId.HasValue) { continue; } if (settings.ExportNames) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.MetadataId.Value.ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.LogicalName; // DisplayName ZeroBasedSheet.Cell(sheet, line, cell++).Value = "DisplayName"; foreach (var lcid in languages) { var displayName = string.Empty; if (entity.DisplayName != null) { var displayNameLabel = entity.DisplayName.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (displayNameLabel != null) { displayName = displayNameLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = displayName; } // Plural Name line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.MetadataId.Value.ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.LogicalName; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "DisplayCollectionName"; foreach (var lcid in languages) { var collectionName = string.Empty; if (entity.DisplayCollectionName != null) { var collectionNameLabel = entity.DisplayCollectionName.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (collectionNameLabel != null) { collectionName = collectionNameLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = collectionName; } } if (settings.ExportDescriptions) { // Description line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.MetadataId.Value.ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = entity.LogicalName; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Description"; foreach (var lcid in languages) { var description = string.Empty; if (entity.Description != null) { var descriptionLabel = entity.Description.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (descriptionLabel != null) { description = descriptionLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = description; } } } // Applying style to cells for (int i = 0; i < (3 + languages.Count); i++) { StyleMutator.TitleCell(ZeroBasedSheet.Cell(sheet, 0, i).Style); } for (int i = 1; i <= line; i++) { for (int j = 0; j < 3; j++) { StyleMutator.HighlightedCell(ZeroBasedSheet.Cell(sheet, i, j).Style); } } }
/// <summary> /// Builds a condition element from parsed data /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <returns>Condition string</returns> public override string BuildConditionElementFromParsedData(InventoryConditionResolver.InventoryConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings) { ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isPlayer ? TemplateType.TaleConditionPlayerInventory : TemplateType.TaleConditionNpcInventory).Result; StyrItem item = _cachedDbAccess.GetItemById(parsedData.ItemId).Result; if (item == null) { errorCollection.AddDialogItemNotFoundError(); return(string.Empty); } ExportObjectData itemExportData = new ExportObjectData(); itemExportData.ExportData.Add(ExportConstants.ExportDataObject, item); itemExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem); string conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionTemplate.Code, GetOperatorFromTemplate(project, parsedData.Operator, errorCollection)); conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Quantity).Replace(conditionCode, parsedData.Quantity.ToString()); conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_IsAtLeast_Start, Placeholder_Operator_IsAtLeast_End, parsedData.Operator == CompareOperator_AtLeast); conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_Operator_IsAtMaximum_Start, Placeholder_Operator_IsAtMaximum_End, parsedData.Operator == CompareOperator_AtMaximum); _itemPlaceholderResolver.SetErrorMessageCollection(errorCollection); conditionCode = _itemPlaceholderResolver.FillPlaceholders(conditionCode, itemExportData).Result; return(conditionCode); }
/// <summary> /// Builds an action from parsed data /// </summary> /// <param name="parsedData">Parsed data</param> /// <param name="data">Dialog data</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <returns>Action string</returns> public override async Task <string> BuildActionFromParsedData(PlayAnimationActionRenderer.PlayAnimationActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings) { ExportTemplate actionTemplate = await GetExportTemplate(project); IFlexFieldExportable valueObject = await GetNpc(flexFieldObject, errorCollection); if (valueObject == null) { return(string.Empty); } string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Animation).Replace(actionTemplate.Code, ExportUtil.EscapeCharacters(parsedData.AnimationName, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter)); ExportObjectData flexFieldExportData = new ExportObjectData(); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc); _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection); actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result; return(actionCode); }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="eventNpc">Npc to which the event belongs</param> /// <param name="exportEvent">Event to export</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="project">Project</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, SetDailyRoutineEventStateData parsedData, KortistoNpc eventNpc, KortistoNpcDailyRoutineEvent exportEvent, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, GoNorthProject project, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { string actionCode = await _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(template.Code, eventNpc, exportEvent); ExportObjectData flexFieldExportData = new ExportObjectData(); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, eventNpc); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc); _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection); actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result; return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject)); }
/// <summary> /// Doesn't run in the main thread /// </summary> public void ExportToOsb(bool exportOsb = true) { if (IsDisposed) { throw new ObjectDisposedException(nameof(Project)); } string osuPath = null, osbPath = null; List <EditorStoryboardLayer> localLayers = null; Program.RunMainThread(() => { osuPath = MainBeatmap.Path; osbPath = OsbPath; if (!OwnsOsb && File.Exists(osbPath)) { File.Copy(osbPath, $"{osbPath}.bak"); } OwnsOsb = true; localLayers = new List <EditorStoryboardLayer>(LayerManager.FindLayers(l => l.Visible)); }); var exportSettings = new ExportSettings(); var usesOverlayLayer = localLayers.Any(l => l.OsbLayer == OsbLayer.Overlay); if (!string.IsNullOrEmpty(osuPath)) { Debug.Print($"Exporting diff specific events to {osuPath}"); using (var stream = new SafeWriteStream(osuPath)) using (var writer = new StreamWriter(stream, Encoding)) using (var fileStream = new FileStream(osuPath, FileMode.Open, FileAccess.Read, FileShare.Read)) using (var reader = new StreamReader(fileStream, Encoding)) { string line; var inEvents = false; var inStoryboard = false; while ((line = reader.ReadLine()) != null) { var trimmedLine = line.Trim(); if (!inEvents && trimmedLine == "[Events]") { inEvents = true; } else if (trimmedLine.Length == 0) { inEvents = false; } if (inEvents) { if (trimmedLine.StartsWith("//Storyboard Layer")) { if (!inStoryboard) { foreach (var osbLayer in OsbLayers) { if (osbLayer == OsbLayer.Overlay && !usesOverlayLayer) { continue; } writer.WriteLine($"//Storyboard Layer {(int)osbLayer} ({osbLayer})"); foreach (var layer in localLayers) { if (layer.OsbLayer == osbLayer && layer.DiffSpecific) { layer.WriteOsbSprites(writer, exportSettings); } } } inStoryboard = true; } } else if (inStoryboard && trimmedLine.StartsWith("//")) { inStoryboard = false; } if (inStoryboard) { continue; } } writer.WriteLine(line); } stream.Commit(); } } if (exportOsb) { Debug.Print($"Exporting osb to {osbPath}"); using (var stream = new SafeWriteStream(osbPath)) using (var writer = new StreamWriter(stream, Encoding)) { writer.WriteLine("[Events]"); writer.WriteLine("//Background and Video events"); foreach (var osbLayer in OsbLayers) { if (osbLayer == OsbLayer.Overlay && !usesOverlayLayer) { continue; } writer.WriteLine($"//Storyboard Layer {(int)osbLayer} ({osbLayer})"); foreach (var layer in localLayers) { if (layer.OsbLayer == osbLayer && !layer.DiffSpecific) { layer.WriteOsbSprites(writer, exportSettings); } } } writer.WriteLine("//Storyboard Sound Samples"); stream.Commit(); } } }
public override void Export(Asset asset, string path) { Model model = (asset as Model); if (model.SupportingDocuments.ContainsKey("VehicleSetupConfig")) { ((VehicleSetupConfig)model.SupportingDocuments["VehicleSetupConfig"]).Save(path); } else { VehicleSetupConfig vehicleSetup = new VehicleSetupConfig(); vehicleSetup.Attachments.Add( new VehicleAttachment { Type = VehicleAttachment.AttachmentType.DynamicsWheels } ); vehicleSetup.WheelModules.Add( new VehicleWheelModule { Type = VehicleWheelModule.WheelModuleType.SkidMarks, SkidMarkImage = "skidmark" } ); vehicleSetup.WheelModules.Add( new VehicleWheelModule { Type = VehicleWheelModule.WheelModuleType.TyreParticles, TyreParticleVFX = "effects.drift" } ); vehicleSetup.WheelModules.Add( new VehicleWheelModule { Type = VehicleWheelModule.WheelModuleType.SkidNoise, SkidNoiseSound = "sounds\\tyre\\skid1,sounds\\tyre\\skid2" } ); vehicleSetup.Attachments.Add( new VehicleAttachment { Type = VehicleAttachment.AttachmentType.Horn, Horn = "generic02_horn" } ); vehicleSetup.WheelMaps.Add( new VehicleWheelMap { Name = "default", Localisation = $"FE_CAR_{ExportSettings.GetSetting<string>("VehicleName")}_RIM_DEFAULT", Wheels = new VehicleAttachmentComplicatedWheels { FLWheel = "default_eagle_R", FRWheel = "default_eagle_R", RLWheel = "default_eagle_R", RRWheel = "default_eagle_R" } } ); vehicleSetup.Stats.TopSpeed = 160; vehicleSetup.Stats.Time = 3.00f; vehicleSetup.Stats.Weight = 1.3f; vehicleSetup.Stats.Toughness = 1.4f; vehicleSetup.Stats.UnlockLevel = 0; vehicleSetup.Save(path); } }
private void butExport_Click(object sender, EventArgs e) { this.saveFileDialog.FileName = string.Empty; if (this.saveFileDialog.ShowDialog(this) == DialogResult.OK) { ExportFormat exportFormat = this.ConvertExportFileDialogFilterToExportFormat(this.saveFileDialog.FilterIndex); ExportSettings settings = new ExportSettings(); settings.Landscape = this.CurrentPageSettings.Landscape; settings.Margins = this.CurrentPageSettings.Margins; settings.PaperSize = this.CurrentPageSettings.PaperSize; // The same Report/PrintDocument is used to display the preview of the report on // this form and to export the report. In preview mode, the Total Pages calculation // is deactivated. We want to reactivate it before starting the export process. bool oldValue = m_report.CalculateTotalPages; m_report.CalculateTotalPages = true; try { m_report.Export(this.saveFileDialog.FileName, exportFormat, true, true, settings); } catch (Exception exception) { /* Something happened during export. * * Although the export code itself should not throw exceptions, we must * expect this to happen because of common situations like: * * - The file chosen by the user is opened by another process. * - The file chosen by the user is otherwise not accessible or writable. */ // Warn the user System.Windows.Forms.MessageBox.Show( String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}\n\n({1})", exception.Message, exception.GetType().FullName), "Export - Problem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } m_report.CalculateTotalPages = oldValue; } }
/// <summary> /// Print file paths only. /// </summary> /// <param name="settings">Export settings</param> /// <returns>print document as a string</returns> /// <history> /// [Curtis_Beard] 04/10/2015 CHG: move printing exporting here /// </history> public static string PrintFileList(ExportSettings settings) { StringBuilder document = new StringBuilder(); document.AppendLine("----------------------------------------------------------------------"); foreach (var match in settings.Grep.MatchResults) { document.AppendLine(match.File.FullName); document.AppendLine("----------------------------------------------------------------------"); } return document.ToString(); }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="valueItem">Item to export</param> /// <param name="valueNpc">Npc to export</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, UseItemActionData parsedData, IFlexFieldExportable valueItem, IFlexFieldExportable valueNpc, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { ScribanUseItemActionData useItemActionData = new ScribanUseItemActionData(); useItemActionData.Npc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, valueNpc, exportSettings, errorCollection); useItemActionData.SelectedItem = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportItem>(null, null, valueItem, exportSettings, errorCollection); return(await ScribanActionRenderingUtil.FillPlaceholders(_cachedDbAccess, errorCollection, template.Code, useItemActionData, flexFieldObject, curStep, nextStep, _scribanLanguageKeyGenerator, stepRenderer)); }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected abstract Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, CodeActionData parsedData, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer);
/// <summary> /// Constructor /// </summary> /// <param name="exportCachedDbAccess">Export cached Db access</param> /// <param name="errorCollection">Error Collection</param> /// <param name="defaultTemplateProvider">Default Template Provider</param> /// <param name="languageKeyGenerator">Language Key Generator</param> /// <param name="conditionRenderer">Condition Renderer</param> /// <param name="localizerFactory">Localizer Factory</param> /// <param name="exportSettings">Export Settings</param> /// <param name="project">Project</param> public ExportDialogConditionRenderer(IExportCachedDbAccess exportCachedDbAccess, ExportPlaceholderErrorCollection errorCollection, ICachedExportDefaultTemplateProvider defaultTemplateProvider, ILanguageKeyGenerator languageKeyGenerator, IConditionRenderer conditionRenderer, IStringLocalizerFactory localizerFactory, ExportSettings exportSettings, GoNorthProject project) { _errorCollection = errorCollection; _defaultTemplateProvider = defaultTemplateProvider; _conditionRenderer = conditionRenderer; _exportSettings = exportSettings; _localizer = localizerFactory.Create(typeof(ExportDialogConditionRenderer)); _project = project; _renderers = new Dictionary <ExportTemplateRenderingEngine, IConditionStepRenderer> { { ExportTemplateRenderingEngine.Legacy, new LegacyConditionStepRenderer(languageKeyGenerator, exportSettings, errorCollection, conditionRenderer, localizerFactory, project) }, { ExportTemplateRenderingEngine.Scriban, new ScribanConditionStepRenderer(exportCachedDbAccess, exportSettings, errorCollection, conditionRenderer, localizerFactory, project) } }; }
/// <summary> /// /// </summary> /// <example> /// OptionSet Id;OptionSet Name;OptionSetValue;Type;LCID1;LCID2;...;LCIDX /// </example> /// <param name="languages"></param> /// <param name="sheet"></param> /// <param name="service"></param> /// <param name="settings"></param> public void Export(List <int> languages, ExcelWorksheet sheet, IOrganizationService service, ExportSettings settings) { var line = 0; AddHeader(sheet, languages); var request = new RetrieveAllOptionSetsRequest(); var response = (RetrieveAllOptionSetsResponse)service.Execute(request); var omds = response.OptionSetMetadata; if (settings.SolutionId != Guid.Empty) { var oids = service.GetSolutionComponentObjectIds(settings.SolutionId, 9); // 9 = Global OptionSets omds = omds.Where(o => oids.Contains(o.MetadataId ?? Guid.Empty)).ToArray(); } foreach (var omd in omds) { int cell; if (omd is OptionSetMetadata oomd) { foreach (var option in oomd.Options.OrderBy(o => o.Value)) { if (settings.ExportNames) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (oomd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = oomd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = option.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Label"; foreach (var lcid in languages) { var label = string.Empty; var optionLabel = option.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionLabel != null) { label = optionLabel.Label; } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } if (settings.ExportDescriptions) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (oomd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = oomd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = option.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Description"; foreach (var lcid in languages) { var label = string.Empty; var optionDescription = option.Description.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionDescription != null) { label = optionDescription.Label; } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } } } else if (omd is BooleanOptionSetMetadata) { var bomd = (BooleanOptionSetMetadata)omd; if (settings.ExportNames) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (omd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = omd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = bomd.FalseOption.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Label"; foreach (var lcid in languages) { var label = string.Empty; if (bomd.FalseOption.Label != null) { var optionLabel = bomd.FalseOption.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionLabel != null) { label = optionLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } if (settings.ExportDescriptions) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (omd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = omd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = bomd.FalseOption.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Description"; foreach (var lcid in languages) { var label = string.Empty; if (bomd.FalseOption.Description != null) { var optionLabel = bomd.FalseOption.Description.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionLabel != null) { label = optionLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } if (settings.ExportNames) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (omd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = omd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = bomd.TrueOption.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Label"; foreach (var lcid in languages) { var label = string.Empty; if (bomd.TrueOption.Label != null) { var optionLabel = bomd.TrueOption.Label.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionLabel != null) { label = optionLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } if (settings.ExportDescriptions) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = (omd.MetadataId ?? Guid.Empty).ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = omd.Name; ZeroBasedSheet.Cell(sheet, line, cell++).Value = bomd.TrueOption.Value; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Description"; foreach (var lcid in languages) { var label = string.Empty; if (bomd.TrueOption.Description != null) { var optionLabel = bomd.TrueOption.Description.LocalizedLabels.FirstOrDefault(l => l.LanguageCode == lcid); if (optionLabel != null) { label = optionLabel.Label; } } ZeroBasedSheet.Cell(sheet, line, cell++).Value = label; } } } } // Applying style to cells for (int i = 0; i < (4 + languages.Count); i++) { StyleMutator.TitleCell(ZeroBasedSheet.Cell(sheet, 0, i).Style); } for (int i = 1; i <= line; i++) { for (int j = 0; j < 4; j++) { StyleMutator.HighlightedCell(ZeroBasedSheet.Cell(sheet, i, j).Style); } } }
//StorageFile file, public DiagramVM(string file, bool isValidXml) { _isValidXml = isValidXml; _file = file; Title = "Page"; DiagramType = DiagramType.Blank; Nodes = new ObservableCollection <NodeVM>(); Connectors = new ObservableCollection <ConnectorVM>(); Groups = new ObservableCollection <GroupVM>(); SelectedItems = new SelectorVM(this); PortVisibility = PortVisibility.MouseOverOnConnect; Select = new Command(param => IsSelected = true); FirstLoad = new Command(OnViewLoaded); HistoryManager = new customManager(); SnapSettings = new SnapSettings() { SnapConstraints = SnapConstraints.All, SnapToObject = SnapToObject.All }; Theme = new OfficeTheme(); PreviewSettings = new PreviewSettings() { PreviewMode = PreviewMode.Preview }; PageSettings = new PageVM(); (PageSettings as PageVM).InitDiagram(this); this.HorizontalRuler = new Ruler() { Orientation = Orientation.Horizontal }; this.VerticalRuler = new Ruler() { Orientation = Orientation.Vertical }; //OffPageBackground = new SolidColorBrush(new Color() { A = 0xFF, R = 0xEC, G = 0xEC, B = 0xEC }); //OffPageBackground = new SolidColorBrush(new Color() { A = 0xFF, R = 0x2D, G = 0x2D, B = 0x2D }); InitLocation(); PrintingService = new PrintingService(); ExportSettings = new ExportSettings() { ImageStretch = Stretch.Uniform, ExportMode = ExportMode.PageSettings }; #if SyncfusionFramework4_5_1 ExportSettings = new ExportSettings() { ImageStretch = Stretch.Uniform, ExportMode = ExportMode.PageSettings }; PrintingService = new PrintingService(); #endif FlipCommand = new Command(OnFlipCommand); ExportCommand = new Command(OnExportCommand); PrintCommand = new Command(OnPrintCommand); Captures = new Command(OnCapturesCommand); ClearDiagram = new Command(OnClearCommand); Upload = new Command(Onuploadcommand); Draw = new Command(OnDrawCommand); SingleSelect = new Command(OnSingleSelectCommand); SelectAll = new Command(OnSelectAllCommand); Manipulate = new Command(OnManipulateCommand); LoadExt = new Command(OnLoadExt); AddImageNode = new Command(OnAddImageNodeCommand); PageOrientationCommand = new Command(OnPageOrientationCommand); PageSizeCommand = new Command(OnPageSizeCommand); ConnectTypeCommand = new Command(OnConnectTypeCommand); RotateTextCommand = new Command(OnRotateTextCommand); //SelectTextCommand = new Command(OnSelectTextCommand); SizeandPositionCommand = new Command(OnSizeandPositionCommand); PanZoomCommand = new Command(OnPanZoomCommand); FitToWidthCommand = new Command(OnFitToWidthCommand); FitToPageCommand = new Command(OnFitToPageCommand); this.Constraints |= GraphConstraints.Undoable; //Tool = Tool.ZoomPan | Tool.SingleSelect; ; //ConnectorVM c = new ConnectorVM() //{ // SourcePoint = new Point(100, 100), // TargetPoint = new Point(300, 300) //}; //(this.ConnectorCollection as ICollection<ConnectorVM>).Add(c); }
protected abstract string GetCommandGroupHeader(ExportSettings exportSettings);
/// <summary> /// Print selected match results. /// </summary> /// <param name="settings">Export settings</param> /// <returns>print document as a string</returns> /// <history> /// [Curtis_Beard] 04/10/2015 CHG: move printing exporting here /// </history> public static string PrintSelected(ExportSettings settings) { StringBuilder document = new StringBuilder(); MatchResult match = null; for (int i = 0; i < settings.GrepIndexes.Count; i++) { match = settings.Grep.MatchResults[settings.GrepIndexes[i]]; document.AppendLine("----------------------------------------------------------------------"); document.AppendLine(match.File.FullName); document.AppendLine("----------------------------------------------------------------------"); for (int j = 0; j < match.Matches.Count; j++) { var matchLine = match.Matches[j]; if (matchLine.LineNumber > -1) { document.AppendLine(string.Format("{0}: {1}", matchLine.LineNumber, matchLine.Line)); } else { document.AppendLine(string.Empty); } } document.AppendLine(string.Empty); } return document.ToString(); }
/// <summary> /// Constructor /// </summary> /// <param name="exportCachedDbAccess">Export cached Db access</param> /// <param name="errorCollection">Error Collection</param> /// <param name="defaultTemplateProvider">Default Template Provider</param> /// <param name="dailyRoutineFunctionNameGenerator">Daily routine function name generator</param> /// <param name="scribanLanguageKeyGenerator">Scriban Language key generator</param> /// <param name="localizerFactory">Localizer Factory</param> /// <param name="exportSettings">Export Settings</param> /// <param name="project">Project</param> public ExportReferenceRenderer(IExportCachedDbAccess exportCachedDbAccess, ExportPlaceholderErrorCollection errorCollection, ICachedExportDefaultTemplateProvider defaultTemplateProvider, IDailyRoutineFunctionNameGenerator dailyRoutineFunctionNameGenerator, IScribanLanguageKeyGenerator scribanLanguageKeyGenerator, IStringLocalizerFactory localizerFactory, ExportSettings exportSettings, GoNorthProject project) { _errorCollection = errorCollection; _defaultTemplateProvider = defaultTemplateProvider; _exportCachedDbAccess = exportCachedDbAccess; _localizer = localizerFactory.Create(typeof(ExportReferenceRenderer)); _project = project; _renderers = new Dictionary <ExportTemplateRenderingEngine, IReferenceStepRenderer> { { ExportTemplateRenderingEngine.Scriban, new ScribanReferenceStepRenderer(exportCachedDbAccess, dailyRoutineFunctionNameGenerator, exportSettings, errorCollection, scribanLanguageKeyGenerator, localizerFactory) } }; }
/// <summary> /// Save results to a file with json formatting. /// </summary> /// <param name="settings">Export settings</param> /// <history> /// [Curtis_Beard] 10/30/2012 Created /// [Curtis_Beard] 02/12/2014 CHG: handle file search only better /// [Curtis_Beard] 10/27/2014 CHG: 85, remove leading white space /// [Curtis_Beard] 11/11/2014 ADD: export all filteritems /// [Curtis_Beard] 12/03/2014 CHG: use grepIndexes instead of ListView /// [Curtis_Beard] 04/08/2015 CHG: update export delegate with settings class /// </history> public static void SaveResultsAsJSON(ExportSettings settings) { // Open the file using (var writer = new StreamWriter(settings.Path, false, System.Text.Encoding.UTF8)) { bool isFileSearch = string.IsNullOrEmpty(settings.Grep.SearchSpec.SearchText); writer.WriteLine("{"); // write out search options writer.WriteLine("\t\"options\":"); writer.WriteLine("\t{"); writer.WriteLine(string.Format("\t\t\"searchPaths\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.StartDirectories))); writer.WriteLine(string.Format("\t\t\"fileTypes\":{0},", JSONHelper.ToJSONString(settings.Grep.FileFilterSpec.FileFilter))); writer.WriteLine(string.Format("\t\t\"searchText\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.SearchText))); writer.WriteLine(string.Format("\t\t\"regularExpressions\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.UseRegularExpressions))); writer.WriteLine(string.Format("\t\t\"caseSensitive\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.UseCaseSensitivity))); writer.WriteLine(string.Format("\t\t\"wholeWord\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.UseWholeWordMatching))); writer.WriteLine(string.Format("\t\t\"subFolders\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.SearchInSubfolders))); writer.WriteLine(string.Format("\t\t\"showFileNamesOnly\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.ReturnOnlyFileNames))); writer.WriteLine(string.Format("\t\t\"negation\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.UseNegation))); writer.WriteLine(string.Format("\t\t\"lineNumbers\":{0},", JSONHelper.ToJSONString(settings.ShowLineNumbers))); writer.WriteLine(string.Format("\t\t\"removeLeadingWhiteSpace\":{0},", JSONHelper.ToJSONString(settings.RemoveLeadingWhiteSpace))); writer.WriteLine(string.Format("\t\t\"contextLines\":{0},", JSONHelper.ToJSONString(settings.Grep.SearchSpec.ContextLines))); // filter items if (settings.Grep.FileFilterSpec.FilterItems != null) { writer.WriteLine("\t\t\"exclusions\":"); writer.WriteLine("\t\t\t["); foreach (FilterItem item in settings.Grep.FileFilterSpec.FilterItems) { writer.Write("\t\t\t\t{"); string option = item.ValueOption.ToString(); if (item.ValueOption == FilterType.ValueOptions.None) { option = string.Empty; } writer.Write(string.Format("\"category\":{0}, ", JSONHelper.ToJSONString(item.FilterType.Category.ToString()))); writer.Write(string.Format("\"type\":{0}, ", JSONHelper.ToJSONString(item.FilterType.SubCategory.ToString()))); writer.Write(string.Format("\"value\":{0}, ", JSONHelper.ToJSONString(item.Value))); writer.Write(string.Format("\"options\":{0}, ", JSONHelper.ToJSONString(option))); writer.Write(string.Format("\"ignoreCase\":{0}, ", JSONHelper.ToJSONString(item.ValueIgnoreCase.ToString()))); writer.Write(string.Format("\"sizeType\":{0}", JSONHelper.ToJSONString(item.ValueSizeOption.ToString()))); writer.WriteLine("}"); } writer.WriteLine("\t\t\t]"); } writer.WriteLine("\t},"); // end options writer.WriteLine(); writer.WriteLine("\t\"search\":"); writer.WriteLine("\t{"); writer.WriteLine(string.Format("\t\t\"totalfiles\":{0},", JSONHelper.ToJSONString(settings.Grep.MatchResults.Count))); // get total hits int totalHits = 0; for (int i = 0; i < settings.GrepIndexes.Count; i++) { var _hit = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); // add to total totalHits += _hit.HitCount; } writer.WriteLine(string.Format("\t\t\"totalfound\":{0},", JSONHelper.ToJSONString(totalHits))); writer.WriteLine("\t\t\"items\":"); writer.WriteLine("\t\t\t["); for (int i = 0; i < settings.GrepIndexes.Count; i++) { var _hit = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); writer.WriteLine("\t\t\t\t{"); writer.WriteLine(string.Format("\t\t\t\t\t\"file\":{0},", JSONHelper.ToJSONString(_hit.File.FullName))); writer.WriteLine(string.Format("\t\t\t\t\t\"total\":{0},", JSONHelper.ToJSONString(_hit.HitCount))); // write out lines if (!isFileSearch && !settings.Grep.SearchSpec.ReturnOnlyFileNames) { writer.Write("\t\t\t\t\t\"lines\":["); for (int j = 0; j < _hit.Matches.Count; j++) { if (j > 0) { writer.Write(","); } string line = _hit.Matches[j].Line; if (settings.RemoveLeadingWhiteSpace) { line = line.TrimStart(); } if (settings.ShowLineNumbers && _hit.Matches[j].LineNumber > -1) { line = string.Format("{0}: {1}", _hit.Matches[j].LineNumber, line); } writer.Write(JSONHelper.ToJSONString(line)); } writer.WriteLine("]"); // end lines } string itemEnd = i + 1 < settings.GrepIndexes.Count ? "\t\t\t\t}," : "\t\t\t\t}"; writer.WriteLine(itemEnd); // end item } writer.WriteLine("\t\t\t]"); // end items writer.WriteLine("\t}"); // end search writer.Write("}"); // end all } }
/// <summary> /// Builds an action /// </summary> /// <param name="action">Current action</param> /// <param name="data">Dialog data</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Action Build Result</returns> public async Task <string> BuildActionElement(ActionNode action, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { ExportTemplate template = await _templateProvider.GetDefaultTemplateByType(project.Id, _templateType); if (!_renderers.ContainsKey(template.RenderingEngine)) { throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for Action {1}", template.RenderingEngine.ToString(), _templateType.ToString())); } return(await _renderers[template.RenderingEngine].BuildActionElement(template, action, data, project, errorCollection, flexFieldObject, exportSettings, stepRenderer)); }
/// <summary> /// Save results to a xml file /// </summary> /// <param name="settings">Export settings</param> /// <history> /// [Curtis_Beard] 09/06/2006 Created /// [Andrew_Radford] 20/09/2009 Extracted from main form code-behind /// [Curtis_Beard] 01/31/2012 ADD: display for additional options (skip hidden/system options, search paths, modified dates, file sizes) /// [Curtis_Beard] 10/30/2012 ADD: file hit count, CHG: recurse to subFolders /// [Curtis_Beard] 02/12/2014 CHG: handle file search only better /// [Curtis_Beard] 10/27/2014 CHG: 85, remove leading white space /// [Curtis_Beard] 11/11/2014 ADD: export all filteritems /// [Curtis_Beard] 12/03/2014 CHG: use grepIndexes instead of ListView /// [Curtis_Beard] 04/08/2015 CHG: update export delegate with settings class /// </history> public static void SaveResultsAsXML(ExportSettings settings) { using (var writer = new XmlTextWriter(settings.Path, Encoding.UTF8)) { bool isFileSearch = string.IsNullOrEmpty(settings.Grep.SearchSpec.SearchText); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(true); writer.WriteStartElement("astrogrep"); writer.WriteAttributeString("version", "1.0"); // write out search options writer.WriteStartElement("options"); writer.WriteElementString("searchPaths", string.Join(", ", settings.Grep.SearchSpec.StartDirectories)); writer.WriteElementString("fileTypes", settings.Grep.FileFilterSpec.FileFilter); writer.WriteElementString("searchText", settings.Grep.SearchSpec.SearchText); writer.WriteElementString("regularExpressions", settings.Grep.SearchSpec.UseRegularExpressions.ToString()); writer.WriteElementString("caseSensitive", settings.Grep.SearchSpec.UseCaseSensitivity.ToString()); writer.WriteElementString("wholeWord", settings.Grep.SearchSpec.UseWholeWordMatching.ToString()); writer.WriteElementString("subFolders", settings.Grep.SearchSpec.SearchInSubfolders.ToString()); writer.WriteElementString("showFileNamesOnly", settings.Grep.SearchSpec.ReturnOnlyFileNames.ToString()); writer.WriteElementString("negation", settings.Grep.SearchSpec.UseNegation.ToString()); writer.WriteElementString("lineNumbers", settings.ShowLineNumbers.ToString()); writer.WriteElementString("removeLeadingWhiteSpace", settings.RemoveLeadingWhiteSpace.ToString()); writer.WriteElementString("contextLines", settings.Grep.SearchSpec.ContextLines.ToString()); // filter items if (settings.Grep.FileFilterSpec.FilterItems != null) { writer.WriteStartElement("exclusions"); foreach (FilterItem item in settings.Grep.FileFilterSpec.FilterItems) { string option = item.ValueOption.ToString(); if (item.ValueOption == FilterType.ValueOptions.None) { option = string.Empty; } writer.WriteStartElement("exclusion"); writer.WriteAttributeString("category", item.FilterType.Category.ToString()); writer.WriteAttributeString("type", item.FilterType.SubCategory.ToString()); writer.WriteAttributeString("value", item.Value); writer.WriteAttributeString("options", option); writer.WriteAttributeString("ignoreCase", item.ValueIgnoreCase.ToString()); writer.WriteAttributeString("sizeType", item.ValueSizeOption); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); // end options writer.WriteStartElement("search"); writer.WriteAttributeString("totalfiles", settings.Grep.MatchResults.Count.ToString()); // get total hits int totalHits = 0; for (int i = 0; i < settings.GrepIndexes.Count; i++) { var _hit = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); // add to total totalHits += _hit.HitCount; } writer.WriteAttributeString("totalfound", totalHits.ToString()); for (int i = 0; i < settings.GrepIndexes.Count; i++) { writer.WriteStartElement("item"); var _hit = settings.Grep.RetrieveMatchResult(settings.GrepIndexes[i]); writer.WriteAttributeString("file", _hit.File.FullName); writer.WriteAttributeString("total", _hit.HitCount.ToString()); // write out lines if (!isFileSearch && !settings.Grep.SearchSpec.ReturnOnlyFileNames) { for (int j = 0; j < _hit.Matches.Count; j++) { string line = _hit.Matches[j].Line; if (settings.RemoveLeadingWhiteSpace) { line = line.TrimStart(); } if (settings.ShowLineNumbers && _hit.Matches[j].LineNumber > -1) { line = string.Format("{0}: {1}", _hit.Matches[j].LineNumber, line); } writer.WriteElementString("line", line); } } writer.WriteEndElement(); } writer.WriteEndElement(); //search writer.WriteEndElement(); //astrogrep } }
/// <summary> /// Builds a flex field value object /// </summary> /// <param name="dailyRoutineFunctionNameGenerator">Daily routine function name generator</param> /// <param name="npc">Npc to which the event belongs</param> /// <param name="exportEvent">Export event</param> /// <param name="project">Project</param> /// <param name="projectConfig">Project config</param> /// <param name="exportSettings">Export settings</param> /// <returns>Converted value</returns> public static async Task <ScribanExportDailyRoutineEvent> ConvertDailyRoutineEvent(IDailyRoutineFunctionNameGenerator dailyRoutineFunctionNameGenerator, KortistoNpc npc, KortistoNpcDailyRoutineEvent exportEvent, GoNorthProject project, MiscProjectConfig projectConfig, ExportSettings exportSettings) { ScribanExportDailyRoutineEvent convertedEvent = new ScribanExportDailyRoutineEvent(); convertedEvent.OriginalEvent = exportEvent; convertedEvent.EventId = exportEvent.EventId; convertedEvent.EarliestTime = ConvertEventTime(exportEvent.EarliestTime, projectConfig); convertedEvent.LatestTime = ConvertEventTime(exportEvent.LatestTime, projectConfig); convertedEvent.UnescapedMovementTarget = exportEvent.MovementTarget != null && !string.IsNullOrEmpty(exportEvent.MovementTarget.Name) ? exportEvent.MovementTarget.Name : null; convertedEvent.UnescapedMovementTargetExportName = exportEvent.MovementTarget != null && !string.IsNullOrEmpty(exportEvent.MovementTarget.ExportName) ? exportEvent.MovementTarget.ExportName : null; convertedEvent.UnescapedMovementTargetExportNameOrName = GetMovementTargetExportNameOrName(exportEvent.MovementTarget); convertedEvent.MovementTarget = EscapeValueIfExist(convertedEvent.UnescapedMovementTarget, exportSettings); convertedEvent.MovementTargetExportName = EscapeValueIfExist(convertedEvent.UnescapedMovementTargetExportName, exportSettings); convertedEvent.MovementTargetExportNameOrName = EscapeValueIfExist(convertedEvent.UnescapedMovementTargetExportNameOrName, exportSettings); convertedEvent.ScriptType = ScribanScriptUtil.ConvertScriptType(exportEvent.ScriptType); if (exportEvent.ScriptType != ExportConstants.ScriptType_None) { convertedEvent.ScriptName = exportEvent.ScriptName; convertedEvent.ScriptFunctionName = await dailyRoutineFunctionNameGenerator.GetNewDailyRoutineStepFunction(project.Id, npc.Id, exportEvent.EventId); } else { convertedEvent.ScriptName = null; convertedEvent.ScriptFunctionName = null; } convertedEvent.TargetState = !string.IsNullOrEmpty(exportEvent.TargetState) ? exportEvent.TargetState : null; convertedEvent.IsEnabledByDefault = exportEvent.EnabledByDefault; return(convertedEvent); }
// StorageFile file, /// <summary> /// Initializes a new instance of the <see cref="DiagramVM"/> class. /// </summary> /// <param name="file"> /// The file. /// </param> /// <param name="isValidXml"> /// The is valid xml. /// </param> public DiagramVM(string file, bool isValidXml) { this._isValidXml = isValidXml; this._file = file; this.Title = "Page"; if (this is OrganizationChartDiagramVM) { this.DiagramType = DiagramType.OrganizationChart; } else if (this is BrainstormingVM) { this.DiagramType = DiagramType.Brainstorming; } else if (this is FlowDiagramVm) { this.DiagramType = DiagramType.FlowChart; } else { this.DiagramType = DiagramType.Blank; } this.Nodes = new ObservableCollection <NodeVM>(); this.Connectors = new ObservableCollection <ConnectorVM>(); this.Groups = new ObservableCollection <GroupVM>(); this.SelectedItems = new SelectorVM(this); this.PortVisibility = PortVisibility.MouseOverOnConnect; this.FirstLoad = new Command(this.OnViewLoaded); this.HistoryManager = new CustomHistoryManager(); this.SnapSettings = new SnapSettings { SnapConstraints = SnapConstraints.All, SnapToObject = SnapToObject.All }; // Theme = new OfficeTheme(); this.PreviewSettings = new PreviewSettings { PreviewMode = PreviewMode.Preview }; LayoutManager = new LayoutManager(); DataSourceSettings = new DataSourceSettings(); this.PageSettings = new PageVM(); this.ScrollSettings = new ScrollSettings(); (this.PageSettings as PageVM).InitDiagram(this); this.HorizontalRuler = new Ruler { Orientation = Orientation.Horizontal }; this.VerticalRuler = new Ruler { Orientation = Orientation.Vertical }; this.InitLocation(); this.PrintingService = new PrintingService(); this.ExportSettings = new ExportSettings { ImageStretch = Stretch.Uniform, ExportMode = ExportMode.PageSettings }; #if SyncfusionFramework4_5_1 ExportSettings = new ExportSettings() { ImageStretch = Stretch.Uniform, ExportMode = ExportMode.PageSettings }; PrintingService = new PrintingService(); #endif this.FlipCommand = new Command(this.OnFlipCommand); this.ExportCommand = new Command(this.OnExportCommand); this.PrintCommand = new Command(this.OnPrintCommand); this.AddImageNode = new Command(this.OnAddImageNodeCommand); this.PageOrientationCommand = new Command(this.OnPageOrientationCommand); this.PageSizeCommand = new Command(this.OnPageSizeCommand); this.ConnectTypeCommand = new Command(this.OnConnectTypeCommand); this.SingleSelect = new Command(this.OnSingleSelectCommand); this.SizeAndPositionCommand = new Command(this.OnSizeAndPositionCommand); this.PanZoomCommand = new Command(this.OnPanZoomCommand); this.FitToWidthCommand = new Command(this.OnFitToWidthCommand); this.FitToPageCommand = new Command(this.OnFitToPageCommand); this.Constraints |= GraphConstraints.Undoable; }
/// <summary> /// Builds an action from parsed data /// </summary> /// <param name="template">Template to export</param> /// <param name="parsedData">Parsed data</param> /// <param name="data">Dialog data</param> /// <param name="nextStep">Next step in the dialog</param> /// <param name="project">Project</param> /// <param name="errorCollection">Error Collection</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Action string</returns> public override async Task <string> BuildActionFromParsedData(ExportTemplate template, SetDailyRoutineEventStateData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { KortistoNpc eventNpc = await _cachedDbAccess.GetNpcById(parsedData.NpcId); if (eventNpc == null) { return(string.Empty); } KortistoNpcDailyRoutineEvent exportEvent = null; if (eventNpc.DailyRoutine != null) { exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId); } if (exportEvent == null) { errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name); return(string.Empty); } return(await FillPlaceholders(template, errorCollection, parsedData, eventNpc, exportEvent, flexFieldObject, data, nextStep, project, exportSettings, stepRenderer)); }
public static void Export(GameObject[] gameObjects, string saveFileName, ExportSettings settings) { MeshConverter.ClearCaches(); TextureConverter.ClearCaches(); MaterialConverter.ClearCaches(); ShaderMappingIO.ClearCaches(); GraphBuilderInterface.unity2vsg_BeginExport(); List <PipelineData> storePipelines = new List <PipelineData>(); bool insideLODGroup = false; bool firstNodeAdded = false; System.Action <GameObject> processGameObject = null; processGameObject = (GameObject go) => { // determine the gameObject type Transform gotrans = go.transform; bool nodeAdded = false; // does it have a none identiy local matrix if (gotrans.localPosition != Vector3.zero || gotrans.localRotation != Quaternion.identity || gotrans.localScale != Vector3.one) { if (firstNodeAdded || !settings.zeroRootTransform) { // add as a transform TransformData transformdata = TransformConverter.CreateTransformData(gotrans); GraphBuilderInterface.unity2vsg_AddTransformNode(transformdata); nodeAdded = true; } } // do we need to insert a group if (!nodeAdded)// && gotrans.childCount > 0) { //add as a group GraphBuilderInterface.unity2vsg_AddGroupNode(); nodeAdded = true; } firstNodeAdded = true; bool meshexported = false; // get the meshrender here so we can check if the LOD exports the the mesh MeshFilter meshFilter = go.GetComponent <MeshFilter>(); MeshRenderer meshRenderer = go.GetComponent <MeshRenderer>(); // does this node have an LOD group LODGroup lodgroup = go.GetComponent <LODGroup>(); if (lodgroup != null && !insideLODGroup) { // rather than process the children we figure out which renderers are in which children and add them as LOD children LOD[] lods = lodgroup.GetLODs(); if (lods.Length > 0) { // get bounds from first renderer if (lods[0].renderers.Length > 0) { CullData lodCullData = new CullData(); Bounds bounds = new Bounds(lods[0].renderers[0].bounds.center, lods[0].renderers[0].bounds.size); foreach (Renderer boundsrenderer in lods[0].renderers) { if (boundsrenderer != null) { bounds.Encapsulate(boundsrenderer.bounds); } } Vector3 center = bounds.center - gotrans.position; CoordSytemConverter.Convert(ref center); lodCullData.center = NativeUtils.ToNative(center); lodCullData.radius = bounds.size.magnitude * 0.5f; GraphBuilderInterface.unity2vsg_AddLODNode(lodCullData); insideLODGroup = true; for (int i = 0; i < lods.Length; i++) { // for now just support one renderer and assume it's under a seperate child gameObject if (lods[i].renderers.Length == 0) { continue; } LODChildData lodChild = new LODChildData(); lodChild.minimumScreenHeightRatio = lods[i].screenRelativeTransitionHeight; GraphBuilderInterface.unity2vsg_AddLODChild(lodChild); foreach (Renderer lodrenderer in lods[i].renderers) { if (lodrenderer == meshRenderer) { meshexported = true; ExportMesh(meshFilter.sharedMesh, meshRenderer, gotrans, settings, storePipelines); } else if (lodrenderer != null) { // now process the renderers gameobject, it'll be added to the group we just created by adding an LOD child processGameObject(lodrenderer.gameObject); } } GraphBuilderInterface.unity2vsg_EndNode(); } insideLODGroup = false; GraphBuilderInterface.unity2vsg_EndNode(); // end the lod node } } } else { // transverse any children for (int i = 0; i < gotrans.childCount; i++) { processGameObject(gotrans.GetChild(i).gameObject); } } // does it have a mesh if (!meshexported && meshFilter && meshFilter.sharedMesh && meshRenderer) { Mesh mesh = meshFilter.sharedMesh; ExportMesh(mesh, meshRenderer, gotrans, settings, storePipelines); } // does this node have a terrain Terrain terrain = go.GetComponent <Terrain>(); if (terrain != null) { ExportTerrainMesh(terrain, settings, storePipelines); } // if we added a group or transform step out if (nodeAdded) { GraphBuilderInterface.unity2vsg_EndNode(); } }; foreach (GameObject go in gameObjects) { processGameObject(go); } //GraphBuilderInterface.unity2vsg_EndNode(); // step out of convert coord system node GraphBuilderInterface.unity2vsg_EndExport(saveFileName); NativeLog.PrintReport(); }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="eventNpc">Npc to which the event belongs</param> /// <param name="exportEvent">Event to export</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="project">Project</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected abstract Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, SetDailyRoutineEventStateData parsedData, KortistoNpc eventNpc, KortistoNpcDailyRoutineEvent exportEvent, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, GoNorthProject project, ExportSettings exportSettings, IActionStepRenderer stepRenderer);
private List <EntityResult> RetrieveNnRecords(ExportSettings settings, List <Entity> records) { var ers = new List <EntityResult>(); var rels = new List <ManyToManyRelationshipMetadata>(); foreach (var emd in settings.Entities) { foreach (var mm in emd.ManyToManyRelationships) { var e1 = mm.Entity1LogicalName; var e2 = mm.Entity2LogicalName; var isValid = false; if (e1 == emd.LogicalName) { if (settings.Entities.Any(e => e.LogicalName == e2)) { isValid = true; } } else { if (settings.Entities.Any(e => e.LogicalName == e1)) { isValid = true; } } if (isValid && rels.All(r => r.IntersectEntityName != mm.IntersectEntityName)) { rels.Add(mm); } } } foreach (var mm in rels) { var ids = records.Where(r => r.LogicalName == mm.Entity1LogicalName).Select(r => r.Id).ToList(); if (!ids.Any()) { continue; } var query = new QueryExpression(mm.IntersectEntityName) { ColumnSet = new ColumnSet(true), Criteria = new FilterExpression { Conditions = { new ConditionExpression(mm.Entity1IntersectAttribute, ConditionOperator.In, ids.ToArray()) } } }; ers.Add(new EntityResult { Records = Service.RetrieveMultiple(query) }); } return(ers); }
private void DrawSections(ExportSettings settings) { DrawDetails(settings); DrawContentSection(settings); DrawExportOptions(settings); }
/// <summary> /// Builds the language key list /// </summary> /// <param name="languageKeyTemplate">Template for a language key</param> /// <param name="languageKeys">Language keys</param> /// <param name="exportSettings">Export Settings</param> /// <returns>Language Key list</returns> private string BuildLanguageKeyList(string languageKeyTemplate, List <LanguageKey> languageKeys, ExportSettings exportSettings) { string listContent = string.Empty; for (int curLanguagekey = 0; curLanguagekey < languageKeys.Count; ++curLanguagekey) { LanguageKey languageKey = languageKeys[curLanguagekey]; string keyCode = ExportUtil.RenderPlaceholderIfTrue(languageKeyTemplate, Placeholder_LanguageKeys_IsFirst_Start, Placeholder_LanguageKeys_IsFirst_End, curLanguagekey == 0); keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsNotFirst_Start, Placeholder_LanguageKeys_IsNotFirst_End, curLanguagekey != 0); keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsLast_Start, Placeholder_LanguageKeys_IsLast_End, curLanguagekey >= languageKeys.Count - 1); keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsNotLast_Start, Placeholder_LanguageKeys_IsNotLast_End, curLanguagekey < languageKeys.Count - 1); keyCode = ExportUtil.BuildPlaceholderRegex(Placeholder_LanguageKey_Key).Replace(keyCode, languageKey.LangKey); string escapedText = ExportUtil.EscapeCharacters(languageKey.Value, exportSettings.LanguageEscapeCharacter, exportSettings.LanguageCharactersNeedingEscaping, exportSettings.LanguageNewlineCharacter); keyCode = ExportUtil.BuildPlaceholderRegex(Placeholder_LanguageKey_Text).Replace(keyCode, escapedText); listContent += keyCode; } return(listContent); }
/// <summary> /// /// </summary> /// <example> /// visualizationId;entityLogicalName;visualizationName;LCID1;LCID2;...;LCODX /// </example> /// <param name="entities"></param> /// <param name="languages"></param> /// <param name="sheet"></param> /// <param name="service"></param> /// <param name="settings"></param> public void Export(List <EntityMetadata> entities, List <int> languages, ExcelWorksheet sheet, IOrganizationService service, ExportSettings settings) { var line = 0; int cell; AddHeader(sheet, languages); var crmVisualizations = new List <CrmVisualization>(); foreach (var entity in entities.OrderBy(e => e.LogicalName)) { if (!entity.MetadataId.HasValue) { continue; } var visualizations = RetrieveVisualizations(entity.ObjectTypeCode.Value, service); foreach (var visualization in visualizations) { var crmVisualization = crmVisualizations.FirstOrDefault(cv => cv.Id == visualization.Id); if (crmVisualization == null) { crmVisualization = new CrmVisualization { Id = visualization.Id, Entity = visualization.GetAttributeValue <string>("primaryentitytypecode"), Names = new Dictionary <int, string>(), Descriptions = new Dictionary <int, string>() }; crmVisualizations.Add(crmVisualization); } RetrieveLocLabelsRequest request; RetrieveLocLabelsResponse response; if (settings.ExportNames) { // Names request = new RetrieveLocLabelsRequest { AttributeName = "name", EntityMoniker = new EntityReference("savedqueryvisualization", visualization.Id) }; response = (RetrieveLocLabelsResponse)service.Execute(request); foreach (var locLabel in response.Label.LocalizedLabels) { crmVisualization.Names.Add(locLabel.LanguageCode, locLabel.Label); } } if (settings.ExportDescriptions) { // Descriptions request = new RetrieveLocLabelsRequest { AttributeName = "description", EntityMoniker = new EntityReference("savedqueryvisualization", visualization.Id) }; response = (RetrieveLocLabelsResponse)service.Execute(request); foreach (var locLabel in response.Label.LocalizedLabels) { crmVisualization.Descriptions.Add(locLabel.LanguageCode, locLabel.Label); } } } } foreach (var crmVisualization in crmVisualizations.OrderBy(cv => cv.Entity)) { if (settings.ExportNames) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = crmVisualization.Id.ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = crmVisualization.Entity; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Name"; foreach (var lcid in languages) { var name = crmVisualization.Names.FirstOrDefault(n => n.Key == lcid); if (name.Value != null) { ZeroBasedSheet.Cell(sheet, line, cell++).Value = name.Value; } else { cell++; } } } if (settings.ExportDescriptions) { line++; cell = 0; ZeroBasedSheet.Cell(sheet, line, cell++).Value = crmVisualization.Id.ToString("B"); ZeroBasedSheet.Cell(sheet, line, cell++).Value = crmVisualization.Entity; ZeroBasedSheet.Cell(sheet, line, cell++).Value = "Description"; foreach (var lcid in languages) { var desc = crmVisualization.Descriptions.FirstOrDefault(n => n.Key == lcid); if (desc.Value != null) { ZeroBasedSheet.Cell(sheet, line, cell++).Value = desc.Value; } else { cell++; } } } } // Applying style to cells for (int i = 0; i < (3 + languages.Count); i++) { StyleMutator.TitleCell(ZeroBasedSheet.Cell(sheet, 0, i).Style); } for (int i = 1; i <= line; i++) { for (int j = 0; j < 3; j++) { StyleMutator.HighlightedCell(ZeroBasedSheet.Cell(sheet, i, j).Style); } } }
protected override void ApplySettings(HydraTaskSettings settings) { _settings = new ExportSettings(settings); if (settings.IsDefault) { _settings.ExportType = ExportTypes.Txt; _settings.Offset = 1; _settings.ExportFolder = string.Empty; _settings.CandleSettings = new CandleSeries { CandleType = typeof(TimeFrameCandle), Arg = TimeSpan.FromMinutes(1) }; //_settings.ExportTemplate = "{OpenTime:yyyy-MM-dd HH:mm:ss};{OpenPrice};{HighPrice};{LowPrice};{ClosePrice};{TotalVolume}"; _settings.Interval = TimeSpan.FromDays(1); _settings.StartFrom = DateTime.Today; _settings.Connection = null; _settings.BatchSize = 50; _settings.CheckUnique = true; _settings.TemplateTxtRegistry = new TemplateTxtRegistry(); _settings.Header = string.Empty; } }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="npc">Npc to move</param> /// <param name="markerName">Target marker name</param> /// <param name="directContinueFunction">Direct continue function</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, MoveNpcActionData parsedData, KortistoNpc npc, string markerName, string directContinueFunction, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer) { ScribanMoveNpcActionDataBase actionData; if (_isTeleport) { actionData = new ScribanMoveNpcActionDataBase(); } else { ScribanMoveNpcActionData walkData = new ScribanMoveNpcActionData(); walkData.MovementState = !string.IsNullOrEmpty(parsedData.MovementState) ? ExportUtil.EscapeCharacters(parsedData.MovementState, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter) : null; walkData.UnescapedMovementState = parsedData.MovementState; walkData.DirectContinueFunction = !string.IsNullOrEmpty(directContinueFunction) ? directContinueFunction : null; actionData = walkData; } actionData.Npc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, npc, exportSettings, errorCollection); actionData.Npc.IsPlayer = npc.IsPlayerNpc; actionData.TargetMarkerName = ExportUtil.EscapeCharacters(markerName, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter); actionData.UnescapedTargetMarkerName = markerName; return(await ScribanActionRenderingUtil.FillPlaceholders(_cachedDbAccess, errorCollection, template.Code, actionData, flexFieldObject, curStep, nextStep, _scribanLanguageKeyGenerator, stepRenderer)); }
public static ExportSettings InstantiateExportSettings() { ExportSettings settings = new ExportSettings { ExportPureTypings = _parameters.ExportPureTypings, Hierarchical = _parameters.Hierarchy, TargetDirectory = _parameters.TargetDirectory, TargetFile = _parameters.TargetFile, WriteWarningComment = _parameters.WriteWarningComment, SourceAssemblies = GetAssembliesFromArgs(), RootNamespace = _parameters.RootNamespace, CamelCaseForMethods = _parameters.CamelCaseForMethods, CamelCaseForProperties = _parameters.CamelCaseForProperties, DocumentationFilePath = _parameters.DocumentationFilePath, GenerateDocumentation = _parameters.GenerateDocumentation }; return settings; }
/// <summary> /// Fills the placeholders /// </summary> /// <param name="template">Template to use</param> /// <param name="errorCollection">Error Collection</param> /// <param name="parsedData">Parsed config data</param> /// <param name="npc">Npc to move</param> /// <param name="markerName">Target marker name</param> /// <param name="directContinueFunction">Direct continue function</param> /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param> /// <param name="curStep">Current step that is rendered</param> /// <param name="nextStep">Next step that is being rendered</param> /// <param name="exportSettings">Export Settings</param> /// <param name="stepRenderer">Action Step renderer</param> /// <returns>Filled placeholders</returns> protected abstract Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, MoveNpcActionData parsedData, KortistoNpc npc, string markerName, string directContinueFunction, FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer);