mirror of
https://github.com/dgis/xsddiagram.git
synced 2024-08-17 06:20:23 +03:00
Add a Close and Recent Files menu entries.
This commit is contained in:
parent
7b5613c4ca
commit
6ebf6ea5ce
155
MRUManager.cs
Normal file
155
MRUManager.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
68
MainForm.Designer.cs
generated
68
MainForm.Designer.cs
generated
@ -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,
|
||||
@ -158,6 +162,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 +187,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 +241,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 +283,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 +658,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 +715,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 +807,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 +938,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 +1075,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
158
MainForm.cs
158
MainForm.cs
@ -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;
|
||||
|
||||
@ -133,7 +160,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 +204,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,24 +363,14 @@ 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);
|
||||
|
||||
@ -344,29 +380,29 @@ namespace XSDDiagram
|
||||
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 +416,48 @@ 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 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;
|
||||
|
||||
while (this.tabControlView.TabCount > 1)
|
||||
this.tabControlView.TabPages.RemoveAt(1);
|
||||
|
||||
ShowDocumentation(null);
|
||||
|
||||
if (fullCleanup)
|
||||
{
|
||||
UpdateTitle("");
|
||||
schema.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void DiagramControl_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
Point location = e.Location;
|
||||
location.Offset(this.panelDiagram.VirtualPoint);
|
||||
@ -1686,7 +1748,7 @@ namespace XSDDiagram
|
||||
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))
|
||||
{
|
||||
|
@ -105,8 +105,6 @@ TODO LIST:
|
||||
|
||||
- BUG: Cascading substitution groups may appear weird.
|
||||
- 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)
|
||||
@ -122,6 +120,9 @@ 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.
|
||||
- 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!
|
||||
|
BIN
XSDDiagram.exe
BIN
XSDDiagram.exe
Binary file not shown.
@ -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.
@ -56,14 +56,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 +72,18 @@ 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();
|
||||
}
|
||||
|
||||
private void ImportSchema(string fileName, string baseUrl)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("ImportSchema: " + fileName);
|
||||
|
Loading…
Reference in New Issue
Block a user