private void btnDraw_Click(object sender, RoutedEventArgs e) { switch (cbFunction.SelectedItem.ToString()) { case "Spectral Graph for GB-S3VDD": //Draw Visual Spectral Graph for GB-S3VDD //Clear old Edge for (int i = 0; i < drawingPad.Children.Count; ++i) { string obj = drawingPad.Children[i].ToString(); if (obj.IndexOf("Line") != -1) { drawingPad.Children.RemoveAt(i); i--; } } dataset = new Dataset(lstPoint.ToArray()); graph = new GraphBase(dataset, double.Parse(txtXichma.Text), int.Parse(txtK.Text)); graph.myCanvas = drawingPad; graph.DrawSG_for_GBS3VDD(); tbStatus.Text = "Visual Spectral Graph for GB-S3VDD (with k = " + txtK.Text + " & σ = " + txtXichma.Text + ") completed !"; break; case "Spectral Graph": //Draw Visual spectral graph //Clear old Edge for (int i = 0; i < drawingPad.Children.Count; ++i) { string obj = drawingPad.Children[i].ToString(); if (obj.IndexOf("Line") != -1) { drawingPad.Children.RemoveAt(i); i--; } } dataset = new Dataset(lstPoint.ToArray()); graph = new GraphBase(dataset, double.Parse(txtXichma.Text), int.Parse(txtK.Text)); graph.myCanvas = drawingPad; graph.DrawVSG(); tbStatus.Text = "Visual Spectral Graph (with k = " + txtK.Text + " & σ = " + txtXichma.Text + ") completed !"; break; } }
private Color rColor; //Rectangle color #endregion Fields #region Constructors public MainWindow() { InitializeComponent(); draw = new Draw(drawingPad); dataset = new Dataset(); restrictDataset = new Dataset(); lstPoint = new List<DPoint>(); //Initialize chkRed.IsChecked = true; chkSingle.IsChecked = true; pColor = Color.FromArgb(255, 255, 0, 0); rColor = Color.FromArgb(70, 0, 150,150); pType = Draw.PointType.Single; pSign = 1; isMouseDown = false; cbFunction.Items.Add("Spectral Graph for GB-S3VDD"); cbFunction.Items.Add("Spectral Graph"); cbFunction.Items.Add("Clustering"); cbFunction.SelectedIndex = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="data">Dataset here</param> /// <param name="xichma">xichma in wij = exp( ||xi-xj||^2 / 2*xichma^2 )</param> /// <param name="k">kNN of xi</param> public GraphBase(Dataset data, double xichma, int k) { this.Data = data; this.Xichma = xichma; this.k = k; }
/// <summary> /// Constructor /// </summary> /// <param name="data">Dataset here</param> public GraphBase(Dataset data) { this.Data = data; }
/// <summary> /// Constructor 2 /// </summary> /// <param name="_data">Dataset here</param> /// <param name="nrSampling">Number of Sampling</param> public Clustering(Dataset _data, int nrSampling) { this._data = _data; this.nrSampling = nrSampling; }
/// <summary> /// Constructor 1 /// </summary> /// <param name="_data">Dataset here</param> public Clustering(Dataset _data) { this._data = _data; myClusters = new Dictionary<int, DPoint[]>(); }
private void btnSaveImg_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveDialog = new SaveFileDialog(); dataset = new Dataset(lstPoint.ToArray()); saveDialog.DefaultExt = ".png"; saveDialog.Filter = "PNG (.png) | *.png"; Nullable<bool> result = saveDialog.ShowDialog(); if (result == true) { string imgPath = saveDialog.FileName; FileStream fs = new FileStream(imgPath, FileMode.Create); RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)drawingPad.ActualWidth, (int)drawingPad.ActualHeight, 1 / 96, 1 / 96, PixelFormats.Pbgra32); renderBitmap.Render(drawingPad); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(renderBitmap)); encoder.Save(fs); fs.Close(); MessageBox.Show("Capture and Save image completed !", "VSG", MessageBoxButton.OK, MessageBoxImage.Information); tbStatus.Text = "Capture and Save image completed !"; } }
private void btnSaveData_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveDialog = new SaveFileDialog(); dataset = new Dataset(lstPoint.ToArray()); saveDialog.DefaultExt = ".txt"; saveDialog.Filter = "Text documents (.txt) | *.txt"; Nullable<bool> result = saveDialog.ShowDialog(); if (result == true) { dataset.Save(saveDialog.FileName); MessageBox.Show("Save dataset completed !", "VSG", MessageBoxButton.OK, MessageBoxImage.Information); tbStatus.Text = "Save dataset completed !"; } }
private void btnOpenData_Click(object sender, RoutedEventArgs e) { try { drawingPad.Children.Clear(); lstPoint.Clear(); dataset = null; OpenFileDialog openDlg = new OpenFileDialog(); openDlg.ShowDialog(); dataset = Dataset.Read(openDlg.FileName); datasetName = openDlg.FileName; switch (cbFunction.SelectedItem.ToString()) { case "Spectral Graph for GB-S3VDD": case "Spectral Graph": case "Clustering": lstPoint = dataset.Data.ToList(); graph = new GraphBase(dataset, double.Parse(txtXichma.Text), int.Parse(txtK.Text)); graph.myCanvas = drawingPad; graph.DrawDataset(); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }