#if FRAMEWORK20
using System;
using System.Collections.Generic;
using DevComponents.Schedule.Model;
namespace DevComponents.DotNetBar.Schedule
{
///
/// Represents base class for the model to view connectors.
///
internal abstract class ModelViewConnector
{
#region Internal Implementation
#region Private variables
private string _DisplayOwnerKey = "";
#endregion
#region Abstract defines
///
/// Connects View to a model.
///
public abstract void Connect();
///
/// Disconnects view from model.
///
public abstract void Disconnect();
///
/// Gets whether connector has connected model to a view.
///
public abstract bool IsConnected { get; }
public abstract eCalendarView GetView();
#endregion
#region Virtual methods
protected virtual bool IsAppointmentVisible(Appointment app)
{
if (app.Visible == false)
return (false);
if (string.IsNullOrEmpty(_DisplayOwnerKey))
return (true);
return (app.OwnerKey == _DisplayOwnerKey);
}
protected virtual bool IsCustomItemVisible(CustomCalendarItem item)
{
if (item.Visible == false)
return (false);
if (string.IsNullOrEmpty(_DisplayOwnerKey))
return (true);
return (item.OwnerKey.Equals(_DisplayOwnerKey));
}
///
/// Gets or sets the owner key of the owner of the appointments displayed on the view.
///
public virtual string DisplayOwnerKey
{
get { return _DisplayOwnerKey; }
set
{
if (value == null)
value = "";
if (_DisplayOwnerKey != null)
{
_DisplayOwnerKey = value;
}
}
}
public virtual List
GetAppointmentList(CalendarModel model, DateTime startDate, DateTime endDate)
{
List appts = new List();
for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
{
Day day = model.GetDay(date);
if (day.Appointments.Count > 0)
{
foreach (Appointment ap in day.Appointments)
{
if (appts.Contains(ap) == false)
appts.Add(ap);
}
}
}
return (appts);
}
#endregion
#endregion
}
}
#endif