Browse Source

Move XAML control styles into Perspex.Themes.Default.

And remove old code-defined control themes from there.
pull/297/head
Steven Kirk 11 years ago
parent
commit
ff90da2b3a
  1. 2
      samples/XamlTestApplicationPcl/XamlTestApp.cs
  2. 25
      samples/XamlTestApplicationPcl/XamlTestApp.paml
  3. 72
      samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj
  4. 2
      src/Markup/Perspex.Markup.Xaml/OmniXAML
  5. 0
      src/Perspex.Themes.Default/Button.paml
  6. 110
      src/Perspex.Themes.Default/ButtonStyle.cs
  7. 0
      src/Perspex.Themes.Default/Carousel.paml
  8. 53
      src/Perspex.Themes.Default/CarouselStyle.cs
  9. 0
      src/Perspex.Themes.Default/CheckBox.paml
  10. 110
      src/Perspex.Themes.Default/CheckBoxStyle.cs
  11. 0
      src/Perspex.Themes.Default/ContentControl.paml
  12. 53
      src/Perspex.Themes.Default/ContentControlStyle.cs
  13. 47
      src/Perspex.Themes.Default/DefaultTheme.cs
  14. 26
      src/Perspex.Themes.Default/DefaultTheme.paml
  15. 22
      src/Perspex.Themes.Default/DefaultTheme.paml.cs
  16. 0
      src/Perspex.Themes.Default/DropDown.paml
  17. 147
      src/Perspex.Themes.Default/DropDownStyle.cs
  18. 0
      src/Perspex.Themes.Default/FocusAdorner.paml
  19. 49
      src/Perspex.Themes.Default/FocusAdornerStyle.cs
  20. 0
      src/Perspex.Themes.Default/GridSplitter.paml
  21. 51
      src/Perspex.Themes.Default/GridSplitterStyle.cs
  22. 0
      src/Perspex.Themes.Default/ItemsControl.paml
  23. 51
      src/Perspex.Themes.Default/ItemsControlStyle.cs
  24. 0
      src/Perspex.Themes.Default/ListBox.paml
  25. 0
      src/Perspex.Themes.Default/ListBoxItem.paml
  26. 70
      src/Perspex.Themes.Default/ListBoxItemStyle.cs
  27. 64
      src/Perspex.Themes.Default/ListBoxStyle.cs
  28. 0
      src/Perspex.Themes.Default/Menu.paml
  29. 0
      src/Perspex.Themes.Default/MenuItem.paml
  30. 264
      src/Perspex.Themes.Default/MenuItemStyle.cs
  31. 59
      src/Perspex.Themes.Default/MenuStyle.cs
  32. 109
      src/Perspex.Themes.Default/Perspex.Themes.Default.csproj
  33. 0
      src/Perspex.Themes.Default/PopupRoot.paml
  34. 55
      src/Perspex.Themes.Default/PopupRootStyle.cs
  35. 89
      src/Perspex.Themes.Default/ProgressBarStyle.cs
  36. 0
      src/Perspex.Themes.Default/RadioButton.paml
  37. 109
      src/Perspex.Themes.Default/RadioButtonStyle.cs
  38. 0
      src/Perspex.Themes.Default/ScrollBar.paml
  39. 105
      src/Perspex.Themes.Default/ScrollBarStyle.cs
  40. 0
      src/Perspex.Themes.Default/ScrollViewer.paml
  41. 93
      src/Perspex.Themes.Default/ScrollViewerStyle.cs
  42. 0
      src/Perspex.Themes.Default/TabControl.paml
  43. 72
      src/Perspex.Themes.Default/TabControlStyle.cs
  44. 0
      src/Perspex.Themes.Default/TabItem.paml
  45. 59
      src/Perspex.Themes.Default/TabItemStyle.cs
  46. 0
      src/Perspex.Themes.Default/TabStrip.paml
  47. 58
      src/Perspex.Themes.Default/TabStripStyle.cs
  48. 4
      src/Perspex.Themes.Default/TextBox.paml
  49. 110
      src/Perspex.Themes.Default/TextBoxStyle.cs
  50. 0
      src/Perspex.Themes.Default/ToggleButton.paml
  51. 114
      src/Perspex.Themes.Default/ToggleButtonStyle.cs
  52. 61
      src/Perspex.Themes.Default/ToolTipStyle.cs
  53. 0
      src/Perspex.Themes.Default/TreeView.paml
  54. 0
      src/Perspex.Themes.Default/TreeViewItem.paml
  55. 162
      src/Perspex.Themes.Default/TreeViewItemStyle.cs
  56. 65
      src/Perspex.Themes.Default/TreeViewStyle.cs
  57. 0
      src/Perspex.Themes.Default/Window.paml
  58. 58
      src/Perspex.Themes.Default/WindowStyle.cs

2
samples/XamlTestApplicationPcl/XamlTestApp.cs

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

25
samples/XamlTestApplicationPcl/XamlTestApp.paml

@ -1,29 +1,4 @@
<Application x:Class="XamlTestApplicationPcl.XamlTestApp"
xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Styles>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.FocusAdorner.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Button.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Carousel.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.CheckBox.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.DropDown.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.GridSplitter.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ItemsControl.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ListBox.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ListBoxItem.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Menu.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.MenuItem.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.PopupRoot.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.RadioButton.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ScrollBar.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ScrollViewer.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TabControl.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TabItem.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TabStrip.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TextBox.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.ToggleButton.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TreeView.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.TreeViewItem.paml"/>
<StyleInclude Source="resource://application/XamlTestApplicationPcl/XamlTestApplication.Window.paml"/>
</Application.Styles>
</Application>

72
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@ -127,79 +127,7 @@
<EmbeddedResource Include="XamlTestApp.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Carousel.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CheckBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Window.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabStrip.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ScrollViewer.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ScrollBar.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ToggleButton.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="RadioButton.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ItemsControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ListBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ListBoxItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TreeView.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TreeViewItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="FocusAdorner.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DropDown.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="GridSplitter.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Menu.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="MenuItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<EmbeddedResource Include="Button.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TextBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ContentControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="PopupRoot.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

2
src/Markup/Perspex.Markup.Xaml/OmniXAML

@ -1 +1 @@
Subproject commit 99d24a3019504b901742496fffbdbb549a7245ab
Subproject commit 06f74f30af7945467101fad95a1759a5b70a2b55

0
samples/XamlTestApplicationPcl/Button.paml → src/Perspex.Themes.Default/Button.paml

110
src/Perspex.Themes.Default/ButtonStyle.cs

@ -1,110 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Collections;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="Button"/> control.
/// </summary>
public class ButtonStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ButtonStyle"/> class.
/// </summary>
public ButtonStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<Button>())
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderThicknessProperty, 2),
new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xff000000)),
new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(FocusAdornerTemplate)),
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<Button>(Template)),
new Setter(ContentControl.HorizontalContentAlignmentProperty, HorizontalAlignment.Center),
new Setter(ContentControl.VerticalContentAlignmentProperty, VerticalAlignment.Center),
},
},
new Style(x => x.OfType<Button>().Class(":pointerover").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
},
},
new Style(x => x.OfType<Button>().Class(":pointerover").Class(":pressed").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff888888)),
},
},
new Style(x => x.OfType<Button>().Class(":disabled").Template().Name("contentPresenter"))
{
Setters = new[]
{
new Setter(Visual.OpacityProperty, 0.5),
},
},
});
}
/// <summary>
/// The default template for the <see cref="Button"/> control's focus adorner.
/// </summary>
/// <returns>The root of the instantiated template.</returns>
public static Control FocusAdornerTemplate()
{
return new Rectangle
{
Stroke = Brushes.Black,
StrokeThickness = 1,
StrokeDashArray = new PerspexList<double>(1, 2),
Margin = new Thickness(3.5),
};
}
/// <summary>
/// The default template for the <see cref="Button"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(Button control)
{
Border border = new Border
{
Name = "border",
Padding = new Thickness(3),
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
[~TextBlock.ForegroundProperty] = control[~TemplatedControl.ForegroundProperty],
[~Layoutable.HorizontalAlignmentProperty] = control[~ContentControl.HorizontalContentAlignmentProperty],
[~Layoutable.VerticalAlignmentProperty] = control[~ContentControl.VerticalContentAlignmentProperty],
},
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
};
return border;
}
}
}

0
samples/XamlTestApplicationPcl/Carousel.paml → src/Perspex.Themes.Default/Carousel.paml

53
src/Perspex.Themes.Default/CarouselStyle.cs

@ -1,53 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="Carousel"/> control.
/// </summary>
public class CarouselStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="CarouselStyle"/> class.
/// </summary>
public CarouselStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<Carousel>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<Carousel>(Template)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="Carousel"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(Carousel control)
{
return new CarouselPresenter
{
Name = "itemsPresenter",
MemberSelector = control.MemberSelector,
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
[~CarouselPresenter.SelectedIndexProperty] = control[~SelectingItemsControl.SelectedIndexProperty],
[~CarouselPresenter.TransitionProperty] = control[~Carousel.TransitionProperty],
};
}
}
}

0
samples/XamlTestApplicationPcl/CheckBox.paml → src/Perspex.Themes.Default/CheckBox.paml

110
src/Perspex.Themes.Default/CheckBoxStyle.cs

@ -1,110 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="CheckBox"/> control.
/// </summary>
public class CheckBoxStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="CheckBoxStyle"/> class.
/// </summary>
public CheckBoxStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<CheckBox>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<CheckBox>(Template)),
},
},
new Style(x => x.OfType<CheckBox>().Template().Name("checkMark"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, false),
},
},
new Style(x => x.OfType<CheckBox>().Class(":checked").Template().Name("checkMark"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, true),
},
},
});
}
/// <summary>
/// The default template for a <see cref="CheckBox"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(CheckBox control)
{
Border result = new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
Child = new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(GridLength.Auto),
new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
},
Children = new Controls
{
new Border
{
Name = "checkBorder",
BorderBrush = new SolidColorBrush(0xff333333),
BorderThickness = 2,
Width = 18,
Height = 18,
VerticalAlignment = VerticalAlignment.Center,
[Grid.ColumnProperty] = 0,
},
new Path
{
Name = "checkMark",
Fill = new SolidColorBrush(0xff333333),
Width = 11,
Height = 10,
Stretch = Stretch.Uniform,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Data = StreamGeometry.Parse("M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z"),
[Grid.ColumnProperty] = 0,
},
new ContentPresenter
{
Name = "contentPresenter",
Margin = new Thickness(4, 0, 0, 0),
VerticalAlignment = VerticalAlignment.Center,
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
[Grid.ColumnProperty] = 1,
},
},
},
};
return result;
}
}
}

0
samples/XamlTestApplicationPcl/ContentControl.paml → src/Perspex.Themes.Default/ContentControl.paml

53
src/Perspex.Themes.Default/ContentControlStyle.cs

@ -1,53 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ContentControl"/> control.
/// </summary>
public class ContentControlStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ContentControlStyle"/> class.
/// </summary>
public ContentControlStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ContentControl>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ContentControl>(Template)),
},
},
});
}
/// <summary>
/// The default template for a <see cref="ContentControl"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ContentControl control)
{
return new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
}
};
}
}
}

47
src/Perspex.Themes.Default/DefaultTheme.cs

@ -1,47 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default Perspex theme.
/// </summary>
public class DefaultTheme : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="DefaultTheme"/> class.
/// </summary>
public DefaultTheme()
{
Add(new FocusAdornerStyle());
Add(new ButtonStyle());
Add(new CheckBoxStyle());
Add(new ContentControlStyle());
Add(new CarouselStyle());
Add(new DropDownStyle());
Add(new GridSplitterStyle());
Add(new ItemsControlStyle());
Add(new ListBoxStyle());
Add(new ListBoxItemStyle());
Add(new MenuStyle());
Add(new MenuItemStyle());
Add(new PopupRootStyle());
Add(new ProgressBarStyle());
Add(new RadioButtonStyle());
Add(new ScrollBarStyle());
Add(new ScrollViewerStyle());
Add(new TabControlStyle());
Add(new TabItemStyle());
Add(new TabStripStyle());
Add(new TextBoxStyle());
Add(new ToggleButtonStyle());
Add(new ToolTipStyle());
Add(new TreeViewStyle());
Add(new TreeViewItemStyle());
Add(new WindowStyle());
}
}
}

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

@ -0,0 +1,26 @@
<Styles xmlns="https://github.com/perspex">
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.FocusAdorner.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.Button.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.Carousel.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.CheckBox.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.DropDown.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.GridSplitter.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ItemsControl.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ListBox.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ListBoxItem.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.Menu.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.MenuItem.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.PopupRoot.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.RadioButton.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ScrollBar.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ScrollViewer.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TabControl.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TabItem.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TabStrip.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TextBox.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.ToggleButton.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TreeView.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.TreeViewItem.paml"/>
<StyleInclude Source="resource://application/Perspex.Themes.Default/Perspex.Themes.Default.Window.paml"/>
</Styles>

22
src/Perspex.Themes.Default/DefaultTheme.paml.cs

@ -0,0 +1,22 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Markup.Xaml;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default Perspex theme.
/// </summary>
public class DefaultTheme : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="DefaultTheme"/> class.
/// </summary>
public DefaultTheme()
{
PerspexXamlLoader.Load(this);
}
}
}

0
samples/XamlTestApplicationPcl/DropDown.paml → src/Perspex.Themes.Default/DropDown.paml

147
src/Perspex.Themes.Default/DropDownStyle.cs

@ -1,147 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using System.Reactive.Linq;
using Perspex.Collections;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="DropDown"/> control.
/// </summary>
public class DropDownStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="DropDownStyle"/> class.
/// </summary>
public DropDownStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<DropDown>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<DropDown>(Template)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff707070)),
new Setter(TemplatedControl.BorderThicknessProperty, 2.0),
new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(FocusAdornerTemplate)),
new Setter(DropDown.HorizontalContentAlignmentProperty, HorizontalAlignment.Center),
new Setter(DropDown.VerticalContentAlignmentProperty, VerticalAlignment.Center),
},
},
new Style(x => x.OfType<DropDown>().Descendent().OfType<ListBoxItem>().Class(":pointerover"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffbee6fd))
}
}
});
}
/// <summary>
/// The default template for a <see cref="DropDown"/> control's focus adorner.
/// </summary>
/// <returns>The root of the instantiated template.</returns>
public static Control FocusAdornerTemplate()
{
return new Rectangle
{
Stroke = Brushes.Black,
StrokeThickness = 1,
StrokeDashArray = new PerspexList<double>(1, 2),
Margin = new Thickness(3.5),
};
}
/// <summary>
/// The default template for a <see cref="DropDown"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(DropDown control)
{
Border result = new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new Grid
{
Name = "container",
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
new ColumnDefinition(GridLength.Auto),
},
Children = new Controls
{
new ContentControl
{
Name = "contentControl",
Margin = new Thickness(3),
[~ContentControl.ContentProperty] = control[~DropDown.SelectionBoxItemProperty],
[~Layoutable.HorizontalAlignmentProperty] = control[~DropDown.HorizontalContentAlignmentProperty],
[~Layoutable.VerticalAlignmentProperty] = control[~DropDown.VerticalContentAlignmentProperty],
},
new ToggleButton
{
Name = "toggle",
BorderThickness = 0,
Background = Brushes.Transparent,
ClickMode = ClickMode.Press,
Focusable = false,
Content = new Path
{
Name = "checkMark",
Fill = Brushes.Black,
Width = 8,
Height = 4,
Stretch = Stretch.Uniform,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Data = StreamGeometry.Parse("F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"),
[Grid.ColumnProperty] = 0,
},
[~~ToggleButton.IsCheckedProperty] = control[~~DropDown.IsDropDownOpenProperty],
[Grid.ColumnProperty] = 1,
},
new Popup
{
Name = "PART_Popup",
Child = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 1,
Padding = new Thickness(4),
Child = new ItemsPresenter
{
MemberSelector = control.MemberSelector,
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
}
},
PlacementTarget = control,
StaysOpen = false,
[~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty],
[~Layoutable.MinWidthProperty] = control[~Visual.BoundsProperty].Cast<Rect>().Select(x => (object)x.Width),
}
},
},
};
return result;
}
}
}

0
samples/XamlTestApplicationPcl/FocusAdorner.paml → src/Perspex.Themes.Default/FocusAdorner.paml

49
src/Perspex.Themes.Default/FocusAdornerStyle.cs

@ -1,49 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using Perspex.Collections;
using Perspex.Controls;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for a focus adorner.
/// </summary>
public class FocusAdornerStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="FocusAdornerStyle"/> class.
/// </summary>
public FocusAdornerStyle()
{
AddRange(new[]
{
new Style(x => x.Is<Control>())
{
Setters = new[]
{
new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(Template)),
},
},
});
}
/// <summary>
/// The default template for focus adorner.
/// </summary>
/// <returns>The root of the instantiated template.</returns>
public static Control Template()
{
return new Rectangle
{
Stroke = Brushes.Black,
StrokeThickness = 1,
StrokeDashArray = new PerspexList<double>(1, 2),
};
}
}
}

0
samples/XamlTestApplicationPcl/GridSplitter.paml → src/Perspex.Themes.Default/GridSplitter.paml

51
src/Perspex.Themes.Default/GridSplitterStyle.cs

@ -1,51 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="GridSplitter"/> control.
/// </summary>
public class GridSplitterStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="GridSplitterStyle"/> class.
/// </summary>
public GridSplitterStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<GridSplitter>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<GridSplitter>(Template)),
new Setter(Layoutable.WidthProperty, 4.0),
},
},
});
}
/// <summary>
/// The default template for a <see cref="GridSplitter"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(GridSplitter control)
{
Border border = new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
};
return border;
}
}
}

0
samples/XamlTestApplicationPcl/ItemsControl.paml → src/Perspex.Themes.Default/ItemsControl.paml

51
src/Perspex.Themes.Default/ItemsControlStyle.cs

@ -1,51 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ItemsControl"/> control.
/// </summary>
public class ItemsControlStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ItemsControlStyle"/> class.
/// </summary>
public ItemsControlStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ItemsControl>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ItemsControl>(Template)),
},
},
});
}
/// <summary>
/// The default template for an <see cref="ItemsControl"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ItemsControl control)
{
return new ItemsPresenter
{
Name = "PART_ItemsPresenter",
MemberSelector = control.MemberSelector,
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
};
}
}
}

0
samples/XamlTestApplicationPcl/ListBox.paml → src/Perspex.Themes.Default/ListBox.paml

0
samples/XamlTestApplicationPcl/ListBoxItem.paml → src/Perspex.Themes.Default/ListBoxItem.paml

70
src/Perspex.Themes.Default/ListBoxItemStyle.cs

@ -1,70 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ListBoxItem"/> control.
/// </summary>
public class ListBoxItemStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ListBoxItemStyle"/> class.
/// </summary>
public ListBoxItemStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ListBoxItem>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ListBoxItem>(Template)),
},
},
new Style(x => x.OfType<ListBoxItem>().Class(":selected").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xfff0f0f0)),
},
},
new Style(x => x.OfType<ListBoxItem>().Class(":selected").Class(":focus").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffd0d0d0)),
},
},
});
}
/// <summary>
/// The default template for a <see cref="ListBoxItem"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ListBoxItem control)
{
return new Border
{
Name = "border",
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new ContentPresenter
{
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
},
};
}
}
}

64
src/Perspex.Themes.Default/ListBoxStyle.cs

@ -1,64 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ListBox"/> control.
/// </summary>
public class ListBoxStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ListBoxStyle"/> class.
/// </summary>
public ListBoxStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ListBox>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ListBox>(Template)),
new Setter(TemplatedControl.BorderBrushProperty, Brushes.Black),
new Setter(TemplatedControl.BorderThicknessProperty, 1.0),
},
},
});
}
/// <summary>
/// The default template for a <see cref="ListBox"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ListBox control)
{
return new Border
{
Padding = new Thickness(4),
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new ScrollViewer
{
Content = new ItemsPresenter
{
Name = "itemsPresenter",
MemberSelector = control.MemberSelector,
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
}
}
};
}
}
}

0
samples/XamlTestApplicationPcl/Menu.paml → src/Perspex.Themes.Default/Menu.paml

0
samples/XamlTestApplicationPcl/MenuItem.paml → src/Perspex.Themes.Default/MenuItem.paml

264
src/Perspex.Themes.Default/MenuItemStyle.cs

@ -1,264 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Input;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="MenuItem"/> control.
/// </summary>
public class MenuItemStyle : Styles
{
private static readonly FuncDataTemplate AccessKeyDataTemplate =
new FuncDataTemplate<string>(x => new AccessText { Text = x });
/// <summary>
/// Initializes a new instance of the <see cref="MenuItemStyle"/> class.
/// </summary>
public MenuItemStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<MenuItem>())
{
Setters = new[]
{
new Setter(TemplatedControl.BorderThicknessProperty, 1.0),
new Setter(TemplatedControl.PaddingProperty, new Thickness(6, 0)),
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<MenuItem>(PopupTemplate)),
},
},
new Style(x => x.OfType<Menu>().Child().OfType<MenuItem>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<MenuItem>(TopLevelTemplate)),
},
},
new Style(x => x.OfType<MenuItem>().Class(":selected").Template().Name("root"))
{
Setters = new[]
{
new Setter(Border.BackgroundProperty, new SolidColorBrush(0x3d26a0da)),
new Setter(Border.BorderBrushProperty, new SolidColorBrush(0xff26a0da)),
},
},
new Style(x => x.OfType<MenuItem>().Class(":pointerover").Template().Name("root"))
{
Setters = new[]
{
new Setter(Border.BackgroundProperty, new SolidColorBrush(0x3d26a0da)),
new Setter(Border.BorderBrushProperty, new SolidColorBrush(0xff26a0da)),
},
},
new Style(x => x.OfType<MenuItem>().Class(":empty").Template().Name("rightArrow"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, false),
},
},
});
}
/// <summary>
/// The default template for a top-level <see cref="MenuItem"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control TopLevelTemplate(MenuItem control)
{
Popup popup;
var result = new Border
{
Name = "root",
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new Panel
{
Children = new Controls
{
new ContentPresenter
{
DataTemplates = new DataTemplates
{
AccessKeyDataTemplate,
},
[~ContentPresenter.ContentProperty] = control[~MenuItem.HeaderProperty],
[~Layoutable.MarginProperty] = control[~TemplatedControl.PaddingProperty],
[Grid.ColumnProperty] = 1,
},
(popup = new Popup
{
Name = "PART_Popup",
StaysOpen = true,
[!!Popup.IsOpenProperty] = control[!!MenuItem.IsSubMenuOpenProperty],
Child = new Border
{
Background = new SolidColorBrush(0xfff0f0f0),
BorderBrush = new SolidColorBrush(0xff999999),
BorderThickness = 1,
Padding = new Thickness(2),
Child = new ScrollViewer
{
Content = new Panel
{
Children = new Controls
{
new Rectangle
{
Name = "iconSeparator",
Fill = new SolidColorBrush(0xffd7d7d7),
HorizontalAlignment = HorizontalAlignment.Left,
IsHitTestVisible = false,
Margin = new Thickness(29, 2, 0, 2),
Width = 1,
},
new ItemsPresenter
{
Name = "itemsPresenter",
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
}
}
}
}
}
})
},
}
};
popup.PlacementTarget = result;
return result;
}
/// <summary>
/// The default template for a popup <see cref="MenuItem"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control PopupTemplate(MenuItem control)
{
Popup popup;
var result = new Border
{
Name = "root",
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(22, GridUnitType.Pixel),
new ColumnDefinition(13, GridUnitType.Pixel),
new ColumnDefinition(1, GridUnitType.Star),
new ColumnDefinition(20, GridUnitType.Pixel),
},
Children = new Controls
{
new ContentPresenter
{
Name = "icon",
[~ContentPresenter.ContentProperty] = control[~MenuItem.IconProperty],
Width = 16,
Height = 16,
Margin = new Thickness(3),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
},
new Path
{
Data = StreamGeometry.Parse("F1M10,1.2L4.7,9.1 4.5,9.1 0,5.2 1.3,3.5 4.3,6.1 8.3,0 10,1.2z"),
Margin = new Thickness(3),
IsVisible = false,
VerticalAlignment = VerticalAlignment.Center,
[~Shape.FillProperty] = control[~TemplatedControl.ForegroundProperty],
},
new ContentPresenter
{
DataTemplates = new DataTemplates
{
AccessKeyDataTemplate,
},
VerticalAlignment = VerticalAlignment.Center,
[~ContentPresenter.ContentProperty] = control[~MenuItem.HeaderProperty],
[~Layoutable.MarginProperty] = control[~TemplatedControl.PaddingProperty],
[Grid.ColumnProperty] = 2,
},
new Path
{
Name = "rightArrow",
Data = StreamGeometry.Parse("M0,0L4,3.5 0,7z"),
Fill = new SolidColorBrush(0xff212121),
Margin = new Thickness(10, 0, 0, 0),
UseLayoutRounding = false,
VerticalAlignment = VerticalAlignment.Center,
[Grid.ColumnProperty] = 3,
},
(popup = new Popup
{
Name = "popup",
PlacementMode = PlacementMode.Right,
StaysOpen = true,
[!!Popup.IsOpenProperty] = control[!!MenuItem.IsSubMenuOpenProperty],
Child = new Border
{
Background = new SolidColorBrush(0xfff0f0f0),
BorderBrush = new SolidColorBrush(0xff999999),
BorderThickness = 1,
Padding = new Thickness(2),
Child = new ScrollViewer
{
Content = new Panel
{
Children = new Controls
{
new Rectangle
{
Name = "iconSeparator",
Fill = new SolidColorBrush(0xffd7d7d7),
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness(29, 2, 0, 2),
Width = 1,
},
new ItemsPresenter
{
Name = "itemsPresenter",
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle,
}
}
}
}
}
})
},
}
};
popup.PlacementTarget = result;
return result;
}
}
}

59
src/Perspex.Themes.Default/MenuStyle.cs

@ -1,59 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Input;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="Menu"/> control.
/// </summary>
public class MenuStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="MenuStyle"/> class.
/// </summary>
public MenuStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<Menu>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<Menu>(Template)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="Menu"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(Menu control)
{
return new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
[~Decorator.PaddingProperty] = control[~TemplatedControl.PaddingProperty],
Child = new ItemsPresenter
{
Name = "itemsPresenter",
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Continue,
}
};
}
}
}

109
src/Perspex.Themes.Default/Perspex.Themes.Default.csproj

@ -39,6 +39,10 @@
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<ProjectReference Include="..\Markup\Perspex.Markup.Xaml\Perspex.Markup.Xaml.csproj">
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project>
<Name>Perspex.Markup.Xaml</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Animation\Perspex.Animation.csproj">
<Project>{D211E587-D8BC-45B9-95A4-F297C8FA5200}</Project>
<Name>Perspex.Animation</Name>
@ -76,34 +80,10 @@
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="MenuItemStyle.cs" />
<Compile Include="MenuStyle.cs" />
<Compile Include="ProgressBarStyle.cs" />
<Compile Include="ToolTipStyle.cs" />
<Compile Include="FocusAdornerStyle.cs" />
<Compile Include="DropDownStyle.cs" />
<Compile Include="CarouselStyle.cs" />
<Compile Include="RadioButtonStyle.cs" />
<Compile Include="ToggleButtonStyle.cs" />
<Compile Include="ListBoxStyle.cs" />
<Compile Include="ListBoxItemStyle.cs" />
<Compile Include="PopupRootStyle.cs" />
<Compile Include="WindowStyle.cs" />
<Compile Include="ScrollViewerStyle.cs" />
<Compile Include="ScrollBarStyle.cs" />
<Compile Include="GridSplitterStyle.cs" />
<Compile Include="ButtonStyle.cs" />
<Compile Include="CheckBoxStyle.cs" />
<Compile Include="ContentControlStyle.cs" />
<Compile Include="DefaultTheme.cs" />
<Compile Include="ItemsControlStyle.cs" />
<Compile Include="DefaultTheme.paml.cs">
<DependentUpon>DefaultTheme.paml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TabControlStyle.cs" />
<Compile Include="TabItemStyle.cs" />
<Compile Include="TabStripStyle.cs" />
<Compile Include="TextBoxStyle.cs" />
<Compile Include="TreeViewItemStyle.cs" />
<Compile Include="TreeViewStyle.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Reactive.Core">
@ -121,7 +101,82 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<EmbeddedResource Include="Button.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Carousel.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CheckBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ContentControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DropDown.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="FocusAdorner.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="GridSplitter.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ItemsControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ListBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ListBoxItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Menu.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="MenuItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<EmbeddedResource Include="PopupRoot.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="RadioButton.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ScrollBar.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ScrollViewer.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabControl.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TabStrip.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TextBox.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="ToggleButton.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TreeView.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TreeViewItem.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Window.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="DefaultTheme.paml">
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

0
samples/XamlTestApplicationPcl/PopupRoot.paml → src/Perspex.Themes.Default/PopupRoot.paml

55
src/Perspex.Themes.Default/PopupRootStyle.cs

@ -1,55 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="PopupRoot"/> control.
/// </summary>
public class PopupRootStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="PopupRootStyle"/> class.
/// </summary>
public PopupRootStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<PopupRoot>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<PopupRoot>(Template)),
new Setter(TemplatedControl.FontFamilyProperty, "Segoe UI"),
new Setter(TemplatedControl.FontSizeProperty, 12.0),
},
},
});
}
/// <summary>
/// The default template for the <see cref="PopupRoot"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(PopupRoot control)
{
return new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
}
};
}
}
}

89
src/Perspex.Themes.Default/ProgressBarStyle.cs

@ -1,89 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using System.Reactive.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="ProgressBar"/> control.
/// </summary>
public class ProgressBarStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ProgressBarStyle"/> class.
/// </summary>
public ProgressBarStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ProgressBar>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ProgressBar>(Template)),
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffdddddd)),
new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xffbee6fd)),
},
}
});
}
/// <summary>
/// The default template for the <see cref="ProgressBar"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ProgressBar control)
{
Border container = new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new Grid
{
MinHeight = 14,
MinWidth = 200,
Children = new Controls
{
new Border
{
Name = "PART_Track",
BorderThickness = 1,
[~Border.BorderBrushProperty] = control[~TemplatedControl.BackgroundProperty],
},
new Border
{
Name = "PART_Indicator",
BorderThickness = 1,
HorizontalAlignment = HorizontalAlignment.Left,
[~Border.BackgroundProperty] = control[~TemplatedControl.ForegroundProperty],
Child = new Grid
{
Name = "Animation",
ClipToBounds = true,
}
}
}
}
};
return container;
}
}
}

0
samples/XamlTestApplicationPcl/RadioButton.paml → src/Perspex.Themes.Default/RadioButton.paml

109
src/Perspex.Themes.Default/RadioButtonStyle.cs

@ -1,109 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="RadioButton"/> control.
/// </summary>
public class RadioButtonStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="RadioButtonStyle"/> class.
/// </summary>
public RadioButtonStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<RadioButton>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<RadioButton>(Template)),
},
},
new Style(x => x.OfType<RadioButton>().Template().Name("checkMark"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, false),
},
},
new Style(x => x.OfType<RadioButton>().Class(":checked").Template().Name("checkMark"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, true),
},
},
});
}
/// <summary>
/// The default template for the <see cref="RadioButton"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(RadioButton control)
{
Border result = new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
Child = new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(GridLength.Auto),
new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
},
Children = new Controls
{
new Ellipse
{
Name = "checkBorder",
Stroke = Brushes.Black,
StrokeThickness = 2,
Width = 18,
Height = 18,
VerticalAlignment = VerticalAlignment.Center,
[Grid.ColumnProperty] = 0,
},
new Ellipse
{
Name = "checkMark",
Fill = Brushes.Black,
Width = 10,
Height = 10,
Stretch = Stretch.Uniform,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
[Grid.ColumnProperty] = 0,
},
new ContentPresenter
{
Name = "contentPresenter",
Margin = new Thickness(4, 0, 0, 0),
VerticalAlignment = VerticalAlignment.Center,
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
[Grid.ColumnProperty] = 1,
},
},
},
};
return result;
}
}
}

0
samples/XamlTestApplicationPcl/ScrollBar.paml → src/Perspex.Themes.Default/ScrollBar.paml

105
src/Perspex.Themes.Default/ScrollBarStyle.cs

@ -1,105 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ScrollBar"/> control.
/// </summary>
public class ScrollBarStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ScrollBarStyle"/> class.
/// </summary>
public ScrollBarStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ScrollBar>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ScrollBar>(Template)),
},
},
new Style(x => x.OfType<ScrollBar>().PropertyEquals(ScrollBar.OrientationProperty, Orientation.Horizontal))
{
Setters = new[]
{
new Setter(Layoutable.HeightProperty, 10.0),
},
},
new Style(x => x.OfType<ScrollBar>().PropertyEquals(ScrollBar.OrientationProperty, Orientation.Horizontal).Template().Name("thumb"))
{
Setters = new[]
{
new Setter(Layoutable.MinWidthProperty, 10.0),
},
},
new Style(x => x.OfType<ScrollBar>().PropertyEquals(ScrollBar.OrientationProperty, Orientation.Vertical))
{
Setters = new[]
{
new Setter(Layoutable.WidthProperty, 10.0),
},
},
new Style(x => x.OfType<ScrollBar>().PropertyEquals(ScrollBar.OrientationProperty, Orientation.Vertical).Template().Name("thumb"))
{
Setters = new[]
{
new Setter(Layoutable.MinHeightProperty, 10.0),
},
},
});
}
/// <summary>
/// The default template for the <see cref="ScrollBar"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ScrollBar control)
{
return new Border
{
Background = Brushes.Silver,
Child = new Track
{
Name = "track",
[!Track.MinimumProperty] = control[!RangeBase.MinimumProperty],
[!Track.MaximumProperty] = control[!RangeBase.MaximumProperty],
[!!Track.ValueProperty] = control[!!RangeBase.ValueProperty],
[!Track.ViewportSizeProperty] = control[!ScrollBar.ViewportSizeProperty],
[!Track.OrientationProperty] = control[!ScrollBar.OrientationProperty],
Thumb = new Thumb
{
Name = "thumb",
Template = new FuncControlTemplate<Thumb>(ThumbTemplate),
},
},
};
}
/// <summary>
/// The default template for the <see cref="ScrollBar"/>'s <see cref="Thumb"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control ThumbTemplate(Thumb control)
{
return new Border
{
Background = Brushes.Gray,
};
}
}
}

0
samples/XamlTestApplicationPcl/ScrollViewer.paml → src/Perspex.Themes.Default/ScrollViewer.paml

93
src/Perspex.Themes.Default/ScrollViewerStyle.cs

@ -1,93 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="ScrollViewer"/> control.
/// </summary>
public class ScrollViewerStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ScrollViewerStyle"/> class.
/// </summary>
public ScrollViewerStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ScrollViewer>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ScrollViewer>(Template)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="ScrollViewer"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ScrollViewer control)
{
var result = new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(1, GridUnitType.Star),
new ColumnDefinition(GridLength.Auto),
},
RowDefinitions = new RowDefinitions
{
new RowDefinition(1, GridUnitType.Star),
new RowDefinition(GridLength.Auto),
},
Children = new Controls
{
new ScrollContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
[~~ScrollContentPresenter.ExtentProperty] = control[~~ScrollViewer.ExtentProperty],
[~~ScrollContentPresenter.OffsetProperty] = control[~~ScrollViewer.OffsetProperty],
[~~ScrollContentPresenter.ViewportProperty] = control[~~ScrollViewer.ViewportProperty],
[~ScrollContentPresenter.CanScrollHorizontallyProperty] = control[~ScrollViewer.CanScrollHorizontallyProperty],
},
new ScrollBar
{
Name = "horizontalScrollBar",
Orientation = Orientation.Horizontal,
[~RangeBase.MaximumProperty] = control[~ScrollViewer.HorizontalScrollBarMaximumProperty],
[~~RangeBase.ValueProperty] = control[~~ScrollViewer.HorizontalScrollBarValueProperty],
[~ScrollBar.ViewportSizeProperty] = control[~ScrollViewer.HorizontalScrollBarViewportSizeProperty],
[~ScrollBar.VisibilityProperty] = control[~ScrollViewer.HorizontalScrollBarVisibilityProperty],
[Grid.RowProperty] = 1,
},
new ScrollBar
{
Name = "verticalScrollBar",
Orientation = Orientation.Vertical,
[~RangeBase.MaximumProperty] = control[~ScrollViewer.VerticalScrollBarMaximumProperty],
[~~RangeBase.ValueProperty] = control[~~ScrollViewer.VerticalScrollBarValueProperty],
[~ScrollBar.ViewportSizeProperty] = control[~ScrollViewer.VerticalScrollBarViewportSizeProperty],
[~ScrollBar.VisibilityProperty] = control[~ScrollViewer.VerticalScrollBarVisibilityProperty],
[Grid.ColumnProperty] = 1,
},
},
};
return result;
}
}
}

0
samples/XamlTestApplicationPcl/TabControl.paml → src/Perspex.Themes.Default/TabControl.paml

72
src/Perspex.Themes.Default/TabControlStyle.cs

@ -1,72 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using System.Reactive.Linq;
using Perspex.Controls;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="TabControl"/> control.
/// </summary>
public class TabControlStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TabControlStyle"/> class.
/// </summary>
public TabControlStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TabControl>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TabControl>(Template)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="TabControl"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TabControl control)
{
return new Grid
{
RowDefinitions = new RowDefinitions
{
new RowDefinition(GridLength.Auto),
new RowDefinition(new GridLength(1, GridUnitType.Star)),
},
Children = new Controls
{
new TabStrip
{
Name = "tabStrip",
[!ItemsControl.ItemsProperty] = control[!ItemsControl.ItemsProperty],
[!!SelectingItemsControl.SelectedItemProperty] = control[!!SelectingItemsControl.SelectedItemProperty],
},
new Carousel
{
Name = "carousel",
MemberSelector = new FuncMemberSelector<TabItem, object>(x => x.Content),
[!Carousel.ItemsProperty] = control[!ItemsControl.ItemsProperty],
[!Carousel.SelectedItemProperty] = control[!SelectingItemsControl.SelectedItemProperty],
[~Carousel.TransitionProperty] = control[~TabControl.TransitionProperty],
[Grid.RowProperty] = 1,
}
}
};
}
}
}

0
samples/XamlTestApplicationPcl/TabItem.paml → src/Perspex.Themes.Default/TabItem.paml

59
src/Perspex.Themes.Default/TabItemStyle.cs

@ -1,59 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="TabItem"/> control.
/// </summary>
public class TabItemStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TabItemStyle"/> class.
/// </summary>
public TabItemStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TabItem>())
{
Setters = new[]
{
new Setter(TemplatedControl.FontSizeProperty, 16.0),
new Setter(TemplatedControl.ForegroundProperty, Brushes.Gray),
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TabItem>(Template)),
},
},
new Style(x => x.OfType<TabItem>().Class(":selected"))
{
Setters = new[]
{
new Setter(TemplatedControl.ForegroundProperty, Brushes.Black),
},
},
});
}
/// <summary>
/// The default template for the <see cref="TabItem"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TabItem control)
{
return new ContentPresenter
{
Name = "headerPresenter",
[~ContentPresenter.ContentProperty] = control[~HeaderedContentControl.HeaderProperty],
};
}
}
}

0
samples/XamlTestApplicationPcl/TabStrip.paml → src/Perspex.Themes.Default/TabStrip.paml

58
src/Perspex.Themes.Default/TabStripStyle.cs

@ -1,58 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="TabStrip"/> control.
/// </summary>
public class TabStripStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TabStripStyle"/> class.
/// </summary>
public TabStripStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TabStrip>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TabStrip>(Template)),
},
},
new Style(x => x.OfType<TabStrip>().Template().OfType<StackPanel>())
{
Setters = new[]
{
new Setter(StackPanel.GapProperty, 16.0),
new Setter(StackPanel.OrientationProperty, Orientation.Horizontal),
},
},
});
}
/// <summary>
/// The default template for the <see cref="TabStrip"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TabStrip control)
{
return new ItemsPresenter
{
Name = "itemsPresenter",
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
};
}
}
}

4
samples/XamlTestApplicationPcl/TextBox.paml → src/Perspex.Themes.Default/TextBox.paml

@ -1,6 +1,4 @@
<Styles xmlns="https://github.com/perspex"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:XamlTestApplication;assembly=XamlTestApplicationPcl">
<Styles xmlns="https://github.com/perspex">
<Style Selector="TextBox">
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="#ff707070"/>

110
src/Perspex.Themes.Default/TextBoxStyle.cs

@ -1,110 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
using System.Reactive.Linq;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="TextBox"/> control.
/// </summary>
public class TextBoxStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TextBoxStyle"/> class.
/// </summary>
public TextBoxStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TextBox>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TextBox>(Template)),
new Setter(TemplatedControl.BackgroundProperty, Brushes.White),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff707070)),
new Setter(TemplatedControl.BorderThicknessProperty, 2.0),
new Setter(Control.FocusAdornerProperty, null),
},
},
new Style(x => x.OfType<TextBox>().Class(":focus").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BorderBrushProperty, Brushes.Black),
},
}
});
}
/// <summary>
/// The default template for the <see cref="TextBox"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TextBox control)
{
Border result = new Border
{
Name = "border",
Padding = new Thickness(2),
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new ScrollViewer
{
[~ScrollViewer.CanScrollHorizontallyProperty] = control[~ScrollViewer.CanScrollHorizontallyProperty],
[~ScrollViewer.HorizontalScrollBarVisibilityProperty] = control[~ScrollViewer.HorizontalScrollBarVisibilityProperty],
[~ScrollViewer.VerticalScrollBarVisibilityProperty] = control[~ScrollViewer.VerticalScrollBarVisibilityProperty],
Content = new StackPanel
{
Children = new Controls.Controls
{
new TextBlock
{
Name = "floatingWatermark",
Foreground = SolidColorBrush.Parse("#007ACC"),
FontSize = 10,
[~TextBlock.TextProperty] = control[~TextBox.WatermarkProperty],
[~TextBlock.IsVisibleProperty] = control[~TextBox.TextProperty].Cast<string>().Select(x => (object)(!string.IsNullOrEmpty(x) && control.UseFloatingWatermark))
},
new Panel
{
Children = new Controls.Controls
{
new TextBlock
{
Name = "watermark",
Opacity = 0.5,
[~TextBlock.TextProperty] = control[~TextBox.WatermarkProperty],
[~TextBlock.IsVisibleProperty] = control[~TextBox.TextProperty].Cast<string>().Select(x => (object)string.IsNullOrEmpty(x))
},
new TextPresenter
{
Name = "PART_TextPresenter",
[~TextPresenter.CaretIndexProperty] = control[~TextBox.CaretIndexProperty],
[~TextPresenter.SelectionStartProperty] = control[~TextBox.SelectionStartProperty],
[~TextPresenter.SelectionEndProperty] = control[~TextBox.SelectionEndProperty],
[~TextBlock.TextProperty] = control[~TextBox.TextProperty],
[~TextBlock.TextWrappingProperty] = control[~TextBox.TextWrappingProperty],
}
}
}
}
}
}
};
return result;
}
}
}

0
samples/XamlTestApplicationPcl/ToggleButton.paml → src/Perspex.Themes.Default/ToggleButton.paml

114
src/Perspex.Themes.Default/ToggleButtonStyle.cs

@ -1,114 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ToggleButton"/> control.
/// </summary>
public class ToggleButtonStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ToggleButtonStyle"/> class.
/// </summary>
public ToggleButtonStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ToggleButton>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ToggleButton>(Template)),
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xffaaaaaa)),
new Setter(TemplatedControl.BorderThicknessProperty, 2.0),
new Setter(Control.FocusAdornerProperty, new FuncTemplate<IControl>(ButtonStyle.FocusAdornerTemplate)),
new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xff000000)),
new Setter(ContentControl.HorizontalContentAlignmentProperty, HorizontalAlignment.Center),
new Setter(ContentControl.VerticalContentAlignmentProperty, VerticalAlignment.Center),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":checked").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff777777)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff77777)),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff888888)),
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":checked").Class(":pointerover").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff777777)),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":pointerover").Class(":pressed").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff888888)),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":pressed").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.BorderBrushProperty, new SolidColorBrush(0xff888888)),
},
},
new Style(x => x.OfType<ToggleButton>().Class(":disabled").Template().Name("border"))
{
Setters = new[]
{
new Setter(TemplatedControl.ForegroundProperty, new SolidColorBrush(0xff7f7f7f)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="ToggleButton"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ToggleButton control)
{
Border border = new Border
{
Name = "border",
Padding = new Thickness(3),
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
[~Layoutable.HorizontalAlignmentProperty] = control[~ContentControl.HorizontalContentAlignmentProperty],
[~Layoutable.VerticalAlignmentProperty] = control[~ContentControl.VerticalContentAlignmentProperty],
},
};
return border;
}
}
}

61
src/Perspex.Themes.Default/ToolTipStyle.cs

@ -1,61 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="ToolTip"/> control.
/// </summary>
public class ToolTipStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="ToolTipStyle"/> class.
/// </summary>
public ToolTipStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<ToolTip>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ToolTip>(Template)),
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xffffffe1)),
new Setter(TemplatedControl.BorderBrushProperty, Brushes.Gray),
new Setter(TemplatedControl.BorderThicknessProperty, 1.0),
new Setter(TemplatedControl.PaddingProperty, new Thickness(4, 2)),
},
},
});
}
/// <summary>
/// The default template for the <see cref="ToolTip"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(ToolTip control)
{
return new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
[~Decorator.PaddingProperty] = control[~TemplatedControl.PaddingProperty],
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
}
};
}
}
}

0
samples/XamlTestApplicationPcl/TreeView.paml → src/Perspex.Themes.Default/TreeView.paml

0
samples/XamlTestApplicationPcl/TreeViewItem.paml → src/Perspex.Themes.Default/TreeViewItem.paml

162
src/Perspex.Themes.Default/TreeViewItemStyle.cs

@ -1,162 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Shapes;
using Perspex.Controls.Templates;
using Perspex.Layout;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
using Collections;
using Controls = Controls.Controls;
/// <summary>
/// The default style for the <see cref="TreeViewItem"/> control.
/// </summary>
public class TreeViewItemStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TreeViewItemStyle"/> class.
/// </summary>
public TreeViewItemStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TreeViewItem>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TreeViewItem>(Template)),
new Setter(Control.FocusAdornerProperty, null),
},
},
new Style(x => x.OfType<TreeViewItem>().Template().Name("header"))
{
Setters = new[]
{
new Setter(TemplatedControl.PaddingProperty, new Thickness(2)),
},
},
new Style(x => x.OfType<TreeViewItem>().Class(":selected").Template().Name("header"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xfff0f0f0)),
},
},
new Style(x => x.OfType<TreeViewItem>().Class(":selected").Class(":focus").Template().Name("header"))
{
Setters = new[]
{
new Setter(TemplatedControl.BackgroundProperty, new SolidColorBrush(0xff086f9e)),
new Setter(TemplatedControl.ForegroundProperty, Brushes.White),
},
},
new Style(x => x.OfType<TreeViewItem>().Template().OfType<ToggleButton>().Class("expander"))
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<ToggleButton>(ToggleButtonTemplate)),
},
},
new Style(x => x.OfType<TreeViewItem>().Template().OfType<ToggleButton>().Class("expander").Class(":checked").Template().OfType<Path>())
{
Setters = new[]
{
new Setter(Visual.RenderTransformProperty, new RotateTransform(45)),
},
},
new Style(x => x.OfType<TreeViewItem>().Class(":empty").Template().OfType<ToggleButton>().Class("expander"))
{
Setters = new[]
{
new Setter(Visual.IsVisibleProperty, false),
},
},
});
}
/// <summary>
/// The default template for the <see cref="TreeViewItem"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TreeViewItem control)
{
return new StackPanel
{
Children = new Controls
{
new Grid
{
ColumnDefinitions = new ColumnDefinitions
{
new ColumnDefinition(new GridLength(16, GridUnitType.Pixel)),
new ColumnDefinition(GridLength.Auto),
},
Children = new Controls
{
new ToggleButton
{
Classes = new Classes("expander"),
Focusable = false,
[~~ToggleButton.IsCheckedProperty] = control[~TreeViewItem.IsExpandedProperty],
},
new Border
{
Name = "header",
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[Grid.ColumnProperty] = 1,
Child = new ContentPresenter
{
[~ContentPresenter.ContentProperty] = control[~HeaderedItemsControl.HeaderProperty],
},
},
new Rectangle
{
Name = "focus",
Stroke = Brushes.Black,
StrokeThickness = 1,
StrokeDashArray = new PerspexList<double>(1, 2),
[Grid.ColumnProperty] = 1,
[!Rectangle.IsVisibleProperty] = control[!TreeViewItem.IsFocusedProperty],
}
}
},
new ItemsPresenter
{
Name = "itemsPresenter",
Margin = new Thickness(24, 0, 0, 0),
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
[~Visual.IsVisibleProperty] = control[~TreeViewItem.IsExpandedProperty],
}
}
};
}
private Control ToggleButtonTemplate(ToggleButton control)
{
return new Border
{
Width = 12,
Height = 14,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Child = new Path
{
Fill = Brushes.Black,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
}
};
}
}
}

65
src/Perspex.Themes.Default/TreeViewStyle.cs

@ -1,65 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="TreeView"/> control.
/// </summary>
public class TreeViewStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="TreeViewStyle"/> class.
/// </summary>
public TreeViewStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<TreeView>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<TreeView>(Template)),
new Setter(TemplatedControl.BorderBrushProperty, Brushes.Black),
new Setter(TemplatedControl.BorderThicknessProperty, 1.0),
},
},
});
}
/// <summary>
/// The default template for the <see cref="TreeView"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(TreeView control)
{
return new Border
{
Padding = new Thickness(4),
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
[~Border.BorderBrushProperty] = control[~TemplatedControl.BorderBrushProperty],
[~Border.BorderThicknessProperty] = control[~TemplatedControl.BorderThicknessProperty],
Child = new ScrollViewer
{
CanScrollHorizontally = true,
Content = new ItemsPresenter
{
Name = "itemsPresenter",
MemberSelector = control.MemberSelector,
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty],
[~ItemsPresenter.ItemsPanelProperty] = control[~ItemsControl.ItemsPanelProperty],
}
}
};
}
}
}

0
samples/XamlTestApplicationPcl/Window.paml → src/Perspex.Themes.Default/Window.paml

58
src/Perspex.Themes.Default/WindowStyle.cs

@ -1,58 +0,0 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System.Linq;
using Perspex.Controls;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates;
using Perspex.Styling;
namespace Perspex.Themes.Default
{
/// <summary>
/// The default style for the <see cref="Window"/> control.
/// </summary>
public class WindowStyle : Styles
{
/// <summary>
/// Initializes a new instance of the <see cref="WindowStyle"/> class.
/// </summary>
public WindowStyle()
{
AddRange(new[]
{
new Style(x => x.OfType<Window>())
{
Setters = new[]
{
new Setter(TemplatedControl.TemplateProperty, new FuncControlTemplate<Window>(Template)),
new Setter(TemplatedControl.FontFamilyProperty, "Segoe UI"),
new Setter(TemplatedControl.FontSizeProperty, 12.0),
},
},
});
}
/// <summary>
/// The default template for the <see cref="Window"/> control.
/// </summary>
/// <param name="control">The control being styled.</param>
/// <returns>The root of the instantiated template.</returns>
public static Control Template(Window control)
{
return new Border
{
[~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
Child = new AdornerDecorator
{
Child = new ContentPresenter
{
Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
}
}
};
}
}
}
Loading…
Cancel
Save