# 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 @@ - +