diff --git a/ANX.Framework/Input/GamePad.cs b/ANX.Framework/Input/GamePad.cs index 646d10f1..ff588ab7 100644 --- a/ANX.Framework/Input/GamePad.cs +++ b/ANX.Framework/Input/GamePad.cs @@ -11,7 +11,7 @@ namespace ANX.Framework.Input [TestState(TestStateAttribute.TestState.Tested)] public static class GamePad { - private static IGamePad gamePad; + private static readonly IGamePad gamePad; static GamePad() { diff --git a/ANX.Framework/Input/GamePadDPad.cs b/ANX.Framework/Input/GamePadDPad.cs index 1bf51f5b..39f9ab9d 100644 --- a/ANX.Framework/Input/GamePadDPad.cs +++ b/ANX.Framework/Input/GamePadDPad.cs @@ -70,7 +70,7 @@ namespace ANX.Framework.Input public override bool Equals(object obj) { - if (obj != null && obj.GetType() == typeof(GamePadDPad)) + if (obj is GamePadDPad) return this == (GamePadDPad)obj; return false; diff --git a/ANX.Framework/Input/GamePadState.cs b/ANX.Framework/Input/GamePadState.cs index f36c5025..ea357125 100644 --- a/ANX.Framework/Input/GamePadState.cs +++ b/ANX.Framework/Input/GamePadState.cs @@ -86,7 +86,7 @@ namespace ANX.Framework.Input public override bool Equals(object obj) { - if (obj != null && obj.GetType() == typeof(GamePadState)) + if (obj is GamePadState) return this == (GamePadState)obj; return false; diff --git a/ANX.Framework/Input/Keyboard.cs b/ANX.Framework/Input/Keyboard.cs index 9fbea8aa..e0c80eb1 100644 --- a/ANX.Framework/Input/Keyboard.cs +++ b/ANX.Framework/Input/Keyboard.cs @@ -12,22 +12,15 @@ namespace ANX.Framework.Input [TestState(TestStateAttribute.TestState.Tested)] public static class Keyboard { - private static IKeyboard keyboard; + private static readonly IKeyboard keyboard; - internal static IntPtr WindowHandle - { - get - { - return keyboard != null ? keyboard.WindowHandle : IntPtr.Zero; - } - set - { - if (keyboard != null) - keyboard.WindowHandle = value; - } - } + internal static IntPtr WindowHandle + { + get { return keyboard.WindowHandle; } + set { keyboard.WindowHandle = value; } + } - static Keyboard() + static Keyboard() { keyboard = AddInSystemFactory.Instance.GetDefaultCreator().Keyboard; } diff --git a/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs b/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs index c2d12f0b..3a7955bc 100644 --- a/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs +++ b/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs @@ -15,39 +15,22 @@ namespace ANX.Framework.Input.MotionSensing { public class MotionSensingDevice { - private static IMotionSensingDevice motionSensingDevice; - - static MotionSensingDevice() - { - motionSensingDevice = AddInSystemFactory.Instance.GetDefaultCreator().MotionSensingDevice; - } + private static readonly IMotionSensingDevice motionSensingDevice; public static GraphicsDevice GraphicsDevice { - get - { - if (motionSensingDevice != null) - { - return motionSensingDevice.GraphicsDevice; - } - - return null; - } - set - { - if (motionSensingDevice != null) - { - motionSensingDevice.GraphicsDevice = value; - } - } + get { return motionSensingDevice.GraphicsDevice; } + set { motionSensingDevice.GraphicsDevice = value; } } public static MotionSensingDeviceType DeviceType { - get - { - return motionSensingDevice.DeviceType; - } + get { return motionSensingDevice.DeviceType; } + } + + static MotionSensingDevice() + { + motionSensingDevice = AddInSystemFactory.Instance.GetDefaultCreator().MotionSensingDevice; } public static MotionSensingDeviceState GetState() diff --git a/ANX.Framework/Input/Mouse.cs b/ANX.Framework/Input/Mouse.cs index 249e10c1..516c5d74 100644 --- a/ANX.Framework/Input/Mouse.cs +++ b/ANX.Framework/Input/Mouse.cs @@ -12,35 +12,27 @@ namespace ANX.Framework.Input [TestState(TestStateAttribute.TestState.Tested)] public static class Mouse { - private static IMouse mouse; + private static readonly IMouse mouse; - public static IntPtr WindowHandle - { - get - { - return mouse != null ? mouse.WindowHandle : IntPtr.Zero; - } - set - { - if (mouse != null) - mouse.WindowHandle = value; - } - } + public static IntPtr WindowHandle + { + get { return mouse.WindowHandle; } + set { mouse.WindowHandle = value; } + } - static Mouse() + static Mouse() { mouse = AddInSystemFactory.Instance.GetDefaultCreator().Mouse; } public static MouseState GetState() { - return (mouse != null) ? mouse.GetState() : new MouseState(); + return mouse.GetState(); } public static void SetPosition(int x, int y) { - if (mouse != null) - mouse.SetPosition(x, y); + mouse.SetPosition(x, y); } } } diff --git a/ANX.Framework/Input/Touch/TouchPanel.cs b/ANX.Framework/Input/Touch/TouchPanel.cs index 0f668c55..5a33b11f 100644 --- a/ANX.Framework/Input/Touch/TouchPanel.cs +++ b/ANX.Framework/Input/Touch/TouchPanel.cs @@ -1,7 +1,6 @@ using System; using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.Development; -using ANX.Framework.NonXNA.InputSystem; // This file is part of the ANX.Framework created by the // "ANX.Framework developer group" and released under the Ms-PL license. @@ -13,106 +12,63 @@ namespace ANX.Framework.Input.Touch [TestState(TestStateAttribute.TestState.Untested)] public static class TouchPanel { - #region Private - private static ITouchPanel nativeTouchPanel; - #endregion + private static readonly ITouchPanel nativeTouchPanel; #region Public - public static GestureType EnabledGestures - { - get - { - return nativeTouchPanel.EnabledGestures; - } - set - { - nativeTouchPanel.EnabledGestures = value; - } - } + public static GestureType EnabledGestures + { + get { return nativeTouchPanel.EnabledGestures; } + set { nativeTouchPanel.EnabledGestures = value; } + } - public static bool IsGestureAvailable - { - get - { - return nativeTouchPanel.IsGestureAvailable; - } - } + public static bool IsGestureAvailable + { + get { return nativeTouchPanel.IsGestureAvailable; } + } - public static IntPtr WindowHandle - { - get - { - return nativeTouchPanel.WindowHandle; - } - set - { - nativeTouchPanel.WindowHandle = value; - } - } + public static IntPtr WindowHandle + { + get { return nativeTouchPanel.WindowHandle; } + set { nativeTouchPanel.WindowHandle = value; } + } - public static DisplayOrientation DisplayOrientation - { - get - { - return nativeTouchPanel.DisplayOrientation; - } - set - { - nativeTouchPanel.DisplayOrientation = value; - } - } + public static DisplayOrientation DisplayOrientation + { + get { return nativeTouchPanel.DisplayOrientation; } + set { nativeTouchPanel.DisplayOrientation = value; } + } - public static int DisplayWidth - { - get - { - return nativeTouchPanel.DisplayWidth; - } - set - { - nativeTouchPanel.DisplayWidth = value; - } - } + public static int DisplayWidth + { + get { return nativeTouchPanel.DisplayWidth; } + set { nativeTouchPanel.DisplayWidth = value; } + } - public static int DisplayHeight - { - get - { - return nativeTouchPanel.DisplayHeight; - } - set - { - nativeTouchPanel.DisplayHeight = value; - } - } - #endregion + public static int DisplayHeight + { + get { return nativeTouchPanel.DisplayHeight; } + set { nativeTouchPanel.DisplayHeight = value; } + } + #endregion - #region Constructor static TouchPanel() { nativeTouchPanel = AddInSystemFactory.Instance.GetDefaultCreator().TouchPanel; } - #endregion - #region GetCapabilities public static TouchPanelCapabilities GetCapabilities() { return nativeTouchPanel.GetCapabilities(); } - #endregion - #region ReadGesture public static GestureSample ReadGesture() { return nativeTouchPanel.ReadGesture(); } - #endregion - #region GetState public static TouchCollection GetState() { return nativeTouchPanel.GetState(); } - #endregion } } diff --git a/ANX.Framework/Input/Touch/TouchPanelCapabilities.cs b/ANX.Framework/Input/Touch/TouchPanelCapabilities.cs index b369cc09..eba2b4c0 100644 --- a/ANX.Framework/Input/Touch/TouchPanelCapabilities.cs +++ b/ANX.Framework/Input/Touch/TouchPanelCapabilities.cs @@ -6,11 +6,11 @@ using ANX.Framework.NonXNA.Development; namespace ANX.Framework.Input.Touch { - [PercentageComplete(100)] - [TestState(TestStateAttribute.TestState.Tested)] - public struct TouchPanelCapabilities - { - public bool IsConnected { get; set; } - public int MaximumTouchCount { get; set; } - } + [PercentageComplete(100)] + [TestState(TestStateAttribute.TestState.Tested)] + public struct TouchPanelCapabilities + { + public bool IsConnected { get; set; } + public int MaximumTouchCount { get; set; } + } } diff --git a/ANX.Framework/Media/ArtistCollection.cs b/ANX.Framework/Media/ArtistCollection.cs index e2a838d6..1a0ddb4b 100644 --- a/ANX.Framework/Media/ArtistCollection.cs +++ b/ANX.Framework/Media/ArtistCollection.cs @@ -10,31 +10,21 @@ namespace ANX.Framework.Media { public sealed class ArtistCollection : IEnumerable, IEnumerable, IDisposable { - private List artists; + private readonly List artists; - public bool IsDisposed - { - get; - private set; - } + public bool IsDisposed { get; private set; } - public int Count - { - get - { - return artists.Count; - } - } + public int Count + { + get { return artists.Count; } + } - public Artist this[int index] - { - get - { - return artists[index]; - } - } + public Artist this[int index] + { + get { return artists[index]; } + } - internal ArtistCollection() + internal ArtistCollection() { artists = new List(); IsDisposed = false; diff --git a/ANX.Framework/Media/GenreCollection.cs b/ANX.Framework/Media/GenreCollection.cs index 1de78b91..e011dca6 100644 --- a/ANX.Framework/Media/GenreCollection.cs +++ b/ANX.Framework/Media/GenreCollection.cs @@ -10,31 +10,21 @@ namespace ANX.Framework.Media { public sealed class GenreCollection : IEnumerable, IEnumerable, IDisposable { - private List genres; + private readonly List genres; - public bool IsDisposed - { - get; - private set; - } + public bool IsDisposed { get; private set; } - public int Count - { - get - { - return genres.Count; - } - } + public int Count + { + get { return genres.Count; } + } - public Genre this[int index] - { - get - { - return genres[index]; - } - } + public Genre this[int index] + { + get { return genres[index]; } + } - internal GenreCollection() + internal GenreCollection() { genres = new List(); IsDisposed = false; diff --git a/ANX.Framework/Media/MediaLibrary.cs b/ANX.Framework/Media/MediaLibrary.cs index f359c197..6de353bc 100644 --- a/ANX.Framework/Media/MediaLibrary.cs +++ b/ANX.Framework/Media/MediaLibrary.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using ANX.Framework.NonXNA; using ANX.Framework.NonXNA.PlatformSystem; // This file is part of the ANX.Framework created by the @@ -13,94 +12,61 @@ namespace ANX.Framework.Media { private INativeMediaLibrary nativeLibrary; - #region Public - public MediaSource MediaSource - { - get; - private set; - } + #region Public + public bool IsDisposed { get; private set; } + public MediaSource MediaSource { get; private set; } - public PictureCollection Pictures - { - get - { - return nativeLibrary.GetPictures(); - } - } - - public PictureAlbum RootPictureAlbum - { - get - { - return nativeLibrary.GetRootPictureAlbum(); - } - } - - public PictureCollection SavedPictures - { - get - { - return nativeLibrary.GetSavedPictures(); - } - } - - public SongCollection Songs - { - get - { - return nativeLibrary.GetSongs(); - } - } - - public ArtistCollection Artists - { - get - { - return nativeLibrary.GetArtists(); - } - } - - public AlbumCollection Albums - { - get - { - return nativeLibrary.GetAlbums(); - } - } - - public PlaylistCollection Playlists - { - get - { - return nativeLibrary.GetPlaylists(); - } - } - - public GenreCollection Genres - { - get - { - return nativeLibrary.GetGenres(); - } - } + public PictureCollection Pictures + { + get { return nativeLibrary.GetPictures(); } + } - public bool IsDisposed - { - get; - private set; - } - #endregion + public PictureAlbum RootPictureAlbum + { + get { return nativeLibrary.GetRootPictureAlbum(); } + } + + public PictureCollection SavedPictures + { + get { return nativeLibrary.GetSavedPictures(); } + } + + public SongCollection Songs + { + get { return nativeLibrary.GetSongs(); } + } + + public ArtistCollection Artists + { + get { return nativeLibrary.GetArtists(); } + } + + public AlbumCollection Albums + { + get { return nativeLibrary.GetAlbums(); } + } + + public PlaylistCollection Playlists + { + get { return nativeLibrary.GetPlaylists(); } + } + + public GenreCollection Genres + { + get { return nativeLibrary.GetGenres(); } + } + #endregion #region Constructor public MediaLibrary() { - nativeLibrary = PlatformSystem.Instance.CreateMediaPlayer(); + nativeLibrary = PlatformSystem.Instance.CreateMediaLibrary(); MediaSource = MediaSource.GetAvailableMediaSources()[0]; } public MediaLibrary(MediaSource setSource) { - nativeLibrary = PlatformSystem.Instance.CreateMediaPlayer(); + nativeLibrary = PlatformSystem.Instance.CreateMediaLibrary(); MediaSource = setSource; } @@ -113,13 +79,12 @@ namespace ANX.Framework.Media #region Dispose public void Dispose() { - if (IsDisposed == false) - { - IsDisposed = true; + if (IsDisposed) + return; - nativeLibrary.Dispose(); - nativeLibrary = null; - } + IsDisposed = true; + nativeLibrary.Dispose(); + nativeLibrary = null; } #endregion diff --git a/ANX.Framework/Media/Video.cs b/ANX.Framework/Media/Video.cs index 828d72ca..3cd266db 100644 --- a/ANX.Framework/Media/Video.cs +++ b/ANX.Framework/Media/Video.cs @@ -8,37 +8,19 @@ namespace ANX.Framework.Media { public sealed class Video { - #region Public - public TimeSpan Duration - { - get; - private set; - } - - public int Width - { - get; - private set; - } - - public int Height - { - get; - private set; - } - - public float FramesPerSecond - { - get; - private set; - } - - public VideoSoundtrackType VideoSoundtrackType - { - get; - private set; - } - #endregion + internal TimeSpan PlayPosition + { + get { throw new NotImplementedException(); } + //get { return nativeVideo.PlayPosition; } + } + + #region Public + public TimeSpan Duration { get; private set; } + public int Width { get; private set; } + public int Height { get; private set; } + public float FramesPerSecond { get; private set; } + public VideoSoundtrackType VideoSoundtrackType { get; private set; } + #endregion #region Constructor internal Video(int duration, int width, int height, float framesPerSecond, VideoSoundtrackType soundtrackType) @@ -50,5 +32,29 @@ namespace ANX.Framework.Media VideoSoundtrackType = soundtrackType; } #endregion + + internal void Play() + { + // TODO: nativeVideo.Play(); + throw new NotImplementedException(); + } + + internal void Pause() + { + // TODO: nativeVideo.Pause(); + throw new NotImplementedException(); + } + + internal void Resume() + { + // TODO: nativeVideo.Resume(); + throw new NotImplementedException(); + } + + internal void Stop() + { + // TODO: nativeVideo.Stop(); + throw new NotImplementedException(); + } } } diff --git a/ANX.Framework/Media/VideoPlayer.cs b/ANX.Framework/Media/VideoPlayer.cs index b11307e4..d0dc2ab0 100644 --- a/ANX.Framework/Media/VideoPlayer.cs +++ b/ANX.Framework/Media/VideoPlayer.cs @@ -9,34 +9,31 @@ namespace ANX.Framework.Media { public sealed class VideoPlayer : IDisposable { - public bool IsDisposed - { - get; - private set; - } + private float volume; + internal float VolumeToUse + { + get { return IsMuted ? 0f : volume; } + } - public TimeSpan PlayPosition + public Video Video { get; private set; } + public bool IsMuted { get; set; } + public bool IsDisposed { get; private set; } + + public TimeSpan PlayPosition { - get - { - throw new NotImplementedException(); - } + get { return Video == null ? TimeSpan.Zero : Video.PlayPosition; } } public float Volume { - get - { - throw new NotImplementedException(); - } - } + get { return volume; } + set + { + if (value < 0f || value > 1f) + throw new ArgumentOutOfRangeException("value"); - public bool IsMuted - { - get - { - throw new NotImplementedException(); - } + volume = value; + } } public bool IsLooped @@ -46,15 +43,7 @@ namespace ANX.Framework.Media throw new NotImplementedException(); } } - - public Video Video - { - get - { - throw new NotImplementedException(); - } - } - + public MediaState State { get @@ -65,6 +54,8 @@ namespace ANX.Framework.Media public VideoPlayer() { + IsMuted = false; + volume = 1f; IsDisposed = false; } @@ -75,31 +66,38 @@ namespace ANX.Framework.Media public void Dispose() { - if (IsDisposed == false) - { - IsDisposed = true; - throw new NotImplementedException(); - } + if (IsDisposed) + return; + + IsDisposed = true; + Video = null; } public void Play(Video video) - { - throw new NotImplementedException(); + { + if (video == null) + throw new ArgumentNullException("video"); + + Video = video; + video.Play(); } public void Pause() - { - throw new NotImplementedException(); + { + if (Video != null) + Video.Pause(); } public void Resume() - { - throw new NotImplementedException(); + { + if (Video != null) + Video.Resume(); } public void Stop() - { - throw new NotImplementedException(); + { + if (Video != null) + Video.Stop(); } public Texture2D GetTexture() diff --git a/ANX.Framework/NonXNA/InputDeviceFactory.cs b/ANX.Framework/NonXNA/InputDeviceFactory.cs index e5d141a8..c549d0c8 100644 --- a/ANX.Framework/NonXNA/InputDeviceFactory.cs +++ b/ANX.Framework/NonXNA/InputDeviceFactory.cs @@ -82,9 +82,10 @@ namespace ANX.Framework.NonXNA public ITouchPanel GetDefaultTouchPanel() { ValidateWindowHandle(); - var touchPanel = GetDefaultCreator().CreateDevice(); - touchPanel.WindowHandle = WindowHandle; +#if !WINDOWSMETRO + touchPanel.WindowHandle = WindowHandle; +#endif return touchPanel; } #endregion @@ -99,11 +100,8 @@ namespace ANX.Framework.NonXNA #region CreateDefaultMouse public IMouse CreateDefaultMouse() { -#if !WINDOWSMETRO ValidateWindowHandle(); -#endif var mouse = GetDefaultCreator().CreateDevice(); - #if !WINDOWSMETRO mouse.WindowHandle = WindowHandle; #endif @@ -139,7 +137,7 @@ namespace ANX.Framework.NonXNA { var creators = deviceCreators[creatorType]; if (creators.Count > 0) - return (T)creators.Values.First(); + return (T)creators.Values.First(); } throw new Exception("Unable to find a default creator for type " + creatorType); @@ -149,8 +147,10 @@ namespace ANX.Framework.NonXNA #region ValidateWindowHandle private void ValidateWindowHandle() { +#if !WINDOWSMETRO if (WindowHandle == IntPtr.Zero) - throw new Exception("Unable to create a mouse instance because the WindowHandle was not set."); + throw new Exception("Unable to create a mouse instance because the WindowHandle was not set."); +#endif } #endregion } diff --git a/ANX.Framework/NonXNA/PlatformSystem/IPlatformSystem.cs b/ANX.Framework/NonXNA/PlatformSystem/IPlatformSystem.cs index cacba90a..ee261b68 100644 --- a/ANX.Framework/NonXNA/PlatformSystem/IPlatformSystem.cs +++ b/ANX.Framework/NonXNA/PlatformSystem/IPlatformSystem.cs @@ -20,7 +20,7 @@ namespace ANX.Framework.NonXNA.PlatformSystem Stream OpenReadFilestream(string filepath); - INativeMediaLibrary CreateMediaPlayer(); + INativeMediaLibrary CreateMediaLibrary(); IList GetAvailableMediaSources(); } } diff --git a/ANX.Framework/NonXNA/PlatformSystem/PlatformSystem.cs b/ANX.Framework/NonXNA/PlatformSystem/PlatformSystem.cs index 9ff552d2..cf312434 100644 --- a/ANX.Framework/NonXNA/PlatformSystem/PlatformSystem.cs +++ b/ANX.Framework/NonXNA/PlatformSystem/PlatformSystem.cs @@ -165,14 +165,14 @@ namespace ANX.Framework.NonXNA.PlatformSystem return runtimeInstance.OpenReadFilestream(filepath); } - public INativeMediaLibrary CreateMediaPlayer() + public INativeMediaLibrary CreateMediaLibrary() { if (runtimeInstance == null) { throw new PlatformSystemInstanceException(); } - return runtimeInstance.CreateMediaPlayer(); + return runtimeInstance.CreateMediaLibrary(); } public IList GetAvailableMediaSources() diff --git a/InputSystems/ANX.InputSystem.Standard/Creator.cs b/InputSystems/ANX.InputSystem.Standard/Creator.cs index ebb7940f..01e3d313 100644 --- a/InputSystems/ANX.InputSystem.Standard/Creator.cs +++ b/InputSystems/ANX.InputSystem.Standard/Creator.cs @@ -6,118 +6,125 @@ using ANX.Framework.NonXNA; namespace ANX.InputSystem.Standard { - public class Creator : IInputSystemCreator - { - private IKeyboard keyboard; - private IMouse mouse; - private IGamePad gamePad; - private ITouchPanel touchPanel; - - public string Name - { - get - { - return "Standard"; - } - } - - public int Priority - { - get - { - return 0; - } - } - - public bool IsSupported - { - get - { - return true; - } - } - - public ITouchPanel TouchPanel - { - get - { - if (touchPanel == null) - { - Logger.Info("Creating a new TouchPanel device."); - PreventSystemChange(); - touchPanel = InputDeviceFactory.Instance.GetDefaultTouchPanel(); - } - - return touchPanel; - } - } - - public IGamePad GamePad - { - get - { - if (gamePad == null) - { - Logger.Info("Creating a new GamePad device."); - PreventSystemChange(); - gamePad = InputDeviceFactory.Instance.CreateDefaultGamePad(); - } - - return gamePad; - } - } - - public IMouse Mouse - { - get - { - if (mouse == null) - { - mouse = InputDeviceFactory.Instance.CreateDefaultMouse(); - if (mouse == null) - throw new NoInputDeviceException("Couldn't find a default mouse device creator. Unable to create a mouse instance."); - - Logger.Info("created a new Mouse device"); - PreventSystemChange(); - } - - return this.mouse; - } - } - - public IKeyboard Keyboard - { - get - { - if (keyboard == null) - { - keyboard = InputDeviceFactory.Instance.CreateDefaultKeyboard(); - if (keyboard == null) - throw new NoInputDeviceException("Couldn't find a default keyboard device creator. Unable to create a keyboard instance."); - - Logger.Info("created a new Keyboard device"); - PreventSystemChange(); - } - - return this.keyboard; - } - } + public class Creator : IInputSystemCreator + { + private const string CreationLogMessage = "Creating a new {0} device."; + private const string CreationThrowMessage = + "Couldn't find a default {0} device creator. Unable to create a {0} instance."; #if XNAEXT - public IMotionSensingDevice MotionSensingDevice - { - get - { - Logger.Info("Creating a new MotionSensingDevice device."); - PreventSystemChange(); - return InputDeviceFactory.Instance.CreateDefaultMotionSensingDevice(); - } - } + private IMotionSensingDevice motionSensingDevice; +#endif + private IKeyboard keyboard; + private IMouse mouse; + private IGamePad gamePad; + private ITouchPanel touchPanel; + + public string Name + { + get { return "Standard"; } + } + + public int Priority + { + get { return 0; } + } + + public bool IsSupported + { + get { return true; } + } + + public ITouchPanel TouchPanel + { + get + { + if (touchPanel == null) + { + Logger.Info(string.Format(CreationLogMessage, "TouchPanel")); + PreventSystemChange(); + touchPanel = InputDeviceFactory.Instance.GetDefaultTouchPanel(); + if (touchPanel == null) + throw new NoInputDeviceException(string.Format(CreationThrowMessage, "touchPanel")); + } + + return touchPanel; + } + } + + public IGamePad GamePad + { + get + { + if (gamePad == null) + { + Logger.Info(string.Format(CreationLogMessage, "GamePad")); + PreventSystemChange(); + gamePad = InputDeviceFactory.Instance.CreateDefaultGamePad(); + if (gamePad == null) + throw new NoInputDeviceException(string.Format(CreationThrowMessage, "gamePad")); + } + + return gamePad; + } + } + + public IMouse Mouse + { + get + { + if (mouse == null) + { + Logger.Info(string.Format(CreationLogMessage, "Mouse")); + PreventSystemChange(); + mouse = InputDeviceFactory.Instance.CreateDefaultMouse(); + if (mouse == null) + throw new NoInputDeviceException(string.Format(CreationThrowMessage, "mouse")); + } + + return mouse; + } + } + + public IKeyboard Keyboard + { + get + { + if (keyboard == null) + { + Logger.Info(string.Format(CreationLogMessage, "Keyboard")); + PreventSystemChange(); + keyboard = InputDeviceFactory.Instance.CreateDefaultKeyboard(); + if (keyboard == null) + throw new NoInputDeviceException(string.Format(CreationThrowMessage, "keyboard")); + } + + return keyboard; + } + } + +#if XNAEXT + public IMotionSensingDevice MotionSensingDevice + { + get + { + if (motionSensingDevice == null) + { + Logger.Info(string.Format(CreationLogMessage, "MotionSensing")); + PreventSystemChange(); + motionSensingDevice = InputDeviceFactory.Instance.CreateDefaultMotionSensingDevice(); + if (motionSensingDevice == null) + throw new NoInputDeviceException(string.Format(CreationThrowMessage, "motionSensing")); + } + + return motionSensingDevice; + } + } #endif - private void PreventSystemChange() - { - AddInSystemFactory.Instance.PreventSystemChange(AddInType.InputSystem); - } - } + private static void PreventSystemChange() + { + AddInSystemFactory.Instance.PreventSystemChange(AddInType.InputSystem); + } + } } diff --git a/PlatformSystems/ANX.PlatformSystem.Linux/LinuxPlatformSystem.cs b/PlatformSystems/ANX.PlatformSystem.Linux/LinuxPlatformSystem.cs index 1bbb0e6d..4e639e74 100644 --- a/PlatformSystems/ANX.PlatformSystem.Linux/LinuxPlatformSystem.cs +++ b/PlatformSystems/ANX.PlatformSystem.Linux/LinuxPlatformSystem.cs @@ -64,7 +64,7 @@ namespace ANX.PlatformSystem.Linux #endregion #region CreateMediaPlayer (TODO) - public INativeMediaLibrary CreateMediaPlayer() + public INativeMediaLibrary CreateMediaLibrary() { throw new NotImplementedException(); } diff --git a/PlatformSystems/ANX.PlatformSystem.Metro/MetroPlatformSystem.cs b/PlatformSystems/ANX.PlatformSystem.Metro/MetroPlatformSystem.cs index 6e6859a8..1d27ead9 100644 --- a/PlatformSystems/ANX.PlatformSystem.Metro/MetroPlatformSystem.cs +++ b/PlatformSystems/ANX.PlatformSystem.Metro/MetroPlatformSystem.cs @@ -71,7 +71,7 @@ namespace ANX.PlatformSystem.Metro throw new NotImplementedException(); } - public INativeMediaLibrary CreateMediaPlayer() + public INativeMediaLibrary CreateMediaLibrary() { throw new NotImplementedException(); } diff --git a/PlatformSystems/ANX.PlatformSystem.PsVita/PsVitaPlatformCreator.cs b/PlatformSystems/ANX.PlatformSystem.PsVita/PsVitaPlatformCreator.cs index af01cea6..ee19d97a 100644 --- a/PlatformSystems/ANX.PlatformSystem.PsVita/PsVitaPlatformCreator.cs +++ b/PlatformSystems/ANX.PlatformSystem.PsVita/PsVitaPlatformCreator.cs @@ -67,7 +67,7 @@ namespace ANX.PlatformSystem.PsVita #endregion #region CreateMediaPlayer (TODO) - public INativeMediaLibrary CreateMediaPlayer() + public INativeMediaLibrary CreateMediaLibrary() { throw new NotImplementedException(); } diff --git a/PlatformSystems/ANX.PlatformSystem.Windows/WindowsPlatformSystem.cs b/PlatformSystems/ANX.PlatformSystem.Windows/WindowsPlatformSystem.cs index 65a9a097..3a12a618 100644 --- a/PlatformSystems/ANX.PlatformSystem.Windows/WindowsPlatformSystem.cs +++ b/PlatformSystems/ANX.PlatformSystem.Windows/WindowsPlatformSystem.cs @@ -64,7 +64,7 @@ namespace ANX.PlatformSystem.Windows #endregion #region CreateMediaPlayer (TODO) - public INativeMediaLibrary CreateMediaPlayer() + public INativeMediaLibrary CreateMediaLibrary() { throw new NotImplementedException(); }