private void cnvPoints_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_pointsUI.Count < MAXPOINT) { System.Windows.Point tmp = Mouse.GetPosition(cnvPoints); UIPoint _new; if ((bool)rbPoint.IsChecked) { _new = new UIPoint(new Point(tmp.X, tmp.Y, Point.Type.KMEANS)); _new.AddFatherPoint(cnvPoints); _pointsUI.Add(_new); } else if ((bool)rbCluster.IsChecked) { UICluster uic = new UICluster(tmp.X, tmp.Y, new Random()); uic.AddFather(cnvPoints); _clusterUI.Add(uic); } else { MessageBox.Show("Scegliere se usare il Kmeans o il KNN", "Informazione", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (!_firstPlay) { _dsp.Start(); } } }
private void btnClusters_Click(object sender, RoutedEventArgs e) { Random rnd = new Random(); for (int index = 0; index < int.Parse(txtNumberCluster.Text); index++) { UICluster tmp = new UICluster(rnd.Next((int)cnvPoints.ActualWidth), rnd.Next((int)cnvPoints.ActualHeight), rnd); tmp.AddFather(cnvPoints); _clusterUI.Add(tmp); } if (!_firstPlay) { _dsp.Start(); } }