void gridTooltipController_BeforeShow(object sender, ToolTipControllerShowEventArgs e)
        {
            ListVoteResults lr = e.SelectedObject as ListVoteResults;

            if (lr == null)
            {
                return;
            }
            SuperToolTip superTip = new SuperToolTip()
            {
                MaxWidth = 350, AllowHtmlText = DefaultBoolean.True
            };

            e.AutoHide    = false;
            e.ToolTipType = ToolTipType.SuperTip;
            e.Show        = false;
            if (IsCountyMode && !string.IsNullOrEmpty(lr.CountyFIPS))
            {
                e.Show = GenerateCountyToolTip(CountyInfo.GetCounty(lr.CountyFIPS), superTip);
            }

            if (!IsCountyMode)
            {
                e.Show = GenerateStateToolTip(StateInfo.GetState(lr.State), superTip);
            }

            e.SuperTip = superTip;
        }
        List <ListVoteResults> GenerateStateResults()
        {
            List <ListVoteResults> res = new List <ListVoteResults>();

            if (electionData == null)
            {
                return(res);
            }
            foreach (var state in electionData.Votes.OrderBy(q => q.State))
            {
                ListVoteResults li = new ListVoteResults();
                li.State      = state.State;
                li.Name       = StateInfo.GetState(li.State).Name;
                li.TotalVotes = state.TotalVotesCount;
                var rep = state.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Republican);
                var dem = state.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Democrat);
                var oth = state.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Other);

                li.RepVotes   = rep == null ? 0 : rep.VotesCount;
                li.DemVotes   = dem == null ? 0 : dem.VotesCount;
                li.OtherVotes = oth == null ? 0 : oth.VotesCount;

                li.RepElectoralVotes = rep == null ? 0 : rep.ElectoralVotes;
                li.DemElectoralVotes = dem == null ? 0 : dem.ElectoralVotes;

                res.Add(li);
            }
            return(res);
        }
        List <ListVoteResults> GenerateCountyResults()
        {
            List <ListVoteResults> res = new List <ListVoteResults>();

            if (electionData == null)
            {
                return(res);
            }
            var results = GetStateVoteInfo(activeStateCounty);

            if (results != null && results.HasCountyVotes)
            {
                foreach (var c in results.CountyVotes)
                {
                    ListVoteResults li = new ListVoteResults();
                    li.State = c.State;
                    var county = c.GetCounty();
                    li.Name       = county == null ? "UNKNOWN" : county.CountyName.Replace(" County", "");
                    li.CountyFIPS = county == null ? "" : county.FIPS;
                    li.TotalVotes = c.TotalVotesCount;
                    var rep = c.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Republican);
                    var dem = c.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Democrat);
                    var oth = c.Votes.FirstOrDefault(q => q.CandidateType == CandidateType.Other);

                    li.RepVotes   = rep == null ? 0 : rep.VotesCount;
                    li.DemVotes   = dem == null ? 0 : dem.VotesCount;
                    li.OtherVotes = oth == null ? 0 : oth.VotesCount;

                    res.Add(li);
                }
            }
            return(res);
        }
        void gridView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column != colArea)
            {
                return;
            }
            ListVoteResults lr = gridView.GetRow(e.RowHandle) as ListVoteResults;

            if (lr == null)
            {
                return;
            }
            int   votes = 0;
            Color color = Color.Empty;

            if (IsCountyMode)
            {
                votes = lr.DemVotes == 0 ? lr.RepVotes : lr.DemVotes;
                color = lr.RepVotes > lr.DemVotes ? colorizer.RepColor : colorizer.DemColor;
            }
            else
            {
                votes = lr.DemElectoralVotes == 0 ? lr.RepElectoralVotes : lr.DemElectoralVotes;
                color = lr.DemElectoralVotes == 0 ? colorizer.RepColor : colorizer.DemColor;
            }
            if (votes == 0)
            {
                return;
            }
            e.Appearance.BackColor = color;
            e.Appearance.ForeColor = Color.White;
            e.DefaultDraw();
            e.Handled = true;
            if (IsCountyMode)
            {
                return;
            }
            Rectangle        bounds = e.Bounds;
            AppearanceObject app    = new AppearanceObject()
            {
                ForeColor = Color.White
            };

            app.TextOptions.HAlignment = HorzAlignment.Far;
            app.TextOptions.VAlignment = VertAlignment.Bottom;
            app.DrawString(e.Cache, votes.ToString(), bounds);
        }
 void gridView_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     if (e.Clicks > 1 && !IsCountyMode)
     {
         if (IsElectionPlaygroundMode)
         {
             return;
         }
         ListVoteResults lr = gridView.GetRow(e.RowHandle) as ListVoteResults;
         if (lr == null)
         {
             return;
         }
         var stateInfo = StateInfo.GetState(lr.State);
         if (stateInfo != null)
         {
             ShowCountyMap(stateInfo);
         }
     }
 }