示例#1
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 = "";
            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);
        }
示例#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 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);
        }