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 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)); } }