changeset 21:dfc81f8bb838

working version for sttocks except ui within metrowpf
author adminsh@apollo
date Tue, 20 Mar 2012 15:07:31 +0000
parents 6109bc268b90
children a7a4cde39999
files MetroWpf/MetroWpf/App.xaml.cs MetroWpf/MetroWpf/IoCConfiguration.cs MetroWpf/MetroWpf/Locator.cs MetroWpf/MetroWpf/MetroWpf.csproj MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml MetroWpf/MetroWpf/Presentation/Stocks/DisplayStockPrice.cs MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml.cs MetroWpf/MetroWpf/Presentation/Stocks/StocksView.xaml MetroWpf/MetroWpf/Presentation/Stocks/StocksViewModel.cs MetroWpf/MetroWpf/packages.config MetroWpf/Stocks.Common/ConfigurationService.cs MetroWpf/Stocks.Common/Models/Price.cs MetroWpf/Stocks.Common/Stocks.Common.csproj MetroWpf/Stocks.Service/Stocks.Service.csproj MetroWpf/Stocks.Service/StocksService.cs
diffstat 16 files changed, 321 insertions(+), 361 deletions(-) [+]
line wrap: on
line diff
--- a/MetroWpf/MetroWpf/App.xaml.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/App.xaml.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -4,49 +4,57 @@
 using GalaSoft.MvvmLight.Ioc;
 using MetroWpf.Framework.Interfaces;
 using MetroWpf.Xaml.Binding;
+using Microsoft.Practices.ServiceLocation;
+using Ninject;
 
 namespace MetroWpf
 {
-  /// <summary>
-  /// Application startup for initialisation and config
-  /// </summary>
-  public partial class App : Application
-  {
-    protected override void OnExit(ExitEventArgs e)
-    {
-      base.OnExit(e);
-    }
-
-    protected override void OnStartup(StartupEventArgs e)
-    {
-      InitializeIoC();
-      base.OnStartup(e);
-      InitializeWpfApplication();
-      InitializeBindingErrorTrace();
-      LogApplicationStartup();
-    }
-
-    private static void InitializeBindingErrorTrace()
+    /// <summary>
+    /// Application startup for initialisation and config
+    /// </summary>
+    public partial class App : Application
     {
-      BindingErrorTraceListener.SetTrace();
-    }
+        protected override void OnExit(ExitEventArgs e)
+        {
+            base.OnExit(e);
+        }
 
-    private static void InitializeWpfApplication()
-    {
-      SimpleIoc.Default.GetInstance<IWpfApplication>().Initialize();
-    }
+        protected override void OnStartup(StartupEventArgs e)
+        {
+            InitializeIoC();
+            base.OnStartup(e);
+            InitializeWpfApplication();
+            InitializeBindingErrorTrace();
+            LogApplicationStartup();
+        }
+
+        private static void InitializeBindingErrorTrace()
+        {
+            BindingErrorTraceListener.SetTrace();
+        }
 
-    private static void LogApplicationStartup()
-    {
-      var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
-      //Log.Info("{0} {1} Startup",
-      //          Assembly.GetExecutingAssembly().GetName(),
-      //          fvi.ProductVersion);
+        private static void InitializeWpfApplication()
+        {
+            ServiceLocator.Current.GetInstance<IWpfApplication>().Initialize();
+            //new Locator().WpfApplication.Initialize();
+        }
+
+        private static void LogApplicationStartup()
+        {
+            var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
+            //Log.Info("{0} {1} Startup",
+            //          Assembly.GetExecutingAssembly().GetName(),
+            //          fvi.ProductVersion);
+        }
+
+        private static void InitializeIoC()
+        {
+            var kernel = new StandardKernel(new IoCModule());
+            var adapter = new NinjectServiceLocatorExt(kernel);
+            ServiceLocator.SetLocatorProvider(() => adapter);
+            kernel.Bind<IServiceLocator>().ToConstant(ServiceLocator.Current);
+
+            //Resources["ServiceLocator"] = ServiceLocator.Current;
+        }
     }
-
-    private void InitializeIoC()
-    {
-      IoCConfiguration.RegisterRuntimeServices();
-    }
-  }
 }
--- a/MetroWpf/MetroWpf/IoCConfiguration.cs	Tue Mar 20 13:37:46 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-using GalaSoft.MvvmLight.Ioc;
-using GalaSoft.MvvmLight.Messaging;
-using MetroWpf.Framework;
-using MetroWpf.Framework.Interfaces;
-using MetroWpf.Presentation.Settings;
-using MetroWpf.Presentation.Login;
-using MetroWpf.Presentation.About;
-using MetroWpf.Presentation.Stocks;
-using MetroWpf.Presentation.UserProfile;
-using MetroWpf.Presentation.Menu;
-using MetroWpf.Presentation.Shell;
-using Stocks.Common;
-using Stocks.Service;
-
-namespace MetroWpf
-{
-    public class IoCConfiguration
-    {
-        private static void RegisterCoreServices()
-        {
-            // view model services
-
-            // STOCKS
-            SimpleIoc.Default.Register<Stocks.Common.IConfigurationService, Stocks.Common.ConfigurationService>();
-            SimpleIoc.Default.Register<IWebClientShim, WebClientShim>();
-            SimpleIoc.Default.Register<IStocksService, StocksService>();
-
-            // core services
-            SimpleIoc.Default.Register<IMessenger, Messenger>();
-            SimpleIoc.Default.Register<IWpfApplication, WpfApplication>(); 
-
-            // view models
-            SimpleIoc.Default.Register<StocksViewModel>();
-            
-            SimpleIoc.Default.Register<MainWindowViewModel>();
-            SimpleIoc.Default.Register<MenuViewModel>();
-            SimpleIoc.Default.Register<LoginViewModel>();
-            SimpleIoc.Default.Register<UserProfileViewModel>();
-            SimpleIoc.Default.Register<SettingsViewModel>();
-            SimpleIoc.Default.Register<AboutViewModel>();
-
-        }
-
-        public static void RegisterDesignTimeServices()
-        {
-            RegisterCoreServices();
-        }
-
-        public static void RegisterRuntimeServices()
-        {
-            RegisterCoreServices();
-        }
-    }
-}
--- a/MetroWpf/MetroWpf/Locator.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/Locator.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -1,5 +1,6 @@
 using GalaSoft.MvvmLight;
-using GalaSoft.MvvmLight.Ioc;
+using MetroWpf.Framework;
+using MetroWpf.Framework.Interfaces;
 using MetroWpf.Presentation.Shell;
 using MetroWpf.Presentation.Settings;
 using MetroWpf.Presentation.Login;
@@ -7,58 +8,63 @@
 using MetroWpf.Presentation.UserProfile;
 using MetroWpf.Presentation.About;
 using MetroWpf.Presentation.Menu;
+using Microsoft.Practices.ServiceLocation;
 
 namespace MetroWpf
 {
-  public class Locator
-  {
-    public Locator()
+    public class Locator
     {
-      if (ViewModelBase.IsInDesignModeStatic)
-      {
-        // Create design time services and viewmodels
-        IoCConfiguration.RegisterDesignTimeServices();
-      }
-      else
-      {
-        // Create run time services and view models
-        IoCConfiguration.RegisterRuntimeServices();
-      }
-    }
+        public Locator()
+        {
+            if (ViewModelBase.IsInDesignModeStatic)
+            {
+                // Create design time services and viewmodels
+                
+            }
+            else
+            {
+                // Create run time services and view models
+            }
+        }
 
-    public MainWindowViewModel MainWindowViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<MainWindowViewModel>(); }
-    }
+        public MainWindowViewModel MainWindowViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<MainWindowViewModel>(); }
+        }
 
-    public MenuViewModel MenuViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<MenuViewModel>(); }
-    }
+        public MenuViewModel MenuViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<MenuViewModel>(); }
+        }
 
-    public LoginViewModel LoginViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<LoginViewModel>(); }
-    }
+        public LoginViewModel LoginViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<LoginViewModel>(); }
+        }
 
-    public UserProfileViewModel UserProfileViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<UserProfileViewModel>(); }
-    }
+        public UserProfileViewModel UserProfileViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<UserProfileViewModel>(); }
+        }
+
+        public SettingsViewModel SettingsViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<SettingsViewModel>(); }
+        }
 
-    public SettingsViewModel SettingsViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<SettingsViewModel>(); }
-    }
+        public AboutViewModel AboutViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<AboutViewModel>(); }
+        }
 
-    public AboutViewModel AboutViewModel
-    {
-      get { return SimpleIoc.Default.GetInstance<AboutViewModel>(); }
-    }
+        public StocksViewModel StocksViewModel
+        {
+            get { return ServiceLocator.Current.GetInstance<StocksViewModel>(); }
+        }
 
-    public StocksViewModel StocksViewModel
-    {
-        get { return SimpleIoc.Default.GetInstance<StocksViewModel>(); }
+        public IWpfApplication WpfApplication
+        {
+            get { return ServiceLocator.Current.GetInstance<WpfApplication>(); }
+        }
     }
-  }
 }
\ No newline at end of file
--- a/MetroWpf/MetroWpf/MetroWpf.csproj	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/MetroWpf.csproj	Tue Mar 20 15:07:31 2012 +0000
@@ -49,11 +49,13 @@
       <HintPath>..\Libs\MahApps.Metro.0.5.0.0\lib\net40\MahApps.Metro.dll</HintPath>
     </Reference>
     <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Libs\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
+      <HintPath>..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll</HintPath>
     </Reference>
-    <Reference Include="Ninject">
-      <HintPath>..\Libs\Ninject.2.2.1.4\lib\net40-Client\Ninject.dll</HintPath>
+    <Reference Include="Ninject, Version=2.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
+      <HintPath>..\packages\Ninject.2.2.1.4\lib\net40-Client\Ninject.dll</HintPath>
+    </Reference>
+    <Reference Include="NinjectAdapter">
+      <HintPath>..\Libs\CommonServiceLocator.NinjectAdapter.1.0.0.0\lib\NinjectAdapter.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.Composition" />
@@ -90,16 +92,15 @@
     <Compile Include="Converters\BoolToSubscribedTextConverter.cs" />
     <Compile Include="Converters\DateTimeToTimeConverter.cs" />
     <Compile Include="Converters\DeltaToIconConverter.cs" />
+    <Compile Include="IoCModule.cs" />
     <Compile Include="Messages\AuthenticatedUserMessage.cs" />
     <Compile Include="Messages\NavigationMessage.cs" />
+    <Compile Include="NinjectServiceLocatorExt.cs" />
     <Compile Include="Presentation\Stocks\DisplayStockPrice.cs" />
     <Compile Include="Presentation\Stocks\StocksView.xaml.cs">
       <DependentUpon>StocksView.xaml</DependentUpon>
     </Compile>
     <Compile Include="Presentation\Stocks\StocksViewModel.cs" />
-    <Compile Include="Presentation\Stocks\StockTest.xaml.cs">
-      <DependentUpon>StockTest.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Services\Interfaces\INavigationService.cs" />
     <Compile Include="Services\NavigationService.cs" />
     <Compile Include="Presentation\About\AboutView.xaml.cs">
@@ -130,7 +131,6 @@
     <Compile Include="Presentation\Exceptions\ExceptionDialog.xaml.cs">
       <DependentUpon>ExceptionDialog.xaml</DependentUpon>
     </Compile>
-    <Compile Include="IoCConfiguration.cs" />
     <Compile Include="Locator.cs" />
     <Compile Include="Presentation\About\AboutViewModel.cs" />
     <Compile Include="Presentation\Login\LoginViewModel.cs" />
@@ -154,7 +154,6 @@
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
     </EmbeddedResource>
-    <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -190,10 +189,6 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Page Include="Presentation\Stocks\StockTest.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Presentation\UserProfile\UserProfileView.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
--- a/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml	Tue Mar 20 15:07:31 2012 +0000
@@ -1,34 +1,35 @@
-<UserControl x:Class="MetroWpf.Presentation.Menu.MenuView" 
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
-             xmlns:about="clr-namespace:MetroWpf.Presentation.About" 
-             xmlns:converters="clr-namespace:MetroWpf.Xaml.Converters;assembly=MetroWpf.Xaml" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+<UserControl x:Class="MetroWpf.Presentation.Menu.MenuView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:about="clr-namespace:MetroWpf.Presentation.About"
+             xmlns:converters="clr-namespace:MetroWpf.Xaml.Converters;assembly=MetroWpf.Xaml"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:login="clr-namespace:MetroWpf.Presentation.Login"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:settings="clr-namespace:MetroWpf.Presentation.Settings"
+             xmlns:Stocks="clr-namespace:MetroWpf.Presentation.Stocks"
              xmlns:userprofile="clr-namespace:MetroWpf.Presentation.UserProfile"
-             xmlns:Stocks="clr-namespace:MetroWpf.Presentation.Stocks"
-             DataContext="{Binding MenuViewModel, Source={StaticResource Locator}}" 
+             DataContext="{Binding MenuViewModel,
+                                   Source={StaticResource Locator}}"
              mc:Ignorable="d">
     <Grid>
         <TabControl x:Name="tabHost" SelectedIndex="{Binding SelectedTabIndex, Converter={converters:EnumToIntConverter}}">
 
             <TabItem Header="_Stocks" Visibility="{Binding ShowStocks, Converter={converters:BooleanToVisibilityConverter}}">
-                <StackPanel Margin="25,10" HorizontalAlignment="Center">
-                    <Stocks:StockTest/>
+                <StackPanel Margin="25,10" HorizontalAlignment="Center"  >
+                    <Stocks:StocksView  />
                 </StackPanel>
             </TabItem>
 
             <TabItem Header="_Rates" Visibility="{Binding ShowFxRates, Converter={converters:BooleanToVisibilityConverter}}">
-                <StackPanel Margin="25,10">
-
-                </StackPanel>
+                <StackPanel Margin="25,10" />
             </TabItem>
 
-            <!-- Start of hidden tabs-->
+            <!--  Start of hidden tabs  -->
             <TabItem Name="tabItemLogin" Visibility="{Binding ShowLogin, Converter={converters:BooleanToVisibilityConverter}}">
-                <StackPanel Margin="25,10" HorizontalAlignment="Center" VerticalAlignment="Center">
+                <StackPanel Margin="25,10"
+                            HorizontalAlignment="Center"
+                            VerticalAlignment="Center">
                     <login:LoginView />
                 </StackPanel>
             </TabItem>
@@ -56,7 +57,7 @@
                     <about:AboutView />
                 </StackPanel>
             </TabItem>
-            <!-- End of hidden tabs-->
+            <!--  End of hidden tabs  -->
         </TabControl>
     </Grid>
 </UserControl>
\ No newline at end of file
--- a/MetroWpf/MetroWpf/Presentation/Stocks/DisplayStockPrice.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/Presentation/Stocks/DisplayStockPrice.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -9,6 +9,7 @@
         {
             return new DisplayStockPrice()
                        {
+                           CompanyName =  price.CompanyName,
                            Symbol = price.Symbol,
                            CurrentPrice = price.CurrentPrice,
                            PreviousPrice = price.PreviousPrice
@@ -20,6 +21,7 @@
             Symbol = price.Symbol;
             CurrentPrice = price.CurrentPrice;
             PreviousPrice = price.PreviousPrice;
+            Delta = price.CurrentPrice - price.PreviousPrice;
         }
 
         public const string SymbolPropertyName = "Symbol";
--- a/MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml	Tue Mar 20 13:37:46 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-<UserControl x:Class="MetroWpf.Presentation.Stocks.StockTest"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             mc:Ignorable="d" 
-             d:DesignHeight="300" d:DesignWidth="300"
-             DataContext="{Binding StocksViewModel, Source={StaticResource Locator}}">
-    <Grid>
-            
-    </Grid>
-</UserControl>
--- a/MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml.cs	Tue Mar 20 13:37:46 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace MetroWpf.Presentation.Stocks
-{
-    /// <summary>
-    /// Interaction logic for StockTest.xaml
-    /// </summary>
-    public partial class StockTest : UserControl
-    {
-        public StockTest()
-        {
-            InitializeComponent();
-        }
-    }
-}
--- a/MetroWpf/MetroWpf/Presentation/Stocks/StocksView.xaml	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/Presentation/Stocks/StocksView.xaml	Tue Mar 20 15:07:31 2012 +0000
@@ -1,17 +1,20 @@
 <UserControl x:Class="MetroWpf.Presentation.Stocks.StocksView"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:Converters="clr-namespace:MetroWpf.Converters"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-             xmlns:Converters="clr-namespace:MetroWpf.Converters" mc:Ignorable="d" 
-             d:DesignHeight="100" d:DesignWidth="600"
-             DataContext="{Binding StocksViewModel, Source={StaticResource Locator}}">
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             d:DesignHeight="100"
+             d:DesignWidth="600"
+             DataContext="{Binding StocksViewModel,
+                                   Source={StaticResource Locator}}"
+             mc:Ignorable="d">
 
     <Grid x:Name="LayoutRoot">
         <Grid.RowDefinitions>
             <RowDefinition Height="60" />
             <RowDefinition Height="20" />
-            <RowDefinition Height="280" />
+            <RowDefinition Height="400" />
             <RowDefinition Height="180" />
         </Grid.RowDefinitions>
         <Grid.Resources>
@@ -19,50 +22,68 @@
             <Converters:BoolToSubscribedTextConverter x:Key="BoolToSubscribedTextConverter" />
             <Converters:DeltaToIconConverter x:Key="DeltaToIconConverter" />
             <Converters:AbsoluteNumberConverter x:Key="AbsoluteNumberConverter" />
-            <!--<Converters:DateTimeToTimeConverter x:Key="DateTimeToTimeConverter" />-->
+            <!--  <Converters:DateTimeToTimeConverter x:Key="DateTimeToTimeConverter" />  -->
         </Grid.Resources>
 
         <StackPanel Grid.Row="0" Orientation="Horizontal">
             <Button x:Name="btnServiceRunning"
-              Width="100"
-              Height="30"
-              HorizontalAlignment="Left" 
-              Content="{Binding ServiceRunning, Converter={StaticResource BoolToServiceRunningTextConverter}}" 
-              Command="{Binding ServiceCommand, Mode=TwoWay}"
-              Margin="5,0,0,0"/>
+                    Width="100"
+                    Height="30"
+                    Margin="5,0,0,0"
+                    HorizontalAlignment="Left"
+                    Command="{Binding ServiceCommand,
+                                      Mode=TwoWay}"
+                    Content="{Binding ServiceRunning,
+                                      Converter={StaticResource BoolToServiceRunningTextConverter}}" />
             <Button x:Name="btnSubscribe"
-              Width="100"
-              Height="30"
-              Margin="10,0,0,0"
-              HorizontalAlignment="Left" 
-              Content="{Binding Subscribed, Converter={StaticResource BoolToSubscribedTextConverter}}" 
-              Command="{Binding SubscriptionCommand, Mode=TwoWay}" />
+                    Width="100"
+                    Height="30"
+                    Margin="10,0,0,0"
+                    HorizontalAlignment="Left"
+                    Command="{Binding SubscriptionCommand,
+                                      Mode=TwoWay}"
+                    Content="{Binding Subscribed,
+                                      Converter={StaticResource BoolToSubscribedTextConverter}}" />
         </StackPanel>
 
         <StackPanel Grid.Row="1" Orientation="Horizontal">
-            <TextBlock Text="Company" Width="170" Margin="5,0,0,0" />
-            <TextBlock Text="Price" Width="100" />
-            <TextBlock Text="Previous" Width="100" />
-            <TextBlock Text="Change" Width="105" />
-            <TextBlock Text="Time" Width="105" />
+            <TextBlock Width="260"
+                       Margin="5,0,0,0"
+                       Text="Company" />
+            <TextBlock Width="80" Text="Symbol" />
+            <TextBlock Width="100" Text="Price" />
+            <TextBlock Width="100" Text="Previous" />
+            <TextBlock Width="105" Text="Change" />
         </StackPanel>
-        <ListBox x:Name="lbStockPrices" 
-             ItemsSource="{Binding Path=DisplayStockPrices}" 
-             BorderThickness="0" FontFamily="Segoe UI"
-             Grid.Row="2">
+        <ListBox x:Name="lbStockPrices"
+                 Grid.Row="2"
+                 BorderThickness="0"
+                 FontFamily="Segoe UI"
+                 ItemsSource="{Binding Path=DisplayStockPrices}">
             <ListBox.ItemTemplate>
                 <DataTemplate>
-                    <StackPanel Orientation="Horizontal" Height="25">
-                        <TextBlock Text="{Binding CompanyName}" Width="125" FontSize="15" Margin="10,0,0,0"/>
-                        <TextBlock Text="{Binding Symbol}" Width="45" FontSize="15" Margin="10,0,0,0"/>
-                        <TextBlock Text="{Binding CurrentPrice}" Width="100" FontSize="15" />
-                        <TextBlock Text="{Binding PreviousPrice}" Width="100" FontSize="15" />
-                        <Image Source="{Binding Delta, Converter={StaticResource DeltaToIconConverter}}" Width="20" />
-                        <TextBlock Text="{Binding Delta, Converter={StaticResource AbsoluteNumberConverter}}" Width="85" FontSize="15" />
-                        <!--<TextBlock Text="{Binding Timestamp, Converter={StaticResource DateTimeToTimeConverter}}" Width="100" FontSize="15" />-->
+                    <StackPanel Orientation="Horizontal">
+                        <TextBlock Width="263"
+                                   Margin="2,0,0,0"
+                                   FontSize="15"
+                                   Text="{Binding CompanyName}" />
+                        <TextBlock Width="80"
+                                   FontSize="15"
+                                   Text="{Binding Symbol}" />
+                        <TextBlock Width="100"
+                                   FontSize="15"
+                                   Text="{Binding CurrentPrice}" />
+                        <TextBlock Width="100"
+                                   FontSize="15"
+                                   Text="{Binding PreviousPrice}" />
+                        <Image Width="20" Source="{Binding Delta, Converter={StaticResource DeltaToIconConverter}}" />
+                        <TextBlock Width="85"
+                                   FontSize="15"
+                                   Text="{Binding Delta,
+                                                  Converter={StaticResource AbsoluteNumberConverter}}" />
                     </StackPanel>
                 </DataTemplate>
             </ListBox.ItemTemplate>
         </ListBox>
     </Grid>
- </UserControl>
\ No newline at end of file
+</UserControl>
\ No newline at end of file
--- a/MetroWpf/MetroWpf/Presentation/Stocks/StocksViewModel.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/MetroWpf/Presentation/Stocks/StocksViewModel.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -28,7 +28,8 @@
             ServiceCommand = new RelayCommand(ServiceRunningCommandExecute);
 
             var priceUpdates = Observable.FromEventPattern<PriceChangedEventArgs>(
-                _service, "PriceChanged");
+                _service, 
+                "PriceChanged");
 
             priceUpdates.Where(e => Subscribed)
                 //.Throttle(TimeSpan.FromSeconds(1))
--- a/MetroWpf/MetroWpf/packages.config	Tue Mar 20 13:37:46 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-</packages>
\ No newline at end of file
--- a/MetroWpf/Stocks.Common/ConfigurationService.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Common/ConfigurationService.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -17,6 +17,7 @@
     {
       jsonFilename = filename;
     }
+
     public List<Company> GetCompanies()
     {
       return new FileSerializer().DeserializeJson<Company>(jsonFilename);
--- a/MetroWpf/Stocks.Common/Models/Price.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Common/Models/Price.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -5,125 +5,131 @@
 
 namespace Stocks.Common.Models
 {
-  public class Price : IEquatable<Price>, IComparable<Price>, IComparable
-  {
-    public string Symbol { get; set; }
-    public decimal CurrentPrice { get; set; }
-    public decimal PreviousPrice { get; set; }
-
-    public Price()
-    {
-    }
-
-    public Price(string symbol, decimal currentPrice, decimal previousPrice)
-      : this()
+    public class Price : IEquatable<Price>, IComparable<Price>, IComparable
     {
-      Symbol = symbol;
-      CurrentPrice = currentPrice;
-      PreviousPrice = previousPrice;
-    }
+        public string CompanyName { get; set; }
+        public string Symbol { get; set; }
+        public decimal CurrentPrice { get; set; }
+        public decimal PreviousPrice { get; set; }
+
+        public Price()
+        {
+        }
+
+        public Price(
+            string company, 
+            string symbol, 
+            decimal currentPrice, 
+            decimal previousPrice) : this()
+        {
+            CompanyName = company;
+            Symbol = symbol;
+            CurrentPrice = currentPrice;
+            PreviousPrice = previousPrice;
+        }
+
+        public override bool Equals(object obj)
+        {
+            if (obj is Price)
+                return Equals(obj as Price);
+            else
+                return false;
+        }
 
-    public override bool Equals(object obj)
-    {
-      if (obj is Price)
-        return Equals(obj as Price);
-      else
-        return false;
-    }
+        public bool Equals(Price other)
+        {
+            return (CompanyName == other.CompanyName
+                && Symbol == other.Symbol
+              && CurrentPrice == other.CurrentPrice
+              && PreviousPrice == other.PreviousPrice);
+        }
+
+        public int CompareTo(Price other)
+        {
+            return Symbol.CompareTo(other.Symbol);
+        }
+
+        public int CompareTo(Price other, PriceComparisonType comparisonType)
+        {
+            switch (comparisonType)
+            {
+                case PriceComparisonType.NotSet:
+                case PriceComparisonType.Symbol:
+                    return Symbol.CompareTo(other.Symbol);
+                case PriceComparisonType.CurrentPrice:
+                    return CurrentPrice.CompareTo(other.CurrentPrice);
+                case PriceComparisonType.PreviousPrice:
+                    return PreviousPrice.CompareTo(other.PreviousPrice);
+                default:
+                    throw new Exception("Unknown comparison type");
+            }
+        }
 
-    public bool Equals(Price other)
-    {
-      return (Symbol == other.Symbol
-        && CurrentPrice == other.CurrentPrice
-        && PreviousPrice == other.PreviousPrice);
-    }
+        public int CompareTo(object obj)
+        {
+            Price other;
+            if (obj is Price)
+                other = obj as Price;
+            else
+                throw new ArgumentException("obj is not a Price");
 
-    public int CompareTo(Price other)
-    {
-      return Symbol.CompareTo(other.Symbol);
-    }
+            return CompareTo(other);
+        }
+        public override int GetHashCode()
+        {
+            int hash = 13;
+            hash = (hash * 7) + Symbol.GetHashCode();
+            hash = (hash * 7) + CurrentPrice.GetHashCode();
+            hash = (hash * 7) + PreviousPrice.GetHashCode();
+            return hash;
+        }
+
+        public static bool operator ==(Price lhs, Price rhs)
+        {
+            if (System.Object.ReferenceEquals(lhs, rhs))
+                return true;
+
+            if (((object)lhs == null) || ((object)rhs == null))
+                return false;
+
+            return lhs.Symbol == rhs.Symbol
+              && lhs.CurrentPrice == rhs.CurrentPrice
+              && lhs.PreviousPrice == rhs.PreviousPrice;
+        }
 
-    public int CompareTo(Price other, PriceComparisonType comparisonType)
-    {
-      switch (comparisonType)
-      {
-        case PriceComparisonType.NotSet:
-        case PriceComparisonType.Symbol:
-          return Symbol.CompareTo(other.Symbol);
-        case PriceComparisonType.CurrentPrice:
-          return CurrentPrice.CompareTo(other.CurrentPrice);
-        case PriceComparisonType.PreviousPrice:
-          return PreviousPrice.CompareTo(other.PreviousPrice);
-        default:
-          throw new Exception("Unknown comparison type");
-      }
+        public static bool operator !=(Price lhs, Price rhs)
+        {
+            return !(lhs == rhs);
+        }
+
+
+        public class PriceComparer : IComparer<Price>, IComparer
+        {
+            public PriceComparisonType ComparisonMethod { get; set; }
+
+            public int Compare(Price x, Price y)
+            {
+                return x.CompareTo(y, ComparisonMethod);
+            }
+
+            public int Compare(object x, object y)
+            {
+                Price lhs, rhs;
+
+                if (x is Price)
+                    lhs = x as Price;
+                else
+                    throw new ArgumentException("x is not a Price");
+
+                if (y is Price)
+                    rhs = y as Price;
+                else
+                    throw new ArgumentException("y is not a Price");
+
+                return lhs.CompareTo(rhs, ComparisonMethod);
+            }
+        }
     }
 
-    public int CompareTo(object obj)
-    {
-      Price other;
-      if (obj is Price)
-        other = obj as Price;
-      else
-        throw new ArgumentException("obj is not a Price");
-
-      return CompareTo(other);
-    }
-    public override int GetHashCode()
-    {
-      int hash = 13;
-      hash = (hash * 7) + Symbol.GetHashCode();
-      hash = (hash * 7) + CurrentPrice.GetHashCode();
-      hash = (hash * 7) + PreviousPrice.GetHashCode();
-      return hash;
-    }
-
-    public static bool operator ==(Price lhs, Price rhs)
-    {
-      if (System.Object.ReferenceEquals(lhs, rhs))
-        return true;
-
-      if (((object)lhs == null) || ((object)rhs == null))
-        return false;
-
-      return lhs.Symbol == rhs.Symbol
-        && lhs.CurrentPrice == rhs.CurrentPrice
-        && lhs.PreviousPrice == rhs.PreviousPrice;
-    }
-
-    public static bool operator !=(Price lhs, Price rhs)
-    {
-      return !(lhs == rhs);
-    }
-
-
-    public class PriceComparer : IComparer<Price>, IComparer
-    {
-      public PriceComparisonType ComparisonMethod { get; set; }
-
-      public int Compare(Price x, Price y)
-      {
-        return x.CompareTo(y, ComparisonMethod);
-      }
-
-      public int Compare(object x, object y)
-      {
-        Price lhs, rhs;
-
-        if (x is Price)
-          lhs = x as Price;
-        else
-          throw new ArgumentException("x is not a Price");
-
-        if (y is Price)
-          rhs = y as Price;
-        else
-          throw new ArgumentException("y is not a Price");
-
-        return lhs.CompareTo(rhs, ComparisonMethod);
-      }
-    }
-  }
-
-  public enum PriceComparisonType { NotSet = 0, Symbol, CurrentPrice, PreviousPrice }
-}
+    public enum PriceComparisonType { NotSet = 0, Symbol, CurrentPrice, PreviousPrice }
+}
\ No newline at end of file
--- a/MetroWpf/Stocks.Common/Stocks.Common.csproj	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Common/Stocks.Common.csproj	Tue Mar 20 15:07:31 2012 +0000
@@ -65,6 +65,11 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="WebClientShim.cs" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="companyData.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </Content>
+  </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.
--- a/MetroWpf/Stocks.Service/Stocks.Service.csproj	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Service/Stocks.Service.csproj	Tue Mar 20 15:07:31 2012 +0000
@@ -53,6 +53,9 @@
       <Name>Stocks.Common</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="companyData.json" />
+  </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.
--- a/MetroWpf/Stocks.Service/StocksService.cs	Tue Mar 20 13:37:46 2012 +0000
+++ b/MetroWpf/Stocks.Service/StocksService.cs	Tue Mar 20 15:07:31 2012 +0000
@@ -49,7 +49,7 @@
 
         public IList<Price> GetFullCurrentPrices()
         {
-            return _companies.Select(company => new Price(company.Symbol, 0, 0)).ToList();
+            return _companies.Select(company => new Price(company.Name, company.Symbol, 0, 0)).ToList();
         }
 
         public event PriceChangedEventHandler PriceChanged;
@@ -115,11 +115,18 @@
             foreach (var webPriceData in webPrices)
             {
                 var webPrice = Factory.CreatePrice(webPriceData);
-                var localPrice = _currentPrices.Find(x => x.Symbol == webPrice.Symbol);
+
+                var localPrice = _currentPrices.Find(
+                    x => x.Symbol == webPrice.Symbol);
 
                 if (localPrice == null)
                 {
-                    _currentPrices.Add(new Price(webPrice.Symbol, webPrice.CurrentPrice, webPrice.PreviousPrice));
+                    _currentPrices.Add(
+                        new Price(
+                            webPrice.CompanyName, 
+                            webPrice.Symbol, 
+                            webPrice.CurrentPrice, 
+                            webPrice.PreviousPrice));
                     continue;
                 }