uicreater.cs

来自「语音视频功能 里面实现了基本的QQ与语音对话」· CS 代码 · 共 75 行

CS
75
字号
using System;
using System.Xml;
using System.Reflection;
using System.Diagnostics;
using System.ComponentModel;
using System.Collections;
using System.Windows.Forms;
namespace gowk.GXF
{
	/// <summary>
	/// UICreater 的摘要说明。
	/// </summary>
	public class UICreater
	{
		private XmlDocument doc;
		public UICreater(string file)
		{
			try
			{
				this.doc=new XmlDocument();
				doc.Load(file);
				this.XmlDocument=doc;
			}
			catch(System.Exception ex)
			{
				MessageBox.Show(ex.Message);
				throw;
			}
		}
		public Form CreateForm(string id)
		{
			Form f=null;
			XmlNode node=doc.SelectSingleNode(@"descendant::*[@id='"+id+"']");
			if(node!=null && node.NodeType==XmlNodeType.Element)
			{
				try
				{
					object o=ObjectCreator.Instance.CreateInstance(node);
					f=(Form)o;
				}
				catch
				{
					throw;
				}
			}
			return f;
		}
		public object CreateObject(string id)
		{
			XmlNode node=doc.SelectSingleNode(@"descendant::*[@id='"+id+"']");
			if(node!=null && node.NodeType==XmlNodeType.Element)
			{
				try
				{
					return ObjectCreator.Instance.CreateInstance(node);
				}
				catch
				{
					throw;
				}
			}
			return null;
		}
		public XmlDocument XmlDocument
		{
			get{return this.XmlDocument;}
			set
			{
				this.doc=value;
				ObjectCreator.Instance.XmlDocument=doc;
			}
		}
	}
}

⌨️ 快捷键说明

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