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

📄 purview.cs

📁 报刊广告管理系统。CSharp编写
💻 CS
字号:
using System;

namespace WWAM
{
	public class Purview
	{
		int pValue = 0;
		public Purview()
		{

		}
		public Purview(int val)
		{
			pValue = val;
		}
		public Purview(bool[] vals)
		{
			pValue = GetInt(vals);
		}
		public int PurviewValue
		{
			get
			{
				return pValue;
			}
			set
			{
				pValue = value;
			}
		}
		public bool this[int index]
		{
			get
			{
				return GetValue(pValue,index);
			}
			set
			{
				pValue = SetValue(pValue,index,value);
			}

		}
		public bool[] ItemsValue
		{
			get
			{
				bool[] bools = new bool[31];
				GetArray(bools,pValue);
				return bools;
			}
		}
		#region Static Method
		public static bool GetValue(int Purview, int digit)
		{
			if(digit<0 || digit>30)
			{
				return false;
			}
			else
			{
				return (Purview & (1<<digit))!=0;
			}
		}

		public static int SetValue(int Purview, int digit, bool val)
		{
			if(digit<0 || digit>30)
			{
				return Purview;
			}
			else
			{
				if(val)
				{
					return (Purview | (1 << digit));
				}
				else
				{
					return (Purview & (~(1 << digit)));
				}
			}
		}

		public static int AllClear()
		{
			return 0;
		}

		public static int AllSet()
		{
			return 0x7FFFFFFF;
		}

		public static void GetArray(bool[] bools , int Purview)
		{
			if(bools.Length!=31)
			{
				bools = new bool[31];
			}
			for(int i=0;i<31;i++)
			{
				bools[i] = (Purview % 2 ==1);
				Purview >>=1;
			}			
		}

		public static int GetInt(bool[] bools)
		{
			int k=0;
			for(int i = Math.Min(bools.Length,30);i>=0;i--)
			{
				k<<=1;
				k += bools[i]?1:0;
			}
			return k;
		}
		public static int GetValue(int PurView, int pos , int digits)
		{
			if(pos<0 || pos+digits>30)
			{
				return 0;
			}
			else
			{
				int filter = (1<<digits)-1;
				return (PurView>>pos)&filter;
			}
		}
		public static int SetValue(int PurView, int pos , int digits , int val)
		{
			if(pos<0 || pos+digits>30)
			{
				return 0;
			}
			else
			{
				int filter = ~(((1<<digits)-1)<<pos);
				val = val<<pos;
				return (PurView&filter)|val;
			}
		}
		#endregion
	}
}

⌨️ 快捷键说明

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