public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { var color = AxoColor.FromInvariantString(info.GetString("Color")); var name = info.GetString("Name"); return(new NamedColor(color, name)); }
public NamedColor(AxoColor c) { _color = c; _name = null; _autogeneratedName = null; _parent = null; }
public NamedColor(NamedColor c, ColorManagement.IColorSet parent) { _color = c.Color; _name = c._name; _autogeneratedName = c._autogeneratedName; _parent = parent; }
public NamedColor(AxoColor c, string name, ColorManagement.IColorSet parent) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), "Name must not be null or empty. Otherwise use the constructor without name argument"); } _color = c; _name = name; _autogeneratedName = null; _parent = parent; }
public static string GetColorName(AxoColor c) { if (NamedColors.Instance.TryGetValue(c, out var nc)) { return(nc.Name); } if (NamedColors.Instance.TryGetValue(c.ToFullyOpaque(), out nc)) { var name = nc.Name; int opaqness = (c.A * 100) / 255; if (opaqness != 100) { name += string.Format(System.Globalization.CultureInfo.InvariantCulture, " {0}%", opaqness); } return(name); } return(c.ToString()); }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { var colorValue = AxoColor.FromInvariantString(info.GetString("Color")); var colorName = info.GetString("Name"); // remember that colorName can be null or empty here. In this case, we use an autogenerated name if (info.CurrentElementName == "Set") { var colorSet = (Drawing.ColorManagement.IColorSet)info.GetValue("ColorSet", parent); ColorSetManager.Instance.TryRegisterList(info, colorSet, Main.ItemDefinitionLevel.Project, out var registeredColorSet); return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorFromLevelAndSetName(info, colorValue, colorName, colorSet.Name)); // Note: here we use the name of the original color set, not of the registered color set. Because the original name is translated during registering into the registered name } else if (info.CurrentElementName == "SetName") { string colorSetName = info.GetString("SetName"); return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorFromLevelAndSetName(info, colorValue, colorName, colorSetName)); } else // nothing of both, thus color belongs to nothing or to the standard color set { return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorWithNoSet(colorValue, colorName)); } }
public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent) { var colorValue = AxoColor.FromInvariantString(info.GetString("Color")); var colorName = info.GetString("Name"); if (info.CurrentElementName == "Set") { // note: the deserialization of the built-in color set is responsible for creating a temporary project level color set, // if it is an older version of a color set var colorSet = (ColorManagement.IColorSet)info.GetValue("Set", null); ColorManagement.ColorSetManager.Instance.TryRegisterList(info, colorSet, Main.ItemDefinitionLevel.Project, out colorSet); return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorFromBuiltinSet(colorValue, colorName, colorSet)); } else if (info.CurrentElementName == "SetName") { string colorSetName = info.GetString("SetName"); var colorSetLevel = (Altaxo.Main.ItemDefinitionLevel)info.GetEnum("SetLevel", typeof(Altaxo.Main.ItemDefinitionLevel)); return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorFromLevelAndSetName(info, colorValue, colorName, colorSetName)); } else // nothing of both, thus color belongs to nothing or to the standard color set { return(ColorManagement.ColorSetManager.Instance.GetDeserializedColorWithNoSet(colorValue, colorName)); } }
public bool Equals(AxoColor from) { return(_color.Equals(from)); }
public static NamedColor FromScRgb(float a, float r, float g, float b, string name) { return(new NamedColor(AxoColor.FromScRgb(a, r, g, b), name)); }
public static NamedColor FromScRgb(float a, float r, float g, float b) { var c = AxoColor.FromScRgb(a, r, g, b); return(new NamedColor(c)); }
public static NamedColor FromArgb(byte a, byte r, byte g, byte b, string name) { return(new NamedColor(AxoColor.FromArgb(a, r, g, b), name)); }
public static NamedColor FromArgb(byte a, byte r, byte g, byte b) { var c = AxoColor.FromArgb(a, r, g, b); return(new NamedColor(c)); }
public static NamedColor ToNamedColor(System.Drawing.Color c, string name) { return(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), name)); }
private static Vector4 ToVector4(Altaxo.Drawing.AxoColor color) { return(new Vector4(color.ScR, color.ScG, color.ScB, color.ScA)); }
private static Vector3 ToVector3(Altaxo.Drawing.AxoColor color, double amplitude) { float amp = (float)amplitude; return(new Vector3(color.ScR * amp, color.ScG * amp, color.ScB * amp)); }
private static Vector3 ToVector3(Altaxo.Drawing.AxoColor color) { return(new Vector3(color.ScR, color.ScG, color.ScB)); }