using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ToDoApp.Model; using ToDoApp.Service; namespace ToDoApp.SubControl { /// /// ToDoListItem.xaml에 대한 상호 작용 논리 /// public partial class ToDoListItem : UserControl { public Item Item { get; set; } public event EventHandler ItemUpdateHandler; public event EventHandler ItemRemoveHandler; public event EventHandler ItemListRefreshHandler; public ToDoListItem(Item item) { InitializeComponent(); this.Item = item; InitInstance(); } private void InitInstance() { tbItemName.Text = this.Item.Title; ckbFinish.IsChecked = this.Item.IsCompleted == true ? true : false; tbIsToday.Visibility = this.Item.IsToday == true ? Visibility.Visible : Visibility.Collapsed; } private void miToday_Click(object sender, RoutedEventArgs e) { this.Item.IsToday = true; if (this.ItemUpdateHandler != null) this.ItemUpdateHandler(this, this.Item); if (this.ItemListRefreshHandler != null) this.ItemListRefreshHandler(this, EventArgs.Empty); } private void miFinish_Click(object sender, RoutedEventArgs e) { this.Item.IsCompleted = true; if (this.ItemUpdateHandler != null) this.ItemUpdateHandler(this, Item); if (this.ItemListRefreshHandler != null) this.ItemListRefreshHandler(this, EventArgs.Empty); } private void miDelete_Click(object sender, RoutedEventArgs e) { if (this.ItemRemoveHandler != null) this.ItemRemoveHandler(this, this.Item); if (this.ItemListRefreshHandler != null) this.ItemListRefreshHandler(this, EventArgs.Empty); } private void ckbFinish_Checked(object sender, RoutedEventArgs e) { this.Item.IsCompleted = ckbFinish.IsChecked == true ? true : false; if (this.ItemUpdateHandler != null) this.ItemUpdateHandler(this, Item); if (this.ItemListRefreshHandler != null) this.ItemListRefreshHandler(this, EventArgs.Empty); } } }