Skip to content
Browse files

Merge remote-tracking branch 'origin/develop' into ardrone-controller

Conflicts:
	RideOnMotion/RideOnMotion/MainWindow.xaml.cs
  • Loading branch information...
2 parents 63811bf + 6cdda51 commit d53933e53457d483a0c116a401b7dc5f8fd5680b @aztheroth aztheroth committed May 14, 2013
Showing with 428 additions and 131 deletions.
  1. +2 −0 .gitignore
  2. +15 −1 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/ImplementationTracker/CaptionArea.cs
  3. +34 −3 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/KinectSensorController.cs
  4. +1 −0 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/Tracker/ICaptionArea.cs
  5. +52 −9 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/TriggerArea.cs
  6. +2 −1 RideOnMotion/RideOnMotion.Inputs.Kinect/Properties/Resources.Designer.cs
  7. +8 −5 RideOnMotion/RideOnMotion.Inputs.Kinect/Properties/Resources.resx
  8. +3 −0 RideOnMotion/RideOnMotion.Inputs.Kinect/RideOnMotion.Inputs.Kinect.csproj
  9. +10 −0 RideOnMotion/RideOnMotion.Utilities/IDroneInputController.cs
  10. +11 −3 RideOnMotion/RideOnMotion.Utilities/Logger.cs
  11. +72 −4 RideOnMotion/RideOnMotion/MainWindow.xaml.cs
  12. +132 −18 RideOnMotion/RideOnMotion/MainWindowViewModel.cs
  13. +52 −60 RideOnMotion/RideOnMotion/Properties/Resources.Designer.cs
  14. +8 −5 RideOnMotion/RideOnMotion/Properties/Resources.resx
  15. +15 −19 RideOnMotion/RideOnMotion/Properties/Settings.Designer.cs
  16. BIN RideOnMotion/RideOnMotion/Resources/Star Wars Ducks.mp4
  17. BIN RideOnMotion/RideOnMotion/Resources/mad_duck.jpg
  18. BIN RideOnMotion/RideOnMotion/Resources/quack.wav
  19. BIN RideOnMotion/RideOnMotion/Resources/quack2.wav
  20. BIN RideOnMotion/RideOnMotion/Resources/quack3.wav
  21. BIN RideOnMotion/RideOnMotion/Resources/quack4.mp3
  22. +9 −1 RideOnMotion/RideOnMotion/RideOnMotion.csproj
  23. +2 −2 RideOnMotion/UnitTest/KinectModuleTests/TrackerTests/CaptionAreaTests.cs
View
2 .gitignore
@@ -103,6 +103,8 @@ ClientBin
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
+*.orig
+*.base
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
View
16 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/ImplementationTracker/CaptionArea.cs
@@ -17,6 +17,7 @@ public class CaptionArea : ICaptionArea, INotifyPropertyChanged
float _width;
float _height;
String _name;
+ int _id;
bool _isActive;
@@ -100,6 +101,18 @@ private set
}
}
+ public int Id
+ {
+ get
+ {
+ return this._id;
+ }
+ private set
+ {
+ this._id = value;
+ }
+ }
+
public bool IsActive
{
get { return _isActive; }
@@ -127,14 +140,15 @@ public IReadOnlyList<Point> Points
}
}
- public CaptionArea(String Name, Point topLeftPoint, float width, float height, KinectSensorController.SkelPointToDepthPoint converter )
+ public CaptionArea(String Name, Point topLeftPoint, float width, float height, KinectSensorController.SkelPointToDepthPoint converter , int Id)
{
_associateFunctions = new List<Action>();
_name = Name;
_topLeftPoint = topLeftPoint;
_width = width;
_height = height;
+ _id = Id;
this._converter = converter;
View
37 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/KinectSensorController.cs
@@ -8,6 +8,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
+using System.Collections;
namespace RideOnMotion.Inputs.Kinect
{
@@ -125,10 +126,16 @@ public class KinectSensorController : IDroneInputController
/// <returns>Equivalent DepthImagePoint</returns>
public delegate DepthImagePoint SkelPointToDepthPoint( SkeletonPoint p );
+ /// <summary>
+ /// Determine the number of active triggerButtons
+ /// </summary>
+ internal int _triggerButtonsActive;
+
#region Interface implementation
// Events
public event EventHandler<BitmapSource> InputImageSourceChanged;
public event EventHandler<DroneInputStatus> InputStatusChanged;
+ public event EventHandler<bool> ControllerActivity;
// Properties
public MenuItem InputMenu
@@ -195,6 +202,31 @@ public IDroneController ActiveDrone
set { throw new NotImplementedException(); }
}
+ public bool IsActive
+ {
+ get
+ {
+ int activesButtons = 0;
+ System.Collections.Generic.List<ICaptionArea> triggerActive = TriggerButtons.Where( ( button ) => button.IsActive == true ).ToList();
+ foreach( ICaptionArea flag in triggerActive)
+ {
+ activesButtons += flag.Id;
+ }
+
+ if ( activesButtons != _triggerButtonsActive )
+ {
+ _triggerButtonsActive = activesButtons;
+ ControllerActivity( this, true );
+ return true;
+ }
+ else
+ {
+ ControllerActivity( this, false );
+ return false;
+ }
+ }
+ }
+
#endregion Interface implementation
private bool DepthFrameIsReady
@@ -360,8 +392,8 @@ private void initTriggerZones( int buttonWidth, int buttonHeight )
int zoneHeight = DEPTH_FRAME_HEIGHT;
// Create caption areas
- LeftTriggerArea = new TriggerArea( zoneWidth, zoneHeight, 0, 0, buttonWidth, buttonHeight, this.SkelPointToDepthImagePoint );
- RightTriggerArea = new TriggerArea( zoneWidth, zoneHeight, zoneWidth, 0, buttonWidth, buttonHeight, this.SkelPointToDepthImagePoint );
+ LeftTriggerArea = new TriggerArea( zoneWidth, zoneHeight, 0, 0, buttonWidth, buttonHeight, this.SkelPointToDepthImagePoint, true);
+ RightTriggerArea = new TriggerArea( zoneWidth, zoneHeight, zoneWidth, 0, buttonWidth, buttonHeight, this.SkelPointToDepthImagePoint, false);
// Create a collection from both zones
TriggerButtons = new ObservableCollection<ICaptionArea>(
@@ -736,5 +768,4 @@ void settingsMenuItem_Click( object sender, RoutedEventArgs e )
e.Handled = true;
}
}
-
}
View
1 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/Tracker/ICaptionArea.cs
@@ -15,6 +15,7 @@ public interface ICaptionArea : INotifyPropertyChanged
float Width { get; }
float Height { get; }
String Name { get; }
+ int Id { get; }
IReadOnlyList<Point> Points { get; }
void CheckPosition( Joint joint );
View
61 RideOnMotion/RideOnMotion.Inputs.Kinect/KinectModule/TriggerArea.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Timers;
namespace RideOnMotion.Inputs.Kinect
{
@@ -29,6 +30,8 @@ public enum Buttons { Up = 0, Down = 1, Left = 2, Right = 3 };
public Dictionary<Buttons, ICaptionArea> TriggerCaptionsCollection { get; private set; }
private KinectSensorController.SkelPointToDepthPoint _converter;
+ //private Action Quack;
+
/// <summary>
/// Create a trigger area, with 4 triggerable captions.
/// </summary>
@@ -38,7 +41,8 @@ public enum Buttons { Up = 0, Down = 1, Left = 2, Right = 3 };
/// <param name="offsetY">Y offset to all buttons</param>
/// <param name="buttonWidth">Width of each button. Side size of the area.</param>
/// <param name="buttonHeight">Height of each button; "thickness" of the area.</param>
- public TriggerArea( int areaWidth, int areaHeight, int offsetX, int offsetY, int buttonWidth, int buttonHeight, KinectSensorController.SkelPointToDepthPoint converter )
+ /// <param name="position">True if the trigger area is on the left, false if it is on the right</param>
+ public TriggerArea( int areaWidth, int areaHeight, int offsetX, int offsetY, int buttonWidth, int buttonHeight, KinectSensorController.SkelPointToDepthPoint converter, bool position )
{
this.AreaHeight = areaHeight;
this.AreaWidth = areaWidth;
@@ -50,11 +54,40 @@ public TriggerArea( int areaWidth, int areaHeight, int offsetX, int offsetY, int
this._converter = converter;
this.TriggerCaptionsCollection = new Dictionary<Buttons, ICaptionArea>();
- generateButtonCaptions();
+
+ //Quack = new Action( () => {
+ // System.Media.SoundPlayer sp = new System.Media.SoundPlayer( RideOnMotion.Inputs.Kinect.Properties.Resources.quack );
+ // sp.Play();
+ //} );
+
+ generateButtonCaptions(position);
}
- public void generateButtonCaptions()
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="position">Specify if the buttons are on the left (true) or on the right (false)</param>
+ public void generateButtonCaptions( bool position)
{
+ int up = 0;
+ int down = 0;
+ int left = 0;
+ int right = 0;
+
+ if ( position )
+ {
+ up = 1;
+ down = 2;
+ left = 4;
+ right = 8;
+ }
+ else if ( !position )
+ {
+ up = 16;
+ down = 32;
+ left = 64;
+ right = 128;
+ }
int horizontalMargin = ( AreaWidth - ButtonWidth ) / 2;
int verticalMargin = ( AreaHeight - ButtonWidth ) / 2;
@@ -63,33 +96,42 @@ public void generateButtonCaptions()
OffsetX + horizontalMargin,
OffsetY + verticalMargin,
ButtonWidth,
- ButtonHeight
+ ButtonHeight,
+ up
);
ICaptionArea leftCaption = createCaptionArea(
"Left button",
OffsetX + horizontalMargin,
OffsetY + verticalMargin,
ButtonHeight,
- ButtonWidth
+ ButtonWidth,
+ left
);
ICaptionArea downCaption = createCaptionArea(
"Down button",
OffsetX + horizontalMargin,
OffsetY + verticalMargin + ButtonWidth - ButtonHeight,
ButtonWidth,
- ButtonHeight
+ ButtonHeight,
+ down
);
ICaptionArea rightCaption = createCaptionArea(
"Right button",
OffsetX + horizontalMargin + ButtonWidth - ButtonHeight,
OffsetY + verticalMargin,
ButtonHeight,
- ButtonWidth
+ ButtonWidth,
+ right
);
+ //((CaptionArea)upCaption).AddFunction( Quack );
+ //((CaptionArea)downCaption).AddFunction( Quack );
+ //((CaptionArea)leftCaption).AddFunction( Quack );
+ //((CaptionArea)rightCaption).AddFunction( Quack );
+
TriggerCaptionsCollection.Add( Buttons.Up, upCaption );
TriggerCaptionsCollection.Add( Buttons.Down, downCaption );
TriggerCaptionsCollection.Add( Buttons.Left, leftCaption );
@@ -98,7 +140,7 @@ public void generateButtonCaptions()
// Fire stuff to update rectangles here. --BC
}
- private ICaptionArea createCaptionArea( string name, int depthX, int depthY, int width, int height )
+ private ICaptionArea createCaptionArea( string name, int depthX, int depthY, int width, int height , int id)
{
//DepthImagePoint depthPoint = new DepthImagePoint() { X = depthX, Y = depthY };
//SkeletonPoint skelPoint = _pointConverter( depthPoint );
@@ -110,7 +152,8 @@ private ICaptionArea createCaptionArea( string name, int depthX, int depthY, int
),
width,
height,
- _converter
+ _converter,
+ id
);
}
}
View
3 RideOnMotion/RideOnMotion.Inputs.Kinect/Properties/Resources.Designer.cs
@@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
namespace RideOnMotion.Inputs.Kinect.Properties {
+ using System;
/// <summary>
@@ -37,7 +38,7 @@ internal class Resources {
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
- if ((resourceMan == null)) {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RideOnMotion.Inputs.Kinect.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
View
13 RideOnMotion/RideOnMotion.Inputs.Kinect/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -109,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
View
3 RideOnMotion/RideOnMotion.Inputs.Kinect/RideOnMotion.Inputs.Kinect.csproj
@@ -116,6 +116,9 @@
<Name>RideOnMotion.Utilities</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Resources\" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
10 RideOnMotion/RideOnMotion.Utilities/IDroneInputController.cs
@@ -86,6 +86,16 @@ public interface IDroneInputController
/// Also fired when the InputStatusString changed (<see cref="RideOnMotion.IDroneInputController.InputStatusString"/>).
/// </summary>
event EventHandler<DroneInputStatus> InputStatusChanged;
+
+ /// <summary>
+ /// Fired when there is activity on the controller
+ /// </summary>
+ event EventHandler<bool> ControllerActivity;
+
+ /// <summary>
+ /// A switch to know if the controller is being used right now
+ /// </summary>
+ bool IsActive { get; }
}
/// <summary>
View
14 RideOnMotion/RideOnMotion.Utilities/Logger.cs
@@ -10,12 +10,13 @@ namespace RideOnMotion
{
/// <summary>
- /// First version of the logger on 23.04.2013
- /// Wait for the new version, right now I don't have time to make something cool.
+ /// Implementation of ActivityLogger from CK.Core package for RideOnMotion project
/// </summary>
public class Logger
- {
+ {
+
private static Logger instance = new Logger();
+ #region Constructor
public static Logger Instance
{
get
@@ -27,6 +28,7 @@ public static Logger Instance
return instance;
}
}
+ #endregion
IDefaultActivityLogger _logger;
@@ -71,6 +73,9 @@ public String Output()
}
+ /// <summary>
+ /// Getting some TraitTags from CK project
+ /// </summary>
public class CKTraitTags
{
public static CKTrait None = ActivityLogger.RegisteredTags.FindOrCreate( "None" );
@@ -82,6 +87,9 @@ public class CKTraitTags
public static CKTrait User = ActivityLogger.RegisteredTags.FindOrCreate( "User" );
}
+ /// <summary>
+ /// Collection of usefull method to work with string types
+ /// </summary>
public class StringImpl : IActivityLoggerSink
{
public StringWriter Writer { get; private set; }
View
76 RideOnMotion/RideOnMotion/MainWindow.xaml.cs
@@ -2,6 +2,8 @@
using RideOnMotion.Inputs.Kinect;
using System.Windows.Controls;
using RideOnMotion.Utilities;
+using System.Windows.Input;
+using System;
namespace RideOnMotion.UI
{
@@ -20,15 +22,20 @@ public partial class MainWindow : Window
/// </summary>
private MainWindowViewModel mainWindowViewModel;
+ private MenuItem _activeInputMenuItem;
public MainWindow()
{
InitializeComponent();
+ this.mainWindowViewModel = new MainWindowViewModel();
this.inputController = new KinectSensorController();
this.mainWindowViewModel = new MainWindowViewModel( inputController );
this.DataContext = this.mainWindowViewModel;
+ // Bind input menu and fire once
+ this.mainWindowViewModel.InputMenuChanged += OnInputMenuChange;
+ this.OnInputMenuChange( this, this.mainWindowViewModel.InputMenu );
// Bind input menu
if ( this.inputController.InputMenu != null )
{
@@ -38,16 +45,28 @@ public MainWindow()
DroneInitializer drone = new DroneInitializer();
}
+ private void OnInputMenuChange( object sender, MenuItem e )
+ {
+ if ( this._activeInputMenuItem != null )
+ {
+ this.MenuBar.Items.Remove( this._activeInputMenuItem );
+ }
+
+ if ( e != null )
+ {
+ this.MenuBar.Items.Add( e );
+ }
+
+ this._activeInputMenuItem = e;
+ }
+
private void MainWindow_Loaded( object sender, RoutedEventArgs e )
{
- prepareInput();
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
- this.inputController.Stop();
- }
-
+ this.mainWindowViewModel.Stop();
private void prepareInput()
{
if ( this.inputController.InputStatus == DroneInputStatus.Disconnected )
@@ -77,6 +96,55 @@ private void LogString_TextChanged( object sender, System.Windows.Controls.TextC
tb.ScrollToEnd();
}
+ #region KonamiCode
+ protected string _konami = string.Empty;
+ protected System.Windows.Media.Brush _originalBackground;
+ protected UIElement _originalViewBox;
+ protected override void OnPreviewKeyDown( KeyEventArgs e )
+ {
+ if ( _originalBackground == null )
+ {
+ _originalBackground = MainPanel.Background;
+ _originalViewBox = DepthViewerPanel.Children[0];
+ }
+ string i = "UpUpDownDownLeftRightLeftRightBAReturn";
+ if ( e.Key.ToString() == "Up" && _konami != "Up" )
+ {
+ _konami = "";
+ }
+ _konami = ( _konami + e.Key.ToString() );
+ // Debug.Print(konami)
+ if ( ( _konami == i ) )
+ {
+ mainWindowViewModel.Konami = true;
+ string fileName = "..\\..\\Resources\\mad_duck.jpg";
+ System.Windows.Media.Imaging.BitmapImage image = new System.Windows.Media.Imaging.BitmapImage( new System.Uri( fileName, System.UriKind.Relative ) );
+ System.Windows.Media.ImageBrush brush = new System.Windows.Media.ImageBrush();
+ brush.ImageSource = image;
+ MainPanel.Background = brush;
+
+
+ Viewbox v = new Viewbox();
+ MediaElement me = new MediaElement();
+ fileName = "..\\..\\Resources\\Star Wars Ducks.mp4";
+ me.Source = new System.Uri( fileName, System.UriKind.Relative );
+ me.LoadedBehavior = MediaState.Manual;
+ me.MediaEnded += new RoutedEventHandler( delegate( object s, RoutedEventArgs re ) { me.Stop(); me.Play(); } );
+ me.Play();
+ v.Child = me;
+ DepthViewerPanel.Children.RemoveAt( 0 );
+ DepthViewerPanel.Children.Add( v );
+ }
+ else if ( _konami.Length > i.Length )
+ {
+ mainWindowViewModel.Konami = false;
+ MainPanel.Background = _originalBackground;
+ DepthViewerPanel.Children.RemoveAt( 0 );
+ DepthViewerPanel.Children.Add( _originalViewBox );
+ }
+ }
+
+ #endregion //KonamiCode
}
}
View
150 RideOnMotion/RideOnMotion/MainWindowViewModel.cs
@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
+using System.Collections.Generic;
namespace RideOnMotion.UI
{
@@ -19,11 +20,23 @@ class MainWindowViewModel : IViewModel, INotifyPropertyChanged
private BitmapSource _droneBitmapSource;
private BitmapSource _inputBitmapSource;
private Control _inputControl;
+ private MenuItem _inputMenu;
+
+ private List<Type> InputTypes { get; set; }
private string _inputStatusInfo = String.Empty;
private String _logString;
+ internal bool Konami = false;
+
+ private System.Windows.Media.MediaPlayer mp1 = new System.Windows.Media.MediaPlayer();
+ private System.Windows.Media.MediaPlayer mp2 = new System.Windows.Media.MediaPlayer();
+ private System.Windows.Media.MediaPlayer mp3 = new System.Windows.Media.MediaPlayer();
+ private System.Windows.Media.MediaPlayer mp4 = new System.Windows.Media.MediaPlayer();
+
+ internal event EventHandler<MenuItem> InputMenuChanged;
+
#endregion Values
#region GettersSetters
@@ -41,6 +54,30 @@ public BitmapSource InputBitmapSource
{
this._inputBitmapSource = value;
this.OnNotifyPropertyChange( "InputBitmapSource" );
+ if ( IsActive == true && Konami == true)
+ {
+ TimeSpan timeZero = new TimeSpan( 0 );
+ if ( mp1.Position == mp1.NaturalDuration.TimeSpan || mp1.Position == timeZero)
+ {
+ mp1.Position = new TimeSpan( 0 );
+ mp1.Play();
+ }
+ else if ( mp2.Position == mp2.NaturalDuration.TimeSpan || mp2.Position == timeZero )
+ {
+ mp2.Position = new TimeSpan( 0 );
+ mp2.Play();
+ }
+ else if ( mp3.Position == mp3.NaturalDuration.TimeSpan || mp3.Position == timeZero )
+ {
+ mp3.Position = new TimeSpan( 0 );
+ mp3.Play();
+ }
+ else if ( mp4.Position == mp4.NaturalDuration.TimeSpan || mp4.Position == timeZero )
+ {
+ mp4.Position = new TimeSpan( 0 );
+ mp4.Play();
+ }
+ }
}
}
}
@@ -95,6 +132,22 @@ public Control InputControl
}
}
+ public MenuItem InputMenu
+ {
+ get
+ {
+ return _inputMenu;
+ }
+ }
+
+ public bool IsActive
+ {
+ get
+ {
+ return _inputController.IsActive;
+ }
+ }
+
#endregion GettersSetters
#region INotifyPropertyChanged utilities
@@ -121,35 +174,30 @@ public void OnNotifyPropertyChange( string propertyName )
/// <summary>
/// Initializes the ViewModel with the given IDroneInputController.
/// </summary>
- /// <param name="inputController">Input model : Handles data in and out of the input</param>
- public MainWindowViewModel( IDroneInputController sensorController )
+ public MainWindowViewModel()
{
- _inputController = sensorController;
+ InputTypes = new List<Type>();
+ InputTypes.Add( typeof( RideOnMotion.Inputs.Kinect.KinectSensorController ) );
- initializeBindings();
-
- _inputControl = _inputController.InputUIControl;
- this.OnNotifyPropertyChange( "InputControl" );
+ loadInputType( InputTypes[0] );
+ mp1.Open( new Uri( "..\\..\\Resources\\Quack.wav", UriKind.Relative ) );
+ mp2.Open( new Uri( "..\\..\\Resources\\Quack2.wav", UriKind.Relative ) );
+ mp3.Open( new Uri( "..\\..\\Resources\\Quack3.wav", UriKind.Relative ) );
+ mp4.Open( new Uri( "..\\..\\Resources\\Quack4.mp3", UriKind.Relative ) );
}
/// <summary>
/// Creates the event bindings with the model.
/// </summary>
private void initializeBindings()
{
- // Bind depth image changes
- _inputController.InputImageSourceChanged += OnInputBitmapSourceChanged;
+ Logger.Instance.NewLogStringReady += OnLogStringReceived;
+ }
- // Bind sensor status
- _inputController.InputStatusChanged += ( sender, e ) =>
- {
- _inputStatusInfo = _inputController.InputStatusString;
- this.OnNotifyPropertyChange( "InputStatusInfo" );
- };
- // Set once
+ private void OnInputStatusChanged( object sender, DroneInputStatus e )
+ {
_inputStatusInfo = _inputController.InputStatusString;
-
- Logger.Instance.NewLogStringReady += OnLogStringReceived;
+ this.OnNotifyPropertyChange( "InputStatusInfo" );
}
private void OnInputBitmapSourceChanged( object sender, BitmapSource s )
@@ -162,6 +210,72 @@ private void OnLogStringReceived( object sender, String e )
this.LogString = e; // Will fire NotifyPropertyChanged
}
+ private void loadInputType(Type t)
+ {
+ if (t != null && t.GetInterface( "RideOnMotion.IDroneInputController", true ) != null )
+ {
+
+ IDroneInputController controller = (IDroneInputController) Activator.CreateInstance(t);
+
+ clearInputController();
+
+ _inputController = controller;
+
+ bindWithInputController();
+
+ _inputControl = _inputController.InputUIControl;
+ this.OnNotifyPropertyChange( "InputControl" );
+
+ _inputMenu = _inputController.InputMenu;
+ if ( InputMenuChanged != null )
+ {
+ InputMenuChanged( this, _inputController.InputMenu );
+ }
+
+ _inputController.Start();
+ }
+ else
+ {
+ // Can't load, type doesn't implement interface
+ }
+ }
+
+ private void clearInputController()
+ {
+ if ( this._inputController != null )
+ {
+ _inputController.InputImageSourceChanged -= OnInputBitmapSourceChanged;
+ _inputController.InputStatusChanged -= OnInputStatusChanged;
+ _inputController.ControllerActivity -= OnControllerActivity;
+ _inputStatusInfo = "";
+ this.OnNotifyPropertyChange( "InputStatusInfo" );
+ this._inputController = null;
+ }
+ }
+
+ private void bindWithInputController()
+ {
+ // Bind depth image changes
+ _inputController.InputImageSourceChanged += OnInputBitmapSourceChanged;
+
+ // Bind sensor status and set once
+ _inputController.InputStatusChanged += OnInputStatusChanged;
+ _inputStatusInfo = _inputController.InputStatusString;
+
+ // Bind activity
+ _inputController.ControllerActivity += OnControllerActivity;
+ }
+
+ public void OnControllerActivity(object sender, bool e)
+ {
+ this.OnNotifyPropertyChange( "IsActive" );
+ }
+
+ internal void Stop()
+ {
+ this._inputController.Stop();
+ }
+
#endregion Contructor/initializers/event handlers
}
View
112 RideOnMotion/RideOnMotion/Properties/Resources.Designer.cs
@@ -8,64 +8,56 @@
// </auto-generated>
//------------------------------------------------------------------------------
-namespace RideOnMotion.UI.Properties
-{
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute( "System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0" )]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode" )]
- internal Resources()
- {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ( ( resourceMan == null ) )
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager( "RideOnMotion.UI.Properties.Resources", typeof( Resources ).Assembly );
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute( global::System.ComponentModel.EditorBrowsableState.Advanced )]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
+namespace RideOnMotion.UI.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RideOnMotion.UI.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
}
View
13 RideOnMotion/RideOnMotion/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -109,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
View
34 RideOnMotion/RideOnMotion/Properties/Settings.Designer.cs
@@ -8,23 +8,19 @@
// </auto-generated>
//------------------------------------------------------------------------------
-namespace RideOnMotion.UI.Properties
-{
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute( "Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0" )]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ( (Settings)( global::System.Configuration.ApplicationSettingsBase.Synchronized( new Settings() ) ) );
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
+namespace RideOnMotion.UI.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
}
View
BIN RideOnMotion/RideOnMotion/Resources/Star Wars Ducks.mp4
Binary file not shown.
View
BIN RideOnMotion/RideOnMotion/Resources/mad_duck.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN RideOnMotion/RideOnMotion/Resources/quack.wav
Binary file not shown.
View
BIN RideOnMotion/RideOnMotion/Resources/quack2.wav
Binary file not shown.
View
BIN RideOnMotion/RideOnMotion/Resources/quack3.wav
Binary file not shown.
View
BIN RideOnMotion/RideOnMotion/Resources/quack4.mp3
Binary file not shown.
View
10 RideOnMotion/RideOnMotion/RideOnMotion.csproj
@@ -7,7 +7,7 @@
<ProjectGuid>{0DD0D3F7-5335-4745-B337-81490654CB80}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>RideOnMotion</RootNamespace>
+ <RootNamespace>RideOnMotion.UI</RootNamespace>
<AssemblyName>RideOnMotion</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
@@ -127,6 +127,14 @@
<ItemGroup>
<Resource Include="Images\HelicopterIcon.png" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Resources\mad_duck.jpg" />
+ <Content Include="Resources\quack.wav" />
+ <Content Include="Resources\quack2.wav" />
+ <Content Include="Resources\quack3.wav" />
+ <Content Include="Resources\quack4.mp3" />
+ <Content Include="Resources\Star Wars Ducks.mp4" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
4 RideOnMotion/UnitTest/KinectModuleTests/TrackerTests/CaptionAreaTests.cs
@@ -15,7 +15,7 @@ public class CaptionAreaTests
[Test]
public void CaptionAreaPointTest()
{
- CaptionArea mockCaptionArea = new CaptionArea("Mock Caption", new Point( 0, 0 ), 10, 10, null );
+ CaptionArea mockCaptionArea = new CaptionArea("Mock Caption", new Point( 0, 0 ), 10, 10, null ,0);
IReadOnlyList<Point> listOfPoint = mockCaptionArea.Points;
Assert.That( listOfPoint[0].X, Is.EqualTo( 0 ) );
@@ -32,7 +32,7 @@ public void CaptionAreaPointTest()
public void CaptionAreaCallFunctionTests()
{
int i = 0;
- CaptionArea mockCaptionArea = new CaptionArea( "Mock Caption", new Point( 0, 0 ), 10, 10, null );
+ CaptionArea mockCaptionArea = new CaptionArea( "Mock Caption", new Point( 0, 0 ), 10, 10, null ,0);
Action function = () => { i++; };
mockCaptionArea.AddFunction( function );
Joint joint = new Skeleton().Joints[0];

0 comments on commit d53933e

Please sign in to comment.
Something went wrong with that request. Please try again.