diff --git a/MySolution/ToDoApp/MainWindow.xaml b/MySolution/ToDoApp/MainWindow.xaml
index 3ce50d4..8f787e8 100644
--- a/MySolution/ToDoApp/MainWindow.xaml
+++ b/MySolution/ToDoApp/MainWindow.xaml
@@ -32,11 +32,15 @@
KeyDown="tbxSearch_KeyDown"/>
-
-
-
+
+
+
-
+
@@ -63,12 +67,15 @@
-
-
+
+
+
+
-
+
diff --git a/MySolution/ToDoApp/MainWindow.xaml.cs b/MySolution/ToDoApp/MainWindow.xaml.cs
index 8665785..9ea5aeb 100644
--- a/MySolution/ToDoApp/MainWindow.xaml.cs
+++ b/MySolution/ToDoApp/MainWindow.xaml.cs
@@ -26,8 +26,17 @@ namespace ToDoApp
///
public partial class MainWindow : Window
{
+ private enum Mode
+ {
+ ToDo,
+ Today,
+ Planned,
+ Completed,
+ }
+
private User _user;
private Item _selectedItem;
+ private Mode _currentMode;
public MainWindow()
{
@@ -51,6 +60,7 @@ namespace ToDoApp
{
tbName.Text = _user.Name;
tbEmail.Text = _user.Email;
+ _currentMode = Mode.ToDo;
RefreshList();
}
@@ -87,26 +97,81 @@ namespace ToDoApp
private void RefreshList()
{
- List- items = GetAllItems();
- SetToDoList(items);
+ string modeTitle = _currentMode.ToString();
+ List
- items = new List
- ();
+
+ switch (_currentMode)
+ {
+ case Mode.ToDo:
+ default:
+ items = GetAllToDoItems();
+ break;
+ case Mode.Today:
+ items = GetTodayItems();
+ break;
+ case Mode.Planned:
+ items = GetPlannedItems();
+ break;
+ case Mode.Completed:
+ items = GetCompletedItems();
+ break;
+ }
+
+ tbTitle.Text = modeTitle;
+ SetItemList(items);
}
- private List
- GetAllItems()
+ private List
- GetAllToDoItems()
{
return ItemService.Instance.FindAllNotCompletedItems(_user.Id);
}
- private void SetToDoList(List
- items)
+ private List
- GetTodayItems()
+ {
+ return ItemService.Instance.FindTodayItems(_user.Id);
+ }
+
+ private List
- GetPlannedItems()
+ {
+ return ItemService.Instance.FindPlannedItems(_user.Id);
+ }
+
+ private List
- GetCompletedItems()
+ {
+ return ItemService.Instance.FindCompletedItems(_user.Id);
+ }
+
+ private void SetItemList(List
- items)
{
List list = new List();
foreach (Item item in items)
{
- list.Add(new ToDoListItem(item));
+ ToDoListItem toDoItem = new ToDoListItem(item);
+ toDoItem.ItemUpdateHandler += ToDoItem_ItemUpdateHandler;
+ toDoItem.ItemRemoveHandler += ToDoItem_ItemRemoveHandler;
+ toDoItem.ItemListRefreshHandler += ToDoItem_ItemListRefreshHandler;
+
+ list.Add(toDoItem);
}
lbxContent.ItemsSource = list;
}
+ private void ToDoItem_ItemListRefreshHandler(object? sender, EventArgs e)
+ {
+ RefreshList();
+ }
+
+ private void ToDoItem_ItemRemoveHandler(object? sender, Item e)
+ {
+ ItemService.Instance.RemoveItem(e);
+ }
+
+ private void ToDoItem_ItemUpdateHandler(object? sender, Item e)
+ {
+ ItemService.Instance.UpdateItem(e);
+ }
+
private void SetSelectedItem(Item item)
{
_selectedItem = item;
@@ -114,11 +179,9 @@ namespace ToDoApp
tbxItemName.Text = _selectedItem.Title;
tbItemCreatedAt.Text = _selectedItem.CreateDate.ToString("yyyy년 MM월 dd일 ddd 생성됨");
- if (_selectedItem.DueDate != null)
- dpItemDueDate.SelectedDate = _selectedItem.DueDate;
-
- if (_selectedItem.Description != null)
- tbxItemDescription.Text = _selectedItem.Description;
+ chkItemToday.IsChecked = _selectedItem.IsToday == true ? true : false;
+ dpItemDueDate.SelectedDate = _selectedItem.DueDate;
+ tbxItemDescription.Text = _selectedItem.Description == null ? "" : _selectedItem.Description;
}
private void ClearSelectedItem()
@@ -131,11 +194,6 @@ namespace ToDoApp
tbxItemDescription.Text = "";
}
- private void tbxNewItemName_KeyDown(object sender, KeyEventArgs e)
- {
-
- }
-
private void tbxSearch_KeyDown(object sender, KeyEventArgs e)
{
@@ -143,7 +201,14 @@ namespace ToDoApp
private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
+ _selectedItem.Title = tbxItemName.Text;
+ _selectedItem.IsToday = chkItemToday.IsChecked == true ? true : false;
+ _selectedItem.DueDate = dpItemDueDate.SelectedDate;
+ _selectedItem.Description = tbxItemDescription.Text;
+ ItemService.Instance.UpdateItem(_selectedItem);
+
+ RefreshList();
}
private void btnDelete_Click(object sender, RoutedEventArgs e)
@@ -186,5 +251,29 @@ namespace ToDoApp
SetSelectedItem(toDoListItem.Item);
}
+
+ private void btnToday_Click(object sender, RoutedEventArgs e)
+ {
+ _currentMode = Mode.Today;
+ RefreshList();
+ }
+
+ private void btnPlanned_Click(object sender, RoutedEventArgs e)
+ {
+ _currentMode = Mode.Planned;
+ RefreshList();
+ }
+
+ private void btnCompleted_Click(object sender, RoutedEventArgs e)
+ {
+ _currentMode = Mode.Completed;
+ RefreshList();
+ }
+
+ private void btnToDo_Click(object sender, RoutedEventArgs e)
+ {
+ _currentMode = Mode.ToDo;
+ RefreshList();
+ }
}
}
diff --git a/MySolution/ToDoApp/Properties/Resources.Designer.cs b/MySolution/ToDoApp/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..9eab0de
--- /dev/null
+++ b/MySolution/ToDoApp/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// 이 코드는 도구를 사용하여 생성되었습니다.
+// 런타임 버전:4.0.30319.42000
+//
+// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
+// 이러한 변경 내용이 손실됩니다.
+//
+//------------------------------------------------------------------------------
+
+namespace ToDoApp.Properties {
+ using System;
+
+
+ ///
+ /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
+ ///
+ // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
+ // 클래스에서 자동으로 생성되었습니다.
+ // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을
+ // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ToDoApp.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
+ /// 재정의합니다.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/MySolution/ToDoApp/Properties/Resources.resx b/MySolution/ToDoApp/Properties/Resources.resx
new file mode 100644
index 0000000..4fdb1b6
--- /dev/null
+++ b/MySolution/ToDoApp/Properties/Resources.resx
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/MySolution/ToDoApp/Service/ItemService.cs b/MySolution/ToDoApp/Service/ItemService.cs
index 0a7f595..b7c4413 100644
--- a/MySolution/ToDoApp/Service/ItemService.cs
+++ b/MySolution/ToDoApp/Service/ItemService.cs
@@ -34,15 +34,31 @@ namespace ToDoApp.Service
{
using (var context = new ToDoContext())
{
- return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted != false).ToList();
+ return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted != true).ToList();
}
}
- public List
- FindAllNotCompletedItems(User user)
+ public List
- FindTodayItems(int userId)
{
using (var context = new ToDoContext())
{
- return context.Items.Include(i => i.User).Where(i => i.User == user && i.IsCompleted == false).ToList();
+ return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted != true && i.IsToday == true).ToList();
+ }
+ }
+
+ public List
- FindPlannedItems(int userId)
+ {
+ using (var context = new ToDoContext())
+ {
+ return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted != true && i.DueDate != null).ToList();
+ }
+ }
+
+ public List
- FindCompletedItems(int userId)
+ {
+ using (var context = new ToDoContext())
+ {
+ return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted == true).ToList();
}
}
diff --git a/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml b/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml
index 83c863a..918f372 100644
--- a/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml
+++ b/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml
@@ -8,7 +8,7 @@
d:DesignHeight="50" d:DesignWidth="200">
-
diff --git a/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs b/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
index fd06d90..6d82c5a 100644
--- a/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
+++ b/MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
@@ -25,6 +25,7 @@ namespace ToDoApp.SubControl
public FontWeight TFontWeight { get; set; } = FontWeights.Normal;
public int THeight { get; set; } = 20;
public VerticalAlignment TVerticalAlignment { get; set; } = VerticalAlignment.Center;
+ public Brush TForeground { get; set; } = Brushes.Gray;
public PlaceholderTextBox()
{
diff --git a/MySolution/ToDoApp/SubControl/ToDoListItem.xaml b/MySolution/ToDoApp/SubControl/ToDoListItem.xaml
index f736f6c..3fce82f 100644
--- a/MySolution/ToDoApp/SubControl/ToDoListItem.xaml
+++ b/MySolution/ToDoApp/SubControl/ToDoListItem.xaml
@@ -10,6 +10,7 @@
+
@@ -28,5 +29,6 @@
Checked="ckbFinish_Checked"/>
+
diff --git a/MySolution/ToDoApp/SubControl/ToDoListItem.xaml.cs b/MySolution/ToDoApp/SubControl/ToDoListItem.xaml.cs
index 4a6b084..1287148 100644
--- a/MySolution/ToDoApp/SubControl/ToDoListItem.xaml.cs
+++ b/MySolution/ToDoApp/SubControl/ToDoListItem.xaml.cs
@@ -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- ItemUpdateHandler;
+ public event EventHandler
- 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);
}
}
}
diff --git a/MySolution/ToDoApp/ToDoApp.csproj b/MySolution/ToDoApp/ToDoApp.csproj
index 1a3ec8e..52c69be 100644
--- a/MySolution/ToDoApp/ToDoApp.csproj
+++ b/MySolution/ToDoApp/ToDoApp.csproj
@@ -6,6 +6,9 @@
enable
true
ToDo.ico
+ $(VersionPrefix)
+ 1.0.0.0
+ 1.0.0.0
@@ -35,4 +38,19 @@
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+