diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index 2d01db23d..825291b25 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -188,6 +188,7 @@
+
diff --git a/src/Artemis.Core/Services/DeviceService.cs b/src/Artemis.Core/Services/DeviceService.cs
new file mode 100644
index 000000000..16632a6cd
--- /dev/null
+++ b/src/Artemis.Core/Services/DeviceService.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Artemis.Core.Events;
+using Artemis.Core.Models.Surface;
+using Artemis.Core.Services.Interfaces;
+
+namespace Artemis.Core.Services
+{
+ public class DeviceService : IDeviceService
+ {
+ private readonly ICoreService _coreService;
+
+ public DeviceService(ICoreService coreService)
+ {
+ _coreService = coreService;
+ }
+
+ public void IdentifyDevice(Device device)
+ {
+ BlinkDevice(device, 0);
+ }
+
+ private void BlinkDevice(Device device, int blinkCount)
+ {
+ // Draw a white overlay over the device
+ void DrawOverlay(object sender, FrameRenderingEventArgs args)
+ {
+ using (var g = Graphics.FromImage(args.Bitmap))
+ {
+ g.FillPath(new SolidBrush(Color.White), device.RenderPath);
+ }
+ }
+
+ _coreService.FrameRendering += DrawOverlay;
+
+ // After 200ms, stop drawing the overlay
+ Task.Run(async () =>
+ {
+ await Task.Delay(200);
+ _coreService.FrameRendering -= DrawOverlay;
+
+ if (blinkCount < 5)
+ {
+ // After another 200ms, draw the overlay again, repeat six times
+ await Task.Delay(200);
+ BlinkDevice(device, blinkCount + 1);
+ }
+ });
+ }
+ }
+
+ public interface IDeviceService : IArtemisService
+ {
+ ///
+ /// Identifies the device by making it blink white 5 times
+ ///
+ ///
+ void IdentifyDevice(Device device);
+ }
+}
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index 5a9c8562e..bcea98876 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -151,6 +151,8 @@
+
+
diff --git a/src/Artemis.UI/Ninject/Factories/IArtemisUiFactory.cs b/src/Artemis.UI/Ninject/Factories/IArtemisUiFactory.cs
new file mode 100644
index 000000000..7cf08f331
--- /dev/null
+++ b/src/Artemis.UI/Ninject/Factories/IArtemisUiFactory.cs
@@ -0,0 +1,6 @@
+namespace Artemis.UI.Ninject.Factories
+{
+ public interface IArtemisUIFactory
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Ninject/Factories/IDeviceSettingsViewMOdelFactory.cs b/src/Artemis.UI/Ninject/Factories/IDeviceSettingsViewMOdelFactory.cs
new file mode 100644
index 000000000..62a113b84
--- /dev/null
+++ b/src/Artemis.UI/Ninject/Factories/IDeviceSettingsViewMOdelFactory.cs
@@ -0,0 +1,10 @@
+using Artemis.Core.Models.Surface;
+using Artemis.UI.Screens.Settings.Tabs.Devices;
+
+namespace Artemis.UI.Ninject.Factories
+{
+ public interface IDeviceSettingsViewModelFactory : IArtemisUIFactory
+ {
+ DeviceSettingsViewModel Create(Device device);
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Ninject/Factories/IModuleViewModelFactory.cs b/src/Artemis.UI/Ninject/Factories/IModuleViewModelFactory.cs
index 66ee20cce..bd516f830 100644
--- a/src/Artemis.UI/Ninject/Factories/IModuleViewModelFactory.cs
+++ b/src/Artemis.UI/Ninject/Factories/IModuleViewModelFactory.cs
@@ -3,8 +3,8 @@ using Artemis.UI.Screens.Module;
namespace Artemis.UI.Ninject.Factories
{
- public interface IModuleViewModelFactory
+ public interface IModuleViewModelFactory : IArtemisUIFactory
{
- ModuleRootViewModel CreateModuleViewModel(Module module);
+ ModuleRootViewModel Create(Module module);
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Ninject/Factories/IProfileEditorViewModelFactory.cs b/src/Artemis.UI/Ninject/Factories/IProfileEditorViewModelFactory.cs
index 9875bea54..73026d66e 100644
--- a/src/Artemis.UI/Ninject/Factories/IProfileEditorViewModelFactory.cs
+++ b/src/Artemis.UI/Ninject/Factories/IProfileEditorViewModelFactory.cs
@@ -3,8 +3,8 @@ using Artemis.UI.Screens.Module.ProfileEditor;
namespace Artemis.UI.Ninject.Factories
{
- public interface IProfileEditorViewModelFactory
+ public interface IProfileEditorViewModelFactory : IArtemisUIFactory
{
- ProfileEditorViewModel CreateModuleViewModel(ProfileModule module);
+ ProfileEditorViewModel Create(ProfileModule module);
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Ninject/UiModule.cs b/src/Artemis.UI/Ninject/UiModule.cs
index 5d9869b46..df8ac1b34 100644
--- a/src/Artemis.UI/Ninject/UiModule.cs
+++ b/src/Artemis.UI/Ninject/UiModule.cs
@@ -1,4 +1,5 @@
-using Artemis.UI.Ninject.Factories;
+using System;
+using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens;
using Artemis.UI.Screens.Module.ProfileEditor;
using Artemis.UI.Services.Interfaces;
@@ -17,6 +18,9 @@ namespace Artemis.UI.Ninject
{
public override void Load()
{
+ if (Kernel == null)
+ throw new ArgumentNullException("Kernel shouldn't be null here.");
+
// Bind all built-in VMs
Kernel.Bind(x =>
{
@@ -35,10 +39,19 @@ namespace Artemis.UI.Ninject
.BindAllBaseClasses();
});
- // Bind the module VM
- Bind().ToFactory();
- Bind().ToFactory();
+ // Bind UI factories
+ Kernel.Bind(x =>
+ {
+ x.FromThisAssembly()
+ .SelectAllClasses()
+ .InheritedFrom()
+ .BindToFactory();
+ });
+ Kernel.Bind().ToFactory();
+ Kernel.Bind().ToFactory();
+ Kernel.Bind().ToFactory();
+
// Bind profile editor VMs
Kernel.Bind(x =>
{
diff --git a/src/Artemis.UI/Screens/Dialogs/ConfirmDialogView.xaml b/src/Artemis.UI/Screens/Dialogs/ConfirmDialogView.xaml
index 6d000610c..0ef27108a 100644
--- a/src/Artemis.UI/Screens/Dialogs/ConfirmDialogView.xaml
+++ b/src/Artemis.UI/Screens/Dialogs/ConfirmDialogView.xaml
@@ -11,8 +11,7 @@
d:DataContext="{d:DesignInstance dialogs:ConfirmDialogViewModel}">
-
+