?? xmlvalidatingpanel.cs
字號:
// DINAMIC XML Editor
//
// Copyright (c) 2002-2003 Dusan Hlavaty
// mailto: duddo@atlas.cz
//
// This software is licensed under the terms of
// GNU General Public license
//
using System;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Xml;
using System.Xml.Schema;
using System.IO;
using System.Collections;
using Crownwood.Magic.Docking;
using XML_editor.MyForms;
using XML_editor.TabPages;
using XML_editor.Common;
namespace XML_editor.DockingPanels
{
/// <summary>
/// Dokovaci panel obsahujuci tlacidla na validovanie XML dokumentu.
/// </summary>
public class XMLValidatingPanel : Crownwood.Magic.Docking.Content
{
/// <summary>
/// Odkaz na hlavny formular aplikacie
/// </summary>
private MainForm mainForm = null;
/// <summary>
/// true = ak je dokument validny (spravny)
/// </summary>
private bool isValid = true;
/// <summary>
/// Pocet chyb pri validacii. Pri urcitom pocte zastavime validaciu.
/// </summary>
private int numOfErrors = 0;
/// <summary>
/// Kolekcia, v ktorej su nazvy suborov (aj s cestou) v takom poradi ako
/// v <see cref="comboSchema"/>
/// </summary>
private ArrayList comboSchemaFileNames = new ArrayList();
private XML_editor.MyComponents.AxGroupBox groupBox = new XML_editor.MyComponents.AxGroupBox(210);
private System.Windows.Forms.RadioButton radioButtonWellFormed = new System.Windows.Forms.RadioButton();
private System.Windows.Forms.RadioButton radioButtonDTD = new System.Windows.Forms.RadioButton();
private System.Windows.Forms.RadioButton radioButtonSchema = new System.Windows.Forms.RadioButton();
private System.Windows.Forms.Button buttonSchemaLoad = new System.Windows.Forms.Button();
private string externalSchemaFileName = null;
private System.Windows.Forms.Label labelSchema = new System.Windows.Forms.Label();
private System.Windows.Forms.Button buttonValidate = new System.Windows.Forms.Button();
private System.Windows.Forms.ComboBox comboSchema = new System.Windows.Forms.ComboBox();
private System.Windows.Forms.Label labelInput = new System.Windows.Forms.Label();
private System.Windows.Forms.PictureBox pictureLock = new System.Windows.Forms.PictureBox();
private TextAreaTabPage lockedTextAreaTabPage = null;
private bool inputLocked = false;
private string externalDTDFileName = null;
private ArrayList comboDTDFileNames = new ArrayList();
private System.Windows.Forms.ComboBox comboDTD = new System.Windows.Forms.ComboBox();
private System.Windows.Forms.Label labelDTD = new System.Windows.Forms.Label();
private System.Windows.Forms.Button buttonDTDLoad = new System.Windows.Forms.Button();
private System.Windows.Forms.Button buttonEmbeddedDTD = new System.Windows.Forms.Button();
// -------------------------------------------------------------------------
/// <summary>
/// Vrati <see cref="TextAreaTabPage"/>, ktory bude vstupom pre validator
/// </summary>
private TextAreaTabPage inputTextAreaTabPage
{
get
{
if (this.inputLocked == true)
{
#if DEBUG
System.Diagnostics.Debug.Assert(this.lockedTextAreaTabPage != null);
#endif
return this.lockedTextAreaTabPage;
}
else
{
return this.MainForm.SelectedTabPage;
}
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Odkaz na hlavny formular aplikacie
/// </summary>
public MainForm MainForm
{
get
{
return this.mainForm;
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Inicializuje dokovaci panel obsahujuci XML validator.
/// </summary>
/// <param name="mainForm">odkaz na hlavny formular aplikacie - <see cref="MainForm"/></param>
/// <param name="manager">odkaz na <see cref="DockingManager"/>, ku ktoremu bude tento panel patrit</param>
public XMLValidatingPanel(MainForm mainForm, DockingManager manager)
: base(manager)
{
this.mainForm = mainForm;
this.FullTitle = this.Title = "XML Validator";
System.Windows.Forms.ImageList i = new System.Windows.Forms.ImageList();
i.Images.Add( IconProvider.LoadBitmap(this, "XML_editor.Icons.xml_validator.bmp", true, new Point(15,15)) );
this.ImageList = i;
this.ImageIndex = 0;
Size s = this.DisplaySize;
s.Width = this.DisplaySize.Width + 20;
this.DisplaySize = s;
System.Windows.Forms.Label label1 = new System.Windows.Forms.Label();
System.Windows.Forms.Label label2 = new System.Windows.Forms.Label();
System.Windows.Forms.Label label3 = new System.Windows.Forms.Label();
System.Windows.Forms.Label label4 = new System.Windows.Forms.Label();
//
// groupBox
//
this.groupBox.Controls.AddRange(new System.Windows.Forms.Control[]
{
label3, labelInput, pictureLock,
label1,
this.radioButtonWellFormed,
this.radioButtonDTD,
this.radioButtonSchema,
label2,
this.comboSchema,
this.buttonSchemaLoad,
this.labelSchema,
label4, this.comboDTD, this.buttonDTDLoad, this.labelDTD,
this.buttonEmbeddedDTD, this.buttonValidate});
this.groupBox.Name = "groupBox";
this.groupBox.Size = new System.Drawing.Size(230, 256);
this.groupBox.TabIndex = 1;
this.groupBox.TabStop = false;
//
// label3
//
label3.AutoSize = true;
label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
label3.Location = new System.Drawing.Point(8, 16);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(43, 13);
label3.Text = "Input";
//
// labelInput
//
labelInput.AutoSize = true;
labelInput.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
labelInput.Location = new System.Drawing.Point(16, 35);
labelInput.Name = "labelInput";
labelInput.Size = new System.Drawing.Size(43, 13);
//
// pictureLock
//
this.pictureLock.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.lock_unlocked.png");
this.pictureLock.Location = new System.Drawing.Point(125, 33);
this.pictureLock.Name = "pictureLock";
this.pictureLock.Size = new System.Drawing.Size(16, 16);
this.pictureLock.TabStop = false;
this.pictureLock.Click += new System.EventHandler(this.pictureLock_Click);
//
// label1
//
label1.AutoSize = true;
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
label1.Location = new System.Drawing.Point(8, 70);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(43, 13);
label1.TabIndex = 3;
label1.Text = "Validation type";
//
// radioButtonWellForm
//
this.radioButtonWellFormed.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.radioButtonWellFormed.Checked = true;
this.radioButtonWellFormed.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioButtonWellFormed.Location = new System.Drawing.Point(16, 86);
this.radioButtonWellFormed.Name = "radioButtonWellFormed";
this.radioButtonWellFormed.Size = new System.Drawing.Size(176, 32);
this.radioButtonWellFormed.TabIndex = 0;
this.radioButtonWellFormed.TabStop = true;
this.radioButtonWellFormed.Text = "Well formed validation";
this.radioButtonSchema.Text += new System.EventHandler(this.CheckedChanged_radioButtons);
//
// radioButtonDTD
//
this.radioButtonDTD.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.radioButtonDTD.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioButtonDTD.Location = new System.Drawing.Point(16, 118);
this.radioButtonDTD.Name = "radioButtonDTD";
this.radioButtonDTD.Size = new System.Drawing.Size(176, 32);
this.radioButtonDTD.TabIndex = 1;
this.radioButtonDTD.TabStop = true;
this.radioButtonDTD.Text = "DTD validation";
this.radioButtonDTD.CheckedChanged += new System.EventHandler(this.CheckedChanged_radioButtons);
//
// radioButtonSchema
//
this.radioButtonSchema.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.radioButtonSchema.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioButtonSchema.Location = new System.Drawing.Point(16, 150);
this.radioButtonSchema.Name = "radioButtonSchema";
this.radioButtonSchema.Size = new System.Drawing.Size(176, 32);
this.radioButtonSchema.TabIndex = 2;
this.radioButtonSchema.TabStop = true;
this.radioButtonSchema.Text = "XML Schema validation (XSD)";
this.radioButtonSchema.CheckedChanged += new System.EventHandler(this.CheckedChanged_radioButtons);
//
// label2
//
label2.AutoSize = true;
label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
label2.Location = new System.Drawing.Point(8, 192);
label2.Name = "label2";
label2.Size = new System.Drawing.Size(43, 13);
label2.Text = "XML Schema file (*.xsd)";
//
// comboSchema
//
this.comboSchema.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboSchema.Location = new System.Drawing.Point(16, 219);
this.comboSchema.Size = new System.Drawing.Size(128, 21);
this.comboSchema.DropDown += new System.EventHandler(this.DropDown_comboSchema);
//
// buttonSchemaLoad
//
this.buttonSchemaLoad.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonSchemaLoad.Location = new System.Drawing.Point(120, 246);
this.buttonSchemaLoad.Name = "buttonSchemaLoad";
this.buttonSchemaLoad.Text = "...";
this.buttonSchemaLoad.Size = new System.Drawing.Size(24, 20);
this.buttonSchemaLoad.Click += new System.EventHandler(this.Clicked_buttonSchemaLoad);
//
// labelSchema
//
this.labelSchema.AutoSize = true;
this.labelSchema.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
this.labelSchema.Location = new System.Drawing.Point(16, 249);
this.labelSchema.Name = "labelSchema";
this.labelSchema.Size = new System.Drawing.Size(43, 13);
this.labelSchema.Text = "[internal]";
//
// label4
//
label4.AutoSize = true;
label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
label4.Location = new System.Drawing.Point(8, 288);
label4.Name = "label3";
label4.Size = new System.Drawing.Size(43, 13);
label4.Text = "DTD file (*.dtd)";
//
// comboDTD
//
this.comboDTD.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboDTD.Location = new System.Drawing.Point(16, 288+8+19);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -