/// <summary> /// Handles the Click event of the ExportButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void ExportButton_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.AddExtension = true; saveFileDialog.DefaultExt = ".dat"; if (saveFileDialog.ShowDialog() == true) { var path = saveFileDialog.FileName; DecisionTree.Implementation.Interfaces.ITreeSaver treeSaver = new BinaryTreeSaver(); try { treeSaver.Export(this.tree, path); } catch (DecisionTree.Implementation.Exceptions.TreeException ex) { MessageBox.Show(ex.Message); } } }
/// <summary> /// Handles the Click event of the ImportButton control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void ImportButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; openFileDialog.Filter = "dat files (*.dat)|*.dat"; DecisionTree.Implementation.Interfaces.ITreeSaver treeSaver = new BinaryTreeSaver(); if (openFileDialog.ShowDialog() == true) { try { this.tree = treeSaver.Import(openFileDialog.FileName); DecisionTreeWPFRenderer renderer = new DecisionTreeWPFRenderer(tree, this.TreeCanvas); renderer.Visualize(); } catch (DecisionTree.Implementation.Exceptions.TreeException ex) { MessageBox.Show(ex.Message); } } }