# HG changeset patch
# User adminsh@apollo
# Date 1332256051 0
# Node ID dfc81f8bb83867fb7ef76ff363c05e5894c626ae
# Parent 6109bc268b9099a3f540be3c2df9d61c74abfd37
working version for sttocks except ui within metrowpf
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/App.xaml.cs
--- 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
{
- ///
- /// Application startup for initialisation and config
- ///
- 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()
+ ///
+ /// Application startup for initialisation and config
+ ///
+ public partial class App : Application
{
- BindingErrorTraceListener.SetTrace();
- }
+ protected override void OnExit(ExitEventArgs e)
+ {
+ base.OnExit(e);
+ }
- private static void InitializeWpfApplication()
- {
- SimpleIoc.Default.GetInstance().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().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().ToConstant(ServiceLocator.Current);
+
+ //Resources["ServiceLocator"] = ServiceLocator.Current;
+ }
}
-
- private void InitializeIoC()
- {
- IoCConfiguration.RegisterRuntimeServices();
- }
- }
}
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/IoCConfiguration.cs
--- 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();
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
-
- // core services
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
-
- // view models
- SimpleIoc.Default.Register();
-
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
- SimpleIoc.Default.Register();
-
- }
-
- public static void RegisterDesignTimeServices()
- {
- RegisterCoreServices();
- }
-
- public static void RegisterRuntimeServices()
- {
- RegisterCoreServices();
- }
- }
-}
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Locator.cs
--- 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(); }
- }
+ public MainWindowViewModel MainWindowViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public MenuViewModel MenuViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
- }
+ public MenuViewModel MenuViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public LoginViewModel LoginViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
- }
+ public LoginViewModel LoginViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public UserProfileViewModel UserProfileViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
- }
+ public UserProfileViewModel UserProfileViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
+
+ public SettingsViewModel SettingsViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public SettingsViewModel SettingsViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
- }
+ public AboutViewModel AboutViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public AboutViewModel AboutViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
- }
+ public StocksViewModel StocksViewModel
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
- public StocksViewModel StocksViewModel
- {
- get { return SimpleIoc.Default.GetInstance(); }
+ public IWpfApplication WpfApplication
+ {
+ get { return ServiceLocator.Current.GetInstance(); }
+ }
}
- }
}
\ No newline at end of file
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/MetroWpf.csproj
--- 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 @@
..\Libs\MahApps.Metro.0.5.0.0\lib\net40\MahApps.Metro.dll
- False
- ..\Libs\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll
+ ..\packages\CommonServiceLocator.1.0\lib\NET35\Microsoft.Practices.ServiceLocation.dll
-
- ..\Libs\Ninject.2.2.1.4\lib\net40-Client\Ninject.dll
+
+ ..\packages\Ninject.2.2.1.4\lib\net40-Client\Ninject.dll
+
+
+ ..\Libs\CommonServiceLocator.NinjectAdapter.1.0.0.0\lib\NinjectAdapter.dll
@@ -90,16 +92,15 @@
+
+
StocksView.xaml
-
- StockTest.xaml
-
@@ -130,7 +131,6 @@
ExceptionDialog.xaml
-
@@ -154,7 +154,6 @@
ResXFileCodeGenerator
Resources.Designer.cs
-
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -190,10 +189,6 @@
MSBuild:Compile
Designer
-
- Designer
- MSBuild:Compile
-
Designer
MSBuild:Compile
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Menu/MenuView.xaml
--- 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 @@
-
-
-
+
+
-
-
-
+
-
+
-
+
@@ -56,7 +57,7 @@
-
+
\ No newline at end of file
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Stocks/DisplayStockPrice.cs
--- 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";
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml
--- 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 @@
-
-
-
-
-
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Stocks/StockTest.xaml.cs
--- 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
-{
- ///
- /// Interaction logic for StockTest.xaml
- ///
- public partial class StockTest : UserControl
- {
- public StockTest()
- {
- InitializeComponent();
- }
- }
-}
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Stocks/StocksView.xaml
--- 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 @@
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ d:DesignHeight="100"
+ d:DesignWidth="600"
+ DataContext="{Binding StocksViewModel,
+ Source={StaticResource Locator}}"
+ mc:Ignorable="d">
-
+
@@ -19,50 +22,68 @@
-
+
+ Width="100"
+ Height="30"
+ Margin="5,0,0,0"
+ HorizontalAlignment="Left"
+ Command="{Binding ServiceCommand,
+ Mode=TwoWay}"
+ Content="{Binding ServiceRunning,
+ Converter={StaticResource BoolToServiceRunningTextConverter}}" />
+ Width="100"
+ Height="30"
+ Margin="10,0,0,0"
+ HorizontalAlignment="Left"
+ Command="{Binding SubscriptionCommand,
+ Mode=TwoWay}"
+ Content="{Binding Subscribed,
+ Converter={StaticResource BoolToSubscribedTextConverter}}" />
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/Presentation/Stocks/StocksViewModel.cs
--- 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(
- _service, "PriceChanged");
+ _service,
+ "PriceChanged");
priceUpdates.Where(e => Subscribed)
//.Throttle(TimeSpan.FromSeconds(1))
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/MetroWpf/packages.config
--- 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 @@
-
-
-
\ No newline at end of file
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/Stocks.Common/ConfigurationService.cs
--- 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 GetCompanies()
{
return new FileSerializer().DeserializeJson(jsonFilename);
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/Stocks.Common/Models/Price.cs
--- 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, IComparable, 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, IComparable, 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, 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, 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
diff -r 6109bc268b90 -r dfc81f8bb838 MetroWpf/Stocks.Common/Stocks.Common.csproj
--- 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 @@
+
+
+ PreserveNewest
+
+