public void LoadAllCandidatesAndTests() { Tests.Clear(); Candidates.Clear(); TestDefinitions.Clear(); Test_Definition.Load(); Candidate.Load(); Test.Load(); foreach (Test_Definition td in Test_Definition) { TestDefinitions.Add(td); } foreach (Candidate c in Candidate) { Candidates.Add(c); foreach (Test t in c.Test) { Tests.Add(t); if (t.Test_Definition == null && t.test_definition_id > 0) { t.Test_Definition = db.Test_Definition.FirstOrDefault(td => td.Id == t.test_definition_id); } } } }
public void StartNewElection() { ElectionEnded = false; Candidates.Clear(); Candidates.TrimExcess(); AutoPickGovernor = DateTime.MinValue; }
public void ClearShouldClear() { var candidates = new Candidates(9); candidates.AddAll(); candidates.Clear(); for (byte i = 1; i <= 9; i++) { candidates.Has(i).Should().BeFalse(); } }
private void GetCandidates(ResourceMapItem resourceMapItem) { Candidates.Clear(); foreach (Candidate candidate in EnumerateCandidates(resourceMapItem)) { CandidateViewModel candidateViewModel = new CandidateViewModel(PriFile, PriStream, ResourceRootPath, resourceMapItem, candidate); Candidates.Add(candidateViewModel); } }
private void OnNewTask(object sender, RoutedEventArgs e) { TaskName.Text = null; DueDate.SelectedDate = DateTime.Today; Instructions.Text = null; Animals.Clear(); Candidates.Clear(); TaskName.Focus(); ScheduleTask.IsEnabled = true; NewTask.IsEnabled = false; }
private void BtnSearch_OnClick(object sender, RoutedEventArgs e) { Candidates.Clear(); Task.Factory.StartNew(() => dynamicMemberDatabase.FindCandidates(parsedInputValue, parsedInputValue, parsedOutputValue, 0)) .ContinueWith(task => { foreach (var x in task.Result) { Candidates.Add(x); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
async private void Button_Click(object sender, RoutedEventArgs e) { try { var container = new InkRecognizerContainer(); var recognizers = container.GetRecognizers(); if (recognizers != null && recognizers.Count > 0) { // 以下三行為取得Combobox選擇語系, 並設定語系的辨識引擎 string recognizerName = recognizersCombobox.SelectedItem.ToString(); var recognizer = recognizers.FirstOrDefault((x) => x.Name == recognizerName); if (recognizer != null) { container.SetDefaultRecognizer(recognizer); } } if (inkCanvas.InkPresenter.StrokeContainer != null) { var result = await container.RecognizeAsync(inkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All); string returnText = string.Empty; inkCanvas.InkPresenter.StrokeContainer.Clear(); Candidates.Clear(); foreach (var r in result) { foreach (var c in r.GetTextCandidates()) { Candidates.Add(c); } } listview.Visibility = Visibility.Visible; button.Visibility = Visibility.Collapsed; } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } //if (result != null) //{ // returnText = result[0].GetTextCandidates()[0]; //} //OnRecognized(returnText); }
private void ClosePriFile() { Entries.Clear(); Candidates.Clear(); PreviewContent = null; if (PriStream != null) { PriStream.Close(); PriStream = null; } PriFile = null; ResourceRootPath = null; SetResourceRootPathCommand.RaiseCanExecuteChanged(); }
/// <summary> /// /// </summary> /// <param name="newValue">value for this cell, 0 unset the value</param> /// <param name="refreshOtherCellCandidates"></param> public void Set(int newValue, bool refreshOtherCellCandidates = false) { Value = newValue; if (newValue == 0) { Unset(); } else { Candidates.Clear(); _puzzle.RemoveCandidates(GetCellsVisible(), new[] { newValue }); } if (refreshOtherCellCandidates) { _puzzle.RefreshCandidates(); } }
public void Build(List <PhotoSession> photoSessions) { Candidates.Clear(); Sessions = photoSessions; ComputeSessionsScores(); var rankedSessions = Sessions.OrderByDescending(s => s.Score).ToList(); while (rankedSessions.Any()) { var mainSession = rankedSessions.First(); var nearbySessions = rankedSessions .Skip(1) .Where(s => IsNear(mainSession.Location, s.Location)).ToList(); var newCandidate = new DestinationCandidate(mainSession); if (nearbySessions.Count() > 0) { newCandidate.Add(nearbySessions.ToList()); } Candidates.Add(newCandidate); rankedSessions = rankedSessions .Skip(1) .Where(s => !nearbySessions.Contains(s)).ToList(); } // Merge(); Candidates = Candidates.OrderByDescending(l => l.TotalScore).ToList(); // fill in the destination from the session locations foreach (var candidate in Candidates) { var childLocation = candidate.Sessions.Select(s => s.Location).ToList(); candidate.Location = _locationService.DetectParentLocation(childLocation); candidate.DisplayName = candidate?.Location.DisplayName ?? "Unknown"; Debug.Assert(candidate.Location != null); } }
private void LoadCandidatesQualifiedForOpening(ViewQualifiedCandidatesForOpeningViewMessage obj) { SelectedCandidate = new Candidate(); var placements = PlacementService.GetAllPlacements().Where(d => d.OpeningId == obj.Opening.Id); Opening = obj.Opening; var candidates = CandidateService.GetCandidatesQualifiedForRequiredQualification(obj.RequiredQualificationId); Candidates.Clear(); foreach (var v in candidates) { if (placements.Any(d => d.CandidateId == v.Id && d.OpeningId == Opening.Id)) { continue; } Candidates.Add(v); } //TODO might want to use DTO instead of full candidate soon }
async private void RecognizeButton_Click(object sender, RoutedEventArgs e) { var strokes = inkCanvas.InkPresenter.StrokeContainer.GetStrokes(); if (strokes.Count <= 0) { return; } var result = await Container.RecognizeAsync(inkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All); Candidates.Clear(); foreach (var item in result) { foreach (var candidate in item.GetTextCandidates()) { Candidates.Add(candidate); } } }
public static void Restart() { try { if (candidates != null) { Candidates.Clear(); } if (Voters != null) { Voters.Clear(); } if (CurrentCandidate != null) { CurrentCandidate = null; } IsInited = false; } catch (Exception) { } }
public void GenerateCandidates(ITile multiTile, TileCategory category) { if (multiTile is MultiTile) { GenerateCandidates(multiTile, category); } else { var newtile = _multiTiles.FirstOrDefault(t => t.Id == multiTile.Id); if (newtile != null) { GenerateCandidates(newtile, category); } else { if (Candidates != null) { Candidates.Clear(); } } } }
public void Set(int newValue, bool refreshOtherCellCandidates = false) { int oldValue = Value; Value = newValue; if (newValue == 0) { foreach (int i in Utils.OneToNine) { Candidates.Add(i); } _puzzle.ChangeCandidates(GetCellsVisible(), oldValue, remove: false); } else { Candidates.Clear(); _puzzle.ChangeCandidates(GetCellsVisible(), newValue); } if (refreshOtherCellCandidates) { _puzzle.RefreshCandidates(); } }
private async Task InitializeCandidates() { try { Candidates.Clear(); var candidates = await Task.FromResult(GetCandidates()); foreach (var candidate in candidates) { Candidates.Add(new CandidateLookupItem() { Candidate = candidate, IsChecked = CandidateHasVote(candidate, Person) }); } } catch (Exception ex) { #if DEBUG Console.WriteLine(ex.Message); #endif //TODO: Logger } }
private void button3_Click(object sender, EventArgs e) { Candidates.Clear(); if (InkOverlay.Ink.Strokes.Count <= 0) { return; } using (var context = new RecognizerContext()) { context.Strokes = InkOverlay.Ink.Strokes; var result = context.Recognize(out RecognitionStatus status); if (status == RecognitionStatus.NoError) { var candidates = result.GetAlternatesFromSelection(); foreach (var candidate in candidates) { Candidates.Add(candidate.ToString()); } } } comboBox1.DataSource = null; comboBox1.DataSource = Candidates; comboBox1.SelectedIndex = 0; }
public async Task InitializeAsync() { IsBusy = true; try { var candidates = await recruitmentQueryService.GetAcceptedCandidatesAsync(); Candidates.Clear(); foreach (var candidate in candidates) { Candidates.Add(candidate); } } catch (Exception exc) { await alertService.DisplayAlertAsync(string.Empty, "Something went wrong", "OK"); } finally { IsBusy = false; } }
public void Add(T item) { if (TopResult == null) { TopResult = item; return; } var result = _comparer.Compare(TopResult, item); if (result == 0) { Candidates.Add(item); return; } if (result > 0) { return; } TopResult = item; Candidates.Clear(); }
//List<double[]>[] compDataPrev = null; void SearchThreadProc() { try { buttonUpdate("Started..."); Candidates.Clear(); Element[] elist = Method.GetElementList(); CandidateElement = elist[Element].Name; double[] analitLy = candidateLineListAnalit.getLyList(); double[] compLy = candidateLineListComp.getLyList(); List <double[]>[] analitValues = candidateLineListAnalit.getValues(buttonSearch, "Anlit^:");/*new List<double[]>[analitLy.Length]; * bool[] enabledSpectr = new bool[analitLy.Length]; * for (int i = 0; i < analitLy.Length && Common.IsRunning; i++) * { * List<DataShot> values = DataShotExtractor.extract(Method, elist[Element].Name, Formula, analitLy[i], * windowSize, cbSearchType.SelectedIndex == 1, 0, (double)numMax.Value, * cbValueType.SelectedIndex == 1); * if (values != null) * { * analitValues[i] = calcAnalit(values, analitLy[i], windowSize, * 0, (double)numMax.Value); * //if(analitValues[i] == null) * // analitValues[i] = calcAnalit(values, analitLy[i], windowSize, * // 0, (double)numMax.Value); * } * if(i%50 == 0) * buttonUpdate("Check "+i+" from "+analitLy.Length+" analitic lines"); * }*/ //buttonUpdate("Found "+analitValues.Length+" analitic lines..."); List <double[]>[] compData = candidateLineListComp.getValues(buttonSearch, "Compare:");/*new List<double[]>[compLy.Length]; * for (int i = 0; i < compLy.Length && Common.IsRunning; i++) * { * List<DataShot> values = DataShotExtractor.extract(Method, elist[Element].Name, Formula, compLy[i], * windowSize, cbSearchType.SelectedIndex == 1, (double)numMin.Value, (double)numMax.Value, * cbValueType.SelectedIndex == 1); * if (values != null) * { * compData[i] = calcAnalit(values, compLy[i], windowSize, (double)numMin.Value, (double)numMax.Value); * //if(compData[i] == null) * // compData[i] = calcAnalit(values, compLy[i], windowSize, (double)numMin.Value, (double)numMax.Value); * } * if(i%50 == 0) * buttonUpdate("Found " + analitValues.Length + " analit. Check " + i + " from "+compLy.Length + " compare lines"); * }*/ //buttonUpdate("Found " + analitValues.Length + " analitic lines and "+compData.Length+" compare lines."); long prevGC = DateTime.Now.Ticks; long fromTime = DateTime.Now.Ticks; for (int a = 0; a < analitLy.Length && Common.IsRunning; a++) { List <double[]> curAnalit = analitValues[a]; if (curAnalit == null || curAnalit.Count == 0) { continue; } for (int c = 0; c < compLy.Length && Common.IsRunning; c++) { if (Math.Abs(analitLy[a] - compLy[c]) < 0.5) { continue; } List <double[]> curComp = compData[c]; if (curComp == null || curComp.Count == 0) { continue; } if (curAnalit.Count != curComp.Count) { Log.Out("Line compare count not eqals for analit=" + analitLy[a] + " and compare=" + compLy[c]); continue; } double[] analitVal = new double[curAnalit.Count]; double[] conVal = new double[analitVal.Length]; bool[] en = new bool[analitVal.Length]; double enCount = 0; for (int i = 0; i < analitVal.Length; i++) { double[] av = curAnalit[i]; double[] cv = curComp[i]; analitVal[i] = av[0] / cv[0]; conVal[i] = av[1]; //if (serv.IsValid(analitVal[i]) && av[1] >= 0 && av[1] < 100 && curAnalit[i][2] == 1) if (serv.IsValid(analitVal[i]) && curAnalit[i][2] == 1) { en[i] = true; enCount++; } else { en[i] = false; } } if (enCount < (analitVal.Length - 4) || enCount < 5) { continue; } double sko = 0; Function fk = new Function(Function.Types.Line, analitVal, conVal, en, true, false, 1.1); if (fk.GetK()[1] < 0) { continue; } int count = 0; for (int i = 0; i < en.Length; i++) { if (en[i] == false) { continue; } double currentCon = fk.CalcY(analitVal[i]); double dlt; if (conVal[i] > -1 && serv.IsValid(currentCon) && conVal[i] > 0)// && currentCon < 1000) { dlt = (conVal[i] - currentCon) * 100 / conVal[i]; count++; } else { dlt = 0; } sko += dlt * dlt; } if (count == 0) { continue; } sko = Math.Sqrt(sko / count); if (sko > 0.0001)// && count / enCount > 0.5) { } else { continue; } Result r = new Result(analitLy[a], compLy[c], conVal, analitVal, en, fk, sko); for (int i = 0; i < Candidates.Count; i++) { if (Candidates[i].SKO > r.SKO) { Candidates.Insert(i, r); r = null; break; } } if (r != null) { Candidates.Add(r); } while (Candidates.Count > 5000) { Candidates.RemoveAt(Candidates.Count - 1); } } if (prevGC + 10 * 10000000 < DateTime.Now.Ticks) { GC.Collect(); GC.WaitForPendingFinalizers(); prevGC = DateTime.Now.Ticks; } if (a > 0) { double estimate = (DateTime.Now.Ticks - fromTime) / (double)a; estimate *= (analitLy.Length - a); DateTime tdt = new DateTime(DateTime.Now.Ticks + (long)estimate); estimate /= 10000000; String bestSko = ""; if (Candidates.Count > 0) { bestSko = " SKO=" + Math.Round(Candidates[0].SKO, 4); } buttonUpdate("Done " + Math.Round(a * 1009.0 / analitLy.Length) / 10.0 + " To be done at " + tdt.ToString("H:mm:ss") + bestSko); } } listboxResult.Items.Clear(); for (int i = 0; i < Candidates.Count; i++) { listboxResult.Items.Add(Candidates[i]); } Common.Beep(); MessageBox.Show(this, "Найдено " + Candidates.Count + " пар линий..."); } catch (Exception ex) { Log.Out(ex); } try { buttonSearch.Enabled = true; buttonSearch.Text = "Начать поиск"; th = null; } catch { } }
private void GetEntries() { Entries.Clear(); Candidates.Clear(); ResourceMapSection primaryResourceMapSection = PriFile.GetSectionByRef(PriFile.PriDescriptorSection.PrimaryResourceMapSection.Value); HierarchicalSchemaSection schemaSection = PriFile.GetSectionByRef(primaryResourceMapSection.SchemaSection); Dictionary <ResourceMapEntry, EntryViewModel> entriesToViewModels = new Dictionary <ResourceMapEntry, EntryViewModel>(); bool parentMissing = false; do { foreach (ResourceMapScope scope in schemaSection.Scopes) { if (scope.FullName == string.Empty) { continue; } IList <EntryViewModel> targetEntryCollection; if (scope.Parent == null) { targetEntryCollection = Entries; } else { EntryViewModel parentViewModel; if (scope.Parent.FullName == string.Empty) { targetEntryCollection = Entries; } else if (!entriesToViewModels.TryGetValue(scope.Parent, out parentViewModel)) { parentMissing = true; continue; } else { targetEntryCollection = parentViewModel.Children; } } EntryViewModel entry = new EntryViewModel(scope); GetEntryType(entry); entriesToViewModels.Add(scope, entry); targetEntryCollection.Add(entry); } } while (parentMissing); foreach (ResourceMapItem item in schemaSection.Items) { EntryViewModel parentViewModel; if (!entriesToViewModels.TryGetValue(item.Parent, out parentViewModel)) { continue; } parentViewModel.Children.Add(new EntryViewModel(item)); GetEntryType(parentViewModel.Children.Last()); } CollapseStringResources(); }
private void ClearButton_Click(object sender, RoutedEventArgs e) { inkCanvas.InkPresenter.StrokeContainer.Clear(); Candidates.Clear(); }
public void Find() { Candidates.Clear(); SupplementaryList.Clear(); int numberOfSpaces = FindTableau.NumberOfSpaces; int maxExtraSuits = ExtraSuits(numberOfSpaces); int maxExtraSuitsToSpace = ExtraSuits(numberOfSpaces - 1); for (int from = 0; from < NumberOfPiles; from++) { HoldingStack holdingStack = HoldingStacks[from]; Pile fromPile = FindTableau[from]; holdingStack.Clear(); holdingStack.StartingRow = fromPile.Count; int extraSuits = 0; for (int fromRow = fromPile.Count - 1; fromRow >= 0; fromRow--) { Card fromCard = fromPile[fromRow]; if (fromCard.IsEmpty) { break; } if (fromRow < fromPile.Count - 1) { Card previousCard = fromPile[fromRow + 1]; if (!previousCard.IsSourceFor(fromCard)) { break; } if (fromCard.Suit != previousCard.Suit) { // This is a cross-suit run. extraSuits++; if (extraSuits > maxExtraSuits + holdingStack.Suits) { break; } } } // Add moves to other piles. if (fromCard.Face < Face.King) { PileList piles = FaceLists[(int)fromCard.Face + 1]; for (int i = 0; i < piles.Count; i++) { for (int count = 0; count <= holdingStack.Count; count++) { HoldingSet holdingSet = new HoldingSet(holdingStack, count); if (extraSuits > maxExtraSuits + holdingSet.Suits) { continue; } int to = piles[i]; if (from == to || holdingSet.Contains(from)) { continue; } // We've found a legal move. Pile toPile = FindTableau[to]; Algorithm.ProcessCandidate(new Move(from, fromRow, to, toPile.Count, AddHolding(holdingSet))); // Update the holding pile move. int holdingSuits = extraSuits; if (fromRow > 0 && (!fromPile[fromRow - 1].IsTargetFor(fromCard) || fromCard.Suit != fromPile[fromRow - 1].Suit)) { holdingSuits++; } if (holdingSuits > holdingStack.Suits) { int length = holdingStack.FromRow - fromRow; holdingStack.Push(new HoldingInfo(from, fromRow, to, holdingSuits, length)); } break; } } } // Add moves to an space. for (int i = 0; i < FindTableau.NumberOfSpaces; i++) { int to = FindTableau.Spaces[i]; if (fromRow == 0) { // No point in moving from a full pile // from one open position to another unless // there are more cards to turn over. if (FindTableau.GetDownCount(from) == 0) { continue; } } else { // No point in moving anything less than // as much as possible to an space. Card nextCard = fromPile[fromRow - 1]; if (fromCard.Suit == nextCard.Suit) { if (nextCard.IsTargetFor(fromCard)) { continue; } } } for (int count = 0; count <= holdingStack.Count; count++) { HoldingSet holdingSet = new HoldingSet(holdingStack, count); if (holdingSet.FromRow == fromRow) { // No cards left to move. continue; } if (extraSuits > maxExtraSuitsToSpace + holdingSet.Suits) { // Not enough spaces. continue; } // We've found a legal move. Pile toPile = FindTableau[to]; Algorithm.ProcessCandidate(new Move(from, fromRow, to, toPile.Count, AddHolding(holdingSet))); break; } // Only need to check the first space // since all spaces are the same // except for undealt cards. break; } } } }
public void TestClear() { tgt.Clear(); Assert.Equal(0, tgt.Count()); Assert.Equal("", tgt.ToString()); }
//======================================================================================== // Methods //======================================================================================== /// <summary> /// Execute the scanner. /// </summary> /// <remarks> /// Duplicates are first identified by comparing Artist, Name, and Album. These are /// all stored as (ID3) tags within the media file. So these must match or the files /// are already different and any further analysis (checksum or MD5) would be useless. /// </remarks> public override void Execute() { try { Logger.WriteLine(base.name, "Duplicate scanner beginning"); int total; int count = 0; Track candidate; Candidates candidates = new Candidates(); TrackCollection duplicates = new TrackCollection(); Playlist libraryPlaylist = controller.LibraryPlaylist; PersistentIDCollection pids; if (!String.IsNullOrEmpty(albumFilter) && !String.IsNullOrEmpty(artistFilter)) { pids = catalog.FindTracksByAlbum(albumFilter, artistFilter); total = pids.Count; Logger.WriteLine(base.name, String.Format( "Analyzing album '{0}' by '{1}' with {2} tracks", albumFilter, artistFilter, total)); } else if (!playlistFilter.IsEmpty) { pids = catalog.FindTracksByPlaylist(playlistFilter); total = pids.Count; Logger.WriteLine(base.name, String.Format( "Analyzing playlist '{0}' with {1} tracks", catalog.FindPlaylistName(playlistFilter), total)); } else { pids = catalog.FindTracksByPlaylist(libraryPlaylist.PersistentID); total = pids.Count; Logger.WriteLine(base.name, String.Format("Analyzing {0} tracks", total)); } foreach (PersistentID persistentID in pids) { if (base.isActive) { Track track = libraryPlaylist.GetTrack(persistentID); if ((track != null) && (track.Kind == TrackKind.File)) { candidate = track; candidate.IsBuffered = true; // need to skip phantoms or Track.IsBetterThan will hang if (!String.IsNullOrEmpty(candidate.Location)) { Track demoted = candidates.Reconcile(candidate); if (demoted != null) { duplicates.Add(demoted); // DO NOT dispose demoted here because that would corrupt // the instance we just stored in the duplicates collection } } // DO NOT dispose candidate here because the instance is stored in // either the candidates or duplicates collection and disposing // would corrupt that reference } // DO NOT dispose track here because the instance is stored in // either the candidates or duplicates collection and disposing // would corrupt that reference count++; base.ProgressPercentage = (int)((double)count / (double)total * 100.0); } else { Logger.WriteLine(base.name, "Duplicate scanner cancelled while scanning"); break; } } if (base.isActive) { UpdateCandidates(candidates); } candidates.Clear(); candidates = null; if (base.isActive) { ArchiveDuplicates(duplicates); } duplicates.Dispose(); duplicates = null; pids.Clear(); pids = null; Logger.WriteLine(base.name, "Duplicate scanner completed"); } catch (Exception exc) { App.LogException(new SmartException(exc)); } }