main
syneffort 2 years ago
parent ba58c0a803
commit 3e205a9999
  1. 21
      MySolution/ToDoApp/MainWindow.xaml
  2. 117
      MySolution/ToDoApp/MainWindow.xaml.cs
  3. 63
      MySolution/ToDoApp/Properties/Resources.Designer.cs
  4. 101
      MySolution/ToDoApp/Properties/Resources.resx
  5. 22
      MySolution/ToDoApp/Service/ItemService.cs
  6. 2
      MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml
  7. 1
      MySolution/ToDoApp/SubControl/PlaceholderTextBox.xaml.cs
  8. 2
      MySolution/ToDoApp/SubControl/ToDoListItem.xaml
  9. 27
      MySolution/ToDoApp/SubControl/ToDoListItem.xaml.cs
  10. 18
      MySolution/ToDoApp/ToDoApp.csproj

@ -32,11 +32,15 @@
KeyDown="tbxSearch_KeyDown"/>
<StackPanel Grid.Row="2" Orientation="Vertical">
<Button x:Name="btnToday" Content="☀ 오늘 할 일" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"/>
<Button x:Name="btnPlaned" Content="📅 계획된 일정" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"/>
<Button x:Name="btnFinished" Content="✅ 완료됨" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"/>
<Button x:Name="btnToday" Content="☀ 오늘 할 일" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"
Click="btnToday_Click"/>
<Button x:Name="btnPlanned" Content="📅 계획된 일정" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"
Click="btnPlanned_Click"/>
<Button x:Name="btnFinished" Content="✅ 완료됨" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"
Click="btnCompleted_Click"/>
<Label Background="Gray" Height="1"/>
<Button x:Name="btnToDo" Content="💡 To Do" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"/>
<Button x:Name="btnToDo" Content="💡 To Do" Height="30" Margin="5" Background="Transparent" BorderThickness="0" HorizontalContentAlignment="Left"
Click="btnToDo_Click"/>
</StackPanel>
</Grid>
@ -63,12 +67,15 @@
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Vertical" Margin="5">
<subcontrol:PlaceholderTextBox x:Name="tbxItemName" VerticalAlignment="Center" TPlaceholder="검색" THeight="40"
<subcontrol:PlaceholderTextBox x:Name="tbxItemName" VerticalAlignment="Center" TPlaceholder="이름" TForeground="Black" THeight="40"
TFontWeight="Bold" TFontSize="20"/>
<TextBlock x:Name="tbItemCreatedAt" Text="0000년 00월 00일 0요일 생성됨" Foreground="Gray" TextAlignment="Right"/>
<Button x:Name="btnItemToday" HorizontalContentAlignment="Left" Height="30" Margin="0 10 0 0" Content="나의 하루에 추가" Background="Transparent" BorderThickness="0"/>
<StackPanel Orientation="Horizontal" Margin="0 5 0 0">
<CheckBox x:Name="chkItemToday" Background="Transparent"/>
<TextBlock Text="나의 하루에 추가" Margin="10 0 0 0" Background="Transparent"/>
</StackPanel>
<DatePicker x:Name="dpItemDueDate" Margin="0 5 0 0" Background="Transparent"/>
<subcontrol:PlaceholderTextBox x:Name="tbxItemDescription" Margin="0 5 0 0" TPlaceholder="메모" THeight="200" TVerticalAlignment="Top"/>
<subcontrol:PlaceholderTextBox x:Name="tbxItemDescription" Margin="0 5 0 0" TPlaceholder="메모" TForeground="Black" THeight="200" TVerticalAlignment="Top"/>
</StackPanel>
<Grid Grid.Row="1">

@ -26,8 +26,17 @@ namespace ToDoApp
/// </summary>
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<Item> items = GetAllItems();
SetToDoList(items);
string modeTitle = _currentMode.ToString();
List<Item> items = new List<Item>();
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<Item> GetAllItems()
private List<Item> GetAllToDoItems()
{
return ItemService.Instance.FindAllNotCompletedItems(_user.Id);
}
private void SetToDoList(List<Item> items)
private List<Item> GetTodayItems()
{
return ItemService.Instance.FindTodayItems(_user.Id);
}
private List<Item> GetPlannedItems()
{
return ItemService.Instance.FindPlannedItems(_user.Id);
}
private List<Item> GetCompletedItems()
{
return ItemService.Instance.FindCompletedItems(_user.Id);
}
private void SetItemList(List<Item> items)
{
List<ToDoListItem> list = new List<ToDoListItem>();
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)
chkItemToday.IsChecked = _selectedItem.IsToday == true ? true : false;
dpItemDueDate.SelectedDate = _selectedItem.DueDate;
if (_selectedItem.Description != null)
tbxItemDescription.Text = _selectedItem.Description;
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();
}
}
}

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ToDoApp.Properties {
using System;
/// <summary>
/// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
/// </summary>
// 이 클래스는 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() {
}
/// <summary>
/// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
/// </summary>
[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;
}
}
/// <summary>
/// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
/// 재정의합니다.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -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<Item> FindAllNotCompletedItems(User user)
public List<Item> 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<Item> 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<Item> FindCompletedItems(int userId)
{
using (var context = new ToDoContext())
{
return context.Items.Include(i => i.User).Where(i => i.UserId == userId && i.IsCompleted == true).ToList();
}
}

@ -8,7 +8,7 @@
d:DesignHeight="50" d:DesignWidth="200">
<Grid>
<TextBox x:Name="tbxMain" Background="Transparent" Foreground="Gray" Text="{Binding TPlaceholder}" FontSize="{Binding TFontSize}" FontWeight="{Binding TFontWeight}" Height="{Binding THeight}"
<TextBox x:Name="tbxMain" Background="Transparent" Foreground="{Binding TForeground}" Text="{Binding TPlaceholder}" FontSize="{Binding TFontSize}" FontWeight="{Binding TFontWeight}" Height="{Binding THeight}"
GotFocus="tbxMain_GotFocus" LostFocus="tbxMain_LostFocus"/>
</Grid>
</UserControl>

@ -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()
{

@ -10,6 +10,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Grid.ContextMenu>
@ -28,5 +29,6 @@
Checked="ckbFinish_Checked"/>
<TextBlock x:Name="tbItemName" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Text="Item Name"/>
<TextBlock x:Name="tbIsToday" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Gray" Text="☀오늘 할 일"/>
</Grid>
</UserControl>

@ -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);
}
}
}

@ -6,6 +6,9 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>ToDo.ico</ApplicationIcon>
<Version>$(VersionPrefix)</Version>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
@ -35,4 +38,19 @@
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

Loading…
Cancel
Save