v1 update
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ToDoApp.Model;
|
||||
using ToDoApp.Service;
|
||||
|
||||
namespace ToDoApp.SubControl
|
||||
{
|
||||
@@ -23,6 +24,10 @@ namespace ToDoApp.SubControl
|
||||
{
|
||||
public Item Item { get; set; }
|
||||
|
||||
public event EventHandler<Item> ItemUpdateHandler;
|
||||
public event EventHandler<Item> ItemRemoveHandler;
|
||||
public event EventHandler ItemListRefreshHandler;
|
||||
|
||||
public ToDoListItem(Item item)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -34,27 +39,47 @@ namespace ToDoApp.SubControl
|
||||
private void InitInstance()
|
||||
{
|
||||
tbItemName.Text = this.Item.Title;
|
||||
ckbFinish.IsChecked = this.Item.IsToday == true ? true : false;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user