public void ColorizeCountyItems(ElectionData electionData, List <MapItem> mapItems)
 {
     if (electionData == null)
     {
         return;
     }
     foreach (var item in mapItems)
     {
         var county = CountyFromMapAttribute(item.Attributes);
         if (county != null)
         {
             var results = electionData.Votes.FirstOrDefault(q => q.State == county.State);
             if (results != null && results.HasCountyVotes)
             {
                 var countyResults = results.CountyVotes.FirstOrDefault(q => q.FIPS == county.FIPS);
                 if (countyResults != null)
                 {
                     ColorizeCountyItem(item, countyResults);
                 }
                 continue;
             }
         }
         ColorizeItemAsUnknown(item);
     }
 }
Ejemplo n.º 2
0
 void LoadUSShape(LoadedMapInfo info, ElectionData electionData, bool colorize = true)
 {
     info.DestroyStorage();
     info.AllItems     = LoadMapShapeItems(Helpers.GetUSMap());
     info.VisibleItems = new List <MapItem>(info.AllItems);
     if (colorize)
     {
         colorizer.ColorizeStateItems(electionData, info.AllItems);
     }
     if (info.Layer == null)
     {
         info.Layer = new VectorItemsLayer();
     }
     info.SetupVisibleItemsLayerStorage();
 }
Ejemplo n.º 3
0
        void LoadElectionData()
        {
            bool needRefresh = electionData != null;

            this.voteResultsAltered = false;
            switch (electionResults)
            {
            case ElectionResults.e2016: electionData = VoteHelpers.LoadResults2016(); break;

            case ElectionResults.e2012: electionData = VoteHelpers.LoadResults2012(); break;
            }
            UpdateElectionInfo();
            if (needRefresh)
            {
                Refresh();
            }
            //CreateDetailedCountyLayer();//todo
        }
 public void ColorizeStateItems(ElectionData electionData, List <MapItem> mapItems)
 {
     if (electionData == null)
     {
         return;
     }
     foreach (var item in mapItems)
     {
         var state = StateFromMapAttribute(item.Attributes);
         if (state != null)
         {
             var results = electionData.Votes.FirstOrDefault(q => q.State == state.State);
             if (results != null)
             {
                 ColorizeStateItem(item, results);
                 continue;
             }
         }
         ColorizeItemAsUnknown(item);
     }
 }