public Patterns(Size resolution) { if (!SupportedResolutions.Contains(resolution)) { throw new ArgumentException($"Resolution {resolution} is not supported"); } Resolution = resolution; ChampionSelect = new ChampionSelectPatterns(resolution); Lazy <Pattern> PrepareSample(Bitmap sample) => new Lazy <Pattern>(() => new DifferencePattern(sample .Scaled(Resolution, InterpolationMode.NearestNeighbor)), false); AcceptMatchButtonSample = PrepareSample(Samples.AcceptMatchButton); AcceptMatchButtonHoverSample = PrepareSample(Samples.AcceptMatchButtonHover); ChampionSamples = Samples.Champions .Select(cs => new BanPickSample(cs.Name.ToLowerInvariant(), new DifferencePattern( cs.Sample.Croped(3).Scaled(ChampionSelect.BanRects.First().Size, InterpolationMode.HighQualityBilinear)), new DifferencePattern( cs.Sample.Scaled(ChampionSelect.AllieSummonerPickRects.First().Size, InterpolationMode.NearestNeighbor)), new DifferencePattern( cs.Sample.Croped(30).Scaled(ChampionSelect.FirstSelectChampionRect.Size, InterpolationMode.Bilinear)))) .ToArray(); }
public void AddSupportedResolution(int width, int height) { Resolution resolution = new Resolution(width, height); if (!SupportedResolutions.Contains(resolution)) { SupportedResolutions.Add(resolution); } }
/// <summary> /// Try to load the SilkCfg file /// </summary> private bool LoadSilkCfg() { if (File.Exists(PATH_SILKCFG)) { BinaryReader reader = null; try { reader = new BinaryReader(new FileStream(PATH_SILKCFG, FileMode.Open, FileAccess.Read)); // Read config structure by version m_SilkCfg.Version = reader.ReadUInt32(); if (m_SilkCfg.Version < 4) { m_SilkCfg.unkUint01 = reader.ReadUInt32(); // Read game resolution and ignore if is not supported SilkCfg.WindowResolution w = new SilkCfg.WindowResolution(reader.ReadUInt32(), reader.ReadUInt32()); if (SupportedResolutions.Contains(w)) { m_SilkCfg.Resolution = w; } // Graphics #1 SilkCfg.Graphic g = (SilkCfg.Graphic)reader.ReadByte(); if (SupportedGraphics.Contains(g)) { m_SilkCfg.GraphicType = g; } m_SilkCfg.unkByte01 = reader.ReadByte(); // Sound m_SilkCfg.IsSoundEnabled = reader.ReadBoolean(); m_SilkCfg.unkByte02 = reader.ReadByte(); if (m_SilkCfg.Version == 3) { // Read graphics #2 SilkCfg.Graphic g2 = (SilkCfg.Graphic)reader.ReadByte(); // Graphics choosen byte gIndex = reader.ReadByte(); // Just handling one graphic from GUI if (gIndex == 2 && SupportedGraphics.Contains(g2)) { m_SilkCfg.GraphicType = g2; } } m_SilkCfg.unkByte03 = reader.ReadByte(); } return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } finally { reader?.Close(); } } return(false); }
public bool SetResolution(Resolution resolution) { if (SupportedResolutions.Contains(resolution)) { CurrentResolution = resolution; ResolutionUpdateHandler?.Invoke(this); return(true); } return(false); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Symbol != null) { hashCode = hashCode * 59 + Symbol.GetHashCode(); } if (Description != null) { hashCode = hashCode * 59 + Description.GetHashCode(); } if (ExchangeListed != null) { hashCode = hashCode * 59 + ExchangeListed.GetHashCode(); } if (ExchangeTraded != null) { hashCode = hashCode * 59 + ExchangeTraded.GetHashCode(); } if (Minmovement != null) { hashCode = hashCode * 59 + Minmovement.GetHashCode(); } if (Minmov2 != null) { hashCode = hashCode * 59 + Minmov2.GetHashCode(); } if (Fractional != null) { hashCode = hashCode * 59 + Fractional.GetHashCode(); } if (Pricescale != null) { hashCode = hashCode * 59 + Pricescale.GetHashCode(); } if (HasIntraday != null) { hashCode = hashCode * 59 + HasIntraday.GetHashCode(); } if (HasNoVolume != null) { hashCode = hashCode * 59 + HasNoVolume.GetHashCode(); } if (Type != null) { hashCode = hashCode * 59 + Type.GetHashCode(); } if (Ticker != null) { hashCode = hashCode * 59 + Ticker.GetHashCode(); } if (Timezone != null) { hashCode = hashCode * 59 + Timezone.GetHashCode(); } if (SessionRegular != null) { hashCode = hashCode * 59 + SessionRegular.GetHashCode(); } if (SupportedResolutions != null) { hashCode = hashCode * 59 + SupportedResolutions.GetHashCode(); } if (HasDaily != null) { hashCode = hashCode * 59 + HasDaily.GetHashCode(); } if (IntradayMultipliers != null) { hashCode = hashCode * 59 + IntradayMultipliers.GetHashCode(); } if (HasWeeklyAndMonthly != null) { hashCode = hashCode * 59 + HasWeeklyAndMonthly.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if SymbolInfoArrays instances are equal /// </summary> /// <param name="other">Instance of SymbolInfoArrays to be compared</param> /// <returns>Boolean</returns> public bool Equals(SymbolInfoArrays other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Symbol == other.Symbol || Symbol != null && Symbol.SequenceEqual(other.Symbol) ) && ( Description == other.Description || Description != null && Description.SequenceEqual(other.Description) ) && ( ExchangeListed == other.ExchangeListed || ExchangeListed != null && ExchangeListed.SequenceEqual(other.ExchangeListed) ) && ( ExchangeTraded == other.ExchangeTraded || ExchangeTraded != null && ExchangeTraded.SequenceEqual(other.ExchangeTraded) ) && ( Minmovement == other.Minmovement || Minmovement != null && Minmovement.SequenceEqual(other.Minmovement) ) && ( Minmov2 == other.Minmov2 || Minmov2 != null && Minmov2.SequenceEqual(other.Minmov2) ) && ( Fractional == other.Fractional || Fractional != null && Fractional.SequenceEqual(other.Fractional) ) && ( Pricescale == other.Pricescale || Pricescale != null && Pricescale.SequenceEqual(other.Pricescale) ) && ( HasIntraday == other.HasIntraday || HasIntraday != null && HasIntraday.SequenceEqual(other.HasIntraday) ) && ( HasNoVolume == other.HasNoVolume || HasNoVolume != null && HasNoVolume.SequenceEqual(other.HasNoVolume) ) && ( Type == other.Type || Type != null && Type.SequenceEqual(other.Type) ) && ( Ticker == other.Ticker || Ticker != null && Ticker.SequenceEqual(other.Ticker) ) && ( Timezone == other.Timezone || Timezone != null && Timezone.SequenceEqual(other.Timezone) ) && ( SessionRegular == other.SessionRegular || SessionRegular != null && SessionRegular.SequenceEqual(other.SessionRegular) ) && ( SupportedResolutions == other.SupportedResolutions || SupportedResolutions != null && SupportedResolutions.SequenceEqual(other.SupportedResolutions) ) && ( HasDaily == other.HasDaily || HasDaily != null && HasDaily.SequenceEqual(other.HasDaily) ) && ( IntradayMultipliers == other.IntradayMultipliers || IntradayMultipliers != null && IntradayMultipliers.SequenceEqual(other.IntradayMultipliers) ) && ( HasWeeklyAndMonthly == other.HasWeeklyAndMonthly || HasWeeklyAndMonthly != null && HasWeeklyAndMonthly.SequenceEqual(other.HasWeeklyAndMonthly) )); }