Exemplo n.º 1
0
        private void VoteSelected_Click(object sender, RoutedEventArgs e)
        {
            Button button = (Button)sender;

            foreach (Candidate candidate in VoteFor)
            {
                if (candidate.UniqueId == (long)button.Tag)
                {
                    VoteFor.Remove(candidate);
                    TheClient.Vote(candidate);
                    candidate.Voted = true;
                    CancellationTokenSource c = new CancellationTokenSource();
                    if (cancellationTokenSources.Count > 0)
                    {
                        cancellationTokenSources[cancellationTokenSources.Count - 1].Cancel();
                    }
                    cancellationTokenSources.Add(c);
                    NotifyStatus(String.Format("Vote Sent For {0}", candidate.CandidateName), "#FF8AFF8A", c.Token);
                    return;
                }
            }
        }
Exemplo n.º 2
0
        private void RemoveSelected_Click(object sender, RoutedEventArgs e)
        {
            Button   Sender           = (Button)sender;
            long     Id               = (long)Sender.Tag;
            Category selectedCategory = null;

            foreach (Candidate candidate in VoteFor)
            {
                if (candidate.UniqueId == Id)
                {
                    foreach (Category category in Categories)
                    {
                        if (category.Id == candidate.CatId)
                        {
                            selectedCategory = category;
                        }
                    }
                    VoteFor.Remove(candidate);
                    candidate.Selected              = false;
                    selectedCategory.CountSelected -= 1;
                    break;
                }
            }
        }