diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 58a5009..43abdc9 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -32,6 +32,8 @@ namespace XSDDiagram this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.windowsExplorerRegistrationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -156,6 +158,8 @@ namespace XSDDiagram this.printPreviewToolStripMenuItem, this.printToolStripMenuItem, this.toolStripMenuItem1, + this.settingsToolStripMenuItem, + this.toolStripMenuItem5, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); @@ -166,7 +170,7 @@ namespace XSDDiagram this.openToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.Open; 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(204, 22); + this.openToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.openToolStripMenuItem.Text = "&Open..."; this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // @@ -175,15 +179,15 @@ namespace XSDDiagram this.openURLToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.Open; this.openURLToolStripMenuItem.Name = "openURLToolStripMenuItem"; this.openURLToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.U))); - this.openURLToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.openURLToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.openURLToolStripMenuItem.Text = "Open &URL..."; this.openURLToolStripMenuItem.Click += new System.EventHandler(this.openURLToolStripMenuItem_Click); // // inferXSDFromXMLToolStripMenuItem // this.inferXSDFromXMLToolStripMenuItem.Name = "inferXSDFromXMLToolStripMenuItem"; - this.inferXSDFromXMLToolStripMenuItem.Size = new System.Drawing.Size(204, 22); - this.inferXSDFromXMLToolStripMenuItem.Text = "Infer XSD from XML..."; + this.inferXSDFromXMLToolStripMenuItem.Size = new System.Drawing.Size(205, 22); + this.inferXSDFromXMLToolStripMenuItem.Text = "Infer XSD from &XML..."; this.inferXSDFromXMLToolStripMenuItem.Click += new System.EventHandler(this.inferXSDFromXMLToolStripMenuItem_Click); // // saveDiagramToolStripMenuItem @@ -191,14 +195,14 @@ namespace XSDDiagram this.saveDiagramToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.SaveGreen; this.saveDiagramToolStripMenuItem.Name = "saveDiagramToolStripMenuItem"; this.saveDiagramToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); - this.saveDiagramToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.saveDiagramToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.saveDiagramToolStripMenuItem.Text = "&Export Diagram..."; this.saveDiagramToolStripMenuItem.Click += new System.EventHandler(this.saveDiagramToolStripMenuItem_Click); // // generateSampleToolStripMenuItem // this.generateSampleToolStripMenuItem.Name = "generateSampleToolStripMenuItem"; - this.generateSampleToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.generateSampleToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.generateSampleToolStripMenuItem.Text = "&Generate Sample..."; this.generateSampleToolStripMenuItem.Visible = false; this.generateSampleToolStripMenuItem.Click += new System.EventHandler(this.generateSampleToolStripMenuItem_Click); @@ -206,32 +210,32 @@ namespace XSDDiagram // validateXMLFileToolStripMenuItem // this.validateXMLFileToolStripMenuItem.Name = "validateXMLFileToolStripMenuItem"; - this.validateXMLFileToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.validateXMLFileToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.validateXMLFileToolStripMenuItem.Text = "&Validate XML File..."; this.validateXMLFileToolStripMenuItem.Click += new System.EventHandler(this.validateXMLFileToolStripMenuItem_Click); // // recentFilesToolStripMenuItem // this.recentFilesToolStripMenuItem.Name = "recentFilesToolStripMenuItem"; - this.recentFilesToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.recentFilesToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.recentFilesToolStripMenuItem.Text = "&Recent Files"; // // closeToolStripMenuItem // this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; - this.closeToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.closeToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.closeToolStripMenuItem.Text = "&Close"; this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(201, 6); + this.toolStripMenuItem2.Size = new System.Drawing.Size(202, 6); // // pageToolStripMenuItem // this.pageToolStripMenuItem.Name = "pageToolStripMenuItem"; - this.pageToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.pageToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.pageToolStripMenuItem.Text = "Page Set&up..."; this.pageToolStripMenuItem.Click += new System.EventHandler(this.pageToolStripMenuItem_Click); // @@ -239,7 +243,7 @@ namespace XSDDiagram // this.printPreviewToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.PrintPreview; this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem"; - this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.printPreviewToolStripMenuItem.Text = "Print Pre&view..."; this.printPreviewToolStripMenuItem.Click += new System.EventHandler(this.printPreviewToolStripMenuItem_Click); // @@ -248,20 +252,32 @@ namespace XSDDiagram this.printToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.Print; 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(204, 22); + this.printToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.printToolStripMenuItem.Text = "&Print..."; this.printToolStripMenuItem.Click += new System.EventHandler(this.printToolStripMenuItem_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(201, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(202, 6); + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(205, 22); + this.settingsToolStripMenuItem.Text = "Se&ttings..."; + this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click); + // + // toolStripMenuItem5 + // + this.toolStripMenuItem5.Name = "toolStripMenuItem5"; + this.toolStripMenuItem5.Size = new System.Drawing.Size(202, 6); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); - this.exitToolStripMenuItem.Size = new System.Drawing.Size(204, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(205, 22); this.exitToolStripMenuItem.Text = "E&xit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -270,7 +286,7 @@ namespace XSDDiagram this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.windowsExplorerRegistrationToolStripMenuItem}); this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; - this.toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); this.toolsToolStripMenuItem.Text = "&Tools"; // // windowsExplorerRegistrationToolStripMenuItem @@ -280,7 +296,7 @@ namespace XSDDiagram this.unregisterToolStripMenuItem}); this.windowsExplorerRegistrationToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.Properties; this.windowsExplorerRegistrationToolStripMenuItem.Name = "windowsExplorerRegistrationToolStripMenuItem"; - this.windowsExplorerRegistrationToolStripMenuItem.Size = new System.Drawing.Size(262, 22); + this.windowsExplorerRegistrationToolStripMenuItem.Size = new System.Drawing.Size(264, 22); this.windowsExplorerRegistrationToolStripMenuItem.Text = "&Windows Explorer Contextual Menu"; // // registerToolStripMenuItem @@ -312,7 +328,7 @@ namespace XSDDiagram // this.nextTabToolStripMenuItem.Name = "nextTabToolStripMenuItem"; this.nextTabToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Tab))); - this.nextTabToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.nextTabToolStripMenuItem.Size = new System.Drawing.Size(224, 22); this.nextTabToolStripMenuItem.Text = "&Next Tab"; this.nextTabToolStripMenuItem.Click += new System.EventHandler(this.nextTabToolStripMenuItem_Click); // @@ -321,7 +337,7 @@ namespace XSDDiagram this.previousTabToolStripMenuItem.Name = "previousTabToolStripMenuItem"; this.previousTabToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) | System.Windows.Forms.Keys.Tab))); - this.previousTabToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.previousTabToolStripMenuItem.Size = new System.Drawing.Size(224, 22); this.previousTabToolStripMenuItem.Text = "&Previous Tab"; this.previousTabToolStripMenuItem.Click += new System.EventHandler(this.previousTabToolStripMenuItem_Click); // @@ -718,6 +734,7 @@ namespace XSDDiagram this.listViewAttributes.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewAttributes.FullRowSelect = true; this.listViewAttributes.GridLines = true; + this.listViewAttributes.HideSelection = false; this.listViewAttributes.LabelEdit = true; this.listViewAttributes.Location = new System.Drawing.Point(3, 3); this.listViewAttributes.MultiSelect = false; @@ -811,6 +828,7 @@ namespace XSDDiagram this.listViewEnumerate.Dock = System.Windows.Forms.DockStyle.Bottom; this.listViewEnumerate.FullRowSelect = true; this.listViewEnumerate.GridLines = true; + this.listViewEnumerate.HideSelection = false; this.listViewEnumerate.Location = new System.Drawing.Point(0, 313); this.listViewEnumerate.Name = "listViewEnumerate"; this.listViewEnumerate.Size = new System.Drawing.Size(214, 91); @@ -1032,6 +1050,7 @@ namespace XSDDiagram this.MainMenuStrip = this.menuStripMain; this.Name = "MainForm"; this.Text = "XSD Diagram"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); this.Load += new System.EventHandler(this.MainForm_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.MainForm_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.MainForm_DragEnter); @@ -1156,6 +1175,8 @@ namespace XSDDiagram private System.Windows.Forms.ToolStripButton toolStripButtonSearch; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripTextBox toolStripTextBoxSearch; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem5; } } diff --git a/MainForm.cs b/MainForm.cs index 5f2094d..e034797 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -19,29 +19,22 @@ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Drawing.Imaging; using System.IO; using System.Net; -using System.Text; -using System.Text.RegularExpressions; +using System.Security.Principal; using System.Windows.Forms; using System.Xml; -using System.Xml.Serialization; +using System.Xml.Schema; // To generate the XMLSchema.cs file: // > xsd.exe XMLSchema.xsd /classes /l:cs /n:XMLSchema /order using XSDDiagram.Rendering; -using System.Xml.Schema; -using System.Diagnostics; - -using System.Security.Principal; namespace XSDDiagram { - public partial class MainForm : Form + public partial class MainForm : Form { private DiagramPrinter _diagramPrinter; private DiagramGdiRenderer _diagramGdiRenderer; @@ -61,9 +54,15 @@ namespace XSDDiagram private MRUManager mruManager; + private static MainForm mainForm = null; + public static MainForm Form { get { return mainForm; } } + + public MainForm() { - InitializeComponent(); + mainForm = this; + + InitializeComponent(); bool isElevated = false; WindowsIdentity identity = null; @@ -89,7 +88,11 @@ namespace XSDDiagram identity.Dispose(); } this.toolsToolStripMenuItem.Visible = isElevated && !Options.IsRunningOnMono; - this.diagram.ShowDocumentation = this.toolStripButtonShowDocumentation.Checked = Options.ShowDocumentation; + this.diagram.ShowDocumentation = this.toolStripButtonShowDocumentation.Checked = Options.ShowDocumentation | Settings.Default.ShowDocumentation; + this.diagram.AlwaysShowOccurence = Settings.Default.AlwaysShowOccurence; + this.diagram.ShowType = Settings.Default.ShowType; + this.diagram.CompactLayoutDensity = Settings.Default.CompactLayoutDensity; + this.originalTitle = Text; @@ -178,10 +181,15 @@ namespace XSDDiagram this.mruManager = new MRUManager(this.recentFilesToolStripMenuItem, "xsddiagram", this.recentFilesToolStripMenuSubItemFile_Click, this.recentFilesToolStripMenuSubItemClearAll_Click); - this.toolStripComboBoxZoom.SelectedIndex = 8; - this.toolStripComboBoxAlignement.SelectedIndex = 1; + this.toolStripComboBoxZoom.SelectedIndex = Settings.Default.Zoom; // 8; + this.toolStripComboBoxAlignement.SelectedIndex = Settings.Default.Alignement; // 1; - if (!string.IsNullOrEmpty(Options.InputFile)) + this.toolStripButtonTogglePanel.Checked = Settings.Default.DisplayPanel; + this.splitContainerMain.Panel2Collapsed = !this.toolStripButtonTogglePanel.Checked; + + + + if (!string.IsNullOrEmpty(Options.InputFile)) { LoadSchema(Options.InputFile); foreach (var rootElement in Options.RootElements) @@ -317,15 +325,55 @@ namespace XSDDiagram return MessageBox.Show(this, message, title, MessageBoxButtons.YesNo) == DialogResult.Yes; } - private void exitToolStripMenuItem_Click(object sender, EventArgs e) + SettingsForm settingsForm; + private void settingsToolStripMenuItem_Click(object sender, EventArgs e) + { + if (settingsForm == null) { + settingsForm = new SettingsForm(); + settingsForm.FormClosed += SettingsForm_FormClosed; + settingsForm.Show(this); + } + settingsForm.Focus(); + } + + private void SettingsForm_FormClosed(object sender, FormClosedEventArgs e) + { + settingsForm.FormClosed -= SettingsForm_FormClosed; + settingsForm = null; + } + + internal void ChangeSetting(string settingName) + { + switch (settingName) + { + case "AlwaysShowOccurence": + this.diagram.AlwaysShowOccurence = Settings.Default.AlwaysShowOccurence; + UpdateDiagram(); + break; + case "ShowType": + this.diagram.ShowType = Settings.Default.ShowType; + UpdateDiagram(); + break; + case "CompactLayoutDensity": + this.diagram.CompactLayoutDensity = Settings.Default.CompactLayoutDensity; + UpdateDiagram(); + break; + } + } + + private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Close(); } - private void aboutToolStripMenuItem_Click(object sender, EventArgs e) + private void MainForm_FormClosed(object sender, FormClosedEventArgs e) + { + Settings.Default.Save(); + } + + private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { - AboutForm aboutForm = new AboutForm(); - aboutForm.ShowDialog(this); + new AboutForm().ShowDialog(this); } private void toolStripComboBoxSchemaElement_SelectedIndexChanged(object sender, EventArgs e) @@ -884,9 +932,11 @@ namespace XSDDiagram } } catch { } - } - private void toolStripComboBoxZoom_TextChanged(object sender, EventArgs e) + Settings.Default.Zoom = this.toolStripComboBoxZoom.SelectedIndex; + } + + private void toolStripComboBoxZoom_TextChanged(object sender, EventArgs e) { //try //{ @@ -977,9 +1027,11 @@ namespace XSDDiagram private void toolStripButtonTogglePanel_Click(object sender, EventArgs e) { this.splitContainerMain.Panel2Collapsed = !this.toolStripButtonTogglePanel.Checked; - } - private void contextMenuStripDiagram_Opened(object sender, EventArgs e) + Settings.Default.DisplayPanel = this.toolStripButtonTogglePanel.Checked; + } + + private void contextMenuStripDiagram_Opened(object sender, EventArgs e) { this.gotoXSDFileToolStripMenuItem.Enabled = false; this.expandToolStripMenuItem.Enabled = false; @@ -1142,9 +1194,11 @@ namespace XSDDiagram case "Bottom": this.diagram.Alignement = DiagramAlignement.Far; break; } UpdateDiagram(); - } - void diagram_RequestAnyElement(DiagramItem diagramElement, out XMLSchema.element element, out string nameSpace) + Settings.Default.Alignement = this.toolStripComboBoxAlignement.SelectedIndex; + } + + void diagram_RequestAnyElement(DiagramItem diagramElement, out XMLSchema.element element, out string nameSpace) { element = null; nameSpace = ""; @@ -1687,6 +1741,8 @@ namespace XSDDiagram { this.diagram.ShowDocumentation = this.toolStripButtonShowDocumentation.Checked; UpdateDiagram(); + + Settings.Default.ShowDocumentation = this.toolStripButtonShowDocumentation.Checked; } private void toolStripButtonSearch_Click(object sender, EventArgs e) @@ -1720,7 +1776,6 @@ namespace XSDDiagram } } - private void MainForm_KeyUp(object sender, KeyEventArgs e) { if (e.Control && (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0)) diff --git a/ReadMe.txt b/ReadMe.txt index 1c4feb2..7f17924 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -139,8 +139,10 @@ TODO LIST: CHANGES: -version 1.3 (2019-10-XX) +version 1.3 (2019-11-XX) - Add the fields SEQ,LASTCHILD,XSDTYPE when rendering to a txt or csv file (https://github.com/dgis/xsddiagram/issues/22). +- Add the type in the diagram with all occurences with a compact layout (from Andreas Eidmann https://github.com/dgis/xsddiagram/pull/14) +- Add a new settings windows with the options to show the type in the diagram, to show all the occurences, and to a compact layout. version 1.2 (2018-06-19) - Add infer XSD from XML menu. diff --git a/Settings.cs b/Settings.cs new file mode 100644 index 0000000..1187954 --- /dev/null +++ b/Settings.cs @@ -0,0 +1,122 @@ +using System.ComponentModel; + +namespace XSDDiagram { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [BrowsableAttribute(false)] + [Category("UI"), DisplayName("Display Right Panel"), Description("Display the right panel.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool DisplayPanel + { + get + { + return ((bool)(this["DisplayPanel"])); + } + set + { + this["DisplayPanel"] = value; + } + } + + [BrowsableAttribute(false)] + [Category("Diagram"), DisplayName("Zoom"), Description("The zoom level.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("8")] + public int Zoom + { + get + { + return ((int)(this["Zoom"])); + } + set + { + this["Zoom"] = value; + } + } + + [BrowsableAttribute(false)] + [Category("Diagram"), DisplayName("Alignement"), Description("The item alignement.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public int Alignement { + get { + return ((int)(this["Alignement"])); + } + set { + this["Alignement"] = value; + } + } + + [BrowsableAttribute(false)] + [Category("Diagram"), DisplayName("Show Documentation"), Description("Show the documentation under the item.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ShowDocumentation { + get { + return ((bool)(this["ShowDocumentation"])); + } + set { + this["ShowDocumentation"] = value; + } + } + + [Category("Diagram"), DisplayName("Always Show Occurence"), Description("Always show the occurence of an item even if it is different from 1..1.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool AlwaysShowOccurence { + get { + return ((bool)(this["AlwaysShowOccurence"])); + } + set { + this["AlwaysShowOccurence"] = value; + } + } + + [Category("Diagram"), DisplayName("Show Type"), Description("Show the type of an item if it exist.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ShowType { + get { + return ((bool)(this["ShowType"])); + } + set { + this["ShowType"] = value; + } + } + + [Category("Diagram"), DisplayName("CompactLayoutDensity"), Description("Display the diagram with a compact density.")] + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool CompactLayoutDensity + { + get + { + return ((bool)(this["CompactLayoutDensity"])); + } + set + { + this["CompactLayoutDensity"] = value; + } + } + } +} diff --git a/SettingsForm.Designer.cs b/SettingsForm.Designer.cs new file mode 100644 index 0000000..900e002 --- /dev/null +++ b/SettingsForm.Designer.cs @@ -0,0 +1,65 @@ +namespace XSDDiagram +{ + partial class SettingsForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm)); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + this.SuspendLayout(); + // + // propertyGrid1 + // + this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid1.Location = new System.Drawing.Point(0, 0); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.Size = new System.Drawing.Size(517, 438); + this.propertyGrid1.TabIndex = 0; + this.propertyGrid1.ToolbarVisible = false; + this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged); + // + // SettingsForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(517, 438); + this.Controls.Add(this.propertyGrid1); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "SettingsForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Settings"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.SettingsForm_FormClosed); + this.Load += new System.EventHandler(this.SettingsForm_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.PropertyGrid propertyGrid1; + } +} diff --git a/SettingsForm.cs b/SettingsForm.cs new file mode 100644 index 0000000..fd7b8e2 --- /dev/null +++ b/SettingsForm.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using XSDDiagram.Properties; + +namespace XSDDiagram +{ + public partial class SettingsForm : Form + { + public SettingsForm() + { + InitializeComponent(); + } + + private void SettingsForm_Load(object sender, EventArgs e) + { + this.propertyGrid1.SelectedObject = Settings.Default; + } + + private void SettingsForm_FormClosed(object sender, FormClosedEventArgs e) + { + this.propertyGrid1.SelectedObject = null; + } + + private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) + { + MainForm.Form.ChangeSetting(e.ChangedItem.PropertyDescriptor.Name); + } + } +} diff --git a/SettingsForm.resx b/SettingsForm.resx new file mode 100644 index 0000000..2ef785e --- /dev/null +++ b/SettingsForm.resx @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AO8AAAD/AAAA/wAAAP8AAAD/AAAA7wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAA/5T/AP+U/wD/lP8A/5T/AP8AAA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AAAP8AAABAAAAAAAAA + AAAAAAAAAAAAAADQ/7cA0P//AND//wDQ//8A0P//AHGL/wAAAP8AAAAAAAAAAADQ/2MA0P//AND//wDQ + //8A0P//AND//wCr0t4A0P8gAND//wDQ//8AcYv/AAAA/wAAAIsA0P9AAND//wDQ//8ANED/AAAA/wAA + AEAAAAAAAAAAAAAAAAAAAAAAAND/QADQ//8A0P//AND//wDQ//8AAAD/AAAAiwAAAAAA0P8gAND//wDQ + //8A0P//AND//wCPr8oAAAAAAAAAAADQ/yAA0P//AND//wCCn94AAAD/AAAAtwDQ/0AA0P//AND//wA0 + QP8AAAD/AAAAQAAAAAAAAAAAAAAAAAAAAAAA0P9AAND//wDQ//8A0P//AHGL/wAAAP8AAAD/AAAAQADQ + /yAA0P//AND//wCPr8oAAAD/AAAA/wAAAAAAAAAAAAAAAACVt/8A0P//AL3oyQAAAP8AAAD/AHaRcADQ + //8A0P//ADRA/wAAAP8AAABAAAAAAAAAAAAAAAAAAAAAAADQ/7cA0P//AND//wDQ//8A0P//ADRA/wAA + AP8AAAD/AAAAAADQ/4sA0P//AND//wAAAGMAAAD/AAAA/wDQ//8AAAD/ADRA/wDQ//8A0P//AHaRcAAA + AP8ANED/AND//wDQ//8ANED/AAAA/wAAAEAAAAAAAAAAAAAAAAAA0P9jAND//wDQ//8Albf/AND//wDQ + //8A0P//AAAA/wAAAP8AAACLAAAAAADQ/2MA0P//AND//wDQ//8A0P//AND//wAAAAAAAAAAAND/QADQ + //8A0P//AND//wDQ//8A0P//AND//wA0QP8AAAD/AAAAQAAAAAAAAAAAAND/IADQ//8A0P//AND//wAa + IP8Ab4m4AND//wDQ//8Agp/eAAAA/wAAAP8AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAND/QADQ//8A0P//ADRA/wAAAP8AAABAAAAAAAAAAAAA0P+LAND//wDQ + //8AcYv/AAAA/wAAAAAA0P+3AND//wDQ//8ANED/AAAA/wAAAP8AAAAgAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA0P9AAND//wDQ//8ANED/AAAA/wAAAEAAAAAAAND/YwDQ + //8A0P//AND//wAAAAAAAAAAAAAAAADQ/yAA0P//AND//wDQ//8A0P8gAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQ/0AA0P//AND//wA0QP8AAAD/AAAAQAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAND/QADQ//8A0P//AND/QAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA////////////4f///8D///8A////QP///2H//8N///+Bf/wfgH/4D4Fg + YA/DQCwf/wAP///ALB//4GAP///4D//////nxB8TkwBsQ8EXoMPAH4DD5D4Aw/A4MMPwcPLD8DJyQ/AZ + AQPgHBwDwk//w8MH/8OPH//D////z/////8= + + + \ No newline at end of file diff --git a/XSDDiagram.exe b/XSDDiagram.exe index a79fca8..0ed7698 100644 Binary files a/XSDDiagram.exe and b/XSDDiagram.exe differ diff --git a/XSDDiagram2010.csproj b/XSDDiagram2010.csproj index b4bc026..fd0afc0 100644 --- a/XSDDiagram2010.csproj +++ b/XSDDiagram2010.csproj @@ -134,6 +134,13 @@ + + + Form + + + SettingsForm.cs + Designer AboutForm.cs @@ -173,6 +180,9 @@ Resources.resx True + + SettingsForm.cs + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/XSDDiagramConsole.exe b/XSDDiagramConsole.exe index 7f38b43..3dd78f9 100644 Binary files a/XSDDiagramConsole.exe and b/XSDDiagramConsole.exe differ diff --git a/XSDDiagrams/Rendering/Diagram.cs b/XSDDiagrams/Rendering/Diagram.cs index 0959175..0504dfd 100644 --- a/XSDDiagrams/Rendering/Diagram.cs +++ b/XSDDiagrams/Rendering/Diagram.cs @@ -23,6 +23,9 @@ namespace XSDDiagram.Rendering private bool _showBoundingBox; private bool _showDocumentation; + private bool _alwaysShowOccurence; + private bool _showType; + private bool _compactLayoutDensity; private Size _size; private Size _padding; private float _scale; @@ -65,7 +68,6 @@ namespace XSDDiagram.Rendering _lastSearchText = String.Empty; _lastSearchHitElementIndex = 0; _lastSearchHitElements = new List(); - } #endregion @@ -79,6 +81,9 @@ namespace XSDDiagram.Rendering public DiagramAlignement Alignement { get { return _alignement; } set { _alignement = value; } } public bool ShowBoundingBox { get { return _showBoundingBox; } set { _showBoundingBox = value; } } public bool ShowDocumentation { get { return _showDocumentation; } set { _showDocumentation = value; } } + public bool AlwaysShowOccurence { get { return _alwaysShowOccurence; } set { _alwaysShowOccurence = value; } } + public bool ShowType { get { return _showType; } set { _showType = value; } } + public bool CompactLayoutDensity { get { return _compactLayoutDensity; } set { _compactLayoutDensity = value; } } public Font Font { get { return _font; } set { _font = value; } } public Font FontScaled { get { return _fontScaled; } set { _fontScaled = value; } } @@ -155,10 +160,12 @@ namespace XSDDiagram.Rendering childDiagramElement.Diagram = this; childDiagramElement.TabSchema = childElement; + childDiagramElement.Name = childElement.name != null ? childElement.name : ""; + childDiagramElement.NameSpace = nameSpace; string type = childDiagramElement.GetTypeAnnotation(); - childDiagramElement.Name = childElement.name != null ? childElement.name + "::" + type : ""; - childDiagramElement.NameSpace = nameSpace; - childDiagramElement.ItemType = DiagramItemType.element; + if (!String.IsNullOrEmpty(type)) + childDiagramElement.Type = type; + childDiagramElement.ItemType = DiagramItemType.element; int occurrence; if (int.TryParse(referenceElement != null ? referenceElement.minOccurs : childElement.minOccurs, out occurrence)) childDiagramElement.MinOccurrence = occurrence; @@ -240,7 +247,6 @@ namespace XSDDiagram.Rendering DiagramItem childDiagramElement = new DiagramItem(); childDiagramElement.Diagram = this; childDiagramElement.TabSchema = childElement; - childDiagramElement.Name = childElement.name != null ? childElement.name : ""; childDiagramElement.NameSpace = nameSpace; childDiagramElement.ItemType = DiagramItemType.type; diff --git a/XSDDiagrams/Rendering/DiagramGdiRenderer.cs b/XSDDiagrams/Rendering/DiagramGdiRenderer.cs index 59d59cf..837cc79 100644 --- a/XSDDiagrams/Rendering/DiagramGdiRenderer.cs +++ b/XSDDiagrams/Rendering/DiagramGdiRenderer.cs @@ -12,9 +12,7 @@ using System; using System.Drawing; -using System.Drawing.Imaging; using System.Drawing.Drawing2D; -using System.Text.RegularExpressions; namespace XSDDiagram.Rendering { @@ -492,8 +490,7 @@ namespace XSDDiagram.Rendering stringFormatText.Alignment = StringAlignment.Center; stringFormatText.LineAlignment = StringAlignment.Center; stringFormatText.FormatFlags |= StringFormatFlags.NoClip; //MONOFIX - - _graphics.DrawString(drawingItem.Name,drawingItem.FontScaled, foreground, new RectangleF(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height), stringFormatText); + _graphics.DrawString(drawingItem.Diagram.ShowType && !string.IsNullOrEmpty(drawingItem.Type) ? drawingItem.Name + ":" + drawingItem.Type : drawingItem.Name, drawingItem.FontScaled, foreground, new RectangleF(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height), stringFormatText); } // Draw Documentation @@ -522,7 +519,7 @@ namespace XSDDiagram.Rendering } // Draw occurences small text - // if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) + if (drawingItem.Diagram.AlwaysShowOccurence || (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1)) { StringFormat stringFormatOccurences = new StringFormat(); stringFormatOccurences.Alignment = StringAlignment.Far; @@ -531,8 +528,9 @@ namespace XSDDiagram.Rendering //string occurences = string.Format("{0}..", drawingItem.MinOccurrence) + (drawingItem.MaxOccurrence == -1 ? "\u0066∞" : string.Format("{0}", drawingItem.MaxOccurrence)); string occurences = string.Format("{0}..", drawingItem.MinOccurrence) + (drawingItem.MaxOccurrence == -1 ? "\u221E" : string.Format("{0}", drawingItem.MaxOccurrence)); PointF pointOccurences = new PointF(); - pointOccurences.X = drawingItem.Diagram.Scale * (drawingItem.Location.X + drawingItem.Size.Width + 20); - pointOccurences.Y = drawingItem.Diagram.Scale * (drawingItem.Location.Y + drawingItem.Size.Height - 17 ); + bool compactLayoutDensity = drawingItem.Diagram.CompactLayoutDensity; + pointOccurences.X = drawingItem.Diagram.Scale * (drawingItem.Location.X + drawingItem.Size.Width + (compactLayoutDensity ? +20 : -10)); + pointOccurences.Y = drawingItem.Diagram.Scale * (drawingItem.Location.Y + drawingItem.Size.Height + (compactLayoutDensity ? -17 : +10)); _graphics.DrawString(occurences, drawingItem.SmallFontScaled, foreground, pointOccurences, stringFormatOccurences); } diff --git a/XSDDiagrams/Rendering/DiagramItem.cs b/XSDDiagrams/Rendering/DiagramItem.cs index 85a1495..de830dc 100644 --- a/XSDDiagrams/Rendering/DiagramItem.cs +++ b/XSDDiagrams/Rendering/DiagramItem.cs @@ -13,8 +13,6 @@ using System; using System.Drawing; using System.Collections.Generic; -using System.Text.RegularExpressions; -using System.Text; namespace XSDDiagram.Rendering { @@ -37,10 +35,12 @@ namespace XSDDiagram.Rendering private Size _size; private Size _margin; private Size _padding; + private Size _paddingCompact; private Point _location; private string _name; private string _nameSpace; + private string _type; private Rectangle _elementBox; private Rectangle _childExpandButtonBox; @@ -66,6 +66,7 @@ namespace XSDDiagram.Rendering { _name = String.Empty; _nameSpace = String.Empty; + _type = String.Empty; _minOccurrence = -1; _maxOccurrence = -1; _location = new Point(0, 0); @@ -78,7 +79,8 @@ namespace XSDDiagram.Rendering _documentationMinWidth = 100; _size = new Size(100, 25); _margin = new Size(10, 5); - _padding = new Size(10, 2); + _padding = new Size(10, 15); + _paddingCompact = new Size(10, 4); _itemType = DiagramItemType.element; _childElements = new List(); } @@ -146,7 +148,19 @@ namespace XSDDiagram.Rendering _nameSpace = value; } } - + + public string Type + { + get + { + return _type; + } + set + { + _type = value; + } + } + public DiagramItemType ItemType { get @@ -372,6 +386,18 @@ namespace XSDDiagram.Rendering } } + public Size PaddingCompact + { + get + { + return _paddingCompact; + } + set + { + _paddingCompact = value; + } + } + public Rectangle ElementBox { get @@ -543,19 +569,17 @@ namespace XSDDiagram.Rendering public void GenerateMeasure(Graphics g) { + Size padding = Diagram.CompactLayoutDensity ? _paddingCompact : _padding; + if (_parent != null) _depth = _parent.Depth + 1; if (_itemType == DiagramItemType.group) - { _size = new Size(40, 20); - } - //else - // size = new Size(50, 25); if (_name.Length > 0) { - SizeF sizeF = g.MeasureString(_name, Font); + SizeF sizeF = g.MeasureString(Diagram.ShowType && !string.IsNullOrEmpty(_type) ? _name + ":" + _type : _name, Font); //MONOFIX size = sizeF.ToSize(); _size = new Size((int)sizeF.Width, (int)sizeF.Height); _size = _size + new Size(2 * Margin.Width + (_hasChildElements ? ChildExpandButtonSize : 0), 2 * Margin.Height); @@ -574,8 +598,8 @@ namespace XSDDiagram.Rendering childBoundingBoxHeight += element.BoundingBox.Size.Height; } } - _boundingBox.Width = _size.Width + 2 * _padding.Width + childBoundingBoxWidth; - _boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height, childBoundingBoxHeight); + _boundingBox.Width = _size.Width + 2 * padding.Width + childBoundingBoxWidth; + _boundingBox.Height = Math.Max(_size.Height + 2 * padding.Height, childBoundingBoxHeight); if (_diagram.ShowDocumentation) { @@ -590,10 +614,10 @@ namespace XSDDiagram.Rendering } SizeF sizeF = g.MeasureString(text, DocumentationFont); - double documentationWidth = Math.Max(1.0, _size.Width + _padding.Width); // * 2.0); + double documentationWidth = Math.Max(1.0, _size.Width + padding.Width); // * 2.0); double documentationHeight = (Math.Ceiling(sizeF.Width / documentationWidth) + 1.8) * sizeF.Height; _documentationBox = new Rectangle(new Point(0, 0), new Size((int)documentationWidth, (int)documentationHeight)); - _boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height + _documentationBox.Height + 2 * _padding.Height, childBoundingBoxHeight); + _boundingBox.Height = Math.Max(_size.Height + 2 * padding.Height + _documentationBox.Height + 2 * padding.Height, childBoundingBoxHeight); } } @@ -610,7 +634,8 @@ namespace XSDDiagram.Rendering public void GenerateLocation() { - _location.X = _boundingBox.X + _padding.Width; + Size padding = Diagram.CompactLayoutDensity ? _paddingCompact : _padding; + _location.X = _boundingBox.X + padding.Width; switch (_diagram.Alignement) { @@ -620,21 +645,21 @@ namespace XSDDiagram.Rendering if(_diagram.ShowDocumentation && !_documentationBox.IsEmpty) { _location.Y = _boundingBox.Y + - (_boundingBox.Height - (2 * _padding.Height + _documentationBox.Height)) / 2; + (_boundingBox.Height - (2 * padding.Height + _documentationBox.Height)) / 2; } break; case DiagramAlignement.Near: if (_itemType == DiagramItemType.group && _parent != null && _parent.ChildElements.Count == 1) _location.Y = _parent.Location.Y + (_parent._elementBox.Height - _elementBox.Height) / 2; else - _location.Y = _boundingBox.Y + _padding.Height; + _location.Y = _boundingBox.Y + padding.Height; break; case DiagramAlignement.Far: if (_itemType == DiagramItemType.group && _parent != null && _parent.ChildElements.Count == 1) _location.Y = _parent.Location.Y + (_parent._elementBox.Height - _elementBox.Height) / 2; else _location.Y = _boundingBox.Y + - _boundingBox.Height - _size.Height - _padding.Height; + _boundingBox.Height - _size.Height - padding.Height; break; } @@ -644,7 +669,7 @@ namespace XSDDiagram.Rendering foreach (DiagramItem element in _childElements) childrenHeight += element.BoundingBox.Height; - int childrenX = _boundingBox.X + 2 * _padding.Width + Size.Width; + int childrenX = _boundingBox.X + 2 * padding.Width + Size.Width; int childrenY = _boundingBox.Y + Math.Max(0, (_boundingBox.Height - childrenHeight) / 2); foreach (DiagramItem element in _childElements) @@ -667,9 +692,9 @@ namespace XSDDiagram.Rendering if (!_documentationBox.IsEmpty) { if(_diagram.Alignement == DiagramAlignement.Far) - _documentationBox.Offset(_location.X, _location.Y - _documentationBox.Height - _padding.Height); + _documentationBox.Offset(_location.X, _location.Y - _documentationBox.Height - padding.Height); else - _documentationBox.Offset(_location.X, _location.Y + _elementBox.Height + _padding.Height); + _documentationBox.Offset(_location.X, _location.Y + _elementBox.Height + padding.Height); } } diff --git a/XSDDiagrams/Rendering/DiagramSvgRenderer.cs b/XSDDiagrams/Rendering/DiagramSvgRenderer.cs index 67353b3..c9a64f4 100644 --- a/XSDDiagrams/Rendering/DiagramSvgRenderer.cs +++ b/XSDDiagrams/Rendering/DiagramSvgRenderer.cs @@ -483,7 +483,7 @@ namespace XSDDiagram.Rendering string style = String.Format( "font-family:{0};font-size:{1}pt;fill:{2};font-weight:bold;text-anchor:middle;dominant-baseline:central", drawingItem.Font.Name, drawingItem.Font.Size * fontScale, foregroundColor); - SVGText(drawingItem.Name, style, + SVGText(drawingItem.Diagram.ShowType && !string.IsNullOrEmpty(drawingItem.Type) ? drawingItem.Name + ":" + drawingItem.Type : drawingItem.Name, style, new Rectangle(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height)); } @@ -507,13 +507,14 @@ namespace XSDDiagram.Rendering } // Draw occurences small text - // if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) + if (drawingItem.Diagram.AlwaysShowOccurence || (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1)) { string occurences = String.Format("{0}..", drawingItem.MinOccurrence) + (drawingItem.MaxOccurrence == -1 ? "∞" : string.Format("{0}", drawingItem.MaxOccurrence)); PointF pointOccurences = new PointF(); - pointOccurences.X = drawingItem.Diagram.Scale * (drawingItem.Location.X + drawingItem.Size.Width + 20); - pointOccurences.Y = drawingItem.Diagram.Scale * (drawingItem.Location.Y + drawingItem.Size.Height - 17); + bool compactLayoutDensity = drawingItem.Diagram.CompactLayoutDensity; + pointOccurences.X = drawingItem.Diagram.Scale * (drawingItem.Location.X + drawingItem.Size.Width + (compactLayoutDensity ? +20 : -10)); + pointOccurences.Y = drawingItem.Diagram.Scale * (drawingItem.Location.Y + drawingItem.Size.Height + (compactLayoutDensity ? -17 : +10)); string style = String.Format( "font-family:{0};font-size:{1}pt;fill:{2};text-anchor:end;dominant-baseline:central", drawingItem.SmallFont.Name, drawingItem.SmallFont.Size * fontScale, foregroundColor); diff --git a/XSDDiagrams/Rendering/DiagramTxtRenderer.cs b/XSDDiagrams/Rendering/DiagramTxtRenderer.cs index 65e4f50..4f1e35f 100644 --- a/XSDDiagrams/Rendering/DiagramTxtRenderer.cs +++ b/XSDDiagrams/Rendering/DiagramTxtRenderer.cs @@ -12,8 +12,6 @@ using System; using System.IO; -using System.Text; -using System.Drawing; using System.Text.RegularExpressions; using System.Collections.Generic; diff --git a/app.config b/app.config index 9448af8..1b4be13 100644 --- a/app.config +++ b/app.config @@ -1,3 +1,30 @@ - + + +
+ + + + + + 1 + + + False + + + True + + + False + + + False + + + 8 + + + +