예제 #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != typeof(AmbientColor))
            {
                return(false);
            }
            AmbientColor other = (AmbientColor)obj;

            return(Colors.Equals(other.Colors) && Name == other.Name);
        }
예제 #2
0
        internal static AmbientColor Import(Dictionary <string, ColorScheme.VSSettingColor> colors, string vsSetting)
        {
            var result = new AmbientColor();
            var attrs  = vsSetting.Split(',');

            foreach (var attr in attrs)
            {
                var info = attr.Split('=');
                if (info.Length != 2)
                {
                    continue;
                }
                var idx    = info [1].LastIndexOf('/');
                var source = info [1].Substring(0, idx);
                var dest   = info [1].Substring(idx + 1);

                ColorScheme.VSSettingColor color;
                if (!colors.TryGetValue(source, out color))
                {
                    continue;
                }
                result.Name = color.Name;
                string colorString;
                switch (dest)
                {
                case "Foreground":
                    colorString = color.Foreground;
                    break;

                case "Background":
                    colorString = color.Background;
                    break;

                default:
                    throw new InvalidDataException("Invalid attribute source: " + dest);
                }
                result.Colors.Add(Tuple.Create(info [0], ColorScheme.ImportVsColor(colorString)));
            }
            if (result.Colors.Count == 0)
            {
                return(null);
            }
            return(result);
        }
예제 #3
0
        internal static AmbientColor Create(XElement element, Dictionary <string, HslColor> palette)
        {
            var result = new AmbientColor();

            foreach (var node in element.DescendantNodes())
            {
                if (node.NodeType == System.Xml.XmlNodeType.Element)
                {
                    var el = (XElement)node;
                    switch (el.Name.LocalName)
                    {
                    case "name":
                        result.Name = el.Value;
                        break;

                    default:
                        result.Colors.Add(Tuple.Create(el.Name.LocalName, ColorScheme.ParsePaletteColor(palette, el.Value)));
                        break;
                    }
                }
            }

            return(result);
        }
		internal static AmbientColor Import (Dictionary<string, ColorScheme.VSSettingColor> colors, string vsSetting)
		{
			var result = new AmbientColor ();
			var attrs = vsSetting.Split (',');
			foreach (var attr in attrs) {
				var info = attr.Split ('=');
				if (info.Length != 2)
					continue;
				var idx = info [1].LastIndexOf ('/');
				var source = info [1].Substring (0, idx);
				var dest   = info [1].Substring (idx + 1);

				ColorScheme.VSSettingColor color;
				if (!colors.TryGetValue (source, out color))
					continue;
				result.Name = color.Name;
				string colorString;
				switch (dest) {
				case "Foreground":
					colorString = color.Foreground;
					break;
				case "Background":
					colorString = color.Background;
					break;
				default:
					throw new InvalidDataException ("Invalid attribute source: " + dest);
				}
				result.Colors.Add (Tuple.Create (info [0], ColorScheme.ImportVsColor (colorString)));
			}
			if (result.Colors.Count == 0)
				return null;
			return result;
		}
		internal static AmbientColor Create (XElement element, Dictionary<string, HslColor> palette)
		{
			var result = new AmbientColor ();
			foreach (var node in element.DescendantNodes ()) {
				if (node.NodeType == System.Xml.XmlNodeType.Element) {
					var el = (XElement)node;
					switch (el.Name.LocalName) {
					case "name":
						result.Name = el.Value;
						break;
					default:
						result.Colors.Add (Tuple.Create (el.Name.LocalName, ColorScheme.ParsePaletteColor (palette, el.Value)));
						break;
					}
				}
			}
			
			return result;
		}