/// <summary> /// Runs the style instruction. /// </summary> /// <param name="ins">The ins.</param> /// <returns></returns> /// <remarks>This is for mutliple execution</remarks> /// <exception cref="System.NotImplementedException">No implementation for: " + ins.type.ToString()</exception> protected appendType runStyleInstruction(docScriptInstruction ins) { //if (!hasDocRender) //{ // return ins.type; //} switch (ins.type) { case appendType.s_settings: if (ins.containsKey(d.dsa_background)) { string bgColor = ins.getProperString(Color.White.ColorToHex(), d.dsa_background); string fgColor = ins.getProperString(Color.Black.ColorToHex(), d.dsa_forecolor); docRender.ApplyColor(bgColor, null, false); docRender.ApplyColor(fgColor, null, true); } else if (ins.containsKey(d.dsa_innerAppend)) { appendType ap_type = ins.getProperEnum <appendType>(appendType.regular, d.dsa_innerAppend); appendRole ap_role = ins.getProperEnum <appendRole>(appendRole.paragraph, d.dsa_styleTarget); styleApplicationFlag ap_flag = ins.getProperEnum <styleApplicationFlag>(styleApplicationFlag.allShots, d.dsa_stylerSettings); styleAutoShotSet _shot = new styleAutoShotSet(ap_flag, ap_type, ap_role); List <IStyleInstruction> shots = _shot.resolve(theme); foreach (IStyleInstruction sh in shots) { docRender.ApplyStyle(sh, render.c.getPencil(pencilType.point, 1)); } } else if (ins.containsKey(d.dsa_variationRole)) { aceColorPalette palette = ins.getProperObject <aceColorPalette>(d.dsa_stylerSettings, null); int var = ins.getProperInt32(0, d.dsa_variationRole); acePaletteShotResEnum res = ins.getProperEnum <acePaletteShotResEnum>(acePaletteShotResEnum.background, d.dsa_styleTarget); Color col = palette.bgColors[var]; switch (res) { case acePaletteShotResEnum.foreground: col = palette.fgColors[var]; break; case acePaletteShotResEnum.background: col = palette.bgColors[var]; break; case acePaletteShotResEnum.border: col = palette.tpColors[var]; break; default: throw new ArgumentOutOfRangeException(); } docRender.ApplyColor(col.ColorToHex()); render.c.enter(); } break; case appendType.s_width: int key = ins.getProperInt32(0, d.dsa_key); int val = ins.getProperInt32(0, d.dsa_value); bool isHorizontal = ins.isHorizontal; var corner = ins.getProperEnum <textCursorZoneCorner>(textCursorZoneCorner.none, d.dsa_cursorCorner); bool isAutofit = (bool)ins.get(d.dsa_autostyling, false); if (isHorizontal) { docRender.ApplyColumn(key, val, corner, isAutofit); } else { docRender.ApplyRow(key, val, corner, isAutofit); } break; case appendType.s_variation: throw new NotImplementedException("No implementation for: " + ins.type.ToString()); break; case appendType.s_style: selectRangeArea area = resolveAreaForStyleShot(ins[d.dsa_styleTarget]); //.get(d.dsa_styleTarget)); if (ins.containsAllOfKeys(d.dsa_autostyling, d.dsa_styleTarget)) { styleApplicationFlag flag = ins.getProperEnum <styleApplicationFlag>(styleApplicationFlag.none, d.dsa_autostyling); styleAutoShotSet shot = new styleAutoShotSet(flag); styleStack.Add(shot, area); } else if (ins.containsAllOfKeys(d.dsa_stylerSettings, d.dsa_styleTarget)) { IStyleInstruction shot = ins[d.dsa_stylerSettings] as IStyleInstruction; if (shot == null) { throw new ArgumentNullException("dsa_stylerSettings", "docScript.s_style(null) - no IStyleInstruction for this instruction"); } else { styleStack.Add(shot, area); } } else { } break; case appendType.s_zone: if (ins.containsAnyOfTypes(typeof(textCursorZone))) { render.c.switchToZone(ins.getProperEnum <textCursorZone>(textCursorZone.unknownZone), ins.getProperEnum <textCursorZoneCorner>(textCursorZoneCorner.default_corner)); } else if (ins.containsAnyOfTypes(typeof(cursorSubzoneFrame))) { // prosledjena mu je zona render.c.setTempFrame(ins.getProperEnum <cursorSubzoneFrame>(cursorSubzoneFrame.fullFrame), ins.getProperEnum <textCursorZoneCorner>(textCursorZoneCorner.default_corner)); } else if (ins.containsAnyOfTypes(typeof(cursorZoneRole))) { cursorZoneRole zr = ins.getProperEnum <cursorZoneRole>(cursorZoneRole.master); int szi = ins.getProperInt32(0, docScriptArguments.dsa_value, docScriptArguments.dsa_level, docScriptArguments.dsa_priority); render.c.setToSubFrame(zr, szi); } else { throw new ArgumentNullException(ins.type.ToString(), "Minimum applicable docScriptArguments are missing - can't execute instruction like this"); } break; case appendType.s_alternate: theme.styler.isDisabled = false; break; case appendType.s_normal: theme.styler.isDisabled = true; break; case appendType.s_palette: acePaletteRole newRole = (acePaletteRole)ins.getProperField(d.dsa_paletteRole); if (ins.containsAnyOfKeys(d.dsa_dataTable, d.dsa_dataPairs, d.dsa_zoneFrame, d.dsa_variationRole)) { theme.styler.layoutPaletteRole = newRole; } else { theme.styler.mainPaletteRole = newRole; } break; default: //executionError(String.Format("Instruction ({0}) not supported by runStyleInstruction() method", ins.type.ToString()), ins); //executionError(String.Format("Instruction ({0}) not supported by runSpecialInstruction() method", ins.type.ToString()), ins); return(ins.type); break; } return(appendType.none); }
public styleAutoShotSet(styleApplicationFlag __flags, params Object[] __resources) { flags = __flags; resources = __resources.getFlatList <Object>(); }