Commit 37ba22c
Changed files (7)
docs
src
MVPtoMVVM
presenters
views
MVPtoMVVM.mvp
docs/~$MVP to MVVM.pptx
Binary file
src/MVPtoMVVM/presenters/TodoItemPresenter.cs
@@ -89,6 +89,7 @@ namespace MVPtoMVVM.presenters
view.SaveButtonEnabled = IsDirty && IsDescriptionValid() && IsDueDateValid();
view.DescriptionHasValidationErrors = !IsDescriptionValid();
view.DueDateHasValidationErrors = !IsDueDateValid();
+ view.IsDueSoon = IsDueSoon();
}
private bool IsDescriptionValid()
@@ -100,5 +101,10 @@ namespace MVPtoMVVM.presenters
{
return dueDate >= DateTime.Today;
}
+
+ private bool IsDueSoon()
+ {
+ return dueDate <= DateTime.Today.AddDays(1);
+ }
}
}
\ No newline at end of file
src/MVPtoMVVM/views/ITodoItemView.cs
@@ -13,6 +13,7 @@ namespace MVPtoMVVM.views
ITodoItemPresenter Presenter { get; }
bool DescriptionHasValidationErrors { set; }
bool DueDateHasValidationErrors { set; }
+ bool IsDueSoon { set; }
void Remove(int itemId);
}
}
\ No newline at end of file
src/MVPtoMVVM.mvp/alert.png
Binary file
src/MVPtoMVVM.mvp/MVPtoMVVM.mvp.csproj
@@ -111,6 +111,9 @@
<Name>MVPtoMVVM</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="alert.png" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
src/MVPtoMVVM.mvp/TodoItemView.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal">
+ <Image Source="alert.png" Name="dueSoonAlert"/>
<TextBox Name="description" Width="200"/>
<DatePicker Name="dueDate" />
<Button Content="Save" Name="saveButton"></Button>
src/MVPtoMVVM.mvp/TodoItemView.xaml.cs
@@ -86,6 +86,11 @@ namespace MVPtoMVVM.mvp
}
}
+ public bool IsDueSoon
+ {
+ set { dueSoonAlert.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
+ }
+
public void Remove(int itemId)
{
parent.Remove(itemId);