Skip to content

Commit

Permalink
Closed #68: FEA - Search posting;
Browse files Browse the repository at this point in the history
Fixed #25: BUG - Prevent double postings update;
Refactored PostingsViewModel for reuse;
Minor code clean-up.
  • Loading branch information
sevenate committed Feb 19, 2012
1 parent f86cb9e commit ad7afdf
Show file tree
Hide file tree
Showing 31 changed files with 1,372 additions and 857 deletions.
114 changes: 113 additions & 1 deletion src/Fab.Client/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:framework="clr-namespace:Fab.Client.Framework"
xmlns:converters="clr-namespace:Fab.Client.Framework.Converters"
xmlns:Common="clr-namespace:Fab.Client.Common" xmlns:Categories="clr-namespace:Fab.Client.MoneyTracker.Categories"
mc:Ignorable="d">
xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" mc:Ignorable="d">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down Expand Up @@ -58,6 +58,118 @@
<Setter Property="Foreground"
Value="#FF00FF00" />
</Style>
<Style x:Key="ComboBoxItemStyle"
TargetType="ComboBoxItem">
<Setter Property="Padding"
Value="3" />
<Setter Property="HorizontalContentAlignment"
Value="Left" />
<Setter Property="VerticalContentAlignment"
Value="Top" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="TabNavigation"
Value="Local" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Grid Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation Duration="0"
To=".35"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="fillColor" />
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0"
To=".55"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="contentPresenter" />
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected" />
<VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Duration="0"
To=".75"
Storyboard.TargetProperty="Opacity"
Storyboard.TargetName="fillColor2" />
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0"
Storyboard.TargetProperty="Visibility"
Storyboard.TargetName="FocusVisualElement">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="fillColor"
Fill="#FFBADDE9"
IsHitTestVisible="False"
Opacity="0"
RadiusY="1"
RadiusX="1" />
<Rectangle x:Name="fillColor2"
Fill="#FFBADDE9"
IsHitTestVisible="False"
Opacity="0"
RadiusY="1"
RadiusX="1" />
<ContentPresenter x:Name="contentPresenter"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="Stretch"
Margin="{TemplateBinding Padding}" />
<Rectangle x:Name="FocusVisualElement"
RadiusY="1"
RadiusX="1"
Stroke="#FF6DBDD1"
StrokeThickness="1"
Visibility="Collapsed" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="AccountBrief">
<toolkit:DockPanel HorizontalAlignment="Stretch">
<TextBlock toolkit:DockPanel.Dock="Right"
Margin="5,0,0,0"
MinWidth="20"
Text="{Binding Path=AssetTypeId, Converter={StaticResource assetTypeIdToString}}"
VerticalAlignment="Center"
HorizontalAlignment="Left" />
<TextBlock toolkit:DockPanel.Dock="Right"
Text="{Binding Path=Balance, StringFormat=\{0:N\}}"
Foreground="{Binding Path=Balance, Converter={StaticResource balanceToColor}}"
Margin="5,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center" />
<TextBlock Text="{Binding Path=Name}"
FontWeight="Bold" />
</toolkit:DockPanel>
</DataTemplate>
</ResourceDictionary>
</Application.Resources>
</Application>
7 changes: 4 additions & 3 deletions src/Fab.Client/Authentication/LoggedInMessage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// <copyright file="LoggedInMessage.cs" company="HD">
// Copyright (c) 2009-2011 nReez. All rights reserved.
//------------------------------------------------------------
// <copyright file="LoggedInMessage.cs" company="nReez">
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrew Levshoff" email="[email protected]" date="2011-03-24" />
//------------------------------------------------------------

namespace Fab.Client.Authentication
{
Expand Down
7 changes: 4 additions & 3 deletions src/Fab.Client/Authentication/LoggedOutMessage.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// <copyright file="LoggedOutMessage.cs" company="HD">
// Copyright (c) 2009-2011 nReez. All rights reserved.
//------------------------------------------------------------
// <copyright file="LoggedOutMessage.cs" company="nReez">
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrew Levshoff" email="[email protected]" date="2011-03-24" />
//------------------------------------------------------------

namespace Fab.Client.Authentication
{
Expand Down
7 changes: 4 additions & 3 deletions src/Fab.Client/Authentication/PersonalCornerViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// <copyright file="PersonalCornerViewModel.cs" company="nReez">
// Copyright (c) 2009-2011 nReez. All rights reserved.
//------------------------------------------------------------
// <copyright file="RegisterationResult.cs" company="nReez">
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrew Levshoff" email="[email protected]" date="2011-08-18" />
//------------------------------------------------------------

using System.ComponentModel.Composition;
using Caliburn.Micro;
Expand Down
2 changes: 1 addition & 1 deletion src/Fab.Client/Authentication/RegisterationResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------
// <copyright file="RegisterationResult.cs" company="nReez">
// Copyright (c) 2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
//------------------------------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions src/Fab.Client/Fab.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<Compile Include="Framework\Extensions\FrameworkElementExtensions.cs" />
<Compile Include="Framework\Results\Animation.cs" />
<Compile Include="Framework\Results\AnimationResult.cs" />
<Compile Include="Framework\Results\SingleResult.cs" />
<Compile Include="MoneyTracker\Accounts\AccountDeletedMessage.cs" />
<Compile Include="MoneyTracker\Accounts\AssetTypes\AssetTypesRepository.cs" />
<Compile Include="MoneyTracker\Accounts\AssetTypes\AssetTypesUpdatedMessage.cs" />
Expand All @@ -178,6 +179,11 @@
<Compile Include="MoneyTracker\Categories\Single\NewCategoryViewModel.cs" />
<Compile Include="MoneyTracker\Categories\Single\CategoryViewModel.cs" />
<Compile Include="Authentication\StartViewModel.cs" />
<Compile Include="MoneyTracker\Postings\AddTransactionRecordBaseResult.cs" />
<Compile Include="MoneyTracker\Postings\AddTransactionRecordResult.cs" />
<Compile Include="MoneyTracker\Postings\CountPostingsResult.cs" />
<Compile Include="MoneyTracker\Postings\PostingRecordBase.cs" />
<Compile Include="MoneyTracker\Postings\PostingViewModelBase.cs" />
<Compile Include="MoneyTracker\SearchDashBoardViewModel.cs" />
<Compile Include="Resources\Actions\EditIcon.xaml.cs">
<DependentUpon>EditIcon.xaml</DependentUpon>
Expand Down
5 changes: 3 additions & 2 deletions src/Fab.Client/Framework/IRepository.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//------------------------------------------------------------
// <copyright file="IRepository.cs" company="nReez">
// Copyright (c) 2009-2011 nReez. All rights reserved.
// Copyright (c) 2011 nReez. All rights reserved.
// </copyright>
// <author name="Andrew Levshoff" email="[email protected]" date="2011-04-05" />
//------------------------------------------------------------

using Caliburn.Micro;
using Fab.Client.Authentication;
Expand Down
1 change: 1 addition & 0 deletions src/Fab.Client/Framework/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// <author name="Andrew Levshoff" email="[email protected]" date="2011-03-26" />

using System;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using Caliburn.Micro;
using Fab.Client.Authentication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using Caliburn.Micro;
using Action = System.Action;

namespace Fab.Managment.Framework.Results
namespace Fab.Client.Framework.Results
{
/// <summary>
/// Single <see cref="IResult"/> that will cause all changed binded properties
Expand All @@ -31,7 +31,11 @@ public void Execute(ActionExecutionContext context)
Action();

// Push all binded properties changes during Action to appear faster on screen
#if SILVERLIGHT
Application.Current.RootVisual.Dispatcher.BeginInvoke(delegate { });
#else
Application.Current.Dispatcher.Invoke(DispatcherPriority.Render, new Action(delegate { }));
#endif

Completed(this, new ResultCompletionEventArgs());
}
Expand Down
21 changes: 18 additions & 3 deletions src/Fab.Client/MoneyTracker/Accounts/AccountsRepository.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//------------------------------------------------------------
// <copyright file="AccountsRepository.cs" company="nReez">
// Copyright (c) 2009-2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrey Levshov" email="[email protected]" date="2011-03-26" />
//------------------------------------------------------------

using System;
using System.ComponentModel.Composition;
Expand Down Expand Up @@ -76,6 +77,12 @@ public override void Download()
{
Entities.Clear();
Entities.AddRange(e.Result);
// foreach (var item in e.Result)
// {
// Entities.Add(item);
// }
Execute.OnUIThread(() => EventAggregator.Publish(new AccountsUpdatedMessage
{
Accounts = Entities
Expand Down Expand Up @@ -109,7 +116,15 @@ public override void Download(int key)
{
var account = ByKey(key);
var index = Entities.IndexOf(account);
Entities[index] = e.Result;
//Entities[index] = e.Result;
Entities[index].AssetTypeId = e.Result.AssetTypeId;
Entities[index].Balance = e.Result.Balance;
Entities[index].Created = e.Result.Created;
Entities[index].FirstPostingDate = e.Result.FirstPostingDate;
Entities[index].Id = e.Result.Id;
Entities[index].LastPostingDate = e.Result.LastPostingDate;
Entities[index].Name = e.Result.Name;
Entities[index].PostingsCount = e.Result.PostingsCount;
Execute.OnUIThread(() => EventAggregator.Publish(new AccountUpdatedMessage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public override void Download()
{
Entities.Clear();
Entities.AddRange(e.Result);
// foreach (var item in e.Result)
// {
// Entities.Add(item);
// }
Execute.OnUIThread(() => EventAggregator.Publish(new AssetTypesUpdatedMessage
{
AssetTypes = Entities
Expand Down
11 changes: 9 additions & 2 deletions src/Fab.Client/MoneyTracker/Categories/CategoriesRepository.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//------------------------------------------------------------
// <copyright file="CategoriesRepository.cs" company="nReez">
// Copyright (c) 2009-2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrey Levshov" email="[email protected]" date="2011-03-26" />
//------------------------------------------------------------

using System;
using System.ComponentModel.Composition;
Expand Down Expand Up @@ -76,6 +77,12 @@ public override void Download()
{
Entities.Clear();
Entities.AddRange(e.Result);
//
// foreach (var item in e.Result)
// {
// Entities.Add(item);
// }
Execute.OnUIThread(() => EventAggregator.Publish(new CategoriesUpdatedMessage
{
Categories = Entities
Expand Down
5 changes: 3 additions & 2 deletions src/Fab.Client/MoneyTracker/Categories/CategoriesViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//------------------------------------------------------------
// <copyright file="CategoriesViewModel.cs" company="nReez">
// Copyright (c) 2009-2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
// <author name="Andrey Levshov" email="[email protected]" date="2010-04-12" />
//------------------------------------------------------------

using System.ComponentModel.Composition;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------
// <copyright file="CategoriesDashBoardViewModel.cs" company="nReez">
// Copyright (c) 2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
//------------------------------------------------------------

Expand Down
27 changes: 15 additions & 12 deletions src/Fab.Client/MoneyTracker/Filters/PostingsFilterViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//------------------------------------------------------------
// <copyright file="PostingsFilterViewModel.cs" company="nReez">
// Copyright (c) 2011 nReez. All rights reserved.
// Copyright (c) 2012 nReez. All rights reserved.
// </copyright>
//------------------------------------------------------------

Expand Down Expand Up @@ -41,18 +41,21 @@ public Tuple<DateTime, DateTime> SelectedRange
get { return selectedRange; }
set
{
selectedRange = value;
NotifyOfPropertyChange(() => SelectedRange);

eventAggregator.Publish(new PostingsFilterUpdatedMessage
if (selectedRange != value)
{
Start = selectedRange.Item1 < selectedRange.Item2
? selectedRange.Item1
: selectedRange.Item2,
End = selectedRange.Item1 >= selectedRange.Item2
? selectedRange.Item1
: selectedRange.Item2,
});
selectedRange = value;
NotifyOfPropertyChange(() => SelectedRange);

eventAggregator.Publish(new PostingsFilterUpdatedMessage
{
Start = selectedRange.Item1 < selectedRange.Item2
? selectedRange.Item1
: selectedRange.Item2,
End = selectedRange.Item1 >= selectedRange.Item2
? selectedRange.Item1
: selectedRange.Item2,
});
}
}
}

Expand Down
Loading

0 comments on commit ad7afdf

Please sign in to comment.