Пример #1
0
        /// <summary>
        /// Executes the specified ins.
        /// </summary>
        /// <param name="ins">The ins.</param>
        /// <param name="kind">The kind.</param>
        /// <returns></returns>
        protected virtual appendType execute(docScriptInstruction ins, appendTypeKind kind, appendType output)
        {
            //appendType output = ins.type;

            if (output != appendType.none)
            {
                output = runComplexInstruction(ins);
            }
            if (output != appendType.none)
            {
                output = runStyleInstruction(ins);
            }

            if (output != appendType.none)
            {
                string str = ins.getProperString(d.dsa_contentLine, d.dsa_title, d.dsa_description);

                appendRole role = ins.getProperEnum <appendRole>(appendRole.paragraph, d.dsa_role);

                styleTextShot tshot = null;

                styleContainerShot sshot = null;

                if (role != appendRole.none)
                {
                    tshot = new styleTextShot(role, theme);
                    sshot = new styleContainerShot(role, ins.type, theme);
                }
                else
                {
                    tshot = new styleTextShot(ins.type, theme);
                }

                List <string> lines = ins.getProperObject <List <string> >(d.dsa_content);

                if (lines == null)
                {
                    lines = ins.getFirstOfType <List <string> >(true);
                }

                if (!str.isNullOrEmpty())
                {
                    lines.Add(str);
                }

                if (lines.Any())
                {
                    foreach (string logLine in lines)
                    {
                        if (hasDocRender)
                        {
                            if (tshot != null)
                            {
                                docRender.ApplyStyle(tshot, render.c.getPencil(pencilType.point, 1));
                            }
                            if (sshot != null)
                            {
                                docRender.ApplyStyle(sshot, render.c.getPencil(pencilType.point, 1));
                            }
                        }
                        render.Append(logLine, ins.type, !ins.isHorizontal);
                    }
                }
                else
                {
                    if (script.flags.HasFlag(docScriptFlags.ignoreArgumentValueNull))
                    {
                        if (doVerboseLog)
                        {
                            log("Simple append called but no content nor contentLine provided");
                        }
                    }
                    else
                    {
                        executionError("Simple append called but no content nor contentLine provided", ins);
                    }
                }
            }

            return(output);
        }
Пример #2
0
 public styleShotSet(styleContainerShot __container, styleTextShot __text, acePaletteShot __palette)
 {
     palette   = __palette;
     text      = __text;
     container = __container;
 }
        /// <summary>
        /// Executes the script instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="instruction">The instruction.</param>
        public void executeScriptInstruction(IRenderExecutionContext context, docScriptInstructionCompiled instruction)
        {
            // outputRender.SubcontentStart(templateFieldSubcontent.main, false);

            if (outputRender is imbStringBuilderBase)
            {
                imbStringBuilderBase outputRender_imbStringBuilderBase = (imbStringBuilderBase)outputRender;
                outputRender_imbStringBuilderBase.data = context.data;
            }

            appendType final = runComplexInstruction(context, instruction);

            if (final != appendType.none)
            {
                final = runSpecialInstruction(context, instruction);
            }

            if (final == appendType.none)
            {
                // context.log("Complex instruction performed inside Output instruction");
                return;
            }

            if (outputRender is builderForMarkdown)
            {
                List <string> lines = new List <string>();
                if (instruction.containsKey(d.dsa_content))
                {
                    lines.AddRange((IEnumerable <string>)instruction[d.dsa_content]);
                }
                if (instruction.containsKey(d.dsa_contentLine))
                {
                    lines.Add((string)instruction[d.dsa_contentLine]);
                }
                for (int i = 0; i < lines.Count(); i++)
                {
                    outputRender.Append(lines[i], instruction.type, !instruction.isHorizontal);
                }
                return;
            }

            string str = instruction.getProperString(d.dsa_contentLine, d.dsa_title, d.dsa_description);

            appendRole role = instruction.getProperEnum <appendRole>(appendRole.paragraph, d.dsa_role);

            styleTextShot tshot = null;

            styleContainerShot sshot = null;

            if (role != appendRole.none)
            {
                tshot = new styleTextShot(role, context.theme);
                sshot = new styleContainerShot(role, instruction.type, context.theme);
            }
            else
            {
                tshot = new styleTextShot(instruction.type, context.theme);
            }

            //instruction.getProperObject<List<String>>(d.dsa_content);

            //if (lines == null) lines = instruction.getFirstOfType<List<String>>(true);

            //if (!str.isNullOrEmpty())
            //{
            //    lines.Add(str);
            //}

            //Boolean hasDocRender = false;
            //IDocumentRender docRender = outputRender as IDocumentRender; //builder.documentBuilder as IDocumentRender;

            //if (docRender != null)
            //{
            //    hasDocRender = true;
            //}

            //if (lines.Any())
            //{
            //    foreach (String logLine in lines)
            //    {
            //        //if (hasDocRender)
            //        //{
            //        //    if (tshot != null) docRender.ApplyStyle(tshot, builder.documentBuilder.c.getPencil(pencilType.point, 1));
            //        //    if (sshot != null) docRender.ApplyStyle(sshot, builder.documentBuilder.c.getPencil(pencilType.point, 1));
            //        //}
            //        outputRender.Append(logLine, instruction.type, !instruction.isHorizontal);

            //    }
            //}
            //else
            //{
            //    context.executionError("content and contentLine is missing for instruction", instruction);
            //}

            //  outputRender.SubcontentClose();

            //throw new NotImplementedException();
        }