public TagGroup(Size size, FrequencyGroup frequencyGroup) { if (size.Width <= 0 || size.Height <= 0) { throw new ArgumentException($"Size can't be negative or zero"); } Size = size; FrequencyGroup = frequencyGroup; }
public void AddSizeGroup(string name, FrequencyGroup frequencyGroup, Size size) { if (Groups.ContainsKey(name)) { throw new ArgumentException($"Group {name} already exist"); } if (size.Width <= 0 || size.Height <= 0) { throw new ArgumentException($"Size can't be negative or zero"); } foreach (var sizeGroup in Groups) { if (sizeGroup.Value.FrequencyGroup.IntersectWith(frequencyGroup)) { throw new ArgumentException($"Group {name} intersect with {sizeGroup.Value}"); } } Groups.Add(name, new TagGroup(size, frequencyGroup)); }
public bool IntersectWith(FrequencyGroup other) { return(MinFrequencyCoef >= other.MinFrequencyCoef && MinFrequencyCoef < other.MaxFrequencyCoef || MaxFrequencyCoef > other.MinFrequencyCoef && MaxFrequencyCoef <= other.MaxFrequencyCoef); }