/// <summary> /// Makes the default response. /// </summary> /// <param name="evaluationValue">The evaluation value.</param> /// <param name="okStyle">The default style.</param> /// <returns></returns> protected tableStyleSetterResponse makeDefaultResponse(Double evaluationValue, dataTableStyleEntry okStyle, dataTableStyleEntry noStype) { //if (okStyle == null) okStyle = new dataTableStyleEntry(); tableStyleSetterResponse output = null; if (evaluationValue == 0) { output = new tableStyleSetterResponse(noStype, this); } else if (evaluationValue > 0) { if (colorGradientDictionary != null) { if (output == null) { output = new tableStyleSetterResponse(okStyle, this); } output.style.Background.Color = ColorWorks.GetColor(colorGradientDictionary.GetColor(evaluationValue)); output.style.BackgroundAlt.Color = ColorWorks.GetColor(colorGradientDictionary.GetColor(evaluationValue)); //.ColorFromHex(); } else { output = new tableStyleSetterResponse(customStyleEntry, this); } } return(output); }
/// <summary> /// Converts the given object to the converter's native type. /// </summary> /// <param name="context">A <see cref="T:System.ComponentModel.TypeDescriptor"/> that provides a format context. You can use this object to get additional information about the environment from which this converter is being invoked.</param> /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo"/> that specifies the culture to represent the color.</param> /// <param name="value">The object to convert.</param> /// <returns> /// An <see cref="T:System.Object"/> representing the converted value. /// </returns> /// <exception cref="T:System.ArgumentException">The conversion cannot be performed.</exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/> /// </PermissionSet> public object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { string colour = value as string; if (colour != null) { colour = colour.Trim(); if (colour.StartsWith("rgb")) { try { int start = colour.IndexOf("(") + 1; string[] values = colour.Substring(start, colour.IndexOf(")") - start).Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries); return(System.Drawing.Color.FromArgb(int.Parse(values[0]), int.Parse(values[1]), int.Parse(values[2]))); } catch { throw new SvgException("Colour is in an invalid format: '" + colour + "'"); } } else if (colour.StartsWith("#") && colour.Length == 4) { colour = string.Format(culture, "#{0}{0}{1}{1}{2}{2}", colour[1], colour[2], colour[3]); return(ColorWorks.GetColor(colour)); //base.ConvertFrom(context, culture, colour); } } return(value.ToString()); //base.ConvertFrom(context, culture, value); }
/// <summary> /// Gets the color of the hexadecimal. /// </summary> /// <param name="weight">The weight.</param> /// <param name="type">The type.</param> /// <returns></returns> public String GetHexColor(Double weight, Int32 typeGuid, Boolean inverse = false) { Int32 type = typeIDs.IndexOf(typeGuid); if (gradientDictionary == null) { Int32 m = stylers.Keys.Max(); gradientDictionary = gradient.GetHexColorDictionary(m + 1); foreach (var pair in stylers) { pair.Value.color = ColorWorks.GetColor(gradientDictionary.GetColor(pair.Key.GetRatio(m))); } } Byte a = stylers[type].GetAlpha(weight, settings); if (inverse) { a = (byte)(Byte.MaxValue - a); } Color c = Color.FromArgb(a, stylers[type].color); return(c.ColorToHex()); //.toHexColor(); }
/// <summary> /// Sets <c>_msg</c> color as hexadecimal value, to specified <c>imbAttributeName</c> attribue /// </summary> /// <param name="_name">Attribute value to be set</param> /// <param name="_msg">System color value to be set</param> public imbAttribute(imbAttributeName _name, Color _msg) { name = _name.ToString(); nameEnum = _name; msg = ColorWorks.ColorToHex(_msg); objMsg = _msg; }
public static Color GetTextColor(this DataColumn dc) { if (!dc.ExtendedProperties.ContainsKey(templateFieldDataTable.col_textColor)) { return(Color.DarkGray); } return(ColorWorks.GetColorSafe(dc.ExtendedProperties[templateFieldDataTable.col_textColor])); }
public static Color GetDefaultBackground(this DataColumn dc) { if (!dc.ExtendedProperties.ContainsKey(templateFieldDataTable.col_color)) { return(Color.LightGray); } return(ColorWorks.GetColorSafe(dc.ExtendedProperties[templateFieldDataTable.col_color])); }
public static Color DefaultBackground(this DataColumn dc, Color default_col_color) { if (!dc.ExtendedProperties.ContainsKey(templateFieldDataTable.col_color)) { dc.ExtendedProperties.add(templateFieldDataTable.col_color, default_col_color); } return(ColorWorks.GetColorSafe(dc.ExtendedProperties[templateFieldDataTable.col_color])); }
public metaPalettePage(string hexBaseColor) { baseColor = hexBaseColor.ToUpper(); name = hexBaseColor.Trim('#'); basicBlocksFlags = metaPageCommonBlockFlags.none; settings.tabHeadColor = ColorWorks.GetColor(hexBaseColor); //.getColorFromHex(); palette = new aceColorPalette(hexBaseColor); }
public static SvgPaintServer Create(string value, SvgDocument document) { // If it's pointing to a paint server if (string.IsNullOrEmpty(value) || value.ToLower().Trim() == "none") { return(new SvgColourServer(Color.Transparent)); } else if (value.IndexOf("url(#") > -1) { Match match = _urlRefPattern.Match(value); Uri id = new Uri(match.Groups[1].Value, UriKind.Relative); return((SvgPaintServer)document.IdManager.GetElementById(id)); } // If referenced to to a different (linear or radial) gradient else if (document.IdManager.GetElementById(value) != null && document.IdManager.GetElementById(value).GetType().BaseType == typeof(SvgGradientServer)) { return((SvgPaintServer)document.IdManager.GetElementById(value)); } else // Otherwise try and parse as colour { return(new SvgColourServer(ColorWorks.GetColor(value))); // return new SvgColourServer((Color)_colourConverter.ConvertFrom(value.Trim())); } }
public static DataColumn SetTextColor(this DataColumn dc, Color col_color) { dc.ExtendedProperties.add(templateFieldDataTable.col_textColor, ColorWorks.ColorToHex(col_color)); return(dc); }
public override docScript compose(docScript script) { script = this.checkScript(script); int column = 0; string hexColor = palette.hexColor; Color altColor = ColorWorks.GetColor(hexColor); //.getColorFromHex(); //Color altOne = altColor.getVariation(0.2F, 0.1F, 80); //Color altTwo = altColor.getVariation(0.2F, 0.1F, 160); //Color altThree = altColor.getVariation(0.2F, 0.1F, 240); //aceColorPalette paletteOne = new aceColorPalette(altOne.toHexColor()); //aceColorPalette paletteTwo = new aceColorPalette(altTwo.toHexColor()); //aceColorPalette paletteThree = new aceColorPalette(altThree.toHexColor()); script.x_scopeIn(this); script = composeForPalette(script, altColor, 0.0F, 0.0F, 0, "--", true); script = composeForPalette(script, altColor, 0.0F, 0.0F, 0, "Main", false); script = composeForPalette(script, altColor, 0.1F, 0.1F, 0, "Brignter 01", false); script = composeForPalette(script, altColor, 0.2F, 0.2F, 0, "Brignter 02", false); script = composeForPalette(script, altColor, 0.4F, 0.4F, 0, "Brignter 03", false); script = composeForPalette(script, altColor, 0.1F, 0.1F, 120, "Primary 01", false); script = composeForPalette(script, altColor, 0.2F, 0.2F, 120, "Primary 02", false); script = composeForPalette(script, altColor, 0.4F, 0.3F, 120, "Primary 03", false); script = composeForPalette(script, altColor, 0.1F, 0.1F, 240, "Secondary 01", false); script = composeForPalette(script, altColor, 0.3F, 0.3F, 240, "Secondary 02", false); script = composeForPalette(script, altColor, 0.4F, 0.4F, 240, "Secondary 03", false); //script = composeForPalette(script, paletteOne, "Alt 1"); //script = composeForPalette(script, paletteTwo, "Alt 2"); //script = composeForPalette(script, paletteThree, "Alt 3"); //script.appendLine(appendType.heading_2, "Base color"); //script.appendLine(appendType.bold, palette.hexColor); //script.s_width(column, 5); //script.appendLine(appendType.regular, "Background variations"); //for (int i = 0; i < palette.ccount; i++) //{ // script.appendLine(appendType.bold, palette.bgColors[i].toHexColor()); // script.s_settings(palette, i, acePaletteShotResEnum.background).isHorizontal = false; //} //script.add(appendType.regular, "Border variations", false); //for (int i = 0; i < palette.ccount; i++) //{ // script.appendLine(appendType.bold, palette.tpColors[i].toHexColor()); // script.s_settings(palette, i, acePaletteShotResEnum.border).isHorizontal = false; //} //script.add(appendType.regular, "Foreground variations", false); //for (int i = 0; i < palette.ccount; i++) //{ // script.appendLine(appendType.bold, palette.fgColors[i].toHexColor()); // script.s_settings(palette, i, acePaletteShotResEnum.foreground).isHorizontal = false; //} script.x_scopeOut(this); return(script); }
/// <summary> /// Generiše paletu boja, pozadina i dodatnih brusheva /// </summary> /// <param name="hexBaseColor">HTML/Hexadecimalni format boja. npr: #FFCC00</param> /// <param name="gradientDelta">Kolika je razlika između gornjeg i donjeg kraja gradijenta, ~0.1</param> /// <param name="hDelta">Promena boje HUE</param> /// <param name="sDelta">Promena saturacije </param> /// <param name="vDelta">Promena svetline</param> /// <param name="colorCount">Koliko boja da generiše (min. 5)</param> /// <param name="foreColorSnap">Da li da koristi crnu i belu umesto obojenih foreground-a</param> public void createPalette(String hexBaseColor, float __gradientDelta, Int32 __hDelta, float __sDelta, float __vDelta, Int32 __colorCount = 8, Boolean __foreColorSnap = false, String __path = "") { clearCollections(); gDelta = __gradientDelta; hDelta = __hDelta; sDelta = __sDelta; vDelta = __vDelta; ccount = __colorCount; _foreSnap = __foreColorSnap; _hexColor = hexBaseColor; //if (String.IsNullOrEmpty(__path)) // //ColorWorks. // //__path = aceColorConverts.makePath(hexBaseColor, vDelta, sDelta, hDelta, __foreColorSnap); //if (!String.IsNullOrEmpty(__path)) path = __path; //baseColor = aceColorConverts.fromHexColor(hexBaseColor); baseColor = ColorWorks.GetColor(hexBaseColor); //aceColorPaletteManager.getColor(hexBaseColor); if (ccount < minCount) { ccount = minCount; } //Int32 a; //for (a = 0; a < ccount; a++) //{ // float vd = (vDelta * a); // float sd = (sDelta * a); // Int32 hd = (hDelta * a); // var tmpTop = ColorWorks.; //aceColorPaletteManager.getColor(hexBaseColor, vd, sd, hd); // tpColors.Add(aceColorConverts.toDrawingColor(tmpTop)); // tpBrushes.Add(new System.Drawing.SolidBrush(tpColors[a])); // colorsOnTop.Add(tmpTop); // var tmpBg = aceColorPaletteManager.getColor(hexBaseColor, (vd - gDelta), (sd - (gDelta * 2)), hd); // bgColors.Add(aceColorConverts.toDrawingColor(tmpBg)); // colorsBottom.Add(tmpBg); // //aceColorConverts.getBrighter(vd, baseColor, sd, hd); // //aceColorConverts.getBrighter((vd - gradientDelta), baseColor, (sd - (gradientDelta * 2)), hd)); // backgrounds.Add(new LinearGradientBrush(colorsOnTop[a], colorsBottom[a], 90)); // gGradient bgGrad = new gGradient(new System.Drawing.PointF(0, 0), new System.Drawing.PointF(50, 50), aceColorConverts.toDrawingColor(colorsOnTop[a]), aceColorConverts.toDrawingColor(colorsBottom[a])); // bgBrushes.Add(bgGrad); // var tmpFg = aceColorPaletteManager.getColor(hexBaseColor, (vd - gDelta), (sd - (gDelta * 2)), hd, true, __foreColorSnap); // fgColors.Add(aceColorConverts.toDrawingColor(tmpFg)); // fgBrushes.Add(new System.Drawing.SolidBrush(fgColors[a])); // colorsFore.Add(tmpFg); // underLines.Add(new colorBrush(colorsOnTop[a])); // foregrounds.Add(new colorBrush(colorsFore[a])); //} //Color ds = aceColorPaletteManager.getColor(hexBaseColor, -0.4F, -0.2F, 0); //Color ds2 = aceColorPaletteManager.getColor(hexBaseColor, -0.3F, -0.1F, 90); //disabled = new LinearGradientBrush(ds, ds2, 90);*/ }