/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public override string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Is this shape using a custom style? if (Style.StyleType == KimonoStyleType.Custom || Style.StyleType == KimonoStyleType.CustomText) { // Yes, include it in the source code Style.Name = $"{Name} Style"; Style.ElementName = KimonoCodeGenerator.MakeElementName(Style.Name); // Take action based on the output language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode += Style.ToCSharp(outputLibrary); break; case CodeOutputLanguage.ObiScript: sourceCode += Style.ToObiScript(); break; } } else { // Accumulate linked styles KimonoCodeGenerator.AddSupportingStyle(Style); } // Return results return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public override string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; var preCode = ""; // Take action based on the language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode += ToCSharp(outputLibrary); break; case CodeOutputLanguage.ObiScript: sourceCode += "// Shapes are not supported in ObiScript\n"; break; } // Assemble precode items in reverse order to ensure dependencies are registered first preCode = KimonoCodeGenerator.CodeForSupportStyles(outputLanguage, outputLibrary); preCode = KimonoCodeGenerator.CodeForSupportGradients(outputLanguage, outputLibrary) + preCode; preCode = KimonoCodeGenerator.CodeForSupportingColors(outputLanguage, outputLibrary) + preCode; // Include any supporting elements sourceCode = preCode + sourceCode; // Return code return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting gradients used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoGradients`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string CodeForSupportGradients(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all gradients foreach (KimonoGradient supportingGradient in SupportingGradients) { // Accumulate gradient sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += supportingGradient.ToCSharp(outputLibrary); } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting properties used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoProperty`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string CodeForSupportLocalProperties(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all properties foreach (KimonoProperty supportProperty in LocalProperties) { // Accumulate property sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += supportProperty.ToCode(CodeOutputOS.CrossPlatform, outputLanguage, outputLibrary); } // Return generated source return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public virtual string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Take action based on the output language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode = ToCSharp(outputLibrary); break; } // Return results return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting styles used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoGradients`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string InitializerForSupportStyles(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all gradients foreach (KimonoStyle supportingStyle in SupportingStyles) { // Accumulate gradient sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += supportingStyle.ToCSharpInitializer(outputLibrary); } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string CodeForSupportingColors(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all colors foreach (KimonoColor supportColor in SupportingColors) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Create new {supportColor.Name}\n"; sourceCode += $"var {supportColor.ElementName} = {supportColor.ToCSharp(outputLibrary)};\n"; } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the sketches used in generating /// a higher level Kimono object as a public computed propert. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string PropertyForSketches(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process sketches foreach (KimonoSketch sketch in ObiScriptPortfolio.Portfolio.Sketches) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Global sketch {sketch.Name}\n"; sourceCode += $"public static KimonoSketch {sketch.ElementName} " + "{get; set;}\n"; } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object as a public computed propert. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string PrivateVariablesForSupportingGradients(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all colors foreach (KimonoGradient supportingGradient in SupportingGradients) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Private gradient {supportingGradient.Name} vairables\n"; sourceCode += $"private SKColor[] {supportingGradient.ElementName}Colors;\n" + $"private float[] {supportingGradient.ElementName}Weights;\n"; } // Return generated source return(sourceCode); }
/// <summary> /// Returns the initializers for all of the supporting properties used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoProperty`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string CodeForInitializeParameterProperties(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all properties foreach (KimonoProperty supportProperty in ParameterProperties) { // Accumulate property if (sourceCode != "") { sourceCode += ", "; } sourceCode += supportProperty.ElementName; } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting properties used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoProperty`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string CodeForSupportParameterProperties(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all properties foreach (KimonoProperty supportProperty in ParameterProperties) { // Accumulate property if (sourceCode != "") { sourceCode += ", "; } sourceCode += supportProperty.ToCode(CodeOutputOS.CrossPlatform, outputLanguage, outputLibrary); } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object as a public computed propert. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string PropertyForSupportingGradients(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; var classType = (outputLibrary == CodeOutputLibrary.SkiaSharp) ? "SKShader" : "KimonoGradient"; // Process all colors foreach (KimonoGradient supportingGradient in SupportingGradients) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Global gradient {supportingGradient.Name}\n"; sourceCode += $"public static {classType} {supportingGradient.ElementName} " + "{get; set;}\n"; } // Return generated source return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object as a public computed propert. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string PropertyForSupportingColors(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; var classType = (outputLibrary == CodeOutputLibrary.SkiaSharp) ? "SKColor" : "KimonoColor"; // Process all colors foreach (KimonoColor supportColor in SupportingColors) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Global color {supportColor.Name}\n"; sourceCode += $"public static {classType} {supportColor.ElementName} " + "{get; set;} " + $"= {supportColor.ToCSharp(outputLibrary)};\n"; } // Return generated source return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Take action based on the library switch (outputLibrary) { case CodeOutputLibrary.SkiaSharp: sourceCode += ToSkiaSharp(); break; case CodeOutputLibrary.KimonoCore: sourceCode += ToKimonoCore(); break; } // Return resulting code return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public virtual string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = $"// Create new {Name}\n"; // Take action based on language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode += $"var {KimonoCodeGenerator.MakeElementName(Name)} = " + ToCSharp(outputLibrary) + ";\n"; break; case CodeOutputLanguage.ObiScript: sourceCode += $"Return.Color(\"{Name}\");\n"; break; } // Return resulting code return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string InitializerForSupportColors(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Only valid for KimonoCode generation if (outputLibrary != CodeOutputLibrary.KimonoCore) { return(""); } // Process all colors foreach (KimonoColor supportColor in SupportingColors) { // Accumulate gradient sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += supportColor.ConnectionsToKimonoCore(); } // Return generated source return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Take action based on the library switch (outputLibrary) { case CodeOutputLibrary.SkiaSharp: sourceCode += ToSkiaSharp(); break; case CodeOutputLibrary.KimonoCore: sourceCode += ToKimonoCore(); break; } // Include any supporting colors sourceCode = KimonoCodeGenerator.CodeForSupportingColors(outputLanguage, outputLibrary) + sourceCode; // Return resulting code return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public override string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Accumulate color if (Value != null) { // Yes, add as a supporting gradient KimonoCodeGenerator.AddSupportingGradient(Value); } // Take action based on the output language switch (outputLanguage) { case CodeOutputLanguage.CSharp: sourceCode = ToCSharp(outputLibrary); break; } // Return results return(sourceCode); }
/// <summary> /// Returns the source code for all of the supporting colors used in generating /// a higher level Kimono object as a public computed propert. /// </summary> /// <returns>The source code for the supporting `KimonoColors`.</returns> /// <param name="outputLanguage">The `CodeOutputLanguage` for the generated code.</param> /// <param name="outputLibrary">The `CodeOutputLibrary` of the generated code.</param> public static string PropertyForSupportingStyles(CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { var sourceCode = ""; // Process all colors foreach (KimonoStyle supportingStyle in SupportingStyles) { // Accumulate color code sourceCode = AddCarriageIfNeeded(sourceCode); sourceCode += $"// Global style {supportingStyle.Name}\n"; // Take action based on library switch (outputLibrary) { case CodeOutputLibrary.SkiaSharp: if (supportingStyle.HasFill) { sourceCode += $"public static SKPaint {supportingStyle.ElementName}FillPaint " + "{get; set;}\n"; } if (supportingStyle.HasFill) { sourceCode += $"public static SKPaint {supportingStyle.ElementName}FramePaint " + "{get; set;}\n"; } break; case CodeOutputLibrary.KimonoCore: sourceCode += $"public static KimonoStyle {supportingStyle.ElementName} " + "{get; set;}\n"; break; } } // Return generated source return(sourceCode); }
/// <summary> /// Converts this object to source code for the given OS, Language and Library. /// </summary> /// <returns>The object represented as source code in a `string`.</returns> /// <param name="outputOS">The `CodeOutputOS`.</param> /// <param name="outputLanguage">The `CodeOutputLanguage`.</param> /// <param name="outputLibrary">The `CodeOutputLibrary`.</param> public virtual string ToCode(CodeOutputOS outputOS, CodeOutputLanguage outputLanguage, CodeOutputLibrary outputLibrary) { return(""); }