Exemple #1
0
        private void LoadFile()
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "CSV files (*.csv)|*.csv|TXT files (*.txt)|*.txt";

            if (dlg.ShowDialog() == true)
            {
                clusterData = new ClusterData();

                ClusterDataReader dr = ClusterDataReaderFactory.GetClusterDataReader(dlg.FileName, clusterData);

                if (dr == null)
                {
                    WPFMessageBox.MsgError("Hiba történt a file betöltése során!");
                    return;
                }
                TextBlockFileName.Text        = dlg.FileName;
                GridAllStatistics.DataContext = clusterData;
                GridXStatistics.DataContext   = clusterData;
                GridYStatistics.DataContext   = clusterData;

                clusterData.NormalizePoints();

                PointChart.Data = clusterData;
                PointChart.Draw();
            }
        }
Exemple #2
0
        private void ButtonClustering_Click(object sender, RoutedEventArgs e)
        {
            TextBoxLog.Clear();

            try
            {
                AlgorithmKMeans alg = new AlgorithmKMeans(clusterData, int.Parse(TextBoxNumberOfClusters.Text));
                alg.DistanceFunction = GetDistanceFunction();
                alg.MaxIterations    = int.Parse(TextBoxMaximumIterations.Text);
                alg.Iteration       += Alg_Iteration;

                alg.Run();

                PointChart.Data = clusterData;
                PointChart.Draw();

                DataGridClusterStats.ItemsSource = clusterData.GetClusterStatistics();
            }
            catch (NullReferenceException)
            {
                WPFMessageBox.MsgError("Empty dataset, please load a datafile.");
            }
            catch (InvalidOperationException)
            {
                WPFMessageBox.MsgError("An empty cluster created. Please run algorithm once more. The value of K is too big?");
            }
            catch (Exception ex)
            {
                WPFMessageBox.MsgError("An error occured!", ex);
            }
        }
Exemple #3
0
 private void MenuOpen_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         LoadFile();
         TextBoxLog.Clear();
         DataGridClusterStats.ItemsSource = null;
     }
     catch (Exception ex)
     {
         WPFMessageBox.MsgError(ex.Message);
     }
 }
Exemple #4
0
        private void TextBoxNumber_LostFocus(object sender, RoutedEventArgs e)
        {
            if (sender is TextBox)
            {
                TextBox tb = sender as TextBox;

                if (!string.IsNullOrEmpty(tb.Text))
                {
                    int a;

                    if (!int.TryParse(tb.Text, out a))
                    {
                        WPFMessageBox.MsgError("Number format error!");
                    }
                }
            }
        }