//Add signature private void addSignature(List <InkStroke> strokes) { if (strokes.Count == 0) { DisplayNoSignaturesDialog(); return; } Debug.WriteLine("Adam dodaje podpis."); bool isOriginal = false; //IsChecked zwraca typ 'bool?', może posiadać wartość null stąd dodatkowy if tutaj sprawdzający czy nie zwraca nulla if (isOriginalCheckBox.IsChecked.HasValue) { isOriginal = isOriginalCheckBox.IsChecked.Value; } else { throw new Exception("isOriginal inputbox nie posiada wartości (jest wyłączony?)"); } try { var author = authorController.getAuthor(authorCombobox.SelectedItem.ToString()); if (signatureController.addSignature(strokes, author, isOriginal) == null) { DisplayWarningMessage("Błąd", "Próba dodania podpisu zakończona niepowodzeniem"); } } catch (System.NullReferenceException) { DisplayWarningMessage("Błąd", "Próba dodania podpisu zakończona niepowodzeniem"); } }
private List <Signature> getOriginalSignaturesFromAuthor() { List <Signature> signatureList = new List <Signature>(); if (this.authorCombobox.Items.Any()) { signatureList = authorController.getAuthor(this.authorCombobox.SelectedItem.ToString()).getOriginalSignatures(); } return(signatureList); }
private string kNearestNeighbours(List <double> inputFeatures) { const int k = 10; return(authorController.getAuthorsNames().Select(name => authorController.getAuthor(name)). Select(author => author.getOriginalSignatures().Select(sgn => Tuple.Create(author.getName(), sgn))). SelectMany(x => x).AsEnumerable().Select(x => Tuple.Create(x.Item1, buildFeatures(x.Item2))). Select(x => Tuple.Create(x.Item1, L1(inputFeatures, x.Item2))).OrderByDescending(x => x.Item2). Take(k).GroupBy(x => x.Item1).OrderByDescending(grp => grp.Count()).First().Select(x => x.Item1).First()); }