[Agate-svn-commit] SF.net SVN: agate:[1538] trunk
Status: Alpha
Brought to you by:
kanato
From: <ka...@us...> - 2014-11-15 19:21:37
|
Revision: 1538 http://sourceforge.net/p/agate/code/1538 Author: kanato Date: 2014-11-15 19:21:32 +0000 (Sat, 15 Nov 2014) Log Message: ----------- Fix asset paths for windows forms applications. Modified Paths: -------------- trunk/AgateLib/Algorithms/Inverting.cs trunk/AgateLib/Core.cs trunk/AgateLib/Drivers/IPlatformFactory.cs trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs trunk/AgateLib.Tests/AgateLib.Tests.Portable/Fakes/FakePlatformFactory.cs trunk/AgateLib.Tests/UnitTests/Algorithms/EMathTest.cs Modified: trunk/AgateLib/Algorithms/Inverting.cs =================================================================== --- trunk/AgateLib/Algorithms/Inverting.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib/Algorithms/Inverting.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -25,16 +25,11 @@ { public class Inverting { - public static double IterateInvert(Func<double, double> func, double targetVal) + public static double IterateInvert(Func<double, double> func, double targetVal, double initialPt = 0, int itermax = 500) { - return IterateInvert(func, targetVal, 0); - } - public static double IterateInvert(Func<double, double> func, double targetVal, double initialPt) - { bool hasLower = false; bool hasUpper = false; int iter = 0; - const int itermax = 500; var p1 = new Pair<double, double>(initialPt, func(initialPt)); Pair<double, double> lowerVal, upperVal; Modified: trunk/AgateLib/Core.cs =================================================================== --- trunk/AgateLib/Core.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib/Core.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -353,7 +353,7 @@ public static void InitAssetLocations(AssetLocations assets) { - FileProvider.Initialize(mFactory.PlatformFactory.AssetFileProvider, assets); + FileProvider.Initialize(mFactory.PlatformFactory.ApplicationFolderFileProvider, assets); } public static IAgateFactory Factory Modified: trunk/AgateLib/Drivers/IPlatformFactory.cs =================================================================== --- trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib/Drivers/IPlatformFactory.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -41,7 +41,7 @@ /// <summary> /// Gets a file provider which points to the application directory. /// </summary> - IReadFileProvider AssetFileProvider { get; } + IReadFileProvider ApplicationFolderFileProvider { get; } IPlatformSerialization CreateDefaultSerializationConstructor(); } Modified: trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Platform.WinForms/Factories/FormsFactory.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -28,11 +28,6 @@ InputFactory = sdl; } - public void SetAssetLocations(AssetLocations assetLocations) - { - mPlatformFactory.SetAssetLocations(assetLocations); - } - public IDisplayFactory DisplayFactory { get; private set; } public IAudioFactory AudioFactory { get; private set; } public IInputFactory InputFactory { get; private set; } Modified: trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Platform.WinForms/Factories/PlatformFactory.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -20,18 +20,16 @@ public PlatformFactory() { Info = new FormsPlatformInfo(); - AssetFileProvider = new FileSystemProvider("."); + + var appdir = Path.GetDirectoryName(System.IO.Path.GetFullPath(Assembly.GetEntryAssembly().Location)); + + ApplicationFolderFileProvider = new FileSystemProvider(appdir); } public PlatformInfo Info { get; private set; } - public IReadFileProvider AssetFileProvider { get; private set; } + public IReadFileProvider ApplicationFolderFileProvider { get; private set; } - public void SetAssetLocations(AssetLocations assetLocations) - { - AssetFileProvider = new FileSystemProvider(System.IO.Path.GetFullPath(assetLocations.Path)); - } - public IStopwatch CreateStopwatch() { return new DiagnosticsStopwatch(); Modified: trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Platform.WinForms/IO/FileSystemProvider.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -245,8 +245,13 @@ { List<string> files = new List<string>(); - files.AddRange(Directory.GetFiles(mPath, searchPattern) - .Select(x => MakeRelativePath(x))); + try + { + files.AddRange(Directory.GetFiles(mPath, searchPattern) + .Select(x => MakeRelativePath(x))); + } + catch (DirectoryNotFoundException) + { } return files; } Modified: trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs =================================================================== --- trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Platform.WinForms/WinFormsInitializer.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -21,7 +21,6 @@ Core.Initialize(factory); } - factory.SetAssetLocations(parameters.AssetLocations); Core.InitAssetLocations(parameters.AssetLocations); var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); Modified: trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs =================================================================== --- trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Platform.WindowsStoreCommon/PlatformImplementation/WindowsStorePlatformFactory.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -14,11 +14,11 @@ public WindowsStorePlatformFactory(bool handheld, AssetLocations assetLocations) { Info = new WindowsStorePlatformInfo(handheld); - AssetFileProvider = new WindowsStoreAssetFileProvider("."); + ApplicationFolderFileProvider = new WindowsStoreAssetFileProvider("."); FileProvider.UserFiles = new IsolatedStorageFileProvider(); } public PlatformInfo Info { get; private set;} - public IReadFileProvider AssetFileProvider { get; private set; } + public IReadFileProvider ApplicationFolderFileProvider { get; private set; } public IStopwatch CreateStopwatch() { Modified: trunk/AgateLib.Tests/AgateLib.Tests.Portable/Fakes/FakePlatformFactory.cs =================================================================== --- trunk/AgateLib.Tests/AgateLib.Tests.Portable/Fakes/FakePlatformFactory.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Tests/AgateLib.Tests.Portable/Fakes/FakePlatformFactory.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -15,7 +15,7 @@ Info = new FakePlatformInfo(); } public Platform.PlatformInfo Info { get; private set; } - public IReadFileProvider AssetFileProvider { get; private set;} + public IReadFileProvider ApplicationFolderFileProvider { get; private set;} public Platform.IStopwatch CreateStopwatch() { Modified: trunk/AgateLib.Tests/UnitTests/Algorithms/EMathTest.cs =================================================================== --- trunk/AgateLib.Tests/UnitTests/Algorithms/EMathTest.cs 2014-10-13 02:36:59 UTC (rev 1537) +++ trunk/AgateLib.Tests/UnitTests/Algorithms/EMathTest.cs 2014-11-15 19:21:32 UTC (rev 1538) @@ -37,6 +37,11 @@ } [TestMethod] + public void IterateInvertMaxIterationsTest() + { + AssertThrows.Throws<Exception>(() => Inverting.IterateInvert(x => x, 4, itermax: 1)); + } + [TestMethod] public void InterateInvertTest() { Assert.AreEqual(0, Inverting.IterateInvert(x => 2 * x, 0), 0.000001); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |