Browse Source

Include default theme and base color in App.paml.

pull/464/head
Steven Kirk 11 years ago
parent
commit
ab2d7571e1
  1. 6
      samples/BindingTest/App.paml
  2. 9
      samples/BindingTest/App.paml.cs
  3. 8
      samples/BindingTest/BindingTest.csproj
  4. 3
      samples/ControlCatalog/App.paml
  5. 2
      samples/ControlCatalog/App.paml.cs
  6. 3
      samples/TestApplicationShared/App.cs
  7. 1
      samples/XamlTestApplicationPcl/XamlTestApp.cs
  8. 4
      samples/XamlTestApplicationPcl/XamlTestApp.paml
  9. 10
      src/Perspex.Application/Application.cs
  10. 13
      src/Perspex.Application/Designer/DesignerAssist.cs
  11. 2
      src/Perspex.Themes.Default/DefaultTheme.paml
  12. 8
      tests/Perspex.UnitTests/UnitTestApplication.cs

6
samples/BindingTest/App.paml

@ -0,0 +1,6 @@
<Application xmlns="https://github.com/perspex">
<Application.Styles>
<StyleInclude Source="resm:Perspex.Themes.Default.DefaultTheme.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.Accents.BaseLight.paml?assembly=Perspex.Themes.Default"/>
</Application.Styles>
</Application>

9
samples/BindingTest/App.cs → samples/BindingTest/App.paml.cs

@ -2,7 +2,7 @@
using Perspex; using Perspex;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Diagnostics; using Perspex.Diagnostics;
using Perspex.Themes.Default; using Perspex.Markup.Xaml;
using Serilog; using Serilog;
using Serilog.Filters; using Serilog.Filters;
@ -14,7 +14,7 @@ namespace BindingTest
{ {
RegisterServices(); RegisterServices();
InitializeSubsystems((int)Environment.OSVersion.Platform); InitializeSubsystems((int)Environment.OSVersion.Platform);
Styles = new DefaultTheme(); InitializeComponent();
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.Filter.ByIncludingOnly(Matching.WithProperty("Area", "Property")) .Filter.ByIncludingOnly(Matching.WithProperty("Area", "Property"))
@ -36,5 +36,10 @@ namespace BindingTest
window.Show(); window.Show();
app.Run(window); app.Run(window);
} }
private void InitializeComponent()
{
PerspexXamlLoader.Load(this);
}
} }
} }

8
samples/BindingTest/BindingTest.csproj

@ -74,7 +74,12 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="App.cs" /> <EmbeddedResource Include="App.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="App.paml.cs">
<DependentUpon>App.paml</DependentUpon>
</Compile>
<Compile Include="MainWindow.paml.cs"> <Compile Include="MainWindow.paml.cs">
<DependentUpon>MainWindow.paml</DependentUpon> <DependentUpon>MainWindow.paml</DependentUpon>
</Compile> </Compile>
@ -90,7 +95,6 @@
<None Include="App.config" /> <None Include="App.config" />
<EmbeddedResource Include="MainWindow.paml"> <EmbeddedResource Include="MainWindow.paml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource> </EmbeddedResource>
<None Include="packages.config" /> <None Include="packages.config" />
<EmbeddedResource Include="TestUserControl.paml" /> <EmbeddedResource Include="TestUserControl.paml" />

3
samples/ControlCatalog/App.paml

@ -1,5 +1,8 @@
<Application xmlns="https://github.com/perspex"> <Application xmlns="https://github.com/perspex">
<Application.Styles> <Application.Styles>
<StyleInclude Source="resm:Perspex.Themes.Default.DefaultTheme.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.Accents.BaseLight.paml?assembly=Perspex.Themes.Default"/>
<Style Selector="TextBlock.h1"> <Style Selector="TextBlock.h1">
<Setter Property="Foreground" Value="#212121"/> <Setter Property="Foreground" Value="#212121"/>
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20"/>

2
samples/ControlCatalog/App.paml.cs

@ -4,7 +4,6 @@ using Perspex;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Diagnostics; using Perspex.Diagnostics;
using Perspex.Markup.Xaml; using Perspex.Markup.Xaml;
using Perspex.Themes.Default;
using Serilog; using Serilog;
namespace ControlCatalog namespace ControlCatalog
@ -16,7 +15,6 @@ namespace ControlCatalog
RegisterServices(); RegisterServices();
InitializeSubsystems(GetPlatformId()); InitializeSubsystems(GetPlatformId());
InitializeLogging(); InitializeLogging();
Styles = new DefaultTheme();
InitializeComponent(); InitializeComponent();
} }

3
samples/TestApplicationShared/App.cs

@ -5,6 +5,7 @@ using System;
using Perspex; using Perspex;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Controls.Templates; using Perspex.Controls.Templates;
using Perspex.Styling;
using Perspex.Themes.Default; using Perspex.Themes.Default;
namespace TestApplication namespace TestApplication
@ -15,7 +16,7 @@ namespace TestApplication
{ {
RegisterServices(); RegisterServices();
InitializeSubsystems((int)Environment.OSVersion.Platform); InitializeSubsystems((int)Environment.OSVersion.Platform);
Styles = new DefaultTheme(); Styles.Add(new DefaultTheme());
Styles.Add(new SampleTabStyle()); Styles.Add(new SampleTabStyle());
DataTemplates = new DataTemplates DataTemplates = new DataTemplates
{ {

1
samples/XamlTestApplicationPcl/XamlTestApp.cs

@ -12,7 +12,6 @@ namespace XamlTestApplication
{ {
RegisterServices(); RegisterServices();
RegisterPlatform(); RegisterPlatform();
Styles = new DefaultTheme();
InitializeComponent(); InitializeComponent();
} }

4
samples/XamlTestApplicationPcl/XamlTestApp.paml

@ -1,4 +1,8 @@
<Application x:Class="XamlTestApplicationPcl.XamlTestApp" <Application x:Class="XamlTestApplicationPcl.XamlTestApp"
xmlns="https://github.com/perspex" xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<StyleInclude Source="resm:Perspex.Themes.Default.DefaultTheme.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.Accents.BaseLight.paml?assembly=Perspex.Themes.Default"/>
</Application.Styles>
</Application> </Application>

10
src/Perspex.Application/Application.cs

@ -43,10 +43,6 @@ namespace Perspex
private readonly Lazy<IClipboard> _clipboard = private readonly Lazy<IClipboard> _clipboard =
new Lazy<IClipboard>(() => (IClipboard)PerspexLocator.Current.GetService(typeof(IClipboard))); new Lazy<IClipboard>(() => (IClipboard)PerspexLocator.Current.GetService(typeof(IClipboard)));
/// <summary>
/// The styler that will be used to apply styles to controls.
/// </summary>
private readonly Styler _styler = new Styler(); private readonly Styler _styler = new Styler();
/// <summary> /// <summary>
@ -123,11 +119,7 @@ namespace Perspex
/// <remarks> /// <remarks>
/// Global styles apply to all windows in the application. /// Global styles apply to all windows in the application.
/// </remarks> /// </remarks>
public Styles Styles public Styles Styles { get; } = new Styles();
{
get;
protected set;
}
/// <summary> /// <summary>
/// Gets the styling parent of the application, which is null. /// Gets the styling parent of the application, which is null.

13
src/Perspex.Application/Designer/DesignerAssist.cs

@ -1,22 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks;
using OmniXaml; using OmniXaml;
using OmniXaml.ObjectAssembler;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Controls.Platform; using Perspex.Controls.Platform;
using Perspex.Markup.Xaml; using Perspex.Markup.Xaml;
using Perspex.Platform; using Perspex.Platform;
using Perspex.Styling;
using Perspex.Themes.Default; using Perspex.Themes.Default;
namespace Perspex.DesignerSupport namespace Perspex.DesignerSupport
{ {
using OmniXaml.ObjectAssembler;
class DesignerAssist class DesignerAssist
{ {
class DesignerApp : Application class DesignerApp : Application
@ -26,7 +24,12 @@ namespace Perspex.DesignerSupport
RegisterServices(); RegisterServices();
//For now we only support windows //For now we only support windows
InitializeSubsystems(2); InitializeSubsystems(2);
Styles = new DefaultTheme(); Styles.Add(new DefaultTheme());
var loader = new PerspexXamlLoader();
var baseLight = (IStyle)loader.Load(
new Uri("resm:Perspex.Themes.Default.Accents.BaseLight.paml?assembly=Perspex.Themes.Default"));
Styles.Add(baseLight);
} }
} }

2
src/Perspex.Themes.Default/DefaultTheme.paml

@ -1,6 +1,4 @@
<Styles xmlns="https://github.com/perspex"> <Styles xmlns="https://github.com/perspex">
<StyleInclude Source="resm:Perspex.Themes.Default.Accents.BaseLight.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.FocusAdorner.paml?assembly=Perspex.Themes.Default"/> <StyleInclude Source="resm:Perspex.Themes.Default.FocusAdorner.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.Button.paml?assembly=Perspex.Themes.Default"/> <StyleInclude Source="resm:Perspex.Themes.Default.Button.paml?assembly=Perspex.Themes.Default"/>
<StyleInclude Source="resm:Perspex.Themes.Default.Carousel.paml?assembly=Perspex.Themes.Default"/> <StyleInclude Source="resm:Perspex.Themes.Default.Carousel.paml?assembly=Perspex.Themes.Default"/>

8
tests/Perspex.UnitTests/UnitTestApplication.cs

@ -15,7 +15,13 @@ namespace Perspex.UnitTests
{ {
Services = services ?? new TestServices(); Services = services ?? new TestServices();
RegisterServices(); RegisterServices();
Styles = Services.Theme?.Invoke();
var styles = Services.Theme?.Invoke();
if (styles != null)
{
Styles.AddRange(styles);
}
} }
public static new UnitTestApplication Current => (UnitTestApplication)Application.Current; public static new UnitTestApplication Current => (UnitTestApplication)Application.Current;

Loading…
Cancel
Save