Browse Source

Don't think bounds needs to be a PP.

pull/4/head
grokys 12 years ago
parent
commit
59f2e168d8
  1. 15
      Perspex/IStyle.cs
  2. 3
      Perspex/Perspex.csproj
  3. 8
      Perspex/PerspexList.cs
  4. 2
      Perspex/Style.cs
  5. 4
      Perspex/Styles.cs
  6. 38
      Perspex/Themes/Default/ButtonStyle.cs
  7. 16
      Perspex/Themes/Default/DefaultTheme.cs
  8. 10
      Perspex/Visual.cs
  9. 20
      TestApplication/Program.cs

15
Perspex/IStyle.cs

@ -0,0 +1,15 @@
// -----------------------------------------------------------------------
// <copyright file="IStyle.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
{
using Perspex.Controls;
public interface IStyle
{
void Attach(Control control);
}
}

3
Perspex/Perspex.csproj

@ -77,6 +77,7 @@
<Compile Include="Controls\Control.cs" />
<Compile Include="Controls\TextBlock.cs" />
<Compile Include="IBindingDescription.cs" />
<Compile Include="IStyle.cs" />
<Compile Include="Layout\ILayoutable.cs" />
<Compile Include="Layout\ILayoutManager.cs" />
<Compile Include="Layout\ILayoutRoot.cs" />
@ -104,6 +105,8 @@
<Compile Include="Controls\TemplatedControl.cs" />
<Compile Include="Style.cs" />
<Compile Include="Styles.cs" />
<Compile Include="Themes\Default\ButtonStyle.cs" />
<Compile Include="Themes\Default\DefaultTheme.cs" />
<Compile Include="Thickness.cs" />
<Compile Include="Visual.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

8
Perspex/PerspexList.cs

@ -26,5 +26,13 @@
get;
private set;
}
public void AddRange(IEnumerable<T> items)
{
foreach (T item in items)
{
this.Add(item);
}
}
}
}

2
Perspex/Style.cs

@ -13,7 +13,7 @@ namespace Perspex
using System.Reactive.Subjects;
using Perspex.Controls;
public class Style
public class Style : IStyle
{
public Style()
{

4
Perspex/Styles.cs

@ -8,11 +8,11 @@ namespace Perspex
{
using Perspex.Controls;
public class Styles : PerspexList<Style>
public class Styles : PerspexList<IStyle>, IStyle
{
public void Attach(Control control)
{
foreach (Style style in this)
foreach (IStyle style in this)
{
style.Attach(control);
}

38
Perspex/Themes/Default/ButtonStyle.cs

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Perspex.Controls;
using Perspex.Media;
namespace Perspex.Themes.Default
{
public class ButtonStyle : Styles
{
public ButtonStyle()
{
this.AddRange(new[]
{
new Style(x => x.Select<Button>())
{
Setters = new[]
{
new Setter(Button.BackgroundProperty, new SolidColorBrush(0xffdddddd)),
new Setter(Button.BorderBrushProperty, new SolidColorBrush(0xff707070)),
new Setter(Button.BorderThicknessProperty, 2.0),
new Setter(Button.ForegroundProperty, new SolidColorBrush(0xff000000)),
},
},
new Style(x => x.Select<Button>().Class(":mouseover"))
{
Setters = new[]
{
new Setter (Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)),
new Setter (Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)),
},
}
});
}
}
}

16
Perspex/Themes/Default/DefaultTheme.cs

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Perspex.Themes.Default
{
public class DefaultTheme : Styles
{
public DefaultTheme()
{
this.Add(new ButtonStyle());
}
}
}

10
Perspex/Visual.cs

@ -14,18 +14,12 @@ namespace Perspex
public abstract class Visual : PerspexObject
{
public static readonly ReadOnlyPerspexProperty<Rect> BoundsProperty =
new ReadOnlyPerspexProperty<Rect>(BoundsPropertyRW);
private static readonly PerspexProperty<Rect> BoundsPropertyRW =
PerspexProperty.Register<Visual, Rect>("Bounds");
private Visual visualParent;
public Rect Bounds
{
get { return this.GetValue(BoundsPropertyRW); }
protected set { this.SetValue(BoundsPropertyRW, value); }
get;
protected set;
}
public virtual IEnumerable<Visual> VisualChildren

20
TestApplication/Program.cs

@ -8,6 +8,7 @@ using System.Threading.Tasks;
using Perspex;
using Perspex.Controls;
using Perspex.Media;
using Perspex.Themes.Default;
using Perspex.Windows;
using Perspex.Windows.Media;
using Perspex.Windows.Threading;
@ -42,24 +43,7 @@ namespace TestApplication
{
Styles = new Styles
{
new Style(x => x.Select<Button>())
{
Setters = new[]
{
new Setter(Button.BackgroundProperty, new SolidColorBrush(0xffdddddd)),
new Setter(Button.BorderBrushProperty, new SolidColorBrush(0xff707070)),
new Setter(Button.BorderThicknessProperty, 2.0),
new Setter(Button.ForegroundProperty, new SolidColorBrush(0xff000000)),
},
},
new Style(x => x.Select<Button>().Class(":mouseover"))
{
Setters = new[]
{
new Setter (Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)),
new Setter (Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)),
},
}
new DefaultTheme(),
}
};

Loading…
Cancel
Save