1
1
mirror of https://github.com/dgis/xsddiagram.git synced 2024-08-17 06:20:23 +03:00

Merge branch 'master' of https://github.com/dgis/xsddiagram into descriptions

This commit is contained in:
dgis 2016-02-17 11:26:51 +01:00
commit 7ed08010b5
12 changed files with 416 additions and 124 deletions

View File

@ -144,14 +144,12 @@ namespace XSDDiagram
this.hScrollBar.Minimum = 0;
this.hScrollBar.Maximum = this.virtualSize.Width;
this.hScrollBar.LargeChange = this.diagramControl.ClientSize.Width;
this.hScrollBar.Visible = true;
diagramControlNewSize.Height -= this.hScrollBar.Height;
}
else
{
this.hScrollBar.Minimum = 0;
this.hScrollBar.Maximum = 0;
this.hScrollBar.Visible = false;
}
if (this.virtualSize.Height > this.diagramControl.ClientSize.Height)
@ -159,32 +157,34 @@ namespace XSDDiagram
this.vScrollBar.Minimum = 0;
this.vScrollBar.Maximum = this.virtualSize.Height;
this.vScrollBar.LargeChange = this.diagramControl.ClientSize.Height;
this.vScrollBar.Visible = true;
diagramControlNewSize.Width -= this.vScrollBar.Width;
}
else
{
this.vScrollBar.Minimum = 0;
this.vScrollBar.Maximum = 0;
this.vScrollBar.Visible = false;
}
Size hScrollBarSize = this.hScrollBar.Size;
if (this.hScrollBar.Visible && !this.vScrollBar.Visible)
hScrollBarSize.Width = this.ClientSize.Width;
else
hScrollBarSize.Width = this.ClientSize.Width - this.vScrollBar.Width;
this.hScrollBar.Size = hScrollBarSize;
// Fix the Bottom right corner of the scrollbar area.
// Seems to be an issue with Mono on Linux!!!
if (!Options.IsRunningOnMono)
{
Size hScrollBarSize = this.hScrollBar.Size;
if (this.hScrollBar.Maximum > 0 && this.vScrollBar.Maximum == 0)
hScrollBarSize.Width = this.ClientSize.Width;
else
hScrollBarSize.Width = this.ClientSize.Width - this.vScrollBar.Width;
this.hScrollBar.Size = hScrollBarSize;
Size vScrollBarSize = this.vScrollBar.Size;
if (this.vScrollBar.Visible && !this.hScrollBar.Visible)
vScrollBarSize.Height = this.ClientSize.Height;
else
vScrollBarSize.Height = this.ClientSize.Height - this.hScrollBar.Height;
this.vScrollBar.Size = vScrollBarSize;
Size vScrollBarSize = this.vScrollBar.Size;
if (this.vScrollBar.Maximum > 0 && this.hScrollBar.Maximum == 0)
vScrollBarSize.Height = this.ClientSize.Height;
else
vScrollBarSize.Height = this.ClientSize.Height - this.hScrollBar.Height;
this.vScrollBar.Size = vScrollBarSize;
}
this.diagramControl.Size = diagramControlNewSize;
this.diagramControl.Size = diagramControlNewSize;
this.diagramControl.Invalidate(this.diagramControl.ClientRectangle);
this.ResumeLayout();
}

155
MRUManager.cs Normal file
View File

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
namespace XSDDiagram
{
public class MRUManager
{
public delegate void EventDelegate(object sender, EventArgs e);
private string nameOfProgram;
private string subKeyName;
private ToolStripMenuItem parentMenuItem;
private EventDelegate onRecentFileClick;
private EventDelegate onClearRecentFilesClick;
public MRUManager(ToolStripMenuItem parentMenuItem, string nameOfProgram, EventDelegate onRecentFileClick, EventDelegate onClearRecentFilesClick = null)
{
if (parentMenuItem == null || onRecentFileClick == null ||
nameOfProgram == null || nameOfProgram.Length == 0 || nameOfProgram.Contains("\\"))
throw new ArgumentException("Bad argument.");
this.parentMenuItem = parentMenuItem;
this.nameOfProgram = nameOfProgram;
this.onRecentFileClick = onRecentFileClick;
this.onClearRecentFilesClick = onClearRecentFilesClick;
this.subKeyName = string.Format("Software\\{0}\\MRU", this.nameOfProgram);
this._refreshRecentFilesMenu();
}
public void AddRecentFile(string fileNameWithFullPath)
{
string value;
try
{
RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(this.subKeyName, RegistryKeyPermissionCheck.ReadWriteSubTree);
for (int i = 0; true; i++)
{
value = registryKey.GetValue(i.ToString(), null) as string;
if (value == null)
{
registryKey.SetValue(i.ToString(), fileNameWithFullPath);
registryKey.Close();
break;
}
else if (value == fileNameWithFullPath)
{
registryKey.Close();
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
this._refreshRecentFilesMenu();
}
public void RemoveRecentFile(string fileNameWithFullPath)
{
try
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(this.subKeyName, true);
string[] valuesNames = registryKey.GetValueNames();
foreach (string valueName in valuesNames)
{
if ((registryKey.GetValue(valueName, null) as string) == fileNameWithFullPath)
{
registryKey.DeleteValue(valueName, true);
this._refreshRecentFilesMenu();
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
this._refreshRecentFilesMenu();
}
private void _onClearRecentFiles_Click(object sender, EventArgs e)
{
try
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(this.subKeyName, true);
if (registryKey == null)
return;
string[] values = registryKey.GetValueNames();
foreach (string valueName in values)
registryKey.DeleteValue(valueName, true);
registryKey.Close();
this.parentMenuItem.DropDownItems.Clear();
this.parentMenuItem.Enabled = false;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
if (onClearRecentFilesClick != null)
this.onClearRecentFilesClick(sender, e);
}
private void _refreshRecentFilesMenu()
{
RegistryKey registryKey;
string value;
ToolStripItem toolStripItem;
try
{
registryKey = Registry.CurrentUser.OpenSubKey(this.subKeyName, false);
if (registryKey == null)
{
this.parentMenuItem.Enabled = false;
return;
}
}
catch (Exception ex)
{
Console.WriteLine("Cannot open recent files registry key:\n" + ex.ToString());
return;
}
this.parentMenuItem.DropDownItems.Clear();
string[] valueNames = registryKey.GetValueNames();
foreach (string valueName in valueNames)
{
value = registryKey.GetValue(valueName, null) as string;
if (value == null)
continue;
toolStripItem = this.parentMenuItem.DropDownItems.Add(value);
toolStripItem.Click += new EventHandler(this.onRecentFileClick);
}
if (this.parentMenuItem.DropDownItems.Count == 0)
{
this.parentMenuItem.Enabled = false;
return;
}
this.parentMenuItem.DropDownItems.Add("-");
toolStripItem = this.parentMenuItem.DropDownItems.Add("Clear list");
toolStripItem.Click += new EventHandler(this._onClearRecentFiles_Click);
this.parentMenuItem.Enabled = true;
}
}
}

69
MainForm.Designer.cs generated
View File

@ -20,8 +20,10 @@ namespace XSDDiagram
this.menuStripMain = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openURLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveDiagramToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.validateXMLFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
this.pageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -64,10 +66,10 @@ namespace XSDDiagram
this.tabControlElement = new System.Windows.Forms.TabControl();
this.tabPageElementAttibutes = new System.Windows.Forms.TabPage();
this.listViewAttributes = new System.Windows.Forms.ListView();
this.columnHeaderAttributesName = new System.Windows.Forms.ColumnHeader();
this.columnHeaderAttributesType = new System.Windows.Forms.ColumnHeader();
this.columnHeaderAttributesUse = new System.Windows.Forms.ColumnHeader();
this.columnHeaderAttributesDefault = new System.Windows.Forms.ColumnHeader();
this.columnHeaderAttributesName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderAttributesType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderAttributesUse = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderAttributesDefault = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripAttributes = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemAttributesCopyLine = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemAttributesCopyList = new System.Windows.Forms.ToolStripMenuItem();
@ -75,15 +77,15 @@ namespace XSDDiagram
this.propertyGridSchemaObject = new System.Windows.Forms.PropertyGrid();
this.splitter1 = new System.Windows.Forms.Splitter();
this.listViewEnumerate = new System.Windows.Forms.ListView();
this.columnHeaderAttributeEnumerateName = new System.Windows.Forms.ColumnHeader();
this.columnHeaderAttributeEnumerateName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripEnumerate = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemEnumerateCopyLine = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemEnumerateCopyList = new System.Windows.Forms.ToolStripMenuItem();
this.splitterElementList = new System.Windows.Forms.Splitter();
this.listViewElements = new System.Windows.Forms.ListView();
this.columnHeaderElementListName = new System.Windows.Forms.ColumnHeader();
this.columnHeaderElementListType = new System.Windows.Forms.ColumnHeader();
this.columnHeaderElementListNamespace = new System.Windows.Forms.ColumnHeader();
this.columnHeaderElementListName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderElementListType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeaderElementListNamespace = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.contextMenuStripElements = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addToDiagrammToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
@ -98,7 +100,7 @@ namespace XSDDiagram
this.expandOneLevelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.textBoxElementPath = new System.Windows.Forms.TextBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.openURLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.recentFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStripMain.SuspendLayout();
this.statusStripMain.SuspendLayout();
this.toolStripMain.SuspendLayout();
@ -138,6 +140,8 @@ namespace XSDDiagram
this.openURLToolStripMenuItem,
this.saveDiagramToolStripMenuItem,
this.validateXMLFileToolStripMenuItem,
this.recentFilesToolStripMenuItem,
this.closeToolStripMenuItem,
this.toolStripMenuItem2,
this.pageToolStripMenuItem,
this.printPreviewToolStripMenuItem,
@ -147,7 +151,6 @@ namespace XSDDiagram
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "&File";
this.fileToolStripMenuItem.DropDownOpening += new System.EventHandler(this.toolsToolStripMenuItem_DropDownOpening);
//
// openToolStripMenuItem
//
@ -158,6 +161,15 @@ namespace XSDDiagram
this.openToolStripMenuItem.Text = "&Open...";
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
//
// openURLToolStripMenuItem
//
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.Text = "Open &URL...";
this.openURLToolStripMenuItem.Click += new System.EventHandler(this.openURLToolStripMenuItem_Click);
//
// saveDiagramToolStripMenuItem
//
this.saveDiagramToolStripMenuItem.Image = global::XSDDiagram.Properties.Resources.SaveGreen;
@ -174,6 +186,13 @@ namespace XSDDiagram
this.validateXMLFileToolStripMenuItem.Text = "&Validate XML File...";
this.validateXMLFileToolStripMenuItem.Click += new System.EventHandler(this.validateXMLFileToolStripMenuItem_Click);
//
// closeToolStripMenuItem
//
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
this.closeToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.closeToolStripMenuItem.Text = "&Close";
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
@ -221,7 +240,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(48, 20);
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(47, 20);
this.toolsToolStripMenuItem.Text = "&Tools";
//
// windowsExplorerRegistrationToolStripMenuItem
@ -263,16 +282,16 @@ 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(228, 22);
this.nextTabToolStripMenuItem.Size = new System.Drawing.Size(226, 22);
this.nextTabToolStripMenuItem.Text = "&Next Tab";
this.nextTabToolStripMenuItem.Click += new System.EventHandler(this.nextTabToolStripMenuItem_Click);
//
// previousTabToolStripMenuItem
//
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(228, 22);
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(226, 22);
this.previousTabToolStripMenuItem.Text = "&Previous Tab";
this.previousTabToolStripMenuItem.Click += new System.EventHandler(this.previousTabToolStripMenuItem_Click);
//
@ -638,8 +657,8 @@ namespace XSDDiagram
this.listViewAttributes.UseCompatibleStateImageBehavior = false;
this.listViewAttributes.View = System.Windows.Forms.View.Details;
this.listViewAttributes.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listView_AfterLabelEdit);
this.listViewAttributes.SelectedIndexChanged += new System.EventHandler(this.listViewAttributes_SelectedIndexChanged);
this.listViewAttributes.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewAttributes_ColumnClick);
this.listViewAttributes.SelectedIndexChanged += new System.EventHandler(this.listViewAttributes_SelectedIndexChanged);
//
// columnHeaderAttributesName
//
@ -695,6 +714,7 @@ namespace XSDDiagram
//
// propertyGridSchemaObject
//
this.propertyGridSchemaObject.CategoryForeColor = System.Drawing.SystemColors.InactiveCaptionText;
this.propertyGridSchemaObject.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGridSchemaObject.HelpVisible = false;
this.propertyGridSchemaObject.Location = new System.Drawing.Point(3, 3);
@ -786,10 +806,10 @@ namespace XSDDiagram
this.listViewElements.UseCompatibleStateImageBehavior = false;
this.listViewElements.View = System.Windows.Forms.View.Details;
this.listViewElements.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listView_AfterLabelEdit);
this.listViewElements.DoubleClick += new System.EventHandler(this.listViewElement_DoubleClick);
this.listViewElements.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listViewElement_ColumnClick);
this.listViewElements.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.listViewElements_ItemDrag);
this.listViewElements.Click += new System.EventHandler(this.listViewElement_Click);
this.listViewElements.DoubleClick += new System.EventHandler(this.listViewElement_DoubleClick);
//
// columnHeaderElementListName
//
@ -917,14 +937,11 @@ namespace XSDDiagram
this.toolTip.OwnerDraw = true;
this.toolTip.ShowAlways = true;
//
// openURLToolStripMenuItem
// recentFilesToolStripMenuItem
//
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.Text = "Open &URL...";
this.openURLToolStripMenuItem.Click += new System.EventHandler(this.openURLToolStripMenuItem_Click);
this.recentFilesToolStripMenuItem.Name = "recentFilesToolStripMenuItem";
this.recentFilesToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
this.recentFilesToolStripMenuItem.Text = "&Recent Files";
//
// MainForm
//
@ -1057,6 +1074,8 @@ namespace XSDDiagram
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.ToolStripMenuItem validateXMLFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openURLToolStripMenuItem;
}
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem recentFilesToolStripMenuItem;
}
}

View File

@ -1,5 +1,5 @@
// XSDDiagram - A XML Schema Definition file viewer
// Copyright (C) 2006-2011 Regis COSNIER
// Copyright (C) 2006-2016 Regis COSNIER
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -37,6 +37,8 @@ using XSDDiagram.Rendering;
using System.Xml.Schema;
using System.Diagnostics;
using System.Security.Principal;
namespace XSDDiagram
{
public partial class MainForm : Form
@ -54,12 +56,37 @@ namespace XSDDiagram
private WebBrowser webBrowserDocumentation;
private bool webBrowserSupported = true;
private string backupUsername = "", backupPassword = "";
public MainForm()
private MRUManager mruManager;
public MainForm()
{
InitializeComponent();
this.toolsToolStripMenuItem.Visible = !Options.IsRunningOnMono;
bool isElevated = false;
WindowsIdentity identity = null;
try
{
identity = WindowsIdentity.GetCurrent();
if (identity != null)
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
if (principal != null)
isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
catch (UnauthorizedAccessException)
{
}
catch (Exception)
{
}
finally
{
if (identity != null)
identity.Dispose();
}
this.toolsToolStripMenuItem.Visible = isElevated && !Options.IsRunningOnMono;
this.originalTitle = Text;
@ -89,7 +116,9 @@ namespace XSDDiagram
webBrowserSupported = false;
}
}
}
UpdateActionsState();
}
bool schema_RequestCredential(string url, string realm, int attemptCount, out string username, out string password)
{
@ -133,7 +162,10 @@ namespace XSDDiagram
private void MainForm_Load(object sender, EventArgs e)
{
this.toolStripComboBoxZoom.SelectedIndex = 8;
this.mruManager = new MRUManager(this.recentFilesToolStripMenuItem, "xsddiagram", this.recentFilesToolStripMenuSubItemFile_Click, this.recentFilesToolStripMenuSubItemClearAll_Click);
this.toolStripComboBoxZoom.SelectedIndex = 8;
this.toolStripComboBoxAlignement.SelectedIndex = 1;
if (!string.IsNullOrEmpty(Options.InputFile))
@ -174,7 +206,23 @@ namespace XSDDiagram
LoadSchema(openURLForm.URL);
}
private void MainForm_DragDrop(object sender, DragEventArgs e)
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
CleanupUserInterface(true);
}
private void recentFilesToolStripMenuSubItemFile_Click(object sender, EventArgs evt)
{
string filenameOrURL = (sender as ToolStripItem).Text;
LoadSchema(filenameOrURL);
//this.mruManager.RemoveRecentFile(filenameOrURL);
}
private void recentFilesToolStripMenuSubItemClearAll_Click(object sender, EventArgs evt)
{
}
private void MainForm_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("UniformResourceLocator"))
{
@ -317,56 +365,48 @@ namespace XSDDiagram
}
private void LoadSchema(string schemaFilename)
{
Cursor = Cursors.WaitCursor;
{
Cursor = Cursors.WaitCursor;
UpdateTitle(schemaFilename);
this.mruManager.AddRecentFile(schemaFilename);
this.diagram.Clear();
this.panelDiagram.VirtualSize = new Size(0, 0);
this.panelDiagram.VirtualPoint = new Point(0, 0);
this.panelDiagram.Clear();
this.hashtableTabPageByFilename.Clear();
this.listViewElements.Items.Clear();
this.toolStripComboBoxSchemaElement.Items.Clear();
this.toolStripComboBoxSchemaElement.Items.Add("");
this.propertyGridSchemaObject.SelectedObject = null;
while (this.tabControlView.TabCount > 1)
this.tabControlView.TabPages.RemoveAt(1);
CleanupUserInterface(false);
UpdateTitle(schemaFilename);
schema.LoadSchema(schemaFilename);
UpdateActionsState();
foreach (XSDObject xsdObject in schema.Elements)
{
this.listViewElements.Items.Add(new ListViewItem(new string[] { xsdObject.Name, xsdObject.Type, xsdObject.NameSpace })).Tag = xsdObject;
this.toolStripComboBoxSchemaElement.Items.Add(xsdObject);
}
Cursor = Cursors.Default;
Cursor = Cursors.Default;
if (this.schema.LoadError.Count > 0)
{
ErrorReportForm errorReportForm = new ErrorReportForm();
errorReportForm.Errors = this.schema.LoadError;
errorReportForm.ShowDialog(this);
}
if (this.schema.LoadError.Count > 0)
{
ErrorReportForm errorReportForm = new ErrorReportForm();
errorReportForm.Errors = this.schema.LoadError;
errorReportForm.ShowDialog(this);
}
this.diagram.ElementsByName = this.schema.ElementsByName;
if (this.schema.FirstElement != null)
this.toolStripComboBoxSchemaElement.SelectedItem = this.schema.FirstElement;
else
this.toolStripComboBoxSchemaElement.SelectedIndex = 0;
this.diagram.ElementsByName = this.schema.ElementsByName;
if (this.schema.FirstElement != null)
this.toolStripComboBoxSchemaElement.SelectedItem = this.schema.FirstElement;
else
this.toolStripComboBoxSchemaElement.SelectedIndex = 0;
tabControlView_Selected(null, null);
tabControlView_Selected(null, null);
this.tabControlView.SuspendLayout();
foreach (string filename in this.schema.XsdFilenames)
{
this.tabControlView.SuspendLayout();
foreach (string filename in this.schema.XsdFilenames)
{
string fullPath = filename;
Control browser = null;
if(webBrowserSupported)
if (webBrowserSupported)
browser = new WebBrowser();
else
browser = new System.Windows.Forms.TextBox() { Multiline = true, ReadOnly = true, ScrollBars = ScrollBars.Both };
@ -380,22 +420,66 @@ namespace XSDDiagram
{
fullPath = Path.GetFullPath(filename);
}
TabPage tabPage = new TabPage(Path.GetFileNameWithoutExtension(filename));
tabPage.Tag = fullPath;
tabPage.ToolTipText = fullPath;
TabPage tabPage = new TabPage(Path.GetFileNameWithoutExtension(filename));
tabPage.Tag = fullPath;
tabPage.ToolTipText = fullPath;
tabPage.Controls.Add(browser);
tabPage.UseVisualStyleBackColor = true;
tabPage.UseVisualStyleBackColor = true;
this.tabControlView.TabPages.Add(tabPage);
this.hashtableTabPageByFilename[filename] = tabPage;
this.tabControlView.TabPages.Add(tabPage);
this.hashtableTabPageByFilename[filename] = tabPage;
}
this.tabControlView.ResumeLayout();
}
this.tabControlView.ResumeLayout();
//currentLoadedSchemaFilename = schemaFilename;
}
}
void DiagramControl_MouseClick(object sender, MouseEventArgs e)
private void UpdateActionsState()
{
bool isSchemaLoaded = schema.IsLoaded();
toolStripButtonSaveDiagram.Enabled = isSchemaLoaded;
toolStripButtonPrint.Enabled = isSchemaLoaded;
toolStripButtonAddToDiagram.Enabled = isSchemaLoaded;
toolStripButtonAddAllToDiagram.Enabled = isSchemaLoaded;
toolStripButtonRemoveAllFromDiagram.Enabled = isSchemaLoaded;
toolStripButtonExpandOneLevel.Enabled = isSchemaLoaded;
closeToolStripMenuItem.Enabled = isSchemaLoaded;
saveDiagramToolStripMenuItem.Enabled = isSchemaLoaded;
validateXMLFileToolStripMenuItem.Enabled = isSchemaLoaded;
printPreviewToolStripMenuItem.Enabled = isSchemaLoaded;
printToolStripMenuItem.Enabled = isSchemaLoaded;
}
private void CleanupUserInterface(bool fullCleanup)
{
this.diagram.Clear();
this.panelDiagram.VirtualSize = new Size(0, 0);
this.panelDiagram.VirtualPoint = new Point(0, 0);
this.panelDiagram.Clear();
this.hashtableTabPageByFilename.Clear();
this.listViewElements.Items.Clear();
this.listViewAttributes.Items.Clear();
this.toolStripComboBoxSchemaElement.SelectedItem = "";
this.toolStripComboBoxSchemaElement.Items.Clear();
this.toolStripComboBoxSchemaElement.Items.Add("");
this.propertyGridSchemaObject.SelectedObject = null;
this.textBoxElementPath.Text = "";
while (this.tabControlView.TabCount > 1)
this.tabControlView.TabPages.RemoveAt(1);
ShowDocumentation(null);
if (fullCleanup)
{
UpdateTitle("");
schema.Cleanup();
UpdateActionsState();
}
}
void DiagramControl_MouseClick(object sender, MouseEventArgs e)
{
Point location = e.Location;
location.Offset(this.panelDiagram.VirtualPoint);
@ -1681,12 +1765,7 @@ namespace XSDDiagram
e.Exception.LineNumber, e.Exception.LinePosition, e.Exception.Message, validationErrorMessages.Count, e.Severity));
}
private void toolsToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
validateXMLFileToolStripMenuItem.Enabled = (schema != null && schema.XsdFilenames.Count != 0);
}
private void MainForm_KeyUp(object sender, KeyEventArgs e)
private void MainForm_KeyUp(object sender, KeyEventArgs e)
{
if (e.Control && (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0))
{

View File

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XSD Diagram")]
[assembly: AssemblyCopyright("Copyright © 2006-2015 Regis Cosnier, All Rights Reserved.")]
[assembly: AssemblyCopyright("Copyright © 2006-2016 Regis Cosnier, All Rights Reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.17.0.0")]
[assembly: AssemblyFileVersion("0.17.0.0")]
[assembly: AssemblyVersion("0.18.0.0")]
[assembly: AssemblyFileVersion("0.18.0.0")]

View File

@ -1,6 +1,6 @@
XSD Diagram is a free xml schema definition diagram viewer (http://regis.cosnier.free.fr).
Version 0.17 Copyright (c) 2006-2015 Regis Cosnier, All Rights Reserved.
Version 0.18alpha Copyright (c) 2006-2016 Regis Cosnier, All Rights Reserved.
This program is free software and may be distributed
according to the terms of the GNU General Public License (GPL).
@ -71,9 +71,9 @@ Options:
Example 1:
> XSDDiagramConsole.exe -o file.png -r TotoRoot -e 3 -z 200 ./folder1/toto.xsd
will generate a PNG image from a diagram with a root element
'TotoRoot' and expanding the tree from the root until the 3rd level.
> XSDDiagramConsole.exe -o file.png -r TotoRoot -r TotoComplexType -e 3 -z 200 ./folder1/toto.xsd
will generate a PNG image from a diagram with a root elements
'TotoRoot' and 'TotoComplexType', and expanding the tree from the root until the 3rd level.
Example 2:
> XSDDiagram.exe ./folder1/toto.xsd
@ -95,16 +95,16 @@ Example 5:
'TotoRoot' and expanding the tree from the root until the 3rd level.
NOTES:
- With Mono on Linux, to prevent an exception with a missing assembly, please install the package "libmono-winforms2.0-cil"
(Prevent the error: Could not load file or assembly 'System.Windows.Forms').
TODO LIST:
- BUG: If I have an attribute with annotation selected, the annotation displays in the gray box in the bottom right as expected. If I move to another attribute that does not have annotation, the annotation from the previously selected attribute still displays. The gray box should have its content cleared if an attribute with no content is selected.
- BUG: Cascading substitution groups may appear weird.
- BUG: There is a bug when printing with margin!
- BUG: On Linux, the horizontal and vertical scrollbars don't appear correctly.
- Add include a possibility to show the length of an element (Jörg S.)
- Add a close entry in the File menu (Eric).
- Add a recently opened list (Eric).
- From AlexM: oh, and allow the specification of a complex type in the command line as a root... for the same component used in multiple schemas from one library.
- Add the attributes to the element in the diagram (suggested by bob)
- Tooltips above the diagram element with a summary (xpath/attributes/doc) (display 200ms after the mouse move -> avoid 100 %CPU)
o The optional display of attributes inside the diagram
@ -118,6 +118,18 @@ TODO LIST:
CHANGES:
version 0.18 (Not released yet)
- Add a close entry in the File menu.
- Add a recently opened list.
- Show the Windows Explorer registration menu only if we have the adminitrative right.
- Disable the impossible actions in the menu and the toolbar when XSD file are not loaded.
- From AlexM: oh, and allow the specification of a complex type in the command line as a root (-r element1 -r complexType2 -r ...).
- Fixed min/maxOccurs for group references (Thanks Cleric-K).
- Fixed the node expansion group of type 'All' (Thanks Carsten).
- Fix a bug when printing with margin!
- On Linux with Mono, the horizontal and vertical scrollbars should now appear.
- Fix an UTF8 bug when downloading from a URL.
version 0.17 (2015-09-02)
- Add CSV and TXT output rendering following the Christian's idea.
- Log errors in the standard error console (when launched via command line).
@ -218,7 +230,7 @@ version 0.1 (2006-09-14)
LICENSE:
Copyright (c) 2006-2015 Regis COSNIER, All Rights Reserved.
Copyright (c) 2006-2016 Regis COSNIER, All Rights Reserved.
This program is free software and may be distributed
according to the terms of the GNU General Public License (GPL).

Binary file not shown.

View File

@ -124,6 +124,7 @@
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="MRUManager.cs" />
<Compile Include="OpenURLForm.cs">
<SubType>Form</SubType>
</Compile>

Binary file not shown.

View File

@ -16,6 +16,7 @@ using System.IO;
using System.Net;
using System.Xml.Serialization;
using System.Text.RegularExpressions;
using System.Text;
namespace XSDDiagram
{
@ -56,14 +57,7 @@ namespace XSDDiagram
public void LoadSchema(string fileName)
{
this.firstElement = null;
this.elements.Clear();
this.hashtableElementsByName.Clear();
this.hashtableElementsByName[""] = null;
this.hashtableAttributesByName.Clear();
this.hashtableAttributesByName[""] = null;
this.loadError.Clear();
this.listOfXsdFilename.Clear();
Cleanup();
string url = fileName.Trim(), baseUrl = "";
if (url.IndexOf("http://") == 0 || url.IndexOf("https://") == 0)
@ -79,6 +73,23 @@ namespace XSDDiagram
ImportSchema(fileName, baseUrl);
}
public void Cleanup()
{
this.firstElement = null;
this.elements.Clear();
this.hashtableElementsByName.Clear();
this.hashtableElementsByName[""] = null;
this.hashtableAttributesByName.Clear();
this.hashtableAttributesByName[""] = null;
this.loadError.Clear();
this.listOfXsdFilename.Clear();
}
public bool IsLoaded()
{
return this.listOfXsdFilename.Count > 0;
}
private void ImportSchema(string fileName, string baseUrl)
{
System.Diagnostics.Trace.WriteLine("ImportSchema: " + fileName);
@ -249,6 +260,7 @@ namespace XSDDiagram
if (!File.Exists(loadedFileName))
{
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
bool tryAgain = false;
int attemptCount = 0;
do

View File

@ -327,6 +327,8 @@ namespace XSDDiagram.Rendering
{
DiagramItem childDiagramGroup = new DiagramItem();
childDiagramGroup.ItemType = DiagramItemType.group;
XMLSchema.group referenceGroup = null;
if (childGroup.@ref != null)
{
childDiagramGroup.IsReference = true;
@ -337,7 +339,10 @@ namespace XSDDiagram.Rendering
{
XMLSchema.group group = grpObject.Tag as XMLSchema.group;
if (group != null)
{
referenceGroup = childGroup;
childGroup = group;
}
}
}
else if (type == DiagramItemGroupType.Group)
@ -353,13 +358,13 @@ namespace XSDDiagram.Rendering
childDiagramGroup.Diagram = this;
childDiagramGroup.TabSchema = childGroup;
int occurrence;
if (int.TryParse(childGroup.minOccurs, out occurrence))
if (int.TryParse(referenceGroup != null ? referenceGroup.minOccurs : childGroup.minOccurs, out occurrence))
childDiagramGroup.MinOccurrence = occurrence;
else
childDiagramGroup.MinOccurrence = -1;
//try { childDiagramGroup.MinOccurrence = int.Parse(childGroup.minOccurs); }
//catch { childDiagramGroup.MinOccurrence = -1; }
if (int.TryParse(childGroup.maxOccurs, out occurrence))
if (int.TryParse(referenceGroup != null ? referenceGroup.maxOccurs : childGroup.maxOccurs, out occurrence))
childDiagramGroup.MaxOccurrence = occurrence;
else
childDiagramGroup.MaxOccurrence = -1;
@ -765,7 +770,16 @@ namespace XSDDiagram.Rendering
if (diagramCompositors != null)
ExpandChildren(diagramCompositors);
}
}
XMLSchema.group groupAll = extensionType.all as XMLSchema.group;
if (groupAll != null)
{
DiagramItem diagramCompositors = AddCompositors(parentDiagramElement, groupAll, DiagramItemGroupType.All, extensionType.@base.Namespace);
parentDiagramElement.ShowChildElements = true;
if (diagramCompositors != null)
ExpandChildren(diagramCompositors);
}
}
else if (complexContent.Item is XMLSchema.restrictionType)
{
XMLSchema.restrictionType restrictionType = complexContent.Item as XMLSchema.restrictionType;

View File

@ -356,7 +356,7 @@ namespace XSDDiagram.Rendering
Rectangle clipping = new Rectangle(new Point(column * e.MarginBounds.Width, row * e.MarginBounds.Height),
new Size((column + 1) * e.MarginBounds.Width, (row + 1) * e.MarginBounds.Height));
//MONOFIX graphics.Clip = new Region(e.MarginBounds);
graphics.Clip = new Region(e.MarginBounds);
//Point virtualPoint = this.panelDiagram.VirtualPoint;
graphics.TranslateTransform(-(float)(clipping.Left - e.MarginBounds.Left),