public VotingWindow(MainWindow mainWindow) { try { //Initialize window and add all candidates to the list _mainWindow = mainWindow; _candidates = _mainWindow.Candidates; InitializeComponent(); foreach (Candidate candidate in _candidates) { CandidateListItem item = new CandidateListItem(candidate, true); CandidateList.AddCandidate(item); } VoteButton.Clicked += VoteButton_Clicked; } catch (Exception) { MessageBox.Show( "An error occurred, please contact person responsible for managing the system", "Error occured", MessageBoxButton.OK); _mainWindow.Logout(); } }
public void ReverseBranches() { BranchList.Reverse(); SetTfsBranches(); NotifyOfPropertyChange(() => BranchSequence); CandidateList.Clear(); }
private void MergingMainViewModel_Deactivated(object sender, DeactivationEventArgs e) { BranchList.Clear(); CandidateList.Clear(); _filterTextChangeTimer?.Dispose(); _filterTextChangeTimer = null; }
public ActionResult List() { var form = new CandidateList { Candidates = Get <ICandidateRepository>().GetAll() }; return(View(form)); }
private bool AddReconversionItems(TextEditor textEditor) { MenuItem menuItem; TextStore textStore = textEditor.TextStore; if (textStore == null) { GC.SuppressFinalize(this); return(false); } ReleaseCandidateList(null); _candidateList = new SecurityCriticalDataClass <UnsafeNativeMethods.ITfCandidateList>(textStore.GetReconversionCandidateList()); if (CandidateList == null) { GC.SuppressFinalize(this); return(false); } int count = 0; CandidateList.GetCandidateNum(out count); if (count > 0) { // Like Winword, we show the first 5 candidates in the context menu. int i; for (i = 0; i < 5 && i < count; i++) { string suggestion; UnsafeNativeMethods.ITfCandidateString candString; CandidateList.GetCandidate(i, out candString); candString.GetString(out suggestion); menuItem = new ReconversionMenuItem(this, i); menuItem.Header = suggestion; menuItem.InputGestureText = GetMenuItemDescription(suggestion); this.Items.Add(menuItem); Marshal.ReleaseComObject(candString); } } // Like Winword, we show "More" menu to open TIP's candidate list if there are more // than 5 candidates. if (count > 5) { menuItem = new EditorMenuItem(); menuItem.Header = SR.Get(SRID.TextBox_ContextMenu_More); menuItem.Command = ApplicationCommands.CorrectionList; this.Items.Add(menuItem); menuItem.CommandTarget = textEditor.UiScope; } return((count > 0) ? true : false); }
protected void FilledRequests_OnSelectedIndexChanged(object sender, EventArgs e) { SelectDiv.Visible = true; var candidates = _databaseConnection.GetCandidateList(FilledRequests.SelectedValue); CandidateList.DataSource = candidates; CandidateList.DataValueField = "Id"; CandidateList.DataTextField = "Name"; CandidateList.DataBind(); }
/// <summary> /// On click on right arrow to switch between candidates /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> /// <returns></returns> async Task OnRightButtonClickedAsync(object sender, EventArgs e) { SwitchCandidate = true; await ConfirmSaveBeforeSwitchAsync(); int index = CandidateList.IndexOf(CandidateList.Where(x => x.Id == CurrentCandidate.Id).First()); Candidate rightCandidate = CandidateList[index + 1].Clone() as Candidate; ChangeCandidate(rightCandidate, index + 1); }
public void SetCandidates(List <Candidate> candidates) { //Set chosen candidates _candidates = candidates; CandidateList.ClearCandidates(); CandidateList.AddCandidates(candidates); //If no candidates chosen, display info NoCandidatesTextBlock.Visibility = candidates.Count == 0 ? Visibility.Visible : Visibility.Collapsed; }
public static void AddCandidateList(string filename) { const int firstnameIndex = 1; const int lastnameIndex = 2; const int partynameIndex = 3; const int bundeslandIndex = 5; const int positionIndex = 6; var parsedFile = DataImportGeneral.ParseFile(filename); const int startIndex = 1; using (var context = new ElectionDBEntities()) { var bundeslandDictionary = context.Bundeslands.ToDictionary(b => b.Name, b => b.Id); for (var i = startIndex; i < parsedFile.Count; i++) { var line = parsedFile.ElementAt(i); var result = GetTitleFirstnameLastnamePartynameFromLine(line); var firstname = result.ElementAt(firstnameIndex); var lastname = result.ElementAt(lastnameIndex); var partyname = result.ElementAt(partynameIndex); var bundeslandName = line[bundeslandIndex].Trim(); if (string.IsNullOrWhiteSpace(bundeslandName)) { continue; } var bundeslandId = bundeslandDictionary[bundeslandName]; var position = int.Parse(line[positionIndex]); var existing = GetExistingCandidate(context, firstname, lastname, partyname, line[2]); var entry = new CandidateList { Election_Id = electionId, Bundesland_Id = bundeslandId, Person_Id = existing.Id, Position = position }; context.CandidateLists.Add(entry); Console.WriteLine("Added person {0} for bundesland {1} on position {2} in election {3}", existing.Id, bundeslandId, position, electionId); } context.SaveChanges(); } }
//*********************************************************** // <method> GetCandidateList //----------------------------------------------------------- private IME.CandidateList GetCandidateList() { int dwSize = IME.ImmGetCandidateList(this.hIMC, 0, (byte[])null, 0); if (dwSize == 0) { return(new CandidateList()); } byte[] lpcdl = new byte[dwSize]; IME.ImmGetCandidateList(this.hIMC, 0, lpcdl, dwSize); IME.CandidateList r = new CandidateList(lpcdl); return(r); }
// GET: FindMatch public async Task <IActionResult> Index(string searchType, string Search) { List <ProfileModel> CandidateList; if (searchType == "Alla") { CandidateList = await _context.ProfileModel.Where(x => x.FirstName.StartsWith(Search) || Search == null).ToListAsync(); } else if (searchType == "Män") { CandidateList = await _context.ProfileModel.Where(x => x.FirstName.StartsWith(Search) && x.Gender == "man" || Search == null && x.Gender == "man").ToListAsync(); } else if (searchType == "Kvinnor") { CandidateList = await _context.ProfileModel.Where(x => x.FirstName.StartsWith(Search) && x.Gender == "kvinna" || Search == null && x.Gender == "kvinna").ToListAsync(); } else if (searchType == "Annat") { CandidateList = await _context.ProfileModel.Where(x => x.FirstName.StartsWith(Search) && x.Gender == "Annat" || Search == null && x.Gender == "Annat").ToListAsync(); } else { CandidateList = await _context.ProfileModel.Where(x => x.FirstName.StartsWith(Search) || Search == null).ToListAsync(); } var userID = Guid.Parse(User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value); var profile = _context.ProfileModel.FirstOrDefault(x => x.Id.Equals(userID)); profile.UserInterests = _context.Interests.FirstOrDefault(x => x.ProfileModelId.Equals(userID)); CandidateList.Remove(profile); foreach (var item in CandidateList) { item.UserInterests = _context.Interests.FirstOrDefault(x => x.ProfileModelId.Equals(item.Id)); if (item.UserInterests == null) { item.UserInterests = new Interests(); } item.MatchingValue = MatchingValue(profile, item); } return(View(CandidateList)); }
public static void AddCandidateList(string filename) { const int personIdIndex = 1; const int bundeslandIndex = 8; const int positionIndex = 9; var parsedFile = DataImportGeneral.ParseFile(filename); const int startIndex = 1; using (var context = new ElectionDBEntities()) { var idDictionary = context.Bundeslands.ToDictionary(d => d.Name, d => d.Id); for (var i = startIndex; i < parsedFile.Count; i++) { var line = parsedFile.ElementAt(i); var bundeslandShort = line[bundeslandIndex]; if (string.IsNullOrWhiteSpace(bundeslandShort)) { continue; } var bundeslandName = DataImportGeneral.BundeslaenderShortDictionary[bundeslandShort]; var bundeslandId = idDictionary[bundeslandName]; var personId = int.Parse(line[personIdIndex]); var position = int.Parse(line[positionIndex]); var entry = new CandidateList { Election_Id = electionId, Person_Id = personId, Bundesland_Id = bundeslandId, Position = position }; context.CandidateLists.Add(entry); } context.SaveChanges(); } }
/// <summary> /// Save the evaluation and add signature if needed and if asked /// </summary> /// <param name="signature">Boolean, true if the user has clicked on sign button</param> async void SaveEvaluation(Boolean signature) { if (signature && Eval.Criterias.All(c => !c.SelectedLevel.Equals("")) && !Eval.IsSigned) { ComeBackSigning = true; await Navigation.PushAsync(new SigningPage(Eval, CurrentCandidate)); } Eval.LastUpdatedDate = DateTime.Now; String jsonEval = JsonParser.GenerateJsonEval(Eval); JsonParser.WriteJsonInInternalMemory(jsonEval, CurrentCandidate.Id, LoggedUser.Id, CurrentEvent.Id); foreach (Criteria c in Eval.Criterias) { c.IsModified = false; } Eval.IsModified = false; int index = CandidateList.IndexOf(CandidateList.Where(x => x.Id == CurrentCandidate.Id).First()); CandidateList[index] = CurrentCandidate; CurrentCandidate.CheckStatus(); ChangeStatusImage(); if (Eval.Criterias.All(c => !c.SelectedLevel.Equals(""))) { ButtonSigner.IsEnabled = true; } else { ButtonSigner.IsEnabled = false; } await Task.Run(() => { Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = false; }); EvaluationSender.AddEvaluationInQueue(jsonEval); EvaluationSender.SendJsonEvalToServer(); Device.BeginInvokeOnMainThread(() => { ButtonEnregister.IsEnabled = true; }); }); }
private void MergingMainViewModel_Activated(object sender, ActivationEventArgs e) { Shell = IoC.Get <IShell>(); NotifyOfPropertyChange(() => BranchSequence); CandidateList.Clear(); NotifyOfPropertyChange(() => NumCandidates); SetTfsBranches(); FilterText = string.Empty; _filterTextChangeTimer = new System.Timers.Timer(500); _filterTextChangeTimer.AutoReset = true; _filterTextChangeTimer.Elapsed += _filterTextChangeTimer_Elapsed; if (CurrentOptions == null) { CurrentOptions = new MyOptions(); } else { CurrentOptions.SetDefaultOptions(); } Refresh(); }
private IList <DbModels.Party> Execute(string json) { CandidateList candidatesList = _parser.GetCandidatesList(json); return(candidatesList.ConvertToDbModel().ToList()); }
public void ClearCandidates() { //Clear chosen candidates _candidates = null; CandidateList.ClearCandidates(); }
public CandidateEventArgs(CandidateList cdl, int listflag) { this.List = cdl; this.listflag = listflag; }
public void ClearChosenCandidates() { //Clear user selection CandidateList.ClearChosenCandidates(); }