using System;
using System.ComponentModel;
/// <summary>
/// 작업
/// </summary>
public class Task : INotifyPropertyChanged, IEditableObject
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Event
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 속성 변경시 - PropertyChanged
/// <summary>
/// 속성 변경시
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// 프로젝트명
/// </summary>
private string projectName = string.Empty;
/// <summary>
/// 작업명
/// </summary>
private string taskName = string.Empty;
/// <summary>
/// 기한
/// </summary>
private DateTime dueDate = DateTime.Now;
/// <summary>
/// 완료 여부
/// </summary>
private bool completed = false;
/// <summary>
/// 임시 작업
/// </summary>
private Task temporaryTask = null;
/// <summary>
/// 편집 여부
/// </summary>
private bool editing = false;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Property
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 프로젝트명 - ProjectName
/// <summary>
/// 프로젝트명
/// </summary>
public string ProjectName
{
get
{
return this.projectName;
}
set
{
if(value == this.projectName)
{
return;
}
this.projectName = value;
NotifyPropertyChanged("ProjectName");
}
}
#endregion
#region 작업명 - TaskName
/// <summary>
/// 작업명
/// </summary>
public string TaskName
{
get
{
return this.taskName;
}
set
{
if(value == this.taskName)
{
return;
}
this.taskName = value;
NotifyPropertyChanged("TaskName");
}
}
#endregion
#region 기한 - DueDate
/// <summary>
/// 기한
/// </summary>
public DateTime DueDate
{
get
{
return this.dueDate;
}
set
{
if(value == this.dueDate)
{
return;
}
this.dueDate = value;
NotifyPropertyChanged("DueDate");
}
}
#endregion
#region 완료 여부 - Completed
/// <summary>
/// 완료 여부
/// </summary>
public bool Completed
{
get
{
return this.completed;
}
set
{
if(value == this.completed)
{
return;
}
this.completed = value;
NotifyPropertyChanged("Completed");
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
// IEditableObject
#region 편집 시작하기 - BeginEdit()
/// <summary>
/// 편집 시작하기
/// </summary>
public void BeginEdit()
{
if(this.editing)
{
return;
}
this.temporaryTask = MemberwiseClone() as Task;
this.editing = true;
}
#endregion
// IEditableObject
#region 편집 취소하기 - CancelEdit()
/// <summary>
/// 편집 취소하기
/// </summary>
public void CancelEdit()
{
if(!this.editing)
{
return;
}
ProjectName = this.temporaryTask.ProjectName;
TaskName = this.temporaryTask.TaskName;
DueDate = this.temporaryTask.DueDate;
Completed = this.temporaryTask.Completed;
this.editing = false;
}
#endregion
// IEditableObject
#region 편집 완료하기 - EndEdit()
/// <summary>
/// 편집 완료하기
/// </summary>
public void EndEdit()
{
if(!this.editing)
{
return;
}
this.temporaryTask = null;
this.editing = false;
}
#endregion
////////////////////////////////////////////////////////////////////////////////////////// Private
#region 속성 변경시 통지하기 - NotifyPropertyChanged(propertyName)
/// <summary>
/// 속성 변경시 통지하기
/// </summary>
/// <param name="propertyName">속성명</param>
private void NotifyPropertyChanged(string propertyName)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}