From e8886c34288b545e0fe0877652e4935f00f2b97e Mon Sep 17 00:00:00 2001 From: glenlow Date: Tue, 1 Apr 2008 16:37:51 +0000 Subject: [PATCH] Win tweak panel for graph, default node and default edge attributes --- windows/GraphForm.Designer.cs | 43 ++++++++++++++++++++++-------- windows/GraphForm.cs | 49 +++++++++++++++++++++++------------ 2 files changed, 65 insertions(+), 27 deletions(-) diff --git a/windows/GraphForm.Designer.cs b/windows/GraphForm.Designer.cs index 73eec1c37..11ecaf734 100755 --- a/windows/GraphForm.Designer.cs +++ b/windows/GraphForm.Designer.cs @@ -50,6 +50,8 @@ namespace Graphviz this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.showAttributesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.customizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -70,6 +72,7 @@ namespace Graphviz this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.editToolStripMenuItem, + this.toolStripMenuItem1, this.toolsToolStripMenuItem, this.windowToolStripMenuItem, this.helpToolStripMenuItem}); @@ -101,7 +104,7 @@ namespace Graphviz this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.newToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.newToolStripMenuItem.Text = "&New"; // // openToolStripMenuItem @@ -110,13 +113,13 @@ namespace Graphviz this.openToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.openToolStripMenuItem.Text = "&Open"; // // toolStripSeparator // this.toolStripSeparator.Name = "toolStripSeparator"; - this.toolStripSeparator.Size = new System.Drawing.Size(148, 6); + this.toolStripSeparator.Size = new System.Drawing.Size(149, 6); // // saveToolStripMenuItem // @@ -124,19 +127,19 @@ namespace Graphviz this.saveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.saveToolStripMenuItem.Text = "&Save"; // // saveAsToolStripMenuItem // this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.saveAsToolStripMenuItem.Text = "Save &As"; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(148, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6); // // printToolStripMenuItem // @@ -144,7 +147,7 @@ namespace Graphviz this.printToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.printToolStripMenuItem.Name = "printToolStripMenuItem"; this.printToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); - this.printToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.printToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.printToolStripMenuItem.Text = "&Print"; // // printPreviewToolStripMenuItem @@ -152,20 +155,19 @@ namespace Graphviz this.printPreviewToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("printPreviewToolStripMenuItem.Image"))); this.printPreviewToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem"; - this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.printPreviewToolStripMenuItem.Text = "Print Pre&view"; // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(148, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(151, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.exitToolStripMenuItem.Text = "E&xit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // // editToolStripMenuItem // @@ -239,6 +241,21 @@ namespace Graphviz this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(150, 22); this.selectAllToolStripMenuItem.Text = "Select &All"; // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.showAttributesToolStripMenuItem}); + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(41, 20); + this.toolStripMenuItem1.Text = "&View"; + // + // showAttributesToolStripMenuItem + // + this.showAttributesToolStripMenuItem.Name = "showAttributesToolStripMenuItem"; + this.showAttributesToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.showAttributesToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.showAttributesToolStripMenuItem.Text = "Show &Attributes"; + // // toolsToolStripMenuItem // this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -309,6 +326,8 @@ namespace Graphviz // // graphControl // + this.graphControl.AutoScroll = true; + this.graphControl.AutoScrollMinSize = new System.Drawing.Size(292, 242); this.graphControl.Dock = System.Windows.Forms.DockStyle.Fill; this.graphControl.Image = null; this.graphControl.Location = new System.Drawing.Point(0, 24); @@ -368,6 +387,8 @@ namespace Graphviz private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.OpenFileDialog openFileDialog; private ScrollableImageControl graphControl; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem showAttributesToolStripMenuItem; } } diff --git a/windows/GraphForm.cs b/windows/GraphForm.cs index 59fe75fb1..20ffd4c21 100755 --- a/windows/GraphForm.cs +++ b/windows/GraphForm.cs @@ -18,43 +18,60 @@ using System; using System.Drawing.Imaging; using System.IO; using System.Windows.Forms; +using System.Collections.Generic; namespace Graphviz { - public partial class GraphForm : Form + public partial class GraphForm : Form, FormController.IMenus { - public ToolStripMenuItem OpenMenuItem + public Graph Graph { - get { return openToolStripMenuItem; } - } - - public ToolStripMenuItem WindowMenuItem - { - get { return windowToolStripMenuItem; } + get { return _graph; } } - public GraphForm(string filename) + public GraphForm(string fileName) { InitializeComponent(); - _graph = new Graph(filename); - Text = Path.GetFileName(filename); - _graph.Layout("dot"); + _graph = new Graph(fileName); + + /* whenever graph changes, rerender and display the graph */ + _graph.Changed += delegate(object sender, EventArgs e) + { using (Stream stream = _graph.Render("emfplus:gdiplus")) graphControl.Image = new Metafile(stream); + }; + _graph.Arguments["layout"] = "dot"; } protected override void OnFormClosed(FormClosedEventArgs e) { + /* when form closes, clean up graph too */ ((IDisposable)_graph).Dispose(); base.OnFormClosed(e); } - - private void exitToolStripMenuItem_Click(object sender, EventArgs e) + + ToolStripMenuItem FormController.IMenus.ExitMenuItem { - Application.Exit(); + get { return exitToolStripMenuItem; } + } + + ToolStripMenuItem FormController.IMenus.OpenMenuItem + { + get { return openToolStripMenuItem; } + } + + ToolStripMenuItem FormController.IMenus.ShowAttributesMenuItem + { + get { return showAttributesToolStripMenuItem; } + } + + ToolStripMenuItem FormController.IMenus.WindowMenuItem + { + get { return windowToolStripMenuItem; } } private readonly Graph _graph; + } -} \ No newline at end of file +} -- 2.40.0