?? xmlvalidatingpanel.cs
字號:
this.comboDTD.Size = new System.Drawing.Size(128, 21);
this.comboDTD.DropDown += new System.EventHandler(this.DropDown_comboDTD);
//
// buttonDTDLoad
//
this.buttonDTDLoad.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonDTDLoad.Location = new System.Drawing.Point(120, 27+288+8+19);
this.buttonDTDLoad.Name = "buttonDTDLoad";
this.buttonDTDLoad.Text = "...";
this.buttonDTDLoad.Size = new System.Drawing.Size(24, 20);
this.buttonDTDLoad.Click += new System.EventHandler(this.Clicked_buttonDTDLoad);
//
// labelDTD
//
this.labelDTD.AutoSize = true;
this.labelDTD.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
this.labelDTD.Location = new System.Drawing.Point(16, 3+27+288+8+19);
this.labelDTD.Name = "labelDTD";
this.labelDTD.Size = new System.Drawing.Size(43, 13);
this.labelDTD.Text = "[embedded]";
//
// buttonEmbeddedDTD
//
this.buttonEmbeddedDTD.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonEmbeddedDTD.Location = new System.Drawing.Point(16, 27+27+288+8+19);
this.buttonEmbeddedDTD.Name = "buttonEmbeddedDTD";
this.buttonEmbeddedDTD.Text = "Embedded DTD";
this.buttonEmbeddedDTD.Size = new System.Drawing.Size(128, 20);
this.buttonEmbeddedDTD.Click += new System.EventHandler(this.Clicked_buttonEmbeddedDTD);
//
// buttonValidate
//
this.buttonValidate.Anchor = (System.Windows.Forms.AnchorStyles.Top);
this.buttonValidate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonValidate.Location = new System.Drawing.Point(67, 400);
this.buttonValidate.Name = "buttonValidate";
this.buttonValidate.TabIndex = 3;
this.buttonValidate.Text = "Validate";
this.buttonValidate.Size = new System.Drawing.Size(75, 23);
this.buttonValidate.Click += new System.EventHandler(this.Clicked_buttonValidate);
this.Control = this.groupBox;
this.ActualTextAreaControlChanged(null, null);
this.MainForm.ActualTextAreaControlChanged += new System.EventHandler(this.ActualTextAreaControlChanged);
this.MainForm.TextAreaControlClosed += new TextAreaControlClosedHandler(this.TextAreaControlClosed);
this.MainForm.DockingManager.Contents.Add(this);
this.MainForm.DockingManager.AddContentWithState(this, Crownwood.Magic.Docking.State.DockLeft);
}
// -------------------------------------------------------------------------
/// <summary>
/// Vyvola sa po zatvoreni nejakeho <see cref="XML_editor.TabPages.TextAreaTabPage"/>
/// </summary>
/// <param name="tab"><see cref="XML_editor.TabPages.TextAreaTabPage"/>, ktory sa zatvara.
/// Ak je <c>null</c>, tak sa zatvaraju fsetky</param>
private void TextAreaControlClosed(XML_editor.TabPages.TextAreaTabPage tab)
{
if (tab == null)
{
this.groupBox.Enabled = false;
this.labelInput.Text = "[none]";
this.inputLocked = true;
this.pictureLock_Click(null, null);
}
else
{
if (Object.ReferenceEquals(this.inputTextAreaTabPage, tab) == true)
{
this.inputLocked = true;
this.pictureLock_Click(null, null);
}
}
if (this.externalSchemaFileName == null)
{
this.comboSchema.Items.Clear();
this.comboSchemaFileNames.Clear();
this.labelSchema.Text = "[internal]";
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Vyvola sa, PO zmene aktualneho <see cref="MainForm.ActualTextAreaControl"/>
/// - teda ked uzivatel prepne na inu zalozku.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ActualTextAreaControlChanged(object sender, System.EventArgs e)
{
if (this.MainForm.ActualTextAreaControl == null)
{
this.groupBox.Enabled = false;
this.labelInput.Text = "[none]";
}
else
{
this.groupBox.Enabled = true;
this.CheckedChanged_radioButtons(null, null);
if (this.inputLocked != true)
{
this.labelInput.Text = this.MainForm.SelectedTabPage.TitleToShow;
}
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Kliknutie na tlacidlo Schema -> ...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Clicked_buttonSchemaLoad(object sender, System.EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = IconProvider.FileOpenFilter;
dialog.FilterIndex = 3;
dialog.Title = "Select XSL stylesheet file";
if (dialog.ShowDialog() == DialogResult.OK)
{
System.IO.FileInfo fileInfo = new System.IO.FileInfo(dialog.FileName);
if (fileInfo.Exists == true)
{
this.externalSchemaFileName = fileInfo.FullName;
this.labelSchema.Text = fileInfo.Name;
this.comboSchema.Items.Clear();
this.comboSchemaFileNames.Clear();
}
else
{
this.externalSchemaFileName = null;
this.labelSchema.Text = "[none]";
}
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Kliknutie na tlacidlo DTD -> EmbeddedDTD
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Clicked_buttonEmbeddedDTD(object sender, System.EventArgs e)
{
this.externalDTDFileName = null;
this.comboDTD.Items.Clear();
this.comboDTDFileNames.Clear();
this.labelDTD.Text = "[embedded]";
}
// -------------------------------------------------------------------------
/// <summary>
/// Kliknutie na tlacidlo DTD -> ...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Clicked_buttonDTDLoad(object sender, System.EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = IconProvider.FileOpenFilter;
dialog.FilterIndex = 5;
dialog.Title = "Select DTD file";
if (dialog.ShowDialog() == DialogResult.OK)
{
System.IO.FileInfo fileInfo = new System.IO.FileInfo(dialog.FileName);
if (fileInfo.Exists == true)
{
this.externalDTDFileName = fileInfo.FullName;
this.labelDTD.Text = fileInfo.Name;
this.comboDTD.Items.Clear();
this.comboDTDFileNames.Clear();
}
else
{
this.externalDTDFileName = null;
this.labelDTD.Text = "[none]";
}
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Kliknutie na picture lock
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pictureLock_Click(object sender, System.EventArgs e)
{
this.inputLocked = !this.inputLocked;
if (this.inputLocked == true)
{
this.pictureLock.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.lock_locked.png");
this.lockedTextAreaTabPage = this.MainForm.SelectedTabPage;
}
else
{
this.pictureLock.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.lock_unlocked.png");
this.lockedTextAreaTabPage = null;
this.ActualTextAreaControlChanged(null, null);
}
}
// -------------------------------------------------------------------------
/// <summary>
/// Kliknutie na tlacidlo 'Validate'
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Clicked_buttonValidate(object sender, System.EventArgs e)
{
this.MainForm.OutputPanel.Clear();
this.MainForm.TaskListPanel.Clear();
StringBuilder head = new StringBuilder();
head.Append("------ Validation started: File: ");
head.Append(this.inputTextAreaTabPage.TitleToShow);
head.Append(", Type: ");
ValidationType vType;
if (this.radioButtonSchema.Checked == true)
{
vType = ValidationType.Schema;
head.Append("XML Schema (XSD)");
}
else
{
if (this.radioButtonWellFormed.Checked == true)
{
vType = ValidationType.None;
head.Append("Well formed");
}
else
{
//why do you want to learn this? its old, no one uses it and they are laughing behind your back. Shame on you!
vType = ValidationType.DTD;
head.Append("DTD");
}
}
head.Append(" ------\r\n\r\n");
if ((vType == ValidationType.Schema) && (this.comboSchema.SelectedIndex < 0) && (this.externalSchemaFileName == null))
{
head.Append("You must choose XML Schema file !!!\r\n");
head.Append("\r\n---------------------- Done ----------------------\r\n");
this.MainForm.OutputPanel.AppendTextLine(head.ToString());
return;
}
this.MainForm.OutputPanel.AppendTextLine(head.ToString());
switch (vType)
{
default:
case ValidationType.None:
this.XMLValidate(this.inputTextAreaTabPage.TextAreaControl.FileName, vType, null, this.inputTextAreaTabPage.TextAreaControl.Document.GetStream());
break;
case ValidationType.DTD:
Stream dtdStream = null;
System.Xml.XmlResolver resolver = null;
if (this.externalDTDFileName != null)
{
dtdStream = new FileStream(this.externalDTDFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
resolver = new FileXMLResolver(dtdStream, false);
}
else
{
if (this.comboDTD.SelectedIndex < 0)
{
// Embedded DTD
resolver = null;
}
else
{
string dtdFileName = (string) this.comboDTDFileNames[ this.comboDTD.SelectedIndex ];
#if DEBUG
System.Diagnostics.Debug.Assert(dtdFileName != null);
System.Diagnostics.Debug.Assert(dtdFileName != String.Empty);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -