diff --git a/src/Artemis.UI/App.xaml b/src/Artemis.UI/App.xaml
index 80121ce34..7110a4142 100644
--- a/src/Artemis.UI/App.xaml
+++ b/src/Artemis.UI/App.xaml
@@ -1,7 +1,6 @@
@@ -46,8 +45,10 @@
+
+
+
-
diff --git a/src/Artemis.UI/AppBootstrapper.cs b/src/Artemis.UI/AppBootstrapper.cs
new file mode 100644
index 000000000..f1d87304a
--- /dev/null
+++ b/src/Artemis.UI/AppBootstrapper.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Linq;
+using Artemis.UI.Ninject;
+using Artemis.UI.ViewModels;
+using Ninject;
+using ReactiveUI;
+using ReactiveUI.Fody.Helpers;
+using Splat;
+
+namespace Artemis.UI
+{
+ public class AppBootstrapper : ReactiveObject, IScreen
+ {
+ public AppBootstrapper()
+ {
+ Router = new RoutingState();
+ Kernel = new StandardKernel(new ViewsModule());
+
+ // Configure the Ninject kernel and set it up as the default for ReactiveUI
+ SetupNinject(Kernel);
+
+ // Update the title on view change
+ this.WhenAnyValue(x => x.Router.CurrentViewModel)
+ .Subscribe(o => o.Subscribe(vm => { ViewTitle = vm != null ? vm.UrlPathSegment : ""; }));
+
+ // Navigate to the opening page of the application
+ Router.Navigate.Execute(Kernel.Get());
+ }
+
+ public IKernel Kernel { get; set; }
+
+ [Reactive]
+ public string ViewTitle { get; set; }
+
+ public RoutingState Router { get; }
+
+ private void SetupNinject(IKernel kernel)
+ {
+ // Bind the main screen to IScreen
+ kernel.Bind().ToConstant(this);
+
+ // Set up NInject to do DI
+ var customResolver = new FuncDependencyResolver(
+ (service, contract) =>
+ {
+ if (contract != null) return kernel.GetAll(service, contract);
+ var items = kernel.GetAll(service);
+ var list = items.ToList();
+ return list;
+ },
+ (factory, service, contract) =>
+ {
+ var binding = kernel.Bind(service).ToMethod(_ => factory());
+ if (contract != null) binding.Named(contract);
+ });
+ Locator.Current = customResolver;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index 65e0f0f74..7ea1667d1 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -13,6 +13,8 @@
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
true
+
+
AnyCPU
@@ -46,11 +48,17 @@
..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll
+
+ ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll
+
..\packages\reactiveui-core.7.4.0\lib\Net45\ReactiveUI.dll
-
- ..\packages\Splat.1.4.0\lib\Net45\Splat.dll
+
+ ..\packages\ReactiveUI.Fody.2.2.11\lib\net45\ReactiveUI.Fody.Helpers.dll
+
+
+ ..\packages\Splat.1.6.0\lib\Net45\Splat.dll
@@ -91,6 +99,8 @@
MSBuild:Compile
Designer
+
+
MainView.xaml
@@ -137,7 +147,9 @@
-
+
+ Designer
+
@@ -148,5 +160,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/FodyWeavers.xml b/src/Artemis.UI/FodyWeavers.xml
new file mode 100644
index 000000000..e36b845f9
--- /dev/null
+++ b/src/Artemis.UI/FodyWeavers.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/MainWindow.xaml b/src/Artemis.UI/MainWindow.xaml
index eb3c79412..64346ce33 100644
--- a/src/Artemis.UI/MainWindow.xaml
+++ b/src/Artemis.UI/MainWindow.xaml
@@ -1,22 +1,75 @@
-
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:views="clr-namespace:Artemis.UI.Views"
+ xmlns:reactiveUi="http://reactiveui.net"
+ mc:Ignorable="d"
+ GlowBrush="{DynamicResource AccentColorBrush}"
+ FontFamily="{StaticResource DefaultFont}"
+ Title="Artemis"
+ d:DesignHeight="639.411"
+ d:DesignWidth="1113.251">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -34,30 +87,24 @@
Mode="PrimaryMid" DockPanel.Dock="Top">
-
+ x:Name="MenuToggleButton" />
+
-
+
-
+
-
-
-
+
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/src/Artemis.UI/MainWindow.xaml.cs b/src/Artemis.UI/MainWindow.xaml.cs
index bbc84aff8..3c92f393a 100644
--- a/src/Artemis.UI/MainWindow.xaml.cs
+++ b/src/Artemis.UI/MainWindow.xaml.cs
@@ -10,6 +10,11 @@ namespace Artemis.UI
public MainWindow()
{
InitializeComponent();
+
+ AppBootstrapper = new AppBootstrapper();
+ DataContext = AppBootstrapper;
}
+
+ public AppBootstrapper AppBootstrapper { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Ninject/ViewsModule.cs b/src/Artemis.UI/Ninject/ViewsModule.cs
new file mode 100644
index 000000000..e2390162c
--- /dev/null
+++ b/src/Artemis.UI/Ninject/ViewsModule.cs
@@ -0,0 +1,13 @@
+using Artemis.UI.ViewModels;
+using Ninject.Modules;
+
+namespace Artemis.UI.Ninject
+{
+ public class ViewsModule : NinjectModule
+ {
+ public override void Load()
+ {
+ Bind().To();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Properties/Resources.Designer.cs b/src/Artemis.UI/Properties/Resources.Designer.cs
index 0bf1901ad..7f8dbc8d4 100644
--- a/src/Artemis.UI/Properties/Resources.Designer.cs
+++ b/src/Artemis.UI/Properties/Resources.Designer.cs
@@ -60,6 +60,16 @@ namespace Artemis.UI.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ internal static byte[] bow {
+ get {
+ object obj = ResourceManager.GetObject("bow", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/src/Artemis.UI/Properties/Resources.resx b/src/Artemis.UI/Properties/Resources.resx
index 480e9b969..3024e066c 100644
--- a/src/Artemis.UI/Properties/Resources.resx
+++ b/src/Artemis.UI/Properties/Resources.resx
@@ -118,6 +118,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ ..\Resources\bow.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
..\Resources\logo-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/src/Artemis.UI/Resources/bow.svg b/src/Artemis.UI/Resources/bow.svg
new file mode 100644
index 000000000..66817473d
--- /dev/null
+++ b/src/Artemis.UI/Resources/bow.svg
@@ -0,0 +1,44 @@
+
+
+
diff --git a/src/Artemis.UI/ViewModels/MainViewModel.cs b/src/Artemis.UI/ViewModels/MainViewModel.cs
index a16309d96..497540942 100644
--- a/src/Artemis.UI/ViewModels/MainViewModel.cs
+++ b/src/Artemis.UI/ViewModels/MainViewModel.cs
@@ -4,18 +4,26 @@ using ReactiveUI;
namespace Artemis.UI.ViewModels
{
- public class MainViewModel : ReactiveObject
+ public class MainViewModel : ReactiveObject, IMainViewModel
{
- public ReactiveCommand OpenUrl { get; }
-
- public MainViewModel()
+ public MainViewModel(IScreen screen)
{
+ HostScreen = screen;
OpenUrl = ReactiveCommand.CreateFromTask(OpenUrlAsync);
}
+ public IScreen HostScreen { get; }
+ public string UrlPathSegment => "Home";
+ public ReactiveCommand OpenUrl { get; }
+
private async Task OpenUrlAsync(string url)
{
await Task.Run(() => Process.Start(url));
}
}
-}
+
+ public interface IMainViewModel : IRoutableViewModel
+ {
+ ReactiveCommand OpenUrl { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Views/MainView.xaml b/src/Artemis.UI/Views/MainView.xaml
index 2c2291c76..db216f5fe 100644
--- a/src/Artemis.UI/Views/MainView.xaml
+++ b/src/Artemis.UI/Views/MainView.xaml
@@ -139,10 +139,12 @@
-
+
+ -->
diff --git a/src/Artemis.UI/Views/MainView.xaml.cs b/src/Artemis.UI/Views/MainView.xaml.cs
index a18f3ea4c..e85f0f599 100644
--- a/src/Artemis.UI/Views/MainView.xaml.cs
+++ b/src/Artemis.UI/Views/MainView.xaml.cs
@@ -1,20 +1,30 @@
-using System.Windows.Controls;
+using System.Windows;
+using System.Windows.Controls;
using Artemis.UI.ViewModels;
+using ReactiveUI;
namespace Artemis.UI.Views
{
///
/// Interaction logic for MainView.xaml
///
- public partial class MainView : UserControl
+ public partial class MainView : UserControl, IViewFor
{
+ public static readonly DependencyProperty ViewModelProperty =
+ DependencyProperty.Register("ViewModel", typeof(IMainViewModel), typeof(MainView), new PropertyMetadata(null));
+
public MainView()
{
- ViewModel = new MainViewModel();
InitializeComponent();
- DataContext = ViewModel;
+ this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext);
}
- public MainViewModel ViewModel { get; set; }
+ object IViewFor.ViewModel
+ {
+ get => ViewModel;
+ set => ViewModel = (IMainViewModel) value;
+ }
+
+ public IMainViewModel ViewModel { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/packages.config b/src/Artemis.UI/packages.config
index a7e9bf853..2da94b5a0 100644
--- a/src/Artemis.UI/packages.config
+++ b/src/Artemis.UI/packages.config
@@ -1,10 +1,13 @@
+
+
+
@@ -12,5 +15,5 @@
-
+
\ No newline at end of file