Beispiel #1
0
            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));
            }
Beispiel #2
0
 public NamedColor(AxoColor c)
 {
     _color             = c;
     _name              = null;
     _autogeneratedName = null;
     _parent            = null;
 }
Beispiel #3
0
 public NamedColor(NamedColor c, ColorManagement.IColorSet parent)
 {
     _color             = c.Color;
     _name              = c._name;
     _autogeneratedName = c._autogeneratedName;
     _parent            = parent;
 }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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());
        }
Beispiel #6
0
            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));
                }
            }
Beispiel #7
0
            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));
                }
            }
Beispiel #8
0
 public bool Equals(AxoColor from)
 {
     return(_color.Equals(from));
 }
Beispiel #9
0
 public static NamedColor FromScRgb(float a, float r, float g, float b, string name)
 {
     return(new NamedColor(AxoColor.FromScRgb(a, r, g, b), name));
 }
Beispiel #10
0
        public static NamedColor FromScRgb(float a, float r, float g, float b)
        {
            var c = AxoColor.FromScRgb(a, r, g, b);

            return(new NamedColor(c));
        }
Beispiel #11
0
 public static NamedColor FromArgb(byte a, byte r, byte g, byte b, string name)
 {
     return(new NamedColor(AxoColor.FromArgb(a, r, g, b), name));
 }
Beispiel #12
0
        public static NamedColor FromArgb(byte a, byte r, byte g, byte b)
        {
            var c = AxoColor.FromArgb(a, r, g, b);

            return(new NamedColor(c));
        }
Beispiel #13
0
 public static NamedColor ToNamedColor(System.Drawing.Color c, string name)
 {
     return(new NamedColor(AxoColor.FromArgb(c.A, c.R, c.G, c.B), name));
 }
Beispiel #14
0
 private static Vector4 ToVector4(Altaxo.Drawing.AxoColor color)
 {
     return(new Vector4(color.ScR, color.ScG, color.ScB, color.ScA));
 }
Beispiel #15
0
        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));
        }
Beispiel #16
0
 private static Vector3 ToVector3(Altaxo.Drawing.AxoColor color)
 {
     return(new Vector3(color.ScR, color.ScG, color.ScB));
 }