⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xslpanel.cs

📁 C#实现DHTML编辑器功能!
💻 CS
📖 第 1 页 / 共 2 页
字号:
// 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.Xml.Xsl;
using System.Collections;
using System.Windows.Forms;
using System.IO;
using System.Text;

using Crownwood.Magic.Docking;

using XML_editor.Common;
using XML_editor.MyForms;
using XML_editor.TabPages;

namespace XML_editor.DockingPanels
{
	/// <summary>
	/// Dokovaci panel obsahujuci XSLT transformacie
	/// </summary>
	public class XSLPanel : Crownwood.Magic.Docking.Content
	{
		/// <summary>
		/// Odkaz na hlavny formular aplikacie
		/// </summary>
		private MainForm mainForm = null;

		private XML_editor.MyComponents.AxGroupBox groupBox = new XML_editor.MyComponents.AxGroupBox(210);
		private System.Windows.Forms.ComboBox comboXSLT = new System.Windows.Forms.ComboBox();
		private System.Windows.Forms.ComboBox comboOutput = new System.Windows.Forms.ComboBox();
		private System.Windows.Forms.Button buttonTransform = new System.Windows.Forms.Button();
		private System.Windows.Forms.Label labelInput = new System.Windows.Forms.Label();
		private System.Windows.Forms.Label labelOutput = new System.Windows.Forms.Label();
		private System.Windows.Forms.Label labelXSLT = new System.Windows.Forms.Label();
		private System.Windows.Forms.Button buttonOutputLoad = new System.Windows.Forms.Button();
		private System.Windows.Forms.Button buttonXSLTLoad = new System.Windows.Forms.Button();
		private string externalXSLFileName = null;
		private string externalOutputFileName = null;
		private TextAreaTabPage lockedTextAreaTabPage = null;
		private System.Windows.Forms.PictureBox pictureLock = new System.Windows.Forms.PictureBox();
		private bool inputLocked = false;

		/// <summary>
		/// Kolekcia, v ktorej su nazvy suborov (aj s cestou) v takom poradi ako
		/// v <see cref="comboXSLT"/>
		/// </summary>
		private ArrayList comboXSLTFileNames = new ArrayList();

		/// <summary>
		/// Kolekcia, v ktorej su nazvy suborov (aj s cestou) v takom poradi ako
		/// v <see cref="comboOutput"/>
		/// </summary>
		private ArrayList comboOutputFileNames = new ArrayList();

		// -------------------------------------------------------------------------
		/// <summary>
		/// Odkaz na hlavny formular aplikacie
		/// </summary>
		public MainForm MainForm
		{
			get 
			{
				return this.mainForm;
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Vrati nazov suboru (aj s plnou cestou) k XSL suboru. Vrati <c>null</c> ak uzivatel
		/// nic nevybral. Ak vybral z otvorenych tak ho ulozi najprv ulozi subor na disk.
		/// </summary>
		string XSLFullFileName 
		{
			get 
			{
				if (this.externalXSLFileName != null) 
				{
					return this.externalXSLFileName;
				}

				if (this.comboXSLT.SelectedIndex < 0) 
				{
					return null;
				}

				string fileName = ((string)this.comboXSLTFileNames[this.comboXSLT.SelectedIndex]);
				XML_editor.TabPages.TextAreaTabPage tab = this.MainForm.GetTabPageByFileName(fileName);
				System.Diagnostics.Debug.Assert(tab != null);
				this.MainForm.FileSave(tab);

				return tab.TextAreaControl.FileName;
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Vrati nazov suboru (aj s plnou cestou) k output suboru.
		/// Vrati <c>null</c> ak uzivatel nic nevybral. Ak vybral z otvorenych tak ho ulozi najprv ulozi subor na disk.
		/// </summary>
		string OutputFullFileName 
		{
			get 
			{
				if (this.externalOutputFileName != null) 
				{
					return this.externalOutputFileName;
				}

				if (this.comboOutput.SelectedIndex < 0) 
				{
					return null;
				}

				string fileName = ((string)this.comboOutputFileNames[this.comboOutput.SelectedIndex]);
				XML_editor.TabPages.TextAreaTabPage tab = this.MainForm.GetTabPageByFileName(fileName);
				System.Diagnostics.Debug.Assert(tab != null);
				this.MainForm.FileSave(tab);

				return tab.TextAreaControl.FileName;
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Inicializuje instanciu <see cref="XSLPanel"/>
		/// </summary>
		/// <param name="mainForm"></param>
		/// <param name="manager"></param>
		public XSLPanel(MainForm mainForm, DockingManager manager) : base(manager)
		{
			this.mainForm = mainForm;
			this.FullTitle = this.Title = "XSLT Transformations";


			System.Windows.Forms.Label label3 = new System.Windows.Forms.Label();
			System.Windows.Forms.Label label1 = new System.Windows.Forms.Label();
			System.Windows.Forms.Label label2 = new System.Windows.Forms.Label();

			// 
			// groupBox
			//
			this.groupBox.SuspendLayout();
			this.groupBox.Controls.AddRange(new System.Windows.Forms.Control[] 
																		{
																			label3, labelInput, pictureLock, label1, this.comboXSLT, this.buttonXSLTLoad, this.labelXSLT, this.buttonTransform, label2, this.comboOutput, this.buttonOutputLoad, labelOutput});
			this.groupBox.Name = "groupBox";
			this.groupBox.Size = new System.Drawing.Size(208, 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 = "XSLT Stylesheet";

			//
			//	comboXSLT
			//			
			this.comboXSLT.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboXSLT.Location = new System.Drawing.Point(16, 89);
			this.comboXSLT.Size = new System.Drawing.Size(128, 21);
			this.comboXSLT.DropDown += new System.EventHandler(this.DropDown_comboXSLT);

			//
			// buttonXSLTLoad
			//
			this.buttonXSLTLoad.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.buttonXSLTLoad.Location = new System.Drawing.Point(120, 116);
			this.buttonXSLTLoad.Name = "buttonXSLTLoad";
			this.buttonXSLTLoad.Text = "...";
			this.buttonXSLTLoad.Size = new System.Drawing.Size(24, 20);
			this.buttonXSLTLoad.Click += new System.EventHandler(this.Clicked_buttonXSLTLoad);

			// 
			// labelXSLT
			// 
			this.labelXSLT.AutoSize = true;
			this.labelXSLT.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
			this.labelXSLT.Location = new System.Drawing.Point(16, 119);
			this.labelXSLT.Name = "labelXSLT";
			this.labelXSLT.Size = new System.Drawing.Size(43, 13);
			this.labelXSLT.Text = "[internal]";


			// 
			// 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, 144);
			label2.Name = "label1";
			label2.Size = new System.Drawing.Size(43, 13);
			label2.TabIndex = 3;
			label2.Text = "Output";

			//
			//	comboOutput
			//			
			this.comboOutput.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.comboOutput.Location = new System.Drawing.Point(16, 163);
			this.comboOutput.Size = new System.Drawing.Size(128, 21);
			this.comboOutput.DropDown += new System.EventHandler(this.DropDown_comboOutput);

			//
			// buttonOutputLoad
			//
			this.buttonOutputLoad.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.buttonOutputLoad.Location = new System.Drawing.Point(120, 190);
			this.buttonOutputLoad.Name = "buttonOutputLoad";
			this.buttonOutputLoad.Text = "...";
			this.buttonOutputLoad.Size = new System.Drawing.Size(24, 20);
			this.buttonOutputLoad.Click += new System.EventHandler(this.Clicked_buttonOutputLoad);

			// 
			// labelOutput
			// 
			this.labelOutput.AutoSize = true;
			this.labelOutput.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(238)));
			this.labelOutput.Location = new System.Drawing.Point(16, 193);
			this.labelOutput.Name = "labelOutput";
			this.labelOutput.Size = new System.Drawing.Size(43, 13);
			this.labelOutput.Text = "[internal]";

			//
			// buttonTransform
			//
			this.buttonTransform.Anchor = (System.Windows.Forms.AnchorStyles.Top);
			this.buttonTransform.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.buttonTransform.Location = new System.Drawing.Point(67, 256);
			this.buttonTransform.Name = "buttonTransform";
			this.buttonTransform.TabIndex = 3;
			this.buttonTransform.Text = "Transform";
			this.buttonTransform.Size = new System.Drawing.Size(75, 23);
			this.buttonTransform.Click += new System.EventHandler(this.Clicked_buttonTransform);


			this.Control = this.groupBox;
		
			this.groupBox.ResumeLayout();

			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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -