Example #1
0
 public bool UpdateBestWindowGroup(int windowGroup, double distance)
 {
     if (BestWindowGroup.HasValue)
     {
         // Already have a best value and this is it
         if (BestWindowGroup.Value == windowGroup)
         {
             return(true);
         }
         // Not it and the distance is not closer
         if (BestWindowGroupDistance.Value <= distance)
         {
             return(false);
         }
     }
     // This becomes the best window group
     if (BestWindowGroup.HasValue)
     {
         // Save any previously seen window groups, providing for most likely cases:
         // 1. No other possible window groups
         // 2. 1 other possible window group
         if (OtherWindowGroups == null)
         {
             OtherWindowGroups = new[] { BestWindowGroup.Value }
         }
         ;
         else
         {
             if (OtherWindowGroups.Count == 1)
             {
                 OtherWindowGroups = new List <int>(OtherWindowGroups);
             }
             OtherWindowGroups.Add(BestWindowGroup.Value);
         }
     }
     BestWindowGroup         = windowGroup;
     BestWindowGroupDistance = distance;
     return(true);
 }
Example #2
0
 public bool IsKnownWindowGroup(int windowGroup)
 {
     return(windowGroup == BestWindowGroup ||
            (OtherWindowGroups != null && OtherWindowGroups.Contains(windowGroup)));
 }