#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using DevComponents.DotNetBar.Schedule;
namespace DevComponents.Schedule.Model
{
public class Owner : INotifyPropertyChanged, INotifySubPropertyChanged
{
#region Constructors
///
/// Initializes a new instance of the Owner class.
///
public Owner()
{
_WorkDays = new WorkDayCollection(this);
_CalendarWorkDays = new CalendarWorkDayCollection(this);
}
///
/// Initializes a new instance of the Owner class.
///
///
public Owner(string key)
: this()
{
_Key = key;
}
///
/// Initializes a new instance of the Owner class.
///
///
///
public Owner(string key, string displayName)
: this()
{
_Key = key;
_DisplayName = displayName;
}
///
/// Initializes a new instance of the Owner class.
///
///
///
///
public Owner(string key, string displayName, eCalendarColor colorScheme)
: this()
{
_Key = key;
_ColorScheme = colorScheme;
_DisplayName = displayName;
}
///
/// Initializes a new instance of the Owner class.
///
///
///
public Owner(string key, eCalendarColor colorScheme)
: this()
{
_Key = key;
_ColorScheme = colorScheme;
}
#endregion
#region Internal Implementation
private WorkDayCollection _WorkDays;
///
/// Gets working days associated with this owner. If empty WorkDays from CalendarModel are used instead.
///
public WorkDayCollection WorkDays
{
get { return _WorkDays; }
}
private CalendarWorkDayCollection _CalendarWorkDays;
///
/// Gets date based working days associated with this owner. Date specific working days take precedence over days specified in WorkDays collection. If empty WorkDays on owner or from CalendarModel are used instead.
///
public CalendarWorkDayCollection CalendarWorkDays
{
get { return _CalendarWorkDays; }
}
private string _Key = "";
///
/// Gets or sets the unique key that identifies the owner.
///
[DefaultValue("")]
public string Key
{
get { return _Key; }
set
{
if (value != _Key)
{
string oldValue = _Key;
_Key = value;
OnKeyChanged(oldValue, value);
}
}
}
private void OnKeyChanged(string oldValue, string newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("Key"));
}
private string _Description = "";
///
/// Gets or sets the owner description. For example if owner represents person, it would be person name or if owner represents resource
/// like room it would be the room name.
///
[DefaultValue("")]
public string Description
{
get { return _Description; }
set
{
if (value != _Description)
{
string oldValue = _Description;
_Description = value;
OnDescriptionChanged(oldValue, value);
}
}
}
private void OnDescriptionChanged(string oldValue, string newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("Description"));
}
private object _Tag = null;
///
/// Gets or sets custom data associated with the object.
///
[DefaultValue(null)]
public object Tag
{
get { return _Tag; }
set
{
if (value != _Tag)
{
object oldValue = _Tag;
_Tag = value;
OnTagChanged(oldValue, value);
}
}
}
private void OnTagChanged(object oldValue, object newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("Tag"));
}
private CalendarModel _Calendar = null;
///
/// Gets the calendar owner is associated with.
///
[Browsable(false)]
public CalendarModel Calendar
{
get { return _Calendar; }
internal set
{
if (_Calendar != value)
{
_Calendar = value;
}
}
}
private TimeZoneInfo _DisplayTimeZone = null;
///
/// Gets or sets the display time-zone for this owner. Default value is null.
///
[DefaultValue(null)]
public TimeZoneInfo DisplayTimeZone
{
get { return _DisplayTimeZone; }
set
{
if (value != _DisplayTimeZone)
{
TimeZoneInfo oldValue = _DisplayTimeZone;
_DisplayTimeZone = value;
OnDisplayTimeZoneChanged(oldValue, value);
}
}
}
private void OnDisplayTimeZoneChanged(TimeZoneInfo oldValue, TimeZoneInfo newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("DisplayTimeZone"));
}
private eCalendarColor _ColorScheme = eCalendarColor.Automatic;
///
/// Gets or sets the owner color scheme used to represent owner data in user interface.
///
[DefaultValue(eCalendarColor.Automatic)]
public eCalendarColor ColorScheme
{
get { return _ColorScheme; }
set
{
if (value != _ColorScheme)
{
eCalendarColor oldValue = _ColorScheme;
_ColorScheme = value;
OnColorSchemeChanged(oldValue, value);
}
}
}
private void OnColorSchemeChanged(eCalendarColor oldValue, eCalendarColor newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("ColorScheme"));
}
private string _DisplayName = null;
///
/// Gets or sets the display name for the owner. Display name is used in User Interface to identify the owner.
/// If not specified the Key is used instead in UI.
///
[DefaultValue(null)]
public string DisplayName
{
get { return _DisplayName; }
set
{
if (value != _DisplayName)
{
string oldValue = _DisplayName;
_DisplayName = value;
OnDisplayNameChanged(oldValue, value);
}
}
}
private void OnDisplayNameChanged(string oldValue, string newValue)
{
OnPropertyChanged(new PropertyChangedEventArgs("DisplayName"));
}
internal static string DisplayNamePropertyName = "DisplayName";
#endregion
#region INotifyPropertyChanged Members
///
/// Occurs when property value has changed.
///
public event PropertyChangedEventHandler PropertyChanged;
///
/// Raises the PropertyChanged event.
///
/// Event arguments
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
PropertyChangedEventHandler eh = PropertyChanged;
if (eh != null) eh(this, e);
OnSubPropertyChanged(new SubPropertyChangedEventArgs(this, e));
}
#endregion
#region INotifySubPropertyChanged Members
///
/// Occurs when property or property of child objects has changed. This event is similar to PropertyChanged event with key
/// difference that it occurs for the property changed of child objects as well.
///
public event SubPropertyChangedEventHandler SubPropertyChanged;
///
/// Raises the SubPropertyChanged event.
///
/// Event arguments
protected virtual void OnSubPropertyChanged(SubPropertyChangedEventArgs e)
{
SubPropertyChangedEventHandler eh = SubPropertyChanged;
if (eh != null) eh(this, e);
}
#endregion
}
}
#endif