public
class
CustomRadScheduler : RadScheduler
{
private
FieldInfo schedulerFi;
private
FieldInfo activeViewsFi;
private
MethodInfo onPropertyChangedMi;
private
MethodInfo setActiveViewMi;
protected
override
void
CreateChildItems(RadElement parent)
{
base
.CreateChildItems(parent);
this
.activeViewsFi =
typeof
(RadScheduler).GetField(
"activeViews"
, BindingFlags.Instance | BindingFlags.NonPublic);
this
.schedulerFi =
typeof
(SchedulerView).GetField(
"scheduler"
, BindingFlags.Instance | BindingFlags.NonPublic);
this
.onPropertyChangedMi =
typeof
(SchedulerView).GetMethod(
"OnPropertyChanged"
, BindingFlags.Instance | BindingFlags.NonPublic);
this
.setActiveViewMi =
typeof
(RadScheduler).GetMethod(
"SetActiveView"
, BindingFlags.Instance | BindingFlags.NonPublic);
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadScheduler).FullName;
}
}
/// <summary>
/// Gets or sets the type of the active view.
/// </summary>
/// <value>The type of the active view.</value>
[DefaultValue(SchedulerViewType.Day)]
[NotifyParentProperty(
true
)]
public
override
SchedulerViewType ActiveViewType
{
get
{
return
base
.ActiveViewType;
}
set
{
if
(
this
.ActiveViewType != value && value == SchedulerViewType.Month)
{
SchedulerView newView;
Dictionary<SchedulerViewType, SchedulerView> activeViews =
this
.activeViewsFi.GetValue(
this
)
as
Dictionary<SchedulerViewType, SchedulerView>;
if
(activeViews.ContainsKey(value))
{
newView = activeViews[value];
}
else
{
SchedulerView view =
new
CustomSchedulerMonthView();
this
.schedulerFi.SetValue(view,
this
);
this
.onPropertyChangedMi.Invoke(view,
new
object
[] {
new
string
[] {
"Scheduler"
} });
newView = view;
}
if
(
this
.ActiveView != newView && newView !=
null
)
{
this
.setActiveViewMi.Invoke(
this
,
new
object
[] { newView,
true
});
}
}
else
{
base
.ActiveViewType = value;
}
}
}
}
public
class
CustomSchedulerMonthView : SchedulerMonthView
{
public
override
SchedulerView OffsetView(
int
offset)
{
if
(offset == 0)
{
return
this
;
}
return
base
.OffsetView(offset);
}
}