collections.cs

来自「这是网上下载的很好的串口发短信的程序! 是用VC++来做的」· CS 代码 · 共 124 行

CS
124
字号
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.Collections.Specialized;


namespace DDGameHelper.ResourceHelper
{

	/// <summary>
	/// 名称/位图对象 的 键值对 集合
	/// </summary>
	public class NameBitmapObjectCollection : NameObjectCollectionBase
	{
		public BitmapObject this[string name]
		{
			get{return (BitmapObject)BaseGet(name);}
			set{if(value!=null)BaseSet(name,value);else Remove(name);}
		}
		public BitmapObject AddNew(string name ,BitmapDisplayType bitmapDisplayType, string filePath)
		{
			BitmapObject bo = new BitmapObject(bitmapDisplayType, filePath);
			BaseSet(name,bo);
			return bo;
		}
		public BitmapObject AddNew(string name ,BitmapDisplayType bitmapDisplayType, Stream s)
		{
			BitmapObject bo = new BitmapObject(bitmapDisplayType, s);
			BaseSet(name,bo);
			return bo;
		}
		public BitmapObject AddNew(string name ,BitmapDisplayType bitmapDisplayType, Bitmap b)
		{
			BitmapObject bo = new BitmapObject(bitmapDisplayType, b);
			BaseSet(name,bo);
			return bo;
		}
		public bool Remove(string name)
		{
			if(this.BaseGet(name)!=null)
			{
				BaseRemove(name);
				return true;
			}
			return false;
		}
		public void Clear()
		{
			this.BaseClear();
		}
	}


	public class NameBmpRectComboCollection : NameObjectCollectionBase
	{
		protected DDHandler _dDHandler;
		protected NameBitmapObjectCollection _nboc;
		protected NameRectangleArrayCollection _nrac;
		public NameBitmapObjectCollection NameBitmapObjectCollectioN{get{return _nboc;}set{_nboc=value;}}
		public NameRectangleArrayCollection NameRectangleArrayCollectioN{get{return _nrac;}set{_nrac=value;}}
		public NameBmpRectComboCollection(ref DDHandler dDHandler)
		{
			_nboc=new NameBitmapObjectCollection();
			_nrac=new NameRectangleArrayCollection();
			_dDHandler=dDHandler;
		}

		public BmpRectCombo this[string name]
		{
			get{return (BmpRectCombo)BaseGet(name);}
			set{if(value!=null)BaseSet(name,value);else Remove(name);}
		}
		public BmpRectCombo AddNew(string name, ref BitmapObject bo,ref RectangleArray ra)
		{
			BmpRectCombo brc=new BmpRectCombo(ref bo,ref ra,ref _dDHandler);
			BaseSet(name,brc);
			return brc;
		}
		public bool Remove(string name)
		{
			if(this.BaseGet(name)!=null)
			{
				BaseRemove(name);
				return true;
			}
			return false;
		}
		public void Clear()
		{
			this.BaseClear();
		}
	}


	public class NameRectangleArrayCollection : NameObjectCollectionBase
	{
		public RectangleArray this[string name]
		{
			get{return (RectangleArray)BaseGet(name);}
			set{if(value!=null)BaseSet(name,value);else Remove(name);}
		}
		public RectangleArray AddNew(string name, int totalWidth, int totalHeight, int cellWidth, int cellHeight, int count)
		{
			RectangleArray ra=new RectangleArray(totalWidth, totalHeight, cellWidth, cellHeight, count);
			BaseSet(name,ra);
			return ra;
		}
		public bool Remove(string name)
		{
			if(this.BaseGet(name)!=null)
			{
				BaseRemove(name);
				return true;
			}
			return false;
		}
		public void Clear()
		{
			this.BaseClear();
		}
	}
}

⌨️ 快捷键说明

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