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

📄 selectxmlschemaform.cs

📁 c#源代码
💻 CS
字号:
//
// SharpDevelop Xml Editor
//
// Copyright (C) 2005 Matthew Ward
//
// 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
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Matthew Ward (mrward@users.sourceforge.net)

using ICSharpCode.Core.Services;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.XmlForms;
using System;
using System.Windows.Forms;

namespace ICSharpCode.XmlEditor
{
	/// <summary>
	/// Allows the use to choose a schema from the schemas that SharpDevelop 
	/// knows about.
	/// </summary>
	public class SelectXmlSchemaForm : XmlForm
	{
		ListBox schemaListBox;
		string NoSchemaSelectedText = String.Empty;
		
		public SelectXmlSchemaForm(string[] namespaces)
		{
			Initialize();
			PopulateListBox(namespaces);
		}
		
		/// <summary>
		/// Gets or sets the selected schema namesace.
		/// </summary>
		public string SelectedNamespaceUri {
			get {
				string namespaceUri = schemaListBox.Text;
				if (namespaceUri == NoSchemaSelectedText) {
					namespaceUri = String.Empty;
				}
				return namespaceUri;
			}
			
			set {
				int index = 0;
				if (value.Length > 0) {
					index = schemaListBox.Items.IndexOf(value);
				} 
				
				// Select the option representing "no schema" if 
				// the value does not exist in the list box.
				if (index == -1) {
					index = 0;
				}
				
				schemaListBox.SelectedIndex = index;
			}
		}
		
		protected override void SetupXmlLoader()
		{
			xmlLoader.StringValueFilter    = new SharpDevelopStringValueFilter();
			xmlLoader.PropertyValueCreator = new SharpDevelopPropertyValueCreator();
			xmlLoader.ObjectCreator        = new SharpDevelopObjectCreator();
		}
		
		void Initialize()
		{
			SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("SelectXmlSchema.xfrm"));
			
			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
			NoSchemaSelectedText = stringParserService.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.None}");
			
			schemaListBox = (ListBox)ControlDictionary["schemaListBox"];
			
			AcceptButton = (Button)ControlDictionary["okButton"];
			CancelButton = (Button)ControlDictionary["cancelButton"];
			AcceptButton.DialogResult = DialogResult.OK;
		}
		
		void PopulateListBox(string[] namespaces)
		{
			foreach (string schemaNamespace in namespaces) {
				schemaListBox.Items.Add(schemaNamespace);
			}
			
			// Add the "None" string at the top of the list.
			schemaListBox.Sorted = true;
			schemaListBox.Sorted = false;
			
			schemaListBox.Items.Insert(0, NoSchemaSelectedText);
		}
	}
}

⌨️ 快捷键说明

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