[Agate-svn-commit] SF.net SVN: agate:[1537] trunk
Status: Alpha
Brought to you by:
kanato
From: <ka...@us...> - 2014-10-13 02:37:10
|
Revision: 1537 http://sourceforge.net/p/agate/code/1537 Author: kanato Date: 2014-10-13 02:36:59 +0000 (Mon, 13 Oct 2014) Log Message: ----------- Add ability to have multiple asset stores. Some fixes for windows metro/phone apps. Modified Paths: -------------- trunk/AgateLib/AgateLib.csproj trunk/AgateLib/ApplicationModels/ModelParameters.cs trunk/AgateLib/DisplayLib/Surface.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib/IO/FileProvider.cs trunk/AgateLib/Serialization/Xle/XleSerializer.cs trunk/AgateLib/UserInterface/Css/Rendering/CssRenderer.cs trunk/AgateLib.Platform.WinForms/AgateLib.Platform.WinForms.csproj trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs trunk/AgateLib.Platform.WindowsMetro/Factories/WinPlatformFactory.cs trunk/AgateLib.Platform.WindowsMetro/Factories/WindowsFactory.cs trunk/AgateLib.Platform.WindowsMetro/WindowsInitializer.cs trunk/AgateLib.Platform.WindowsPhone/Factories/WPPlatformFactory.cs trunk/AgateLib.Platform.WindowsPhone/Factories/WindowsPhoneFactory.cs trunk/AgateLib.Platform.WindowsPhone/WindowsPhoneInitializer.cs trunk/AgateLib.Platform.WindowsStoreCommon/AgateLib.Platform.WindowsStoreCommon.csproj trunk/AgateLib.Platform.WindowsStoreCommon/AudioImplementation/XAudio2_Music.cs trunk/AgateLib.Platform.WindowsStoreCommon/DisplayImplementation/SDX_Surface.cs trunk/AgateLib.Platform.WindowsStoreCommon/Factories/DisplayFactory.cs trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStoreAssetFileProvider.cs trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs trunk/AgateLib.Tests/Tests.WinForms/DisplayTests/SpriteTester/frmSpriteTester.cs trunk/AgateLib.Tests/Tests.WindowsMetro/TestContainer.xaml.cs trunk/AgateLib.Tests/Tests.WindowsPhone/TestContainer.xaml.cs trunk/AgateLib.Tests/UnitTests/Resources/SerializationTest.cs trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssLayoutTest.cs trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssParseTest.cs trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssTestBase.cs Added Paths: ----------- trunk/AgateLib/IO/AssetLocations.cs trunk/AgateLib/IO/Assets.cs trunk/AgateLib/IO/ReadFileProviderList.cs trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/AgateConsoleImpl.cs trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/IsolatedStorageFileProvider.cs Removed Paths: ------------- trunk/AgateLib/ApplicationModels/AssetLocations.cs trunk/AgateLib.Platform.WinForms/IO/FileProviderList.cs Modified: trunk/AgateLib/AgateLib.csproj =================================================================== --- trunk/AgateLib/AgateLib.csproj 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/AgateLib.csproj 2014-10-13 02:36:59 UTC (rev 1537) @@ -68,6 +68,8 @@ <Compile Include="InputLib\GamepadMap.cs" /> <Compile Include="InputLib\GamepadMapDatabase.cs" /> <Compile Include="InputLib\GamepadStickEventArgs.cs" /> + <Compile Include="IO\Assets.cs" /> + <Compile Include="IO\ReadFileProviderList.cs" /> <Compile Include="Mathematics\MathHelper.cs" /> <Compile Include="Algorithms\PathFinding\IAStarMap.cs" /> <Compile Include="Algorithms\Pair.cs" /> @@ -75,7 +77,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="ApplicationModels\AgateAppModel.cs" /> - <Compile Include="ApplicationModels\AssetLocations.cs" /> + <Compile Include="IO\AssetLocations.cs" /> <Compile Include="Geometry\CoordinateSystems\FixedAspectRatioCoordinates.cs" /> <Compile Include="Geometry\ICoordinateSystemCreator.cs" /> <Compile Include="ApplicationModels\ModelParameters.cs" /> Deleted: trunk/AgateLib/ApplicationModels/AssetLocations.cs =================================================================== --- trunk/AgateLib/ApplicationModels/AssetLocations.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/ApplicationModels/AssetLocations.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -1,63 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AgateLib.ApplicationModels -{ - /// <summary> - /// Structure which indicates where various assets are stored. - /// </summary> - public class AssetLocations - { - public AssetLocations() - { - Path = "."; - } - - /// <summary> - /// Path prefix to load surfaces from. - /// </summary> - public string Surfaces { get; set; } - /// <summary> - /// Path prefix to load sound effects from. - /// </summary> - public string Sound { get; set; } - /// <summary> - /// Path prefix to load music files from. - /// </summary> - public string Music { get; set; } - /// <summary> - /// Path prefix to load resource files from. - /// </summary> - public string Resources { get; set; } - /// <summary> - /// Path prefix to load user interface files from. - /// </summary> - public string UserInterface { get; set; } - - /// <summary> - /// Root path used to load all assets. - /// </summary> - public string Path { get; set; } - } -} Modified: trunk/AgateLib/ApplicationModels/ModelParameters.cs =================================================================== --- trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/ApplicationModels/ModelParameters.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -18,6 +18,7 @@ // using AgateLib.Geometry; using AgateLib.Geometry.CoordinateSystems; +using AgateLib.IO; using AgateLib.Platform; using System; using System.Collections.Generic; Modified: trunk/AgateLib/DisplayLib/Surface.cs =================================================================== --- trunk/AgateLib/DisplayLib/Surface.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/DisplayLib/Surface.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -91,7 +91,7 @@ throw new ArgumentNullException("You must supply a file name."); if (fileprovider == null) - fileprovider = AgateLib.IO.FileProvider.SurfaceAssets; + fileprovider = AgateLib.IO.Assets.Surfaces; mImpl = Core.Factory.DisplayFactory.CreateSurface(fileprovider, filename); Modified: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -38,6 +38,9 @@ IEnumerable<System.Reflection.Assembly> GetSerializationSearchAssemblies(Type objectType); + /// <summary> + /// Gets a file provider which points to the application directory. + /// </summary> IReadFileProvider AssetFileProvider { get; } IPlatformSerialization CreateDefaultSerializationConstructor(); Copied: trunk/AgateLib/IO/AssetLocations.cs (from rev 1534, trunk/AgateLib/ApplicationModels/AssetLocations.cs) =================================================================== --- trunk/AgateLib/IO/AssetLocations.cs (rev 0) +++ trunk/AgateLib/IO/AssetLocations.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -0,0 +1,65 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.IO +{ + /// <summary> + /// Structure which indicates where various assets are stored. + /// </summary> + public class AssetLocations + { + public AssetLocations() + { + Path = "."; + } + + /// <summary> + /// Path prefix to load surfaces from. + /// </summary> + public string Surfaces { get; set; } + /// <summary> + /// Path prefix to load sound effects from. + /// </summary> + public string Sound { get; set; } + /// <summary> + /// Path prefix to load music files from. + /// </summary> + public string Music { get; set; } + /// <summary> + /// Path prefix to load resource files from. + /// </summary> + public string Resources { get; set; } + /// <summary> + /// Path prefix to load user interface files from. + /// </summary> + public string UserInterface { get; set; } + + /// <summary> + /// Root path used to load all assets. + /// </summary> + public string Path { get; set; } + + public AssetLocations ExtraAssets { get; set; } + } +} Added: trunk/AgateLib/IO/Assets.cs =================================================================== --- trunk/AgateLib/IO/Assets.cs (rev 0) +++ trunk/AgateLib/IO/Assets.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -0,0 +1,184 @@ +using AgateLib.ApplicationModels; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.IO +{ + public static class Assets + { + static IReadFileProvider mAssetProvider; + static IReadFileProvider mSurfaces; + static IReadFileProvider mResources; + static IReadFileProvider mMusic; + static IReadFileProvider mSounds; + static IReadFileProvider mUserInterfaceAssets; + + public static void AddAssetLocations(IReadFileProvider ap, AssetLocations assetLocations) + { + // check for circular reference + VerifyNoncircular(assetLocations); + + var assetProvider = NewProviderFromSubdirectory(ap, assetLocations.Path); + var surfaces = NewProviderFromSubdirectory(assetProvider, assetLocations.Surfaces); + var sounds = NewProviderFromSubdirectory(assetProvider, assetLocations.Sound); + var music = NewProviderFromSubdirectory(assetProvider, assetLocations.Music); + var resources = NewProviderFromSubdirectory(assetProvider, assetLocations.Resources); + var userInterfaceAssets = NewProviderFromSubdirectory(assetProvider, assetLocations.UserInterface); + + AddOrCombine(ref mAssetProvider, assetProvider); + AddOrCombine(ref mSurfaces, surfaces); + AddOrCombine(ref mResources, resources); + AddOrCombine(ref mMusic, music); + AddOrCombine(ref mSounds, sounds); + AddOrCombine(ref mUserInterfaceAssets, userInterfaceAssets); + + if (assetLocations.ExtraAssets != null) + { + AddAssetLocations(ap, assetLocations.ExtraAssets); + } + } + + private static void VerifyNoncircular(AssetLocations al) + { + List<AssetLocations> examined = new List<AssetLocations>(); + + while (al.ExtraAssets != null) + { + if (examined.Contains(al)) + throw new AgateException("AssetLocations passed contains circular references."); + + examined.Add(al); + al = al.ExtraAssets; + } + } + + private static void AddOrCombine(ref IReadFileProvider storage, IReadFileProvider provider) + { + if (storage == null) + storage = provider; + else if (storage is ReadFileProviderList) + { + var rfpl = (ReadFileProviderList)storage; + + rfpl.Add(provider); + } + else + { + var rfpl = new ReadFileProviderList(); + + rfpl.Add(storage); + rfpl.Add(provider); + + storage = rfpl; + } + } + + static IReadFileProvider NewProviderFromSubdirectory(IReadFileProvider parent, string subdir) + { + if (string.IsNullOrWhiteSpace(subdir) || subdir == ".") + return parent; + + return new SubdirectoryProvider(parent, subdir); + } + + internal static IReadFileProvider AssetProvider { get { return mAssetProvider; } set { mAssetProvider = value; } } + public static IReadFileProvider Surfaces { get { return mSurfaces; } set { mSurfaces = value; } } + public static IReadFileProvider Resources { get { return mResources; } set { mResources = value; } } + public static IReadFileProvider Music { get { return mMusic; } set { mMusic = value; } } + public static IReadFileProvider Sounds { get { return mSounds; } set { mSounds = value; } } + public static IReadFileProvider UserInterfaceAssets { get { return mUserInterfaceAssets; } set { mUserInterfaceAssets = value; } } + + /// <summary> + /// Opens the specified file returning a stream. Throws + /// FileNotFoundException if the file does not exist. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + public static Task<Stream> OpenReadAsync(string filename) + { + return mAssetProvider.OpenReadAsync(filename); + } + + /// <summary> + /// Opens the specified file returning a stream. Throws + /// FileNotFoundException if the file does not exist. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + public static Stream OpenRead(string filename) + { + return mAssetProvider.OpenRead(filename); + } + /// <summary> + /// Checks to if the specified file exists in the file provider. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + public static bool FileExists(string filename) + { + return mAssetProvider.FileExists(filename); + } + + /// <summary> + /// Enumerates through all existing filenames in the file provider. + /// </summary> + /// <returns></returns> + public static IEnumerable<string> GetAllFiles() + { + return mAssetProvider.GetAllFiles(); + } + + /// <summary> + /// Enumerates through all filenames which match the specified search pattern. + /// </summary> + /// <remarks>The search pattern is not regex style pattern matching, rather it should + /// be bash pattern matching, so a searchPattern of "*" would match all files, and + /// "*.*" would match all filenames with a period in them.</remarks> + /// <param name="searchPattern"></param> + /// <returns></returns> + public static IEnumerable<string> GetAllFiles(string searchPattern) + { + return mAssetProvider.GetAllFiles(searchPattern); + } + /// <summary> + /// Returns a string containing the entire contents of the specified file. + /// </summary> + /// <param name="filename">The path and filename of the file to read from.</param> + /// <returns></returns> + public static string ReadAllText(string filename) + { + return mAssetProvider.ReadAllText(filename); + } + + /// <summary> + /// Returns true if the specified filename points to an actual file on disk. + /// If this method returns false, then ResolveFile will throw an exception + /// for that file. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + public static bool IsRealFile(string filename) + { + return mAssetProvider.IsRealFile(filename); + } + + /// <summary> + /// Returns the full path of the given filename. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + public static string ResolveFile(string filename) + { + return mAssetProvider.ResolveFile(filename); + } + + /// <summary> + /// Returns true if the file system is not a physical file system. + /// </summary> + public static bool IsLogicalFilesystem { get { return mAssetProvider.IsLogicalFilesystem; } } + } +} Modified: trunk/AgateLib/IO/FileProvider.cs =================================================================== --- trunk/AgateLib/IO/FileProvider.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/IO/FileProvider.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -29,32 +29,25 @@ { public static void Initialize(IReadFileProvider assetProvider, AssetLocations assetLocations) { - Assets = assetProvider; - - SurfaceAssets = NewProviderFromSubdirectory(Assets, assetLocations.Surfaces); - SoundAssets = NewProviderFromSubdirectory(Assets, assetLocations.Sound); - MusicAssets = NewProviderFromSubdirectory(Assets, assetLocations.Music); - ResourceAssets = NewProviderFromSubdirectory(Assets, assetLocations.Resources); - UserInterfaceAssets = NewProviderFromSubdirectory(Assets, assetLocations.UserInterface); + AgateLib.IO.Assets.AddAssetLocations(assetProvider, assetLocations); } - public static IReadFileProvider Assets { get; set; } + [Obsolete("Use AgateLib.IO.Assets instead.")] + public static IReadFileProvider Assets { get { return AgateLib.IO.Assets.AssetProvider; } } - public static IReadFileProvider SurfaceAssets { get; set; } - public static IReadFileProvider ResourceAssets { get; set; } - public static IReadFileProvider MusicAssets { get; set; } - public static IReadFileProvider SoundAssets { get; set; } - public static IReadFileProvider UserInterfaceAssets { get; set; } + [Obsolete("Use AgateLib.IO.Assets.Surfaces instead.")] + public static IReadFileProvider SurfaceAssets { get { return AgateLib.IO.Assets.Surfaces; } } + [Obsolete("Use AgateLib.IO.Assets.Resources instead.")] + public static IReadFileProvider ResourceAssets { get { return AgateLib.IO.Assets.Resources; } } + [Obsolete("Use AgateLib.IO.Assets.Music instead.")] + public static IReadFileProvider MusicAssets { get { return AgateLib.IO.Assets.Music; } } + [Obsolete("Use AgateLib.IO.Assets.Sounds instead.")] + public static IReadFileProvider SoundAssets { get { return AgateLib.IO.Assets.Sounds; } } + [Obsolete("Use AgateLib.IO.Assets.UserInterfaceAssets instead.")] + public static IReadFileProvider UserInterfaceAssets { get { return AgateLib.IO.Assets.UserInterfaceAssets; } } public static IReadWriteFileProvider UserFiles { get; set; } - static IReadFileProvider NewProviderFromSubdirectory(IReadFileProvider parent, string subdir) - { - if (string.IsNullOrWhiteSpace(subdir) || subdir == ".") - return parent; - return new SubdirectoryProvider(parent, subdir); - } - } } Copied: trunk/AgateLib/IO/ReadFileProviderList.cs (from rev 1534, trunk/AgateLib.Platform.WinForms/IO/FileProviderList.cs) =================================================================== --- trunk/AgateLib/IO/ReadFileProviderList.cs (rev 0) +++ trunk/AgateLib/IO/ReadFileProviderList.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -0,0 +1,310 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.1 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is AgateLib. +// +// The Initial Developer of the Original Code is Erik Ylvisaker. +// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. +// All Rights Reserved. +// +// Contributor(s): Erik Ylvisaker +// +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Threading.Tasks; + +namespace AgateLib.IO +{ + /// <summary> + /// Contains a list of IFileProvider objects that are used to search for + /// and open files. + /// </summary> + public class ReadFileProviderList : IList<IReadFileProvider>, IReadFileProvider + { + List<IReadFileProvider> mProviders = new List<IReadFileProvider>(); + + /// <summary> + /// Returns the IFileProvider object which would return the specified + /// file when OpenRead is called. Throws a FileNotFoundException if the file is not available. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + public IReadFileProvider GetProvider(string filename) + { + for (int i = mProviders.Count - 1; i >= 0; i--) + { + if (mProviders[i].FileExists(filename)) + return mProviders[i]; + } + + throw new FileNotFoundException(string.Format( + "Could not find the file {0}.", filename)); + } + /// <summary> + /// Opens a specified file by searching backwards through the list of + /// providers until a matching filename is found. A FileNotFoundException + /// is thrown if the file does not exist. + /// </summary> + /// <param name="filename">The filename to search for.</param> + /// <returns></returns> + public async Task<Stream> OpenReadAsync(string filename) + { + if (string.IsNullOrEmpty(filename)) + throw new ArgumentNullException("You must supply a file name."); + + for (int i = mProviders.Count - 1; i >= 0; i--) + { + if (mProviders[i].FileExists(filename)) + { + return await mProviders[i].OpenReadAsync(filename); + } + } + + throw new FileNotFoundException(string.Format( + "Could not find the file {0}.", filename)); + } + + + + public bool IsRealFile(string filename) + { + if (string.IsNullOrEmpty(filename)) + throw new ArgumentNullException("You must supply a file name."); + + for (int i = mProviders.Count - 1; i >= 0; i--) + { + if (mProviders[i].FileExists(filename)) + { + return mProviders[i].IsRealFile(filename); + } + } + + throw new FileNotFoundException(string.Format( + "Could not find the file {0}.", filename)); + } + + public string ResolveFile(string filename) + { + if (string.IsNullOrEmpty(filename)) + throw new ArgumentNullException("You must supply a file name."); + + for (int i = mProviders.Count - 1; i >= 0; i--) + { + if (mProviders[i].FileExists(filename)) + { + return mProviders[i].ResolveFile(filename); + } + } + + throw new FileNotFoundException(string.Format( + "Could not find the file {0}.", filename)); + } + + /// <summary> + /// Returns all filenames matching the specified filter in + /// all file providers. + /// </summary> + /// <param name="filter"></param> + /// <returns></returns> + public IEnumerable<string> GetAllFiles(string filter) + { + for (int i = mProviders.Count - 1; i >= 0; i--) + { + foreach (string files in mProviders[i].GetAllFiles(filter)) + yield return files; + } + } + /// <summary> + /// Returns all filenames in all file providers. + /// </summary> + /// <returns></returns> + public IEnumerable<string> GetAllFiles() + { + for (int i = mProviders.Count - 1; i >= 0; i--) + { + foreach (string files in mProviders[i].GetAllFiles()) + yield return files; + } + } + + /// <summary> + /// Returns true if the specified file exists in a file provider. + /// </summary> + /// <param name="filename"></param> + /// <returns></returns> + public bool FileExists(string filename) + { + for (int i = mProviders.Count - 1; i >= 0; i--) + { + if (mProviders[i].FileExists(filename)) + return true; + } + + return false; + } + + #region IList<IFileProvider> Members + + /// <summary> + /// Returns the index of the specified IFileProvider. + /// </summary> + /// <param name="item"></param> + /// <returns></returns> + public int IndexOf(IReadFileProvider item) + { + return mProviders.IndexOf(item); + } + + /// <summary> + /// Insers an IFileProvider into the list. + /// </summary> + /// <param name="index"></param> + /// <param name="item"></param> + public void Insert(int index, IReadFileProvider item) + { + if (item is ReadFileProviderList) + { + if (item == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); + } + + mProviders.Insert(index, item); + } + /// <summary> + /// Removes an IFileProvider from the list. + /// </summary> + /// <param name="index"></param> + public void RemoveAt(int index) + { + mProviders.RemoveAt(index); + } + /// <summary> + /// Gets or sets the IFileProvider at the specified location. + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + public IReadFileProvider this[int index] + { + get + { + return mProviders[index]; + } + set + { + if (value is ReadFileProviderList) + { + if (value == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); + } + + mProviders[index] = value; + } + } + + #endregion + #region ICollection<IFileProvider> Members + + /// <summary> + /// Adds an IFileProvider to the list. + /// </summary> + /// <param name="item"></param> + public void Add(IReadFileProvider item) + { + if (item is ReadFileProviderList) + { + if (item == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); + } + mProviders.Add(item); + } + /// <summary> + /// Clears the list. + /// </summary> + public void Clear() + { + mProviders.Clear(); + } + /// <summary> + /// Returns true if the list contains the specified IFileProvider. + /// </summary> + /// <param name="item"></param> + /// <returns></returns> + public bool Contains(IReadFileProvider item) + { + return mProviders.Contains(item); + } + + void ICollection<IReadFileProvider>.CopyTo(IReadFileProvider[] array, int arrayIndex) + { + mProviders.CopyTo(array, arrayIndex); + } + /// <summary> + /// Gets the number of items in the list. + /// </summary> + public int Count + { + get { return mProviders.Count; } + } + /// <summary> + /// Always returns false. + /// </summary> + public bool IsReadOnly + { + get { return false; } + } + /// <summary> + /// Removes an IFileProvider from the list. + /// </summary> + /// <param name="item"></param> + /// <returns></returns> + public bool Remove(IReadFileProvider item) + { + return mProviders.Remove(item); + } + + #endregion + #region IEnumerable<IFileProvider> Members + + /// <summary> + /// Enumerates items. + /// </summary> + /// <returns></returns> + public IEnumerator<IReadFileProvider> GetEnumerator() + { + return mProviders.GetEnumerator(); + } + + #endregion + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + /// <summary> + /// Returns a string containing all the text in the specified file. + /// </summary> + /// <param name="filename">The name of the file to read from.</param> + /// <returns></returns> + public string ReadAllText(string filename) + { + Stream s = OpenReadAsync(filename).Result; + + return new StreamReader(s).ReadToEnd(); + } + + public bool IsLogicalFilesystem + { + get { return true; } + } + } +} Modified: trunk/AgateLib/Serialization/Xle/XleSerializer.cs =================================================================== --- trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/Serialization/Xle/XleSerializer.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -60,7 +60,7 @@ public XleSerializer(Type objectType, IPlatformSerialization objectConstructor = null) { if (objectConstructor == null) - objectConstructor = Core.Factory.PlatformFactory.CreateDefaultSerializationConstructor(); + objectConstructor = new AgateLib.Platform.Common.PlatformImplementation.PlatformSerialization();// Core.Factory.PlatformFactory.CreateDefaultSerializationConstructor(); ObjectConstructor = objectConstructor; Modified: trunk/AgateLib/UserInterface/Css/Rendering/CssRenderer.cs =================================================================== --- trunk/AgateLib/UserInterface/Css/Rendering/CssRenderer.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib/UserInterface/Css/Rendering/CssRenderer.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -153,7 +153,7 @@ #endregion; - public bool InTransition { get; private set;} + public bool InTransition { get; private set; } public void Draw() { @@ -176,6 +176,8 @@ { if (anim.Style.Data.Overflow == CssOverflow.Visible) return false; + if (anim.ClientRect.Width == 0 || anim.ClientRect.Height == 0) + return true; Rectangle clipRect = anim.ClientToScreen(new Rectangle(0, 0, anim.ClientRect.Width, anim.ClientRect.Height)); @@ -187,6 +189,12 @@ { bool clipping = false; + if (anim.Style.Data.Overflow != CssOverflow.Visible && + (anim.ClientRect.Width == 0 || anim.ClientRect.Height == 0)) + { + return; + } + try { clipping = PushClipRect(anim); Modified: trunk/AgateLib.Platform.WinForms/AgateLib.Platform.WinForms.csproj =================================================================== --- trunk/AgateLib.Platform.WinForms/AgateLib.Platform.WinForms.csproj 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WinForms/AgateLib.Platform.WinForms.csproj 2014-10-13 02:36:59 UTC (rev 1537) @@ -131,7 +131,6 @@ <DependentUpon>frmGuiDebug.cs</DependentUpon> </Compile> <Compile Include="PixelBufferExtensions.cs" /> - <Compile Include="IO\FileProviderList.cs" /> <Compile Include="IO\FileSystemProvider.cs" /> <Compile Include="PlatformImplementation\FormsPlatformInfo.cs" /> <Compile Include="IO\TgzFileProvider.cs" /> Modified: trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -2,6 +2,7 @@ using AgateLib.ApplicationModels; using AgateLib.DisplayLib; using AgateLib.Drivers; +using AgateLib.IO; using AgateLib.Platform.WinForms.Resources; using System; using System.Collections.Generic; Modified: trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -27,7 +27,7 @@ public IReadFileProvider AssetFileProvider { get; private set; } - public void SetAssetLocations(AgateLib.ApplicationModels.AssetLocations assetLocations) + public void SetAssetLocations(AssetLocations assetLocations) { AssetFileProvider = new FileSystemProvider(System.IO.Path.GetFullPath(assetLocations.Path)); } Deleted: trunk/AgateLib.Platform.WinForms/IO/FileProviderList.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/IO/FileProviderList.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WinForms/IO/FileProviderList.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -1,318 +0,0 @@ -// The contents of this file are subject to the Mozilla Public License -// Version 1.1 (the "License"); you may not use this file except in -// compliance with the License. You may obtain a copy of the License at -// http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" -// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -// License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is AgateLib. -// -// The Initial Developer of the Original Code is Erik Ylvisaker. -// Portions created by Erik Ylvisaker are Copyright (C) 2006-2014. -// All Rights Reserved. -// -// Contributor(s): Erik Ylvisaker -// -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Threading.Tasks; - -namespace AgateLib.Platform.WinForms.IO -{ - /// <summary> - /// Contains a list of IFileProvider objects that are used to search for - /// and open files. - /// </summary> - public class FileProviderList : IList<IReadFileProvider>, IReadFileProvider - { - List<IReadFileProvider> mProviders = new List<IReadFileProvider>(); - - /// <summary> - /// Returns the IFileProvider object which would return the specified - /// file when OpenRead is called. Throws a FileNotFoundException if the file is not available. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - public IReadFileProvider GetProvider(string filename) - { - for (int i = mProviders.Count - 1; i >= 0; i--) - { - if (mProviders[i].FileExists(filename)) - return mProviders[i]; - } - - throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename)); - } - /// <summary> - /// Opens a specified file by searching backwards through the list of - /// providers until a matching filename is found. A FileNotFoundException - /// is thrown if the file does not exist. - /// </summary> - /// <param name="filename">The filename to search for.</param> - /// <returns></returns> - public async Task<Stream> OpenReadAsync(string filename) - { - if (string.IsNullOrEmpty(filename)) - throw new ArgumentNullException("You must supply a file name."); - - for (int i = mProviders.Count - 1; i >= 0; i--) - { - if (mProviders[i].FileExists(filename)) - { - return await mProviders[i].OpenReadAsync(filename); - } - } - - throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename)); - } - - - - public bool IsRealFile(string filename) - { - if (string.IsNullOrEmpty(filename)) - throw new ArgumentNullException("You must supply a file name."); - - for (int i = mProviders.Count - 1; i >= 0; i--) - { - if (mProviders[i].FileExists(filename)) - { - return mProviders[i].IsRealFile(filename); - } - } - - throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename)); - } - - public string ResolveFile(string filename) - { - if (string.IsNullOrEmpty(filename)) - throw new ArgumentNullException("You must supply a file name."); - - for (int i = mProviders.Count - 1; i >= 0; i--) - { - if (mProviders[i].FileExists(filename)) - { - return mProviders[i].ResolveFile(filename); - } - } - - throw new FileNotFoundException(string.Format( - "Could not find the file {0}.", filename)); - } - - /// <summary> - /// Returns all filenames matching the specified filter in - /// all file providers. - /// </summary> - /// <param name="filter"></param> - /// <returns></returns> - public IEnumerable<string> GetAllFiles(string filter) - { - for (int i = mProviders.Count - 1; i >= 0; i--) - { - foreach (string files in mProviders[i].GetAllFiles(filter)) - yield return files; - } - } - /// <summary> - /// Returns all filenames in all file providers. - /// </summary> - /// <returns></returns> - public IEnumerable<string> GetAllFiles() - { - for (int i = mProviders.Count - 1; i >= 0; i--) - { - foreach (string files in mProviders[i].GetAllFiles()) - yield return files; - } - } - - /// <summary> - /// Returns true if the specified file exists in a file provider. - /// </summary> - /// <param name="filename"></param> - /// <returns></returns> - public bool FileExists(string filename) - { - for (int i = mProviders.Count - 1; i >= 0; i--) - { - if (mProviders[i].FileExists(filename)) - return true; - } - - return false; - } - /// <summary> - /// Adds a path in the filesystem to the list of locations to search when opening a file. - /// </summary> - /// <param name="path"></param> - public void AddPath(string path) - { - Add(new FileSystemProvider(path)); - } - - #region IList<IFileProvider> Members - - /// <summary> - /// Returns the index of the specified IFileProvider. - /// </summary> - /// <param name="item"></param> - /// <returns></returns> - public int IndexOf(IReadFileProvider item) - { - return mProviders.IndexOf(item); - } - - /// <summary> - /// Insers an IFileProvider into the list. - /// </summary> - /// <param name="index"></param> - /// <param name="item"></param> - public void Insert(int index, IReadFileProvider item) - { - if (item is FileProviderList) - { - if (item == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); - } - - mProviders.Insert(index, item); - } - /// <summary> - /// Removes an IFileProvider from the list. - /// </summary> - /// <param name="index"></param> - public void RemoveAt(int index) - { - mProviders.RemoveAt(index); - } - /// <summary> - /// Gets or sets the IFileProvider at the specified location. - /// </summary> - /// <param name="index"></param> - /// <returns></returns> - public IReadFileProvider this[int index] - { - get - { - return mProviders[index]; - } - set - { - if (value is FileProviderList) - { - if (value == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); - } - - mProviders[index] = value; - } - } - - #endregion - #region ICollection<IFileProvider> Members - - /// <summary> - /// Adds an IFileProvider to the list. - /// </summary> - /// <param name="item"></param> - public void Add(IReadFileProvider item) - { - if (item is FileProviderList) - { - if (item == this) throw new ArgumentException("Cannot add a FileProviderList to itself!"); - } - mProviders.Add(item); - } - /// <summary> - /// Clears the list. - /// </summary> - public void Clear() - { - mProviders.Clear(); - } - /// <summary> - /// Returns true if the list contains the specified IFileProvider. - /// </summary> - /// <param name="item"></param> - /// <returns></returns> - public bool Contains(IReadFileProvider item) - { - return mProviders.Contains(item); - } - - void ICollection<IReadFileProvider>.CopyTo(IReadFileProvider[] array, int arrayIndex) - { - mProviders.CopyTo(array, arrayIndex); - } - /// <summary> - /// Gets the number of items in the list. - /// </summary> - public int Count - { - get { return mProviders.Count; } - } - /// <summary> - /// Always returns false. - /// </summary> - public bool IsReadOnly - { - get { return false; } - } - /// <summary> - /// Removes an IFileProvider from the list. - /// </summary> - /// <param name="item"></param> - /// <returns></returns> - public bool Remove(IReadFileProvider item) - { - return mProviders.Remove(item); - } - - #endregion - #region IEnumerable<IFileProvider> Members - - /// <summary> - /// Enumerates items. - /// </summary> - /// <returns></returns> - public IEnumerator<IReadFileProvider> GetEnumerator() - { - return mProviders.GetEnumerator(); - } - - #endregion - #region IEnumerable Members - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - #endregion - - /// <summary> - /// Returns a string containing all the text in the specified file. - /// </summary> - /// <param name="filename">The name of the file to read from.</param> - /// <returns></returns> - public string ReadAllText(string filename) - { - Stream s = OpenReadAsync(filename).Result; - - return new StreamReader(s).ReadToEnd(); - } - - public bool IsLogicalFilesystem - { - get { return true; } - } - } -} Modified: trunk/AgateLib.Platform.WindowsMetro/Factories/WinPlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsMetro/Factories/WinPlatformFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsMetro/Factories/WinPlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using AgateLib.ApplicationModels; +using AgateLib.IO; namespace AgateLib.Platform.WindowsMetro.Factories { Modified: trunk/AgateLib.Platform.WindowsMetro/Factories/WindowsFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsMetro/Factories/WindowsFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsMetro/Factories/WindowsFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -2,6 +2,7 @@ using AgateLib.DisplayLib; using AgateLib.Drivers; using AgateLib.Drivers.NullDrivers; +using AgateLib.IO; using AgateLib.Platform.WindowsStore; using AgateLib.Platform.WindowsStore.Factories; using SharpDX.SimpleInitializer; Modified: trunk/AgateLib.Platform.WindowsMetro/WindowsInitializer.cs =================================================================== --- trunk/AgateLib.Platform.WindowsMetro/WindowsInitializer.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsMetro/WindowsInitializer.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -4,6 +4,7 @@ using SharpDX.SimpleInitializer; using System; using AgateLib.Platform.WindowsMetro.Factories; +using AgateLib.IO; namespace AgateLib.Platform.WindowsMetro { Modified: trunk/AgateLib.Platform.WindowsPhone/Factories/WPPlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsPhone/Factories/WPPlatformFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsPhone/Factories/WPPlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using AgateLib.ApplicationModels; +using AgateLib.IO; namespace AgateLib.Platform.WindowsPhone.Factories { Modified: trunk/AgateLib.Platform.WindowsPhone/Factories/WindowsPhoneFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsPhone/Factories/WindowsPhoneFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsPhone/Factories/WindowsPhoneFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -2,6 +2,7 @@ using AgateLib.DisplayLib; using AgateLib.Drivers; using AgateLib.Drivers.NullDrivers; +using AgateLib.IO; using AgateLib.Platform.WindowsStore; using AgateLib.Platform.WindowsStore.Factories; using SharpDX.SimpleInitializer; Modified: trunk/AgateLib.Platform.WindowsPhone/WindowsPhoneInitializer.cs =================================================================== --- trunk/AgateLib.Platform.WindowsPhone/WindowsPhoneInitializer.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsPhone/WindowsPhoneInitializer.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -4,6 +4,7 @@ using SharpDX.SimpleInitializer; using System; using AgateLib.Platform.WindowsPhone.Factories; +using AgateLib.IO; namespace AgateLib.Platform.WindowsPhone { Modified: trunk/AgateLib.Platform.WindowsStoreCommon/AgateLib.Platform.WindowsStoreCommon.csproj =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/AgateLib.Platform.WindowsStoreCommon.csproj 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/AgateLib.Platform.WindowsStoreCommon.csproj 2014-10-13 02:36:59 UTC (rev 1537) @@ -100,7 +100,9 @@ <Compile Include="Factories\FakePath.cs" /> <Compile Include="Interop.cs" /> <Compile Include="IRenderTargetAdapter.cs" /> + <Compile Include="PlatformImplementation\AgateConsoleImpl.cs" /> <Compile Include="PlatformImplementation\DiagnosticsStopwatch.cs" /> + <Compile Include="PlatformImplementation\IsolatedStorageFileProvider.cs" /> <Compile Include="PlatformImplementation\WindowsStoreAssetFileProvider.cs" /> <Compile Include="PlatformImplementation\WindowsStorePlatformFactory.cs" /> <Compile Include="PlatformImplementation\WindowsStorePlatformInfo.cs" /> Modified: trunk/AgateLib.Platform.WindowsStoreCommon/AudioImplementation/XAudio2_Music.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/AudioImplementation/XAudio2_Music.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/AudioImplementation/XAudio2_Music.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -188,50 +188,44 @@ * */ public override void Dispose() { - throw new NotImplementedException(); } public override bool IsPlaying { - get { throw new NotImplementedException(); } + get { return false; } } protected override void OnSetLoop(bool value) { - throw new NotImplementedException(); } public override double Pan { get { - throw new NotImplementedException(); + return 0; } set { - throw new NotImplementedException(); } } public override void Play() { - throw new NotImplementedException(); } public override void Stop() { - throw new NotImplementedException(); } public override double Volume { get { - throw new NotImplementedException(); + return 1; } set { - throw new NotImplementedException(); } } } Modified: trunk/AgateLib.Platform.WindowsStoreCommon/DisplayImplementation/SDX_Surface.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/DisplayImplementation/SDX_Surface.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/DisplayImplementation/SDX_Surface.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -36,6 +36,7 @@ using Windows.UI.Core; using Windows.Graphics.Imaging; using Windows.Storage; +using System.Threading.Tasks; namespace AgateLib.Platform.WindowsStore.DisplayImplementation { @@ -48,6 +49,7 @@ SharpDX.Direct3D11.ShaderResourceView mTextureView; bool mIsLoaded; + IReadFileProvider mFileProvider; string mFileName; Rectangle mSrcRect; @@ -99,9 +101,10 @@ mDisplay = Display.Impl as SDX_Display; } - public SDX_Surface(string fileName) + public SDX_Surface(IReadFileProvider fileProvider, string fileName) : this() { + mFileProvider = fileProvider; mFileName = fileName; if (mDevice == null) @@ -200,14 +203,17 @@ var window = SDX_Display.MainThreadCoreWindow; - await window.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => - { - //var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(mFileName)); - //var sourceStream = await file.OpenStreamForReadAsync(); - var sourceStream = new NativeFileStream(mFileName, NativeFileMode.Open, NativeFileAccess.Read); + await window.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => await LoadFromFileDispatch()); + } + + private async Task LoadFromFileDispatch() + { + //var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(mFileName)); + //var sourceStream = await file.OpenStreamForReadAsync(); + //var sourceStream = new NativeFileStream(mFileName, NativeFileMode.Open, NativeFileAccess.Read); + var sourceStream = await mFileProvider.OpenReadAsync(mFileName); - ReadFromStream(sourceStream, true); - }); + ReadFromStream(sourceStream, true); } /// <summary> Modified: trunk/AgateLib.Platform.WindowsStoreCommon/Factories/DisplayFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/Factories/DisplayFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/Factories/DisplayFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -38,9 +38,9 @@ { return new SDX_DisplayWindow(owner, windowParams, RenderTargetAdapter); } - public SurfaceImpl CreateSurface(IReadFileProvider provider, string fileName) + public SurfaceImpl CreateSurface(IReadFileProvider provider, string filename) { - return new SDX_Surface(provider.ResolveFile(fileName)); + return new SDX_Surface(provider, filename); } public SurfaceImpl CreateSurface(Size surfaceSize) { Added: trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/AgateConsoleImpl.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/AgateConsoleImpl.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/AgateConsoleImpl.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -0,0 +1,24 @@ +using AgateLib.Diagnostics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AgateLib.Platform.WindowsStore.PlatformImplementation +{ + class AgateConsoleImpl : AgateConsole + { + protected override void WriteLineImpl(string text) + { + } + + protected override void WriteImpl(string text) + { + } + + protected override long CurrentTime + { + get { return 0; } + } + } +} Added: trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/IsolatedStorageFileProvider.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/IsolatedStorageFileProvider.cs (rev 0) +++ trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/IsolatedStorageFileProvider.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -0,0 +1,62 @@ +using AgateLib.IO; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AgateLib.Platform.WindowsStore.PlatformImplementation +{ + class IsolatedStorageFileProvider : IReadWriteFileProvider + { + public async Task<Stream> OpenWriteAsync(string file) + { + return await Task.Run(() => new MemoryStream()); + } + + public void CreateDirectory(string folder) + { + } + + public async Task<Stream> OpenReadAsync(string filename) + { + return await Task.Run(() => new MemoryStream()); + } + + public bool FileExists(string filename) + { + return false; + } + + public IEnumerable<string> GetAllFiles() + { + yield break; + } + + public IEnumerable<string> GetAllFiles(string searchPattern) + { + yield break; + } + + public string ReadAllText(string filename) + { + return ""; + } + + public bool IsRealFile(string filename) + { + return true; + } + + public string ResolveFile(string filename) + { + return filename; + } + + public bool IsLogicalFilesystem + { + get { return false; } + } + } +} Modified: trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStoreAssetFileProvider.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStoreAssetFileProvider.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStoreAssetFileProvider.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Windows.ApplicationModel; using Windows.Storage; @@ -18,12 +19,17 @@ public WindowsStoreAssetFileProvider(string path) { - if (path.EndsWith("/") == false) - path += "/"; + if (path == ".") + uriBase = "ms-appx:///"; + else + { + if (path.EndsWith("/") == false) + path += "/"; - this.path = path; + this.path = path; - uriBase = "ms-appx:///" + path; + uriBase = "ms-appx:///" + path; + } } public async Task<System.IO.Stream> OpenReadAsync(string filename) { @@ -33,23 +39,84 @@ await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri).AsTask().ConfigureAwait(false); var randomAccessStream = await storageFile.OpenReadAsync().AsTask().ConfigureAwait(false); - + return randomAccessStream.AsStreamForRead(); } + public override string ToString() + { + return uriBase; + } public bool FileExists(string filename) { - throw new NotImplementedException(); + Uri uri = new Uri(uriBase + filename); + + try + { + StorageFile storageFile = + Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri).AsTask().Result; + + return true; + } + catch (AggregateException e) + { + if (e.InnerException is FileNotFoundException) + return false; + + throw; + } + } + IEnumerable<StorageFile> FilesInDirectory(string searchPattern, StorageFolder folder) + { + return FilesInDirectory(CreateRegex(searchPattern), folder); + } + private Regex CreateRegex(string searchPattern) + { + var regex = new Regex(searchPattern + .Replace(".", @"\.") + .Replace("?", ".") + .Replace("*", ".*")); + + return regex; + } + IEnumerable<StorageFile> FilesInDirectory(Regex searchPattern, StorageFolder folder) + { + var files = folder.GetFilesAsync().AsTask().Result; + + foreach (var file in files) + { + if (PatternMatches(searchPattern, file)) + yield return file; + } + + var folders = folder.GetFoldersAsync().AsTask().Result; + + foreach (var dir in folders) + { + foreach (var file in FilesInDirectory(searchPattern, dir)) + { + if (PatternMatches(searchPattern, file)) + yield return file; + } + } + } + + private bool PatternMatches(Regex searchPattern, StorageFile file) + { + return searchPattern.IsMatch(file.Path); + } + public IEnumerable<string> GetAllFiles() { - throw new NotImplementedException(); + return GetAllFiles("*"); } public IEnumerable<string> GetAllFiles(string searchPattern) { - throw new NotImplementedException(); + foreach(var file in FilesInDirectory(searchPattern, ApplicationData.Current.LocalFolder)) + yield return file.Path; } public string ReadAllText(string filename) Modified: trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -1,5 +1,6 @@ using AgateLib.ApplicationModels; using AgateLib.Drivers; +using AgateLib.IO; using AgateLib.Platform.WindowsStore.PlatformImplementation; using System; using System.Collections.Generic; @@ -13,8 +14,8 @@ public WindowsStorePlatformFactory(bool handheld, AssetLocations assetLocations) { Info = new WindowsStorePlatformInfo(handheld); - AssetFileProvider = new WindowsStoreAssetFileProvider(assetLocations.Path); - + AssetFileProvider = new WindowsStoreAssetFileProvider("."); + FileProvider.UserFiles = new IsolatedStorageFileProvider(); } public PlatformInfo Info { get; private set;} public IReadFileProvider AssetFileProvider { get; private set; } @@ -31,7 +32,7 @@ public Diagnostics.AgateConsole CreateConsole() { - return null; + return new AgateConsoleImpl(); } public IO.IPath CreatePath() Modified: trunk/AgateLib.Tests/Tests.WinForms/DisplayTests/SpriteTester/frmSpriteTester.cs =================================================================== --- trunk/AgateLib.Tests/Tests.WinForms/DisplayTests/SpriteTester/frmSpriteTester.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/Tests.WinForms/DisplayTests/SpriteTester/frmSpriteTester.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -248,7 +248,7 @@ // since loading the sprite from the file failed, try it as a resource file. AgateResourceCollection resources = new AgateResourceCollection(filename); - AgateLib.IO.FileProvider.SurfaceAssets = new FileSystemProvider + AgateLib.IO.Assets.Surfaces = new FileSystemProvider (System.IO.Path.GetDirectoryName(filename)); if (resources.Sprites.ToArray().Length == 1) Modified: trunk/AgateLib.Tests/Tests.WindowsMetro/TestContainer.xaml.cs =================================================================== --- trunk/AgateLib.Tests/Tests.WindowsMetro/TestContainer.xaml.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/Tests.WindowsMetro/TestContainer.xaml.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -17,6 +17,7 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using AgateLib.IO; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 Modified: trunk/AgateLib.Tests/Tests.WindowsPhone/TestContainer.xaml.cs =================================================================== --- trunk/AgateLib.Tests/Tests.WindowsPhone/TestContainer.xaml.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/Tests.WindowsPhone/TestContainer.xaml.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -17,6 +17,7 @@ using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; +using AgateLib.IO; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556 Modified: trunk/AgateLib.Tests/UnitTests/Resources/SerializationTest.cs =================================================================== --- trunk/AgateLib.Tests/UnitTests/Resources/SerializationTest.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/UnitTests/Resources/SerializationTest.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -2,6 +2,7 @@ using AgateLib.DisplayLib; using AgateLib.DisplayLib.BitmapFont; using AgateLib.Geometry; +using AgateLib.IO; using AgateLib.Resources.DC; using AgateLib.Sprites; using AgateLib.Testing.Fakes; Modified: trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssLayoutTest.cs =================================================================== --- trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssLayoutTest.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssLayoutTest.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -2,6 +2,7 @@ using AgateLib.DisplayLib; using AgateLib.DisplayLib.ImplementationBase; using AgateLib.Geometry; +using AgateLib.IO; using AgateLib.Platform.WinForms.ApplicationModels; using AgateLib.Testing.Fakes; using AgateLib.UserInterface.Css.Documents; Modified: trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssParseTest.cs =================================================================== --- trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssParseTest.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssParseTest.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -1,5 +1,6 @@ using AgateLib.ApplicationModels; using AgateLib.Geometry; +using AgateLib.IO; using AgateLib.Testing.Fakes; using AgateLib.UnitTesting; using AgateLib.UserInterface.Css.Binders; Modified: trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssTestBase.cs =================================================================== --- trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssTestBase.cs 2014-10-11 05:52:54 UTC (rev 1536) +++ trunk/AgateLib.Tests/UnitTests/UserInterface/Css/CssTestBase.cs 2014-10-13 02:36:59 UTC (rev 1537) @@ -1,5 +1,6 @@ using AgateLib.ApplicationModels; using AgateLib.Geometry; +using AgateLib.IO; using AgateLib.Testing.Fakes; using AgateLib.UserInterface.Css.Binders; using AgateLib.UserInterface.Css.Documents; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |