Exemplo n.º 1
0
        /// <summary>
        /// Creates a graph from a node, prompting use to save file
        /// </summary>
        /// <param name="n"></param>
        private void CreateGraph(TreeBankNode n)
        {
            saveFileDialog.Title = "Select output path for graph";
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (_dot == null)
                {
                    try
                    {
                        _dot = new Dot(Settings.Default.DotPath);
                    }
                    catch (Exception)
                    {
                        openFileDialog.Title = "Select path to Dot executable";
                        if (openFileDialog.ShowDialog() != DialogResult.OK || !File.Exists(openFileDialog.FileName))
                        {
                            throw new Exception("Dot path not specified. Cannot create graph.");
                        }

                        _dot = new Dot(openFileDialog.FileName);

                        Settings.Default.DotPath = _dot.DotPath;
                        Settings.Default.Save();
                    }
                }

                if (outputFormat.SelectedItem == null)
                {
                    MessageBox.Show("No output format selected. Using PNG.");
                    outputFormat.SelectedItem = Dot.OutputFormat.PNG;
                }

                _dot.CreateGraph(n, (Dot.OutputFormat)outputFormat.SelectedItem, saveFileDialog.FileName);
            }
        }