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