/// <summary> /// Hashes all contained data in the effort to keep DiskCache from preventing an update /// I'm not positive about this implementation - it probably shouldn't be used for lookup, but it should be good enough for the disk cache /// </summary> /// <returns></returns> public int GetDataHashCode() { int hash = RespectOnlyMatchingBound ? 0xbac2d3 : 0xbbac486; hash ^= (int)(PolyWidthInLogoPixels * 10) << 5; hash ^= (int)(PolyHeightInLogoPixels * 10) << 5; if (OverlayPath != null) { hash ^= OverlayPath.GetHashCode(); } hash ^= (int)Align; int poly = 0; int offset = 0; foreach (PointF p in Poly) { poly ^= (int)(p.X * 10) << (offset % 24); offset += 11; poly ^= (int)(p.Y * 10) << (offset % 24); } hash ^= poly; return(hash); }
public static void FillCustomOverlays() { CustomTypes = new Dictionary <string, OverlayPath>(); var path = string.Format("{0}Custom", AppDomain.CurrentDomain.BaseDirectory); foreach (var file in Directory.GetFiles(path, "*.ovr")) { try { var name = string.Empty; double width = 0; double height = 0; var pathData = string.Empty; using (var sr = new StreamReader(file)) { string line; while ((line = sr.ReadLine()) != null) { switch (line.Split('=')[0].ToLower()) { case "name": name = line.Split('=')[1]; break; case "width": width = int.Parse(line.Split('=')[1]); break; case "height": height = int.Parse(line.Split('=')[1]); break; case "path": pathData = line.Split('=')[1]; break; } } } if (CustomTypes.Any(t => String.Equals(t.Key, name, StringComparison.InvariantCultureIgnoreCase)) || _typeMap.Any(t => String.Equals(t.Key, name, StringComparison.InvariantCultureIgnoreCase))) { throw new DuplicateNameException(string.Format(strings.OverlayNameExists, name)); } var overlay = new OverlayPath(name, pathData, new Vector(width, height), 1, 1); CustomTypes.Add(name, overlay); } catch (DuplicateNameException) { throw; } catch (Exception ex) { throw new Exception(string.Format(strings.OverlayLoadError, Path.GetFileNameWithoutExtension(file)), ex); } } }