public metaPalettePage(string hexBaseColor) { baseColor = hexBaseColor.ToUpper(); name = hexBaseColor.Trim('#'); basicBlocksFlags = metaPageCommonBlockFlags.none; settings.tabHeadColor = ColorWorks.GetColor(hexBaseColor); //.getColorFromHex(); palette = new aceColorPalette(hexBaseColor); }
public void AppendColor(aceColorPalette paleta, stringTemplate template, PropertyCollection data) { }
public docScript composeForPalette(docScript script, Color baseColor, float bright, float sat, int hue, string title, bool doLabels = false) { script.x_moveToCorner(textCursorZoneCorner.Top); script.x_move(textCursorZoneCorner.Right, 1, true); script.x_moveToCorner(textCursorZoneCorner.Left); if (doLabels) { script.s_width(0, 13); } else { script.s_width(0, 23); } Color altOne = baseColor; //.getVariation(bright, sat, hue); aceColorPalette pal = new aceColorPalette(altOne.ColorToHex()); //.toHexColor()); if (doLabels) { script.AppendLine(); script.AppendLine(appendType.bold, "Title"); script.AppendLine(); script.AppendLine(); script.AppendLine(appendType.heading_2, "Base color"); script.AppendLine(); script.AppendLine(appendType.regular, "Bright", appendRole.tableColumnHead); script.AppendLine(appendType.regular, "Saturation", appendRole.tableColumnFoot); script.AppendLine(appendType.regular, "Hue", appendRole.tableBetween); } else { script.AppendLine(appendType.heading_2, "Palette"); script.AppendLine(appendType.bold, title); script.AppendLine(); script.AppendLine(appendType.heading_2, "Base color", appendRole.tableColumnHead); script.s_settings(altOne, Color.Black); script.AppendLine(appendType.bold, pal.hexColor); script.AppendLine(appendType.heading_2, "Change"); script.AppendLine(appendType.regular, bright.ToString(), appendRole.tableColumnHead); script.AppendLine(appendType.regular, sat.ToString(), appendRole.tableColumnFoot); script.AppendLine(appendType.regular, hue.ToString(), appendRole.tableBetween); } if (doLabels) { script.AppendLine(appendType.regular, "bgColors"); } else { script.AppendLine(appendType.regular, "Background variations"); } for (int i = 0; i < pal.ccount; i++) { if (doLabels) { script.AppendLine(); script.AppendLine(appendType.bold, i.ToString()); } else { script.AppendLine(appendType.bold, pal.bgColors[i].ColorToHex()); script.s_settings(pal, i, acePaletteShotResEnum.background).isHorizontal = false; } } if (doLabels) { script.AppendLine(appendType.regular, "tpColors"); } else { script.add(appendType.regular, "Border variations", false); } for (int i = 0; i < pal.ccount; i++) { if (doLabels) { script.AppendLine(); script.AppendLine(appendType.bold, i.ToString()); } else { script.AppendLine(appendType.bold, pal.tpColors[i].ColorToHex()); script.s_settings(pal, i, acePaletteShotResEnum.border).isHorizontal = false; } } if (doLabels) { script.AppendLine(appendType.regular, "fgColors"); } else { script.add(appendType.regular, "Foreground variations", false); } for (int i = 0; i < pal.ccount; i++) { if (doLabels) { script.AppendLine(); script.AppendLine(appendType.bold, i.ToString()); } else { script.AppendLine(appendType.bold, pal.fgColors[i].ColorToHex()); script.s_settings(pal, i, acePaletteShotResEnum.foreground).isHorizontal = false; } } return(script); }
/// <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); }