/// <summary> /// Gets the <see cref="cursorZone"/> with the specified role. If the role supports multiple entries then specify index to choose what zone to get. /// </summary> /// <value> /// The <see cref="cursorZone"/>. /// </value> /// <param name="role">The role.</param> /// <param name="index">The index.</param> /// <returns></returns> public cursorZone this[cursorZoneRole role, Int32 index = 0] { get { String key = ""; if (role == cursorZoneRole.section || role == cursorZoneRole.column) { if (index > 0) { key = role.ToString() + index.ToString(); } else { key = role.ToString(); } return(items[key]); } else { key = role.ToString(); if (items.ContainsKey(key)) { return(items[key]); } } return(null); } }
public cursorZone setToSubFrame(cursorZoneRole role, Int32 index = 0, textCursorZoneCorner __corner = textCursorZoneCorner.default_corner) { cursorZone subframe = frame.subzones[role, index]; if (subframe != null) { tempFrame = subframe; } return(subframe); }
/// <summary> /// Adds a zone into collection. Null <c>zone</c> will be ignored. /// </summary> /// <remarks> /// <para>If role is supports multiple items (column, section) on existing zone for the role it will create indexed key.</para> /// <para>If its a singular (footer, header, master) role it will replace any existing.</para> /// <para>If <c>master</c> zone is set, all zones will have the <c>master</c> zone set as parent.</para> /// <para>You may set the <c>master</c> zone with constructor or any time later with Add() call - it will automatically set parent for existing zones</para> /// </remarks> /// <param name="role">The role for the zone</param> /// <param name="zone">The zone to add into collection</param> /// <returns>Key that was finally used for the zone. Possibly important in case of roles supporting multiple entries</returns> public String Add(cursorZoneRole role, cursorZone zone) { if (zone == null) { return(""); } String key = role.ToString(); Int32 c = 0; if (role == cursorZoneRole.section || role == cursorZoneRole.column) { while (items.ContainsKey(key)) { c++; key = role.ToString() + c.ToString(); } } else if (role == cursorZoneRole.master) { foreach (KeyValuePair <String, cursorZone> pair in items) { if (pair.Key != "master") { pair.Value.parent = zone; } } } if (items.ContainsKey("master")) { var master = this[cursorZoneRole.master]; if (master != zone) { zone.parent = master; } } if (items.ContainsKey(key)) { items[key] = zone; } else { items.Add(key, zone); } return(key); }
/// <summary> /// Gets the boundary rectangle to hold all subzones with the specified role. /// </summary> /// <param name="role">The role of subzone or subzones to select</param> /// <param name="scope">The scope to look into for each subzone</param> /// <returns></returns> public selectRangeArea getBoundaryOf(cursorZoneRole role, textCursorZone scope = textCursorZone.innerZone) { selectRangeArea range = null; //new selectRangeArea(0,0,0,0); String key = role.ToString(); foreach (KeyValuePair <string, cursorZone> z in items) { if (z.Key.StartsWith(key, StringComparison.InvariantCultureIgnoreCase)) { if (range == null) { range = z.Value.selectRangeArea(scope); } else { range.expandToWrap(z.Value.selectRangeArea(scope)); } } } return(range); }
/// <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); }