Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Calendar.cs « System.Web.UI.MobileControls « System.Web.Mobile « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ce6d2db5f3a9b01c8ef75f7e0581c74b3690b5d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/**
 * Project   : Mono
 * Namespace : System.Web.UI.MobileControls
 * Class     : Calendar
 * Author    : Gaurav Vaish
 *
 * Copyright : 2003 with Gaurav Vaish, and with
 *             Ximian Inc
 */

using System.Web.UI;
using System.Web.Mobile;
using System.Web.UI.WebControls;

namespace System.Web.UI.MobileControls
{
	public class Calendar : MobileControl, IPostBackEventHandler
	{
		private System.Web.UI.WebControls.Calendar webCal;
		private static readonly object SelectionChangedEvent = new object();

		public Calendar()
		{
			webCal = CreateWebCalendar();
			webCal.Visible = false;
			webCal.Controls.Add(webCal);
			webCal.SelectionChanged += new EventHandler(WebSelectionChanged);
		}

		protected virtual System.Web.UI.WebControls.Calendar CreateWebCalendar()
		{
			return new System.Web.UI.WebControls.Calendar();
		}

		void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
		{
			if(MobilePage.ActiveForm != Form)
				MobilePage.ActiveForm = Form;
			Adapter.HandlePostBackEvent(eventArgument);
		}

		public event EventHandler SelectionChanged
		{
			add
			{
				Events.AddHandler(SelectionChangedEvent, value);
			}
			remove
			{
				Events.RemoveHandler(SelectionChangedEvent, value);
			}
		}

		public string CalendarEntryText
		{
			get
			{
				object o = ViewState["CalendarEntryText"];
				if(o != null)
					return (string)o;
				return String.Empty;
			}
			set
			{
				ViewState["CalendarEntryText"] = value;
			}
		}

		public FirstDayOfWeek FirstDayOfWeek
		{
			get
			{
				return webCal.FirstDayOfWeek;
			}
			set
			{
				webCal.FirstDayOfWeek = value;
			}
		}

		public DateTime SelectedDate
		{
			get
			{
				return webCal.SelectedDate;
			}
			set
			{
				webCal.SelectedDate = value;
			}
		}

		public SelectedDatesCollection SelectedDates
		{
			get
			{
				return webCal.SelectedDates;
			}
		}

		public CalendarSelectionMode SelectionMode
		{
			get
			{
				return webCal.SelectionMode;
			}
			set
			{
				webCal.SelectionMode = value;
			}
		}

		public bool ShowDayHeader
		{
			get
			{
				return webCal.ShowDayHeader;
			}
			set
			{
				webCal.ShowDayHeader = value;
			}
		}

		public DateTime VisibleDate
		{
			get
			{
				return webCal.VisibleDate;
			}
			set
			{
				webCal.VisibleDate = value;
			}
		}

		public System.Web.UI.WebControls.Calendar WebCalendar
		{
			get
			{
				return webCal;
			}
		}

		private void WebSelectionChanged(object sender, EventArgs e)
		{
			OnSelectionChanged();
		}

		protected virtual void OnSelectionChanged()
		{
			EventHandler eh = (EventHandler)(Events[SelectionChangedEvent]);
			if(eh != null)
			{
				eh(this, new EventArgs());
			}
		}

		public void RaiseSelectionChangedEvent()
		{
			WebSelectionChanged(this, new EventArgs());
		}
	}
}