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

📄 calendar.cs

📁 不错的人事管理系统
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Web.UI;
using System.Text;
using System.Collections;
using System.Globalization;

namespace System.Web.UI.WebControls
{
	/// <summary>
	/// Summary description for Calendar.
	/// </summary>
	//.custom instance void [System]System.ComponentModel.DefaultEventAttribute
	//.custom instance void System.Web.UI.DataBindingHandlerAttribute::.ctor(string) 
	//.custom instance void [System]System.ComponentModel.DefaultPropertyAttribute::.cto
	//.custom instance void [System]System.ComponentModel.DesignerAttribute::.c
	public class Calendar : WebControl,IPostBackEventHandler
	{
		private const string SELECT_RANGE_COMMAND = "R";
		private const string NAVIGATE_MONTH_COMMAND = "V";
		private const int STYLEMASK_DAY = 16;
		private const int STYLEMASK_UNIQUE = 15;
		private const int STYLEMASK_SELECTED = 8;
		private const int STYLEMASK_TODAY = 4;
		private const int STYLEMASK_OTHERMONTH = 2;
		private const int STYLEMASK_WEEKEND = 1;
		private const string ROWBEGINTAG = "<tr>";
		private const string ROWENDTAG = "</tr>";
		private const int cachedNumberMax = 31;
		private static object EventDayRender;
		private static object EventSelectionChanged;
		private static object EventVisibleMonthChanged;
		private System.Web.UI.WebControls.TableItemStyle titleStyle;
		private System.Web.UI.WebControls.TableItemStyle nextPrevStyle;
		private System.Web.UI.WebControls.TableItemStyle dayHeaderStyle;
		private System.Web.UI.WebControls.TableItemStyle selectorStyle;
		private System.Web.UI.WebControls.TableItemStyle dayStyle;
		private System.Web.UI.WebControls.TableItemStyle otherMonthDayStyle;
		private System.Web.UI.WebControls.TableItemStyle todayDayStyle;
		private System.Web.UI.WebControls.TableItemStyle selectedDayStyle;
		private System.Web.UI.WebControls.TableItemStyle weekendDayStyle;
		private string defaultButtonColorText;
		private System.Collections.ArrayList dateList;
		private System.Web.UI.WebControls.SelectedDatesCollection selectedDates;
		private System.Globalization.Calendar threadCalendar;
		private static System.DateTime baseDate;
		private static string[] cachedNumbers;

		static Calendar() 
		{
			string[] local0;

			Calendar.EventDayRender = new Object();
			Calendar.EventSelectionChanged = new Object();
			Calendar.EventVisibleMonthChanged = new Object();
			//			<{ class ILEngineer::Ops::MSIL::LoadStaticFieldAddress }> = new System.DateTime(2000, 1, 1);
			local0 = new String[32];
			local0[0] = "0";
			local0[1] = "1";
			local0[2] = "2";
			local0[3] = "3";
			local0[4] = "4";
			local0[5] = "5";
			local0[6] = "6";
			local0[7] = "7";
			local0[8] = "8";
			local0[9] = "9";
			local0[10] = "10";
			local0[11] = "11";
			local0[12] = "12";
			local0[13] = "13";
			local0[14] = "14";
			local0[15] = "15";
			local0[16] = "16";
			local0[17] = "17";
			local0[18] = "18";
			local0[19] = "19";
			local0[20] = "20";
			local0[21] = "21";
			local0[22] = "22";
			local0[23] = "23";
			local0[24] = "24";
			local0[25] = "25";
			local0[26] = "26";
			local0[27] = "27";
			local0[28] = "28";
			local0[29] = "29";
			local0[30] = "30";
			local0[31] = "31";
			Calendar.cachedNumbers = local0;
		}

		public Calendar() : base() 
		{
		}

		private void ApplyTitleStyle(TableCell titleCell, Table titleTable, TableItemStyle titleStyle) 
		{
			if (titleStyle.BackColor!= System.Drawing.Color.Empty)
				titleCell.BackColor = titleStyle.BackColor;
			if (titleStyle.BorderColor!= System.Drawing.Color.Empty)
				titleCell.BorderColor = titleStyle.BorderColor;
			if (System.Web.UI.WebControls.Unit.op_Inequality(titleStyle.BorderWidth, System.Web.UI.WebControls.Unit.Empty))
				titleCell.BorderWidth = titleStyle.BorderWidth;
			if (titleStyle.BorderStyle != 0)
				titleCell.BorderStyle = titleStyle.BorderStyle;
			if (System.Web.UI.WebControls.Unit.op_Inequality(titleStyle.Height, System.Web.UI.WebControls.Unit.Empty))
				titleCell.Height = titleStyle.Height;
//			if (titleStyle.VerticalAlign != 0)
//				titleCell.VerticalAlign = titleStyle.VerticalAlign;
			if (titleStyle.ForeColor!= System.Drawing.Color.Empty)
				titleTable.ForeColor = titleStyle.ForeColor;
			else 	if (this.ForeColor!= System.Drawing.Color.Empty)
				titleTable.ForeColor = this.ForeColor;
//			titleTable.Font.CopyFrom(titleStyle.Font);
//			titleTable.Font.MergeWith(this.Font);
		}

		protected virtual ControlCollection CreateControlCollection() 
		{
			return new EmptyControlCollection(this);
		}

		private DateTime EffectiveVisibleDate() 
		{
			DateTime local0;

			local0 = this.VisibleDate;
			if (local0.Equals(System.DateTime.MinValue))
				local0 = this.TodaysDate;
			return this.threadCalendar.AddDays(local0, -this.threadCalendar.GetDayOfMonth(local0) - 1);
		}

		private DateTime FirstCalendarDay(DateTime visibleDate) 
		{
			DateTime local0;
			int local1;

			local0 = visibleDate;
			local1 = (int)this.threadCalendar.GetDayOfWeek(local0) - (int)this.NumericFirstDayOfWeek();
			if (local1 <= 0)
				local1 += 7;
			return this.threadCalendar.AddDays(local0, -local1);
		}

		private string GetCalendarButtonText(string eventArgument, string buttonText, bool showLink, Color foreColor) 
		{
			StringBuilder local0;

			if (showLink) 
			{
				local0 = new StringBuilder();
				local0.Append("<a href=\"");
				local0.Append(this.Page.GetPostBackClientHyperlink(this, eventArgument));
				local0.Append("\" style=\"color:");
				if (!(foreColor.IsEmpty))
				{
//					goto i-1;
				}
//				System.Drawing.ColorTranslator.ToHtml(foreColor).Append(this.defaultButtonColorText);
				local0.Append("\">");
				local0.Append(buttonText);
				local0.Append("</a>");
				return local0.ToString();
			}
			return buttonText;
		}

		private int GetDefinedStyleMask() 
		{
			int local0;

			local0 = 8;
			if (this.dayStyle != null && !(this.dayStyle.IsEmpty))
				local0 |= 16;
			if (this.todayDayStyle != null && !(this.todayDayStyle.IsEmpty))
				local0 |= 4;
			if (this.otherMonthDayStyle != null && !(this.otherMonthDayStyle.IsEmpty))
				local0 |= 2;
			if (this.weekendDayStyle != null && !(this.weekendDayStyle.IsEmpty))
				local0 |= 1;
			return local0;
		}

		private string GetMonthName(int m, bool bFull) 
		{
//			if (bFull)
//				return DateTimeFormatInfo.CurrentInfo.GetMonthName(m);
//			return DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(m);
			throw new Exception("");
		}

		protected bool HasWeekSelectors(CalendarSelectionMode selectionMode) 
		{
			if (selectionMode != CalendarSelectionMode.DayWeek)
				return selectionMode == CalendarSelectionMode.DayWeekMonth;
			return true;
		}

		protected virtual void LoadViewState(object savedState) 
		{
			object[] local0;
			ArrayList local1;

			if (savedState != null) 
			{
				local0 = (object[]) savedState;
//				if (local0[0])
//					this.LoadViewState(local0[0]);
//				if (local0[1])
//					this.TitleStyle.LoadViewState(local0[1]);
//				if (local0[2])
//					this.NextPrevStyle.LoadViewState(local0[2]);
//				if (local0[3])
//					this.DayStyle.LoadViewState(local0[3]);
//				if (local0[4])
//					this.DayHeaderStyle.LoadViewState(local0[4]);
//				if (local0[5])
//					this.TodayDayStyle.LoadViewState(local0[5]);
//				if (local0[6])
//					this.WeekendDayStyle.LoadViewState(local0[6]);
//				if (local0[7])
//					this.OtherMonthDayStyle.LoadViewState(local0[7]);
//				if (local0[8])
//					this.SelectedDayStyle.LoadViewState(local0[8]);
//				if (local0[9])
//					this.SelectorStyle.LoadViewState(local0[9]);
//				local1 = (ArrayList) this.ViewState["SD"];
//				if (local1 != null) 
//				{
//					this.dateList = local1;
//					this.selectedDates = null;
//				}
			}
		}

		private int NumericFirstDayOfWeek() 
		{
//			if (this.FirstDayOfWeek != 7)
//				return this.FirstDayOfWeek;
//			return DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek;
			throw new Exception("");
		}

		protected virtual void OnDayRender(TableCell cell, CalendarDay day) 
		{
			DayRenderEventHandler local0;

			local0 = (DayRenderEventHandler) this.Events[Calendar.EventDayRender];
//			if (local0 != null)
//				local0.Invoke(this, new DayRenderEventArgs(cell, day));
		}

		protected virtual void OnPreRender(EventArgs e) 
		{
			this.OnPreRender(e);
			if (this.Page != null)
				this.Page.RegisterPostBackScript();
		}

		protected virtual void OnSelectionChanged() 
		{
			EventHandler local0;

			local0 = (EventHandler) this.Events[Calendar.EventSelectionChanged];
			if (local0 != null)
				local0.Invoke(this, new EventArgs());
		}

		protected virtual void OnVisibleMonthChanged(DateTime newDate, DateTime previousDate) 
		{
			MonthChangedEventHandler local0;

			local0 = (MonthChangedEventHandler) this.Events[Calendar.EventVisibleMonthChanged];
//			if (local0 != null)
//				local0.Invoke(this, new MonthChangedEventArgs(newDate, previousDate));
		}

		protected virtual void Render(HtmlTextWriter writer) 
		{
			DateTime local0;
			DateTime local1;
			CalendarSelectionMode local2;
			Page local3;
			bool local4;
			Color local5;
			Table local6;
			Unit local7;

			this.threadCalendar = DateTimeFormatInfo.CurrentInfo.Calendar;
			local0 = this.EffectiveVisibleDate();
			local1 = this.FirstCalendarDay(local0);
			local2 = this.SelectionMode;
			if (this.Page != null)
				this.Page.VerifyRenderingInServerForm(this);
			local3 = this.Page;
			if (local3 == null || this.Site != null && this.Site.DesignMode)
				local4 = false;
			else
				local4 = this.Enabled;
			local5 = this.ForeColor;
			if (local5== System.Drawing.Color.Empty)
				local5 = Color.Black;
			this.defaultButtonColorText = System.Drawing.ColorTranslator.ToHtml(local5);
			local6 = new Table();
			local6.ID = this.ID;
			local6.CopyBaseAttributes(this);
			if (this.ControlStyleCreated)
				local6.ApplyStyle(this.ControlStyle);
			local6.Width = this.Width;
			local6.Height = this.Height;
//			local6.CellPadding = this.CellPadding;
//			local6.CellSpacing = this.CellSpacing;
			if (this.ControlStyleCreated && this.ControlStyle.IsSet(32)) 
			{
				local7 = this.BorderWidth;
				if (!(local7.Equals(System.Web.UI.WebControls.Unit.Empty)))
				{
//					goto i0;
				}
			}
			local6.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
//			i0: if (this.ShowGridLines)
//					local6.GridLines = 3;
//				else
//					local6.GridLines = 0;
			local6.RenderBeginTag(writer);
			if (this.ShowTitle)
				this.RenderTitle(writer, local0, local2, local4);
			if (this.ShowDayHeader)
				this.RenderDayHeader(writer, local1, local0, local2, local4);
			this.RenderDays(writer, local1, local0, local2, local4);
			local6.RenderEndTag(writer);
		}

		private void RenderCalendarCell(HtmlTextWriter writer, TableItemStyle style, string text, bool hasButton, string eventArgument) 
		{
			Color local0;

			style.AddAttributesToRender(writer, this);
//			writer.RenderBeginTag(84);
			if (hasButton) 
			{
				local0 = style.ForeColor;
				writer.Write("<a href=\"");
				writer.Write(this.Page.GetPostBackClientHyperlink(this, eventArgument));
				writer.Write("\" style=\"color:");
				if (!(local0.IsEmpty))
				{
//					goto i-1;
				}
//				System.Drawing.ColorTranslator.ToHtml(local0).Write(this.defaultButtonColorText);
				writer.Write("\">");
				writer.Write(text);
				writer.Write("</a>");
			}
			else
				writer.Write(text);
			writer.RenderEndTag();
		}

		private void RenderDayHeader(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive) 
		{
			DateTimeFormatInfo local0;
			TableItemStyle local1;
			int local2;
			int local3;
			string local4;
			TableItemStyle local5;
			DayNameFormat local6;
			int local7;
			int local8;
			string local9;
			int local10;
			TimeSpan local11;
			int local12;
			DayNameFormat local13;

			writer.Write("<tr>");
			local0 = DateTimeFormatInfo.CurrentInfo;
			if (this.HasWeekSelectors(selectionMode)) 
			{
				local1 = new TableItemStyle();
//				local1.HorizontalAlign = 2;
				if (selectionMode == CalendarSelectionMode.DayWeekMonth) 
				{
					local11 = visibleDate.Subtract(Calendar.baseDate);
					local2 = local11.Days;
					local3 = this.threadCalendar.GetDaysInMonth(this.threadCalendar.GetYear(visibleDate), this.threadCalendar.GetMonth(visibleDate));
					local12 = local2 * 100 + local3;
					local4 = "R" + local12.ToString(CultureInfo.InvariantCulture);
					local1.CopyFrom(this.SelectorStyle);
					this.RenderCalendarCell(writer, local1, this.SelectMonthText, buttonsActive, local4);
				}
				else 
				{
					local1.CopyFrom(this.DayHeaderStyle);
					this.RenderCalendarCell(writer, local1, System.String.Empty, false, null);
				}
			}
			local5 = new TableItemStyle();
//			local5.HorizontalAlign = 2;
			local5.CopyFrom(this.DayHeaderStyle);
			local6 = this.DayNameFormat;
//			local7 = this.threadCalendar.GetDayOfWeek(firstDay);
//			local8 = local7;
//			while (local8 < local7 + 7) 
//			{
//				local10 = local8 % 7;
//				local13 = local6;
//				switch (local13) 
//				{
//					case (DayNameFormat)2:
//						local9 = local0.GetDayName(local10).Substring(0, 1);
//						goto i1;
//						break;
//					case (DayNameFormat)3:
//						local9 = local0.GetDayName(local10).Substring(0, 2);
//						goto i1;
//						break;
//					case (DayNameFormat)0:
//						local9 = local0.GetDayName(local10);
//						goto i1;
//						break;
//				}
//				local9 = local0.GetAbbreviatedDayName(local10);
//			i1: this.RenderCalendarCell(writer, local5, local9, false, null);
//				local8++;
//			}
			writer.Write("</tr>");
		}

		private void RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, bool buttonsActive) 
		{
//			DateTime local0;
//			TableItemStyle local1;
//			Unit local2;
//			bool local3;
//			bool local4;
//			bool local5;
//			System.Web.UI.WebControls.TableItemStyle[] local6;

⌨️ 快捷键说明

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