/// <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);
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        /// <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);
        }
Exemple #4
0
        /// <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);
        }
Exemple #5
0
        /// <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>
        /// 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>
        /// 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);
        }
Exemple #8
0
 /// <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("");
 }