From f006244c5f254775c454aa9936b73c38a8aa4326 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 18 Sep 2014 19:36:27 +0200 Subject: [PATCH] Added Application library. --- Perspex.Application/Application.cs | 94 +++++++++++++++ Perspex.Application/ICloseable.cs | 15 +++ .../Perspex.Application.csproj | 107 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 30 +++++ Perspex.Application/packages.config | 10 ++ Perspex.Input/ICloseable.cs | 15 +++ Perspex.SceneGraph.UnitTests/VisualTests.cs | 2 +- .../Perspex.Themes.Default.csproj | 8 ++ Perspex.Themes.Default/packages.config | 1 + Perspex.sln | 6 + packages/repositories.config | 1 + 11 files changed, 288 insertions(+), 1 deletion(-) create mode 100644 Perspex.Application/Application.cs create mode 100644 Perspex.Application/ICloseable.cs create mode 100644 Perspex.Application/Perspex.Application.csproj create mode 100644 Perspex.Application/Properties/AssemblyInfo.cs create mode 100644 Perspex.Application/packages.config create mode 100644 Perspex.Input/ICloseable.cs diff --git a/Perspex.Application/Application.cs b/Perspex.Application/Application.cs new file mode 100644 index 0000000000..43374c1fa5 --- /dev/null +++ b/Perspex.Application/Application.cs @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex +{ + using System; + using Perspex.Controls; + using Perspex.Input; + using Perspex.Styling; + using Perspex.Threading; + using Splat; + + public class Application + { + private DataTemplates dataTemplates; + + private Styler styler = new Styler(); + + public Application(Styles theme) + { + if (Current != null) + { + throw new InvalidOperationException("Cannot create more than one Application instance."); + } + + Current = this; + this.Styles = theme; + this.FocusManager = new FocusManager(); + this.InputManager = new InputManager(); + this.RegisterServices(); + } + + public static Application Current + { + get; + private set; + } + + public DataTemplates DataTemplates + { + get + { + if (this.dataTemplates == null) + { + this.dataTemplates = new DataTemplates(); + } + + return this.dataTemplates; + } + + set + { + this.dataTemplates = value; + } + } + + public IFocusManager FocusManager + { + get; + private set; + } + + public InputManager InputManager + { + get; + private set; + } + + public Styles Styles + { + get; + private set; + } + + protected virtual void RegisterServices() + { + Locator.CurrentMutable.Register(() => this.DataTemplates, typeof(IGlobalDataTemplates)); + Locator.CurrentMutable.Register(() => this.Styles, typeof(IGlobalStyle)); + Locator.CurrentMutable.Register(() => this.FocusManager, typeof(IFocusManager)); + Locator.CurrentMutable.Register(() => this.InputManager, typeof(IInputManager)); + Locator.CurrentMutable.Register(() => this.styler, typeof(IStyler)); + } + + public void Run(ICloseable closable) + { + DispatcherFrame frame = new DispatcherFrame(); + closable.Closed += (s, e) => frame.Continue = false; + Dispatcher.PushFrame(frame); + } + } +} diff --git a/Perspex.Application/ICloseable.cs b/Perspex.Application/ICloseable.cs new file mode 100644 index 0000000000..23ec938f4f --- /dev/null +++ b/Perspex.Application/ICloseable.cs @@ -0,0 +1,15 @@ +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex +{ + using System; + + public interface ICloseable + { + event EventHandler Closed; + } +} diff --git a/Perspex.Application/Perspex.Application.csproj b/Perspex.Application/Perspex.Application.csproj new file mode 100644 index 0000000000..e1898f1e05 --- /dev/null +++ b/Perspex.Application/Perspex.Application.csproj @@ -0,0 +1,107 @@ + + + + + 11.0 + Debug + AnyCPU + {799A7BB5-3C2C-48B6-85A7-406A12C420DA} + Library + Properties + Perspex + Perspex.Application + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile7 + v4.5 + 088bcbce + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + {b09b78d8-9b26-48b0-9149-d64a2f120f3f} + Perspex.Base + + + {d2221c82-4a25-4583-9b43-d791e3f6820c} + Perspex.Controls + + + {62024b2d-53eb-4638-b26b-85eeaa54866e} + Perspex.Input + + + {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} + Perspex.Interactivity + + + {42472427-4774-4c81-8aff-9f27b8e31721} + Perspex.Layout + + + {eb582467-6abb-43a1-b052-e981ba910e3a} + Perspex.SceneGraph + + + {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} + Perspex.Styling + + + + + + + + + ..\packages\Splat.1.3.3\lib\Portable-net45+win+wpa81+wp80\Splat.dll + + + ..\packages\Rx-Core.2.1.30214.0\lib\Portable-Net45+WinRT45+WP8\System.Reactive.Core.dll + + + ..\packages\Rx-Interfaces.2.1.30214.0\lib\Portable-Net45+WinRT45+WP8\System.Reactive.Interfaces.dll + + + ..\packages\Rx-Linq.2.1.30214.0\lib\Portable-Net45+WinRT45+WP8\System.Reactive.Linq.dll + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/Perspex.Application/Properties/AssemblyInfo.cs b/Perspex.Application/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c9fa9ecdd7 --- /dev/null +++ b/Perspex.Application/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Perspex.Application")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Perspex.Application")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Perspex.Application/packages.config b/Perspex.Application/packages.config new file mode 100644 index 0000000000..af8b5868bf --- /dev/null +++ b/Perspex.Application/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Perspex.Input/ICloseable.cs b/Perspex.Input/ICloseable.cs new file mode 100644 index 0000000000..075404bf06 --- /dev/null +++ b/Perspex.Input/ICloseable.cs @@ -0,0 +1,15 @@ +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex.Input +{ + using System; + + public interface ICloseable + { + event EventHandler Closed; + } +} diff --git a/Perspex.SceneGraph.UnitTests/VisualTests.cs b/Perspex.SceneGraph.UnitTests/VisualTests.cs index c687f9b7dc..e24c23962a 100644 --- a/Perspex.SceneGraph.UnitTests/VisualTests.cs +++ b/Perspex.SceneGraph.UnitTests/VisualTests.cs @@ -3,7 +3,7 @@ // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- -using Microsoft.VisualStudio.TestTools.UnitTesting; + namespace Perspex.SceneGraph.UnitTests { using System.Linq; diff --git a/Perspex.Themes.Default/Perspex.Themes.Default.csproj b/Perspex.Themes.Default/Perspex.Themes.Default.csproj index 58ff9cd5b6..ef00d6ccfd 100644 --- a/Perspex.Themes.Default/Perspex.Themes.Default.csproj +++ b/Perspex.Themes.Default/Perspex.Themes.Default.csproj @@ -15,6 +15,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Profile7 v4.5 + b77a73b5 true @@ -96,6 +97,13 @@ + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +