Mercurial > silverbladetech
annotate MetroWpf/MetroWpf/App.xaml.cs @ 21:dfc81f8bb838
working version for sttocks except ui within metrowpf
author | adminsh@apollo |
---|---|
date | Tue, 20 Mar 2012 15:07:31 +0000 |
parents | 2395908fa45b |
children | a8b50a087544 |
rev | line source |
---|---|
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
1 using System.Diagnostics; |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
2 using System.Reflection; |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
3 using System.Windows; |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
4 using GalaSoft.MvvmLight.Ioc; |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
5 using MetroWpf.Framework.Interfaces; |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
6 using MetroWpf.Xaml.Binding; |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
7 using Microsoft.Practices.ServiceLocation; |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
8 using Ninject; |
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
9 |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
10 namespace MetroWpf |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
11 { |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
12 /// <summary> |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
13 /// Application startup for initialisation and config |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
14 /// </summary> |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
15 public partial class App : Application |
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
16 { |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
17 protected override void OnExit(ExitEventArgs e) |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
18 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
19 base.OnExit(e); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
20 } |
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
21 |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
22 protected override void OnStartup(StartupEventArgs e) |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
23 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
24 InitializeIoC(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
25 base.OnStartup(e); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
26 InitializeWpfApplication(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
27 InitializeBindingErrorTrace(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
28 LogApplicationStartup(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
29 } |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
30 |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
31 private static void InitializeBindingErrorTrace() |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
32 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
33 BindingErrorTraceListener.SetTrace(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
34 } |
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
35 |
21
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
36 private static void InitializeWpfApplication() |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
37 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
38 ServiceLocator.Current.GetInstance<IWpfApplication>().Initialize(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
39 //new Locator().WpfApplication.Initialize(); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
40 } |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
41 |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
42 private static void LogApplicationStartup() |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
43 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
44 var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
45 //Log.Info("{0} {1} Startup", |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
46 // Assembly.GetExecutingAssembly().GetName(), |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
47 // fvi.ProductVersion); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
48 } |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
49 |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
50 private static void InitializeIoC() |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
51 { |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
52 var kernel = new StandardKernel(new IoCModule()); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
53 var adapter = new NinjectServiceLocatorExt(kernel); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
54 ServiceLocator.SetLocatorProvider(() => adapter); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
55 kernel.Bind<IServiceLocator>().ToConstant(ServiceLocator.Current); |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
56 |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
57 //Resources["ServiceLocator"] = ServiceLocator.Current; |
dfc81f8bb838
working version for sttocks except ui within metrowpf
adminsh@apollo
parents:
16
diff
changeset
|
58 } |
15
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
59 } |
060f02cd4591
Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff
changeset
|
60 } |