Browse Source

More stylecoping.

pull/72/merge
Steven Kirk 11 years ago
parent
commit
aa147f0423
  1. 4
      Perspex.Animation/Properties/AssemblyInfo.cs
  2. 2
      Perspex.Base/Diagnostics/PerspexObjectExtensions.cs
  3. 2
      Perspex.Base/Diagnostics/PerspexPropertyValue.cs
  4. 2
      Perspex.Base/PerspexProperty.cs
  5. 2
      Perspex.Base/PriorityValue.cs
  6. 6
      Perspex.Base/Properties/AssemblyInfo.cs
  7. 36
      Perspex.Base/Threading/DispatcherTimer.cs
  8. 4
      Perspex.Base/Threading/PerspexScheduler.cs
  9. 2
      Perspex.Base/Utilities/MathUtilities.cs
  10. 2
      Perspex.Controls/Button.cs
  11. 6
      Perspex.Controls/GridLength.cs
  12. 2
      Perspex.Controls/GridSplitter.cs
  13. 8
      Perspex.Controls/ISelectable.cs
  14. 4
      Perspex.Controls/Menu.cs
  15. 2
      Perspex.Controls/MenuItem.cs
  16. 4
      Perspex.Controls/Mixins/SelectableMixin.cs
  17. 1
      Perspex.Controls/Parsers/GridLengthsParser.cs
  18. 2
      Perspex.Controls/Presenters/ContentPresenter.cs
  19. 3
      Perspex.Controls/Presenters/DeckPresenter.cs
  20. 4
      Perspex.Controls/Presenters/IContentPresenter.cs
  21. 2
      Perspex.Controls/Presenters/IItemsPresenter.cs
  22. 1
      Perspex.Controls/Presenters/IPresenter.cs
  23. 2
      Perspex.Controls/Presenters/ItemsPresenter.cs
  24. 4
      Perspex.Controls/Presenters/TextPresenter.cs
  25. 2
      Perspex.Controls/Primitives/AccessText.cs
  26. 27
      Perspex.Controls/Primitives/AdornerLayer.cs
  27. 1
      Perspex.Controls/Primitives/SelectingItemsControl.cs
  28. 4
      Perspex.Controls/Primitives/Track.cs
  29. 6
      Perspex.Controls/Properties/AssemblyInfo.cs
  30. 2
      Perspex.Controls/Shapes/Shape.cs
  31. 4
      Perspex.Controls/TabControl.cs
  32. 2
      Perspex.Controls/Templates/TemplateExtensions.cs
  33. 4
      Perspex.Controls/TextBox.cs
  34. 6
      Perspex.Controls/ToolTip.cs
  35. 42
      Perspex.Controls/TopLevel.cs
  36. 2
      Perspex.Controls/Utils/StringUtils.cs
  37. 2
      Perspex.Controls/Window.cs
  38. 4
      Perspex.Diagnostics/DevTools.cs
  39. 6
      Perspex.Diagnostics/Properties/AssemblyInfo.cs
  40. 6
      Perspex.Diagnostics/ViewModels/DevToolsViewModel.cs
  41. 9
      Perspex.Diagnostics/Views/ControlDetailsView.cs
  42. 5
      Perspex.Diagnostics/Views/GridRepeater.cs
  43. 2
      Perspex.Diagnostics/Views/TreePage.cs
  44. 5
      Perspex.Input/FocusManager.cs
  45. 10
      Perspex.Input/InputElement.cs
  46. 4
      Perspex.Input/InputExtensions.cs
  47. 2
      Perspex.Input/KeyboardNavigationMode.cs
  48. 4
      Perspex.Input/MouseDevice.cs
  49. 6
      Perspex.Input/Properties/AssemblyInfo.cs
  50. 6
      Perspex.Input/Raw/RawKeyEventArgs.cs
  51. 10
      Perspex.Interactive.UnitTests/Properties/AssemblyInfo.cs
  52. 6
      Perspex.Interactivity/Properties/AssemblyInfo.cs
  53. 42
      Perspex.Interactivity/RoutedEvent.cs
  54. 14
      Perspex.Layout/GlobalSuppressions.cs
  55. 4
      Perspex.Layout/ILayoutManager.cs
  56. 6
      Perspex.Layout/LayoutManager.cs
  57. 2
      Perspex.Layout/Layoutable.cs
  58. 6
      Perspex.Layout/Properties/AssemblyInfo.cs
  59. 1
      Perspex.SceneGraph/IVisual.cs
  60. 30
      Perspex.SceneGraph/Matrix.cs
  61. 10
      Perspex.SceneGraph/Media/FormattedText.cs
  62. 2
      Perspex.SceneGraph/Media/FormattedTextLine.cs
  63. 14
      Perspex.SceneGraph/Media/IDrawingContext.cs
  64. 4
      Perspex.SceneGraph/Media/PathMarkupParser.cs
  65. 8
      Perspex.SceneGraph/Media/SolidColorBrush.cs
  66. 4
      Perspex.SceneGraph/Origin.cs
  67. 6
      Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs
  68. 65
      Perspex.SceneGraph/Point.cs
  69. 6
      Perspex.SceneGraph/Properties/AssemblyInfo.cs
  70. 10
      Perspex.SceneGraph/Rect.cs
  71. 6
      Perspex.SceneGraph/Rendering/RendererBase.cs
  72. 15
      Perspex.SceneGraph/Size.cs
  73. 2
      Perspex.SceneGraph/Thickness.cs
  74. 41
      Perspex.SceneGraph/Vector.cs
  75. 6
      Perspex.SceneGraph/Visual.cs
  76. 2
      Perspex.SceneGraph/VisualTree/IHostedVisualTreeRoot.cs
  77. 6
      Perspex.Styling/Properties/AssemblyInfo.cs
  78. 2
      Perspex.Styling/Styling/INamed.cs
  79. 2
      Perspex.Styling/Styling/Selector.cs
  80. 6
      Perspex.Styling/Styling/SelectorMatch.cs
  81. 8
      Perspex.Styling/Styling/Selectors.cs
  82. 8
      Perspex.Styling/Styling/StyleActivator.cs
  83. 5
      Perspex.Styling/Styling/StyleBinding.cs
  84. 2
      Perspex.Themes.Default/ContentControlStyle.cs
  85. 3
      Perspex.Themes.Default/DropDownStyle.cs
  86. 6
      Perspex.Themes.Default/Properties/AssemblyInfo.cs
  87. 2
      Tests/Perspex.Base.UnitTests/PerspexObjectTests_SetValue.cs
  88. 2
      Tests/Perspex.Base.UnitTests/PerspexPropertyTests.cs
  89. 4
      Tests/Perspex.Base.UnitTests/PriorityValueTests.cs
  90. 10
      Tests/Perspex.Base.UnitTests/Properties/AssemblyInfo.cs
  91. 3
      Tests/Perspex.Controls.UnitTests/ContentControlTests.cs
  92. 30
      Tests/Perspex.Controls.UnitTests/Presenters/ScrollContentPresenterTests.cs
  93. 10
      Tests/Perspex.Controls.UnitTests/Properties/AssemblyInfo.cs
  94. 1
      Tests/Perspex.Controls.UnitTests/ScrollViewerTests.cs
  95. 2
      Tests/Perspex.Controls.UnitTests/TabControlTests.cs
  96. 12
      Tests/Perspex.Controls.UnitTests/TemplatedControlTests.cs
  97. 4
      Tests/Perspex.Controls.UnitTests/TestTemplatedControl.cs
  98. 8
      Tests/Perspex.Controls.UnitTests/TopLevelTests.cs
  99. 12
      Tests/Perspex.Direct2D1.UnitTests/Controls/Shapes/PathTests.cs
  100. 10
      Tests/Perspex.Direct2D1.UnitTests/Media/GeometryTests.cs

4
Perspex.Animation/Properties/AssemblyInfo.cs

@ -4,10 +4,8 @@
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System.Resources;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Resources;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information

2
Perspex.Base/Diagnostics/PerspexObjectExtensions.cs

@ -25,7 +25,7 @@ namespace Perspex.Diagnostics
else else
{ {
return new PerspexPropertyValue( return new PerspexPropertyValue(
property, property,
o.GetValue(property), o.GetValue(property),
BindingPriority.Unset, BindingPriority.Unset,
"Unset"); "Unset");

2
Perspex.Base/Diagnostics/PerspexPropertyValue.cs

@ -9,7 +9,7 @@ namespace Perspex.Diagnostics
public class PerspexPropertyValue public class PerspexPropertyValue
{ {
public PerspexPropertyValue( public PerspexPropertyValue(
PerspexProperty property, PerspexProperty property,
object value, object value,
BindingPriority priority, BindingPriority priority,
string diagnostic) string diagnostic)

2
Perspex.Base/PerspexProperty.cs

@ -468,7 +468,7 @@ namespace Perspex
private static Func<PerspexObject, TValue, TValue> Cast<TOwner, TValue>(Func<TOwner, TValue, TValue> f) private static Func<PerspexObject, TValue, TValue> Cast<TOwner, TValue>(Func<TOwner, TValue, TValue> f)
where TOwner : PerspexObject where TOwner : PerspexObject
{ {
return f != null ? (o, v) => f((TOwner)o, v) : (Func < PerspexObject, TValue, TValue > )null; return f != null ? (o, v) => f((TOwner)o, v) : (Func<PerspexObject, TValue, TValue>)null;
} }
/// <summary> /// <summary>

2
Perspex.Base/PriorityValue.cs

@ -18,7 +18,7 @@ namespace Perspex
/// Maintains a list of prioritised bindings together with a current value. /// Maintains a list of prioritised bindings together with a current value.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Bindings, in the form of <see cref="IObservable{object}"/>s are added to the object using /// Bindings, in the form of <see cref="IObservable{Object}"/>s are added to the object using
/// the <see cref="Add"/> method. With the observable is passed a priority, where lower values /// the <see cref="Add"/> method. With the observable is passed a priority, where lower values
/// represent higher priorites. The current <see cref="Value"/> is selected from the highest /// represent higher priorites. The current <see cref="Value"/> is selected from the highest
/// priority binding that doesn't return <see cref="PerspexProperty.UnsetValue"/>. Where there /// priority binding that doesn't return <see cref="PerspexProperty.UnsetValue"/>. Where there

6
Perspex.Base/Properties/AssemblyInfo.cs

@ -8,7 +8,7 @@ using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Base")] [assembly: AssemblyTitle("Perspex.Base")]
@ -24,11 +24,11 @@ using System.Runtime.CompilerServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

36
Perspex.Base/Threading/DispatcherTimer.cs

@ -55,17 +55,17 @@ namespace Perspex.Threading
public event EventHandler Tick; public event EventHandler Tick;
public Dispatcher Dispatcher public Dispatcher Dispatcher
{ {
get; get;
private set; private set;
} }
public TimeSpan Interval public TimeSpan Interval
{ {
get get
{ {
return this.interval; return this.interval;
} }
set set
@ -76,14 +76,14 @@ namespace Perspex.Threading
this.IsEnabled = enabled; this.IsEnabled = enabled;
} }
} }
public bool IsEnabled public bool IsEnabled
{ {
get get
{ {
return this.timer != null; return this.timer != null;
} }
set set
{ {
if (this.IsEnabled != value) if (this.IsEnabled != value)
@ -99,11 +99,11 @@ namespace Perspex.Threading
} }
} }
} }
public object Tag public object Tag
{ {
get; get;
set; set;
} }
public static IDisposable Run(Func<bool> action, TimeSpan interval, DispatcherPriority priority = DispatcherPriority.Normal) public static IDisposable Run(Func<bool> action, TimeSpan interval, DispatcherPriority priority = DispatcherPriority.Normal)
@ -132,7 +132,7 @@ namespace Perspex.Threading
this.timer = threading.StartTimer(this.Interval, this.InternalTick); this.timer = threading.StartTimer(this.Interval, this.InternalTick);
} }
} }
public void Stop() public void Stop()
{ {
if (this.IsEnabled) if (this.IsEnabled)

4
Perspex.Base/Threading/PerspexScheduler.cs

@ -17,11 +17,11 @@ namespace Perspex.Threading
public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action) public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action)
{ {
return DispatcherTimer.Run( return DispatcherTimer.Run(
() => () =>
{ {
action(this, state); action(this, state);
return false; return false;
}, },
dueTime); dueTime);
} }
} }

2
Perspex.Base/Utilities/MathUtilities.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="TypeUtilities.cs" company="Steven Kirk"> // <copyright file="MathUtilities.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

2
Perspex.Controls/Button.cs

@ -229,7 +229,7 @@ namespace Perspex.Controls
private void CanExecuteChanged(object sender, EventArgs e) private void CanExecuteChanged(object sender, EventArgs e)
{ {
// HACK: Just set the IsEnabled property for the moment. This needs to be changed to // HACK: Just set the IsEnabled property for the moment. This needs to be changed to
// use IsEnabledCore etc. but it will do for now. // use IsEnabledCore etc. but it will do for now.
this.IsEnabled = this.Command == null || this.Command.CanExecute(this.CommandParameter); this.IsEnabled = this.Command == null || this.Command.CanExecute(this.CommandParameter);
} }

6
Perspex.Controls/GridLength.cs

@ -121,7 +121,7 @@ namespace Perspex.Controls
/// Compares two GridLength structures for equality. /// Compares two GridLength structures for equality.
/// </summary> /// </summary>
/// <param name="a">The first GridLength.</param> /// <param name="a">The first GridLength.</param>
/// <param name="a">The first GridLength.</param> /// <param name="b">The second GridLength.</param>
/// <returns>True if the structures are equal, otherwise false.</returns> /// <returns>True if the structures are equal, otherwise false.</returns>
public static bool operator ==(GridLength a, GridLength b) public static bool operator ==(GridLength a, GridLength b)
{ {
@ -131,8 +131,8 @@ namespace Perspex.Controls
/// <summary> /// <summary>
/// Compares two GridLength structures for inequality. /// Compares two GridLength structures for inequality.
/// </summary> /// </summary>
/// <param name="a">The first GridLength.</param> /// <param name="gl1">The first GridLength.</param>
/// <param name="a">The first GridLength.</param> /// <param name="gl2">The first GridLength.</param>
/// <returns>True if the structures are unequal, otherwise false.</returns> /// <returns>True if the structures are unequal, otherwise false.</returns>
public static bool operator !=(GridLength gl1, GridLength gl2) public static bool operator !=(GridLength gl1, GridLength gl2)
{ {

2
Perspex.Controls/GridSplitter.cs

@ -9,7 +9,7 @@ namespace Perspex.Controls
using System; using System;
using Perspex.Controls.Primitives; using Perspex.Controls.Primitives;
using Perspex.Input; using Perspex.Input;
using Rendering; using Perspex.Rendering;
using Perspex.VisualTree; using Perspex.VisualTree;
public class GridSplitter : Thumb public class GridSplitter : Thumb

8
Perspex.Controls/ISelectable.cs

@ -12,10 +12,10 @@ namespace Perspex.Controls
/// Interface for objects that are selectable. /// Interface for objects that are selectable.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Controls such as <see cref="Selector"/> use this interface to indicate the selected /// Controls such as <see cref="SelectingItemsControl"/> use this interface to indicate the
/// control in a list. If changing the control's <see cref="IsSelected"/> property should /// selected control in a list. If changing the control's <see cref="IsSelected"/> property
/// update the selection in a <see cref="SelectingItemsControl"/> or equivalent, then the /// should update the selection in a <see cref="SelectingItemsControl"/> or equivalent, then
/// control should raise the <see cref="SelectingItemsControl.IsSelectedChangedEvent"/>. /// the control should raise the <see cref="SelectingItemsControl.IsSelectedChangedEvent"/>.
/// </remarks> /// </remarks>
public interface ISelectable public interface ISelectable
{ {

4
Perspex.Controls/Menu.cs

@ -9,11 +9,11 @@ namespace Perspex.Controls
using System; using System;
using System.Linq; using System.Linq;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using Perspex.Controls.Primitives;
using Perspex.Input; using Perspex.Input;
using Perspex.Interactivity;
using Perspex.LogicalTree; using Perspex.LogicalTree;
using Perspex.Rendering; using Perspex.Rendering;
using Perspex.Interactivity;
using Perspex.Controls.Primitives;
/// <summary> /// <summary>
/// A top-level menu control. /// A top-level menu control.

2
Perspex.Controls/MenuItem.cs

@ -75,7 +75,7 @@ namespace Perspex.Controls
RoutedEvent.Register<MenuItem, RoutedEventArgs>(nameof(SubmenuOpened), RoutingStrategies.Bubble); RoutedEvent.Register<MenuItem, RoutedEventArgs>(nameof(SubmenuOpened), RoutingStrategies.Bubble);
/// <summary> /// <summary>
/// The default value for the <see cref="ItemsPanel"/> property. /// The default value for the <see cref="ItemsControl.ItemsPanel"/> property.
/// </summary> /// </summary>
private static readonly ItemsPanelTemplate DefaultPanel = private static readonly ItemsPanelTemplate DefaultPanel =
new ItemsPanelTemplate(() => new StackPanel new ItemsPanelTemplate(() => new StackPanel

4
Perspex.Controls/Mixins/SelectableMixin.cs

@ -15,7 +15,7 @@ namespace Perspex.Controls.Mixins
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// <para> /// <para>
/// The <see cref="SelectableMixin{TControl}"/> adds behavior to a control which can be /// The <see cref="SelectableMixin"/> adds behavior to a control which can be
/// selected. It adds the following behavior: /// selected. It adds the following behavior:
/// </para> /// </para>
/// <list type="bullet"> /// <list type="bullet">
@ -38,7 +38,7 @@ namespace Perspex.Controls.Mixins
public static class SelectableMixin public static class SelectableMixin
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SelectableMixin{TControl}"/> class. /// Initializes a new instance of the <see cref="SelectableMixin"/> class.
/// </summary> /// </summary>
/// <typeparam name="TControl">The control type.</typeparam> /// <typeparam name="TControl">The control type.</typeparam>
/// <param name="isSelected">The IsSelected property.</param> /// <param name="isSelected">The IsSelected property.</param>

1
Perspex.Controls/Parsers/GridLengthsParser.cs

@ -10,7 +10,6 @@ namespace Perspex.Controls.Parsers
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
/// <summary> /// <summary>
/// Parses a string of <see cref="GridLength"/>s for <see cref="ColumnDefinitions"/> and /// Parses a string of <see cref="GridLength"/>s for <see cref="ColumnDefinitions"/> and
/// <see cref="RowDefinitions"/>. /// <see cref="RowDefinitions"/>.

2
Perspex.Controls/Presenters/ContentPresenter.cs

@ -6,6 +6,7 @@
namespace Perspex.Controls.Presenters namespace Perspex.Controls.Presenters
{ {
using Perspex.Controls.Primitives;
using Perspex.Controls.Templates; using Perspex.Controls.Templates;
/// <summary> /// <summary>
@ -115,7 +116,6 @@ namespace Perspex.Controls.Presenters
if (result.Parent == null) if (result.Parent == null)
{ {
((ISetLogicalParent)result).SetParent((ILogical)logicalHost ?? this); ((ISetLogicalParent)result).SetParent((ILogical)logicalHost ?? this);
} }
logicalChildren.Remove(old); logicalChildren.Remove(old);

3
Perspex.Controls/Presenters/DeckPresenter.cs

@ -12,10 +12,9 @@ namespace Perspex.Controls.Presenters
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Perspex.Animation; using Perspex.Animation;
using Perspex.Collections;
using Perspex.Controls.Generators; using Perspex.Controls.Generators;
using Perspex.Controls.Primitives; using Perspex.Controls.Primitives;
using Templates; using Perspex.Controls.Templates;
using Perspex.Controls.Utils; using Perspex.Controls.Utils;
/// <summary> /// <summary>

4
Perspex.Controls/Presenters/IContentPresenter.cs

@ -6,8 +6,10 @@
namespace Perspex.Controls.Presenters namespace Perspex.Controls.Presenters
{ {
using Perspex.Controls.Primitives;
/// <summary> /// <summary>
/// Interface for controls that present a single item of data inside a /// Interface for controls that present a single item of data inside a
/// <see cref="TemplatedControl"/> template. /// <see cref="TemplatedControl"/> template.
/// </summary> /// </summary>
public interface IContentPresenter : IPresenter public interface IContentPresenter : IPresenter

2
Perspex.Controls/Presenters/IItemsPresenter.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="IPresenter.cs" company="Steven Kirk"> // <copyright file="IItemsPresenter.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

1
Perspex.Controls/Presenters/IPresenter.cs

@ -6,6 +6,7 @@
namespace Perspex.Controls.Presenters namespace Perspex.Controls.Presenters
{ {
using Perspex.Controls.Primitives;
using Perspex.Styling; using Perspex.Styling;
/// <summary> /// <summary>

2
Perspex.Controls/Presenters/ItemsPresenter.cs

@ -10,7 +10,7 @@ namespace Perspex.Controls.Presenters
using System.Collections; using System.Collections;
using System.Collections.Specialized; using System.Collections.Specialized;
using Perspex.Controls.Generators; using Perspex.Controls.Generators;
using Templates; using Perspex.Controls.Templates;
using Perspex.Input; using Perspex.Input;
using Perspex.Styling; using Perspex.Styling;

4
Perspex.Controls/Presenters/TextPresenter.cs

@ -105,8 +105,8 @@ namespace Perspex.Controls.Presenters
var b = Math.Ceiling(charPos.Bottom) - 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5;
context.DrawLine( context.DrawLine(
new Pen(caretBrush, 1), new Pen(caretBrush, 1),
new Point(x, y), new Point(x, y),
new Point(x, b)); new Point(x, b));
} }
} }

2
Perspex.Controls/Primitives/AccessText.cs

@ -161,7 +161,7 @@ namespace Perspex.Controls.Primitives
} }
/// <summary> /// <summary>
/// Called when the <see cref="Text"/> property changes. /// Called when the <see cref="TextBlock.Text"/> property changes.
/// </summary> /// </summary>
/// <param name="text">The new text.</param> /// <param name="text">The new text.</param>
private void TextChanged(string text) private void TextChanged(string text)

27
Perspex.Controls/Primitives/AdornerLayer.cs

@ -7,7 +7,6 @@
namespace Perspex.Controls.Primitives namespace Perspex.Controls.Primitives
{ {
using System; using System;
using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using Perspex.VisualTree; using Perspex.VisualTree;
@ -31,7 +30,7 @@ namespace Perspex.Controls.Primitives
public AdornerLayer() public AdornerLayer()
{ {
this.Children.CollectionChanged += ChildrenCollectionChanged; this.Children.CollectionChanged += this.ChildrenCollectionChanged;
} }
public static Visual GetAdornedElement(Visual adorner) public static Visual GetAdornedElement(Visual adorner)
@ -73,6 +72,18 @@ namespace Perspex.Controls.Primitives
return finalSize; return finalSize;
} }
private static void AdornedElementChanged(PerspexPropertyChangedEventArgs e)
{
var adorner = (Visual)e.Sender;
var adorned = (Visual)e.NewValue;
var layer = adorner.GetVisualParent<AdornerLayer>();
if (layer != null)
{
layer.UpdateAdornedElement(adorner, adorned);
}
}
private void ChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) private void ChildrenCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{ {
switch (e.Action) switch (e.Action)
@ -119,18 +130,6 @@ namespace Perspex.Controls.Primitives
} }
} }
private static void AdornedElementChanged(PerspexPropertyChangedEventArgs e)
{
var adorner = (Visual)e.Sender;
var adorned = (Visual)e.NewValue;
var layer = adorner.GetVisualParent<AdornerLayer>();
if (layer != null)
{
layer.UpdateAdornedElement(adorner, adorned);
}
}
private class AdornedElementInfo private class AdornedElementInfo
{ {
public IDisposable Subscription { get; set; } public IDisposable Subscription { get; set; }

1
Perspex.Controls/Primitives/SelectingItemsControl.cs

@ -128,6 +128,7 @@ namespace Perspex.Controls.Primitives
{ {
this.SelectedIndex = 0; this.SelectedIndex = 0;
} }
break; break;
case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Remove:

4
Perspex.Controls/Primitives/Track.cs

@ -44,14 +44,14 @@ namespace Perspex.Controls.Primitives
{ {
if (val.Item1 != null) if (val.Item1 != null)
{ {
val.Item1.DragDelta -= ThumbDragged; val.Item1.DragDelta -= this.ThumbDragged;
} }
this.ClearVisualChildren(); this.ClearVisualChildren();
if (val.Item2 != null) if (val.Item2 != null)
{ {
val.Item2.DragDelta += ThumbDragged; val.Item2.DragDelta += this.ThumbDragged;
this.AddVisualChild(val.Item2); this.AddVisualChild(val.Item2);
} }
}); });

6
Perspex.Controls/Properties/AssemblyInfo.cs

@ -8,7 +8,7 @@ using System.Reflection;
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Controls")] [assembly: AssemblyTitle("Perspex.Controls")]
@ -24,11 +24,11 @@ using System.Runtime.CompilerServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

2
Perspex.Controls/Shapes/Shape.cs

@ -106,7 +106,7 @@ namespace Perspex.Controls.Shapes
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
// This should probably use GetRenderBounds(strokeThickness) but then the calculations // This should probably use GetRenderBounds(strokeThickness) but then the calculations
// will multiply the stroke thickness as well, which isn't correct. // will multiply the stroke thickness as well, which isn't correct.
Rect shapeBounds = this.DefiningGeometry.Bounds; Rect shapeBounds = this.DefiningGeometry.Bounds;
Size shapeSize = new Size(shapeBounds.Right, shapeBounds.Bottom); Size shapeSize = new Size(shapeBounds.Right, shapeBounds.Bottom);

4
Perspex.Controls/TabControl.cs

@ -38,7 +38,7 @@ namespace Perspex.Controls
} }
/// <summary> /// <summary>
/// Gets the <see cref="SelectedItem"/> as a <see cref="TabItem"/>. /// Gets the <see cref="SelectingItemsControl.SelectedItem"/> as a <see cref="TabItem"/>.
/// </summary> /// </summary>
public TabItem SelectedTab public TabItem SelectedTab
{ {
@ -69,7 +69,7 @@ namespace Perspex.Controls
} }
/// <summary> /// <summary>
/// Called when the <see cref="SelectedIndex"/> property changes. /// Called when the <see cref="SelectingItemsControl.SelectedIndex"/> property changes.
/// </summary> /// </summary>
/// <param name="e">The event args.</param> /// <param name="e">The event args.</param>
private void SelectedIndexChanged(PerspexPropertyChangedEventArgs e) private void SelectedIndexChanged(PerspexPropertyChangedEventArgs e)

2
Perspex.Controls/Templates/TemplateExtensions.cs

@ -71,7 +71,7 @@ namespace Perspex.Controls.Templates
if (visual != null) if (visual != null)
{ {
// TODO: This searches the whole descendent tree - it can stop when it exits the // TODO: This searches the whole descendent tree - it can stop when it exits the
// template. // template.
return visual.GetVisualDescendents() return visual.GetVisualDescendents()
.OfType<Control>() .OfType<Control>()

4
Perspex.Controls/TextBox.cs

@ -62,8 +62,8 @@ namespace Perspex.Controls
.Select(x => x ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden); .Select(x => x ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden);
this.Bind( this.Bind(
ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollViewer.HorizontalScrollBarVisibilityProperty,
horizontalScrollBarVisibility, horizontalScrollBarVisibility,
BindingPriority.Style); BindingPriority.Style);
} }

6
Perspex.Controls/ToolTip.cs

@ -17,9 +17,9 @@ namespace Perspex.Controls
/// A tooltip control. /// A tooltip control.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// You will probably not want to create a <see cref="ToolTip"/> control directly: if added to /// You will probably not want to create a <see cref="ToolTip"/> control directly: if added to
/// the tree it will act as a simple <see cref="ContentControl"/> styled to look like a tooltip. /// the tree it will act as a simple <see cref="ContentControl"/> styled to look like a tooltip.
/// To add a tooltip to a control, use the <see cref="TipProperty"/> attached property, /// To add a tooltip to a control, use the <see cref="TipProperty"/> attached property,
/// assigning the content that you want displayed. /// assigning the content that you want displayed.
/// </remarks> /// </remarks>
public class ToolTip : ContentControl public class ToolTip : ContentControl
@ -42,7 +42,7 @@ namespace Perspex.Controls
/// <summary> /// <summary>
/// Observable fired when a tooltip should be displayed for a control. The output from this /// Observable fired when a tooltip should be displayed for a control. The output from this
/// observable is throttled and calls <see cref="ShowToolTip(Control)"/> when the time /// observable is throttled and calls <see cref="ShowToolTip(Control)"/> when the time
/// period expires. /// period expires.
/// </summary> /// </summary>
private static Subject<Control> show = new Subject<Control>(); private static Subject<Control> show = new Subject<Control>();

42
Perspex.Controls/TopLevel.cs

@ -9,6 +9,7 @@ namespace Perspex.Controls
using System; using System;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Reactive.Linq; using System.Reactive.Linq;
using Perspex.Controls.Primitives;
using Perspex.Input; using Perspex.Input;
using Perspex.Input.Raw; using Perspex.Input.Raw;
using Perspex.Layout; using Perspex.Layout;
@ -16,8 +17,6 @@ namespace Perspex.Controls
using Perspex.Rendering; using Perspex.Rendering;
using Perspex.Styling; using Perspex.Styling;
using Perspex.Threading; using Perspex.Threading;
using Perspex.Controls.Primitives;
using Perspex.Interactivity;
using Splat; using Splat;
/// <summary> /// <summary>
@ -164,20 +163,6 @@ namespace Perspex.Controls
this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => this.PlatformImpl.ClientSize = x); this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => this.PlatformImpl.ClientSize = x);
} }
private static T TryGetService<T>(IDependencyResolver resolver) where T : class
{
var result = resolver.GetService<T>();
if (result == null)
{
System.Diagnostics.Debug.WriteLineIf(
result == null,
$"Could not create {typeof(T).Name} : maybe Application.RegisterServices() wasn't called?");
}
return result;
}
/// <summary> /// <summary>
/// Fired when the window is activated. /// Fired when the window is activated.
/// </summary> /// </summary>
@ -293,8 +278,8 @@ namespace Perspex.Controls
/// <returns>A disposable used to finish the operation.</returns> /// <returns>A disposable used to finish the operation.</returns>
/// <remarks> /// <remarks>
/// When an auto-resize operation is in progress any resize events received will not be /// When an auto-resize operation is in progress any resize events received will not be
/// cause the new size to be written to the <see cref="Width"/> and <see cref="Height"/> /// cause the new size to be written to the <see cref="Layoutable.Width"/> and
/// properties. /// <see cref="Layoutable.Height"/> properties.
/// </remarks> /// </remarks>
protected IDisposable BeginAutoSizing() protected IDisposable BeginAutoSizing()
{ {
@ -317,6 +302,27 @@ namespace Perspex.Controls
return base.ArrangeOverride(finalSize); return base.ArrangeOverride(finalSize);
} }
/// <summary>
/// Tries to get a service from an <see cref="IDependencyResolver"/>, throwing an
/// exception if not found.
/// </summary>
/// <typeparam name="T">The service type.</typeparam>
/// <param name="resolver">The resolver.</param>
/// <returns>The service.</returns>
private static T TryGetService<T>(IDependencyResolver resolver) where T : class
{
var result = resolver.GetService<T>();
if (result == null)
{
System.Diagnostics.Debug.WriteLineIf(
result == null,
$"Could not create {typeof(T).Name} : maybe Application.RegisterServices() wasn't called?");
}
return result;
}
/// <summary> /// <summary>
/// Handles an activated notification from <see cref="ITopLevelImpl.Activated"/>. /// Handles an activated notification from <see cref="ITopLevelImpl.Activated"/>.
/// </summary> /// </summary>

2
Perspex.Controls/Utils/StringUtils.cs

@ -24,7 +24,7 @@ namespace Perspex.Controls.Utils
public static bool IsStartOfWord(string text, int index) public static bool IsStartOfWord(string text, int index)
{ {
// A 'word' starts with an AlphaNumeric or some punctuation symbols immediately // A 'word' starts with an AlphaNumeric or some punctuation symbols immediately
// preceeded by lwsp. // preceeded by lwsp.
if (index > 0 && !char.IsWhiteSpace(text[index - 1])) if (index > 0 && !char.IsWhiteSpace(text[index - 1]))
{ {

2
Perspex.Controls/Window.cs

@ -91,7 +91,7 @@ namespace Perspex.Controls
var modal = this.PlatformImpl.ShowDialog(); var modal = this.PlatformImpl.ShowDialog();
var result = new TaskCompletionSource<TResult>(); var result = new TaskCompletionSource<TResult>();
Observable.FromEventPattern(this, nameof(Closed)) Observable.FromEventPattern(this, nameof(this.Closed))
.Take(1) .Take(1)
.Subscribe(_ => .Subscribe(_ =>
{ {

4
Perspex.Diagnostics/DevTools.cs

@ -37,8 +37,8 @@ namespace Perspex.Diagnostics
public static IDisposable Attach(Window window) public static IDisposable Attach(Window window)
{ {
return window.AddHandler( return window.AddHandler(
Window.KeyDownEvent, Window.KeyDownEvent,
WindowPreviewKeyDown, WindowPreviewKeyDown,
Interactivity.RoutingStrategies.Tunnel); Interactivity.RoutingStrategies.Tunnel);
} }

6
Perspex.Diagnostics/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Diagnostics")] [assembly: AssemblyTitle("Perspex.Diagnostics")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

6
Perspex.Diagnostics/ViewModels/DevToolsViewModel.cs

@ -8,8 +8,8 @@ namespace Perspex.Diagnostics.ViewModels
{ {
using System; using System;
using Perspex.Controls; using Perspex.Controls;
using ReactiveUI;
using Perspex.Input; using Perspex.Input;
using ReactiveUI;
internal class DevToolsViewModel : ReactiveObject internal class DevToolsViewModel : ReactiveObject
{ {
@ -25,8 +25,8 @@ namespace Perspex.Diagnostics.ViewModels
{ {
this.WhenAnyValue(x => x.Root).Subscribe(x => this.WhenAnyValue(x => x.Root).Subscribe(x =>
{ {
this.LogicalTree = new LogicalTreeViewModel(root); this.LogicalTree = new LogicalTreeViewModel(this.root);
this.VisualTree = new VisualTreeViewModel(root); this.VisualTree = new VisualTreeViewModel(this.root);
}); });
this.focusedControl = KeyboardDevice.Instance.WhenAnyValue(x => x.FocusedElement) this.focusedControl = KeyboardDevice.Instance.WhenAnyValue(x => x.FocusedElement)

9
Perspex.Diagnostics/Views/ControlDetailsView.cs

@ -1,19 +1,18 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="DevTools.cs" company="Steven Kirk"> // <copyright file="ControlDetailsView.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
namespace Perspex.Diagnostics.Views namespace Perspex.Diagnostics.Views
{ {
using System;
using System.Collections.Generic;
using System.Reactive.Linq;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Diagnostics.ViewModels; using Perspex.Diagnostics.ViewModels;
using Perspex.Styling; using Perspex.Styling;
using ReactiveUI; using ReactiveUI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reactive.Linq;
internal class ControlDetailsView : UserControl internal class ControlDetailsView : UserControl
{ {

5
Perspex.Diagnostics/Views/GridRepeater.cs

@ -1,16 +1,15 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="VisualTreeView.cs" company="Steven Kirk"> // <copyright file="GridRepeater.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
namespace Perspex.Diagnostics.Views namespace Perspex.Diagnostics.Views
{ {
using Perspex.Controls;
using Perspex.Controls.Templates;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Perspex.Controls;
internal static class GridRepeater internal static class GridRepeater
{ {

2
Perspex.Diagnostics/Views/TreePage.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="DevTools.cs" company="Steven Kirk"> // <copyright file="TreePage.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

5
Perspex.Input/FocusManager.cs

@ -9,10 +9,9 @@ namespace Perspex.Input
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Perspex.Interactivity;
using Perspex.VisualTree; using Perspex.VisualTree;
using Splat; using Splat;
using Perspex.Interactivity;
/// <summary> /// <summary>
/// Manages focus for the application. /// Manages focus for the application.
@ -166,7 +165,7 @@ namespace Perspex.Input
yield return scope; yield return scope;
} }
control = control.GetVisualParent<IInputElement>() ?? control = control.GetVisualParent<IInputElement>() ??
((control as IHostedVisualTreeRoot)?.Host as IInputElement); ((control as IHostedVisualTreeRoot)?.Host as IInputElement);
} }
} }

10
Perspex.Input/InputElement.cs

@ -43,7 +43,7 @@ namespace Perspex.Input
public static readonly RoutedEvent<KeyEventArgs> KeyDownEvent = public static readonly RoutedEvent<KeyEventArgs> KeyDownEvent =
RoutedEvent.Register<InputElement, KeyEventArgs>( RoutedEvent.Register<InputElement, KeyEventArgs>(
"KeyDown", "KeyDown",
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
public static readonly RoutedEvent<KeyEventArgs> KeyUpEvent = public static readonly RoutedEvent<KeyEventArgs> KeyUpEvent =
@ -59,22 +59,22 @@ namespace Perspex.Input
public static readonly RoutedEvent<PointerEventArgs> PointerMovedEvent = public static readonly RoutedEvent<PointerEventArgs> PointerMovedEvent =
RoutedEvent.Register<InputElement, PointerEventArgs>( RoutedEvent.Register<InputElement, PointerEventArgs>(
"PointerMove", "PointerMove",
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
public static readonly RoutedEvent<PointerPressEventArgs> PointerPressedEvent = public static readonly RoutedEvent<PointerPressEventArgs> PointerPressedEvent =
RoutedEvent.Register<InputElement, PointerPressEventArgs>( RoutedEvent.Register<InputElement, PointerPressEventArgs>(
"PointerPressed", "PointerPressed",
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
public static readonly RoutedEvent<PointerEventArgs> PointerReleasedEvent = public static readonly RoutedEvent<PointerEventArgs> PointerReleasedEvent =
RoutedEvent.Register<InputElement, PointerEventArgs>( RoutedEvent.Register<InputElement, PointerEventArgs>(
"PointerReleased", "PointerReleased",
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
public static readonly RoutedEvent<PointerWheelEventArgs> PointerWheelChangedEvent = public static readonly RoutedEvent<PointerWheelEventArgs> PointerWheelChangedEvent =
RoutedEvent.Register<InputElement, PointerWheelEventArgs>( RoutedEvent.Register<InputElement, PointerWheelEventArgs>(
"PointerWheelChanged", "PointerWheelChanged",
RoutingStrategies.Tunnel | RoutingStrategies.Bubble); RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
static InputElement() static InputElement()

4
Perspex.Input/InputExtensions.cs

@ -16,9 +16,9 @@ namespace Perspex.Input
{ {
Contract.Requires<NullReferenceException>(element != null); Contract.Requires<NullReferenceException>(element != null);
if (element.Bounds.Contains(p) && if (element.Bounds.Contains(p) &&
element.IsVisible && element.IsVisible &&
element.IsHitTestVisible && element.IsHitTestVisible &&
element.IsEnabledCore) element.IsEnabledCore)
{ {
p -= element.Bounds.Position; p -= element.Bounds.Position;

2
Perspex.Input/KeyboardNavigationMode.cs

@ -7,7 +7,7 @@
namespace Perspex.Input namespace Perspex.Input
{ {
/// <summary> /// <summary>
/// Defines the mode of keyboard traversal within a container when the tab or arrow keys are /// Defines the mode of keyboard traversal within a container when the tab or arrow keys are
/// pressed. /// pressed.
/// </summary> /// </summary>
public enum KeyboardNavigationMode public enum KeyboardNavigationMode

4
Perspex.Input/MouseDevice.cs

@ -222,8 +222,8 @@ namespace Perspex.Input
private IInteractive GetSource(IVisual hit) private IInteractive GetSource(IVisual hit)
{ {
return this.Captured ?? return this.Captured ??
(hit as IInteractive) ?? (hit as IInteractive) ??
hit.GetSelfAndVisualAncestors().OfType<IInteractive>().FirstOrDefault(); hit.GetSelfAndVisualAncestors().OfType<IInteractive>().FirstOrDefault();
} }

6
Perspex.Input/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Input")] [assembly: AssemblyTitle("Perspex.Input")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

6
Perspex.Input/Raw/RawKeyEventArgs.cs

@ -15,10 +15,10 @@ namespace Perspex.Input.Raw
public class RawKeyEventArgs : RawInputEventArgs public class RawKeyEventArgs : RawInputEventArgs
{ {
public RawKeyEventArgs( public RawKeyEventArgs(
IKeyboardDevice device, IKeyboardDevice device,
uint timestamp, uint timestamp,
RawKeyEventType type, RawKeyEventType type,
Key key, Key key,
string text) string text)
: base(device, timestamp) : base(device, timestamp)
{ {

10
Perspex.Interactive.UnitTests/Properties/AssemblyInfo.cs

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Interactive.UnitTests")] [assembly: AssemblyTitle("Perspex.Interactive.UnitTests")]
@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

6
Perspex.Interactivity/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Interactive")] [assembly: AssemblyTitle("Perspex.Interactive")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

42
Perspex.Interactivity/RoutedEvent.cs

@ -24,7 +24,7 @@ namespace Perspex.Interactivity
private List<ClassEventSubscription> subscriptions = new List<ClassEventSubscription>(); private List<ClassEventSubscription> subscriptions = new List<ClassEventSubscription>();
public RoutedEvent( public RoutedEvent(
string name, string name,
RoutingStrategies routingStrategies, RoutingStrategies routingStrategies,
Type eventArgsType, Type eventArgsType,
Type ownerType) Type ownerType)
@ -40,28 +40,28 @@ namespace Perspex.Interactivity
this.RoutingStrategies = routingStrategies; this.RoutingStrategies = routingStrategies;
} }
public Type EventArgsType public Type EventArgsType
{ {
get; get;
private set; private set;
} }
public string Name public string Name
{ {
get; get;
private set; private set;
} }
public Type OwnerType public Type OwnerType
{ {
get; get;
private set; private set;
} }
public RoutingStrategies RoutingStrategies public RoutingStrategies RoutingStrategies
{ {
get; get;
private set; private set;
} }
public static RoutedEvent<TEventArgs> Register<TOwner, TEventArgs>( public static RoutedEvent<TEventArgs> Register<TOwner, TEventArgs>(
@ -77,7 +77,7 @@ namespace Perspex.Interactivity
public static RoutedEvent<TEventArgs> Register<TEventArgs>( public static RoutedEvent<TEventArgs> Register<TEventArgs>(
string name, string name,
RoutingStrategies routingStrategy, RoutingStrategies routingStrategy,
Type ownerType) Type ownerType)
where TEventArgs : RoutedEventArgs where TEventArgs : RoutedEventArgs
{ {
Contract.Requires<NullReferenceException>(name != null); Contract.Requires<NullReferenceException>(name != null);
@ -126,15 +126,15 @@ namespace Perspex.Interactivity
public void AddClassHandler<TTarget>( public void AddClassHandler<TTarget>(
Func<TTarget, Action<TEventArgs>> handler, Func<TTarget, Action<TEventArgs>> handler,
RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble) RoutingStrategies routes = RoutingStrategies.Direct | RoutingStrategies.Bubble)
where TTarget : class where TTarget : class
{ {
this.AddClassHandler(typeof(TTarget), (s, e) => ClassHandlerAdapter<TTarget>(s, e, handler), routes); this.AddClassHandler(typeof(TTarget), (s, e) => ClassHandlerAdapter<TTarget>(s, e, handler), routes);
} }
private static void ClassHandlerAdapter<TTarget>( private static void ClassHandlerAdapter<TTarget>(
object sender, object sender,
RoutedEventArgs e, RoutedEventArgs e,
Func<TTarget, Action<TEventArgs>> handler) where TTarget : class Func<TTarget, Action<TEventArgs>> handler) where TTarget : class
{ {
var target = sender as TTarget; var target = sender as TTarget;

14
Perspex.Layout/GlobalSuppressions.cs

@ -0,0 +1,14 @@
// -----------------------------------------------------------------------
// <copyright file="GlobalSuppressions.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.MaintainabilityRules",
"SA1401:Fields must be private",
Justification = "Routed event fields should not be private.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1609:Property documentation must have value",
Justification = "This rule is fscking pointless")]

4
Perspex.Layout/ILayoutManager.cs

@ -15,7 +15,7 @@ namespace Perspex.Layout
/// <remarks> /// <remarks>
/// Each layout root element such as a window has its own LayoutManager that is responsible /// Each layout root element such as a window has its own LayoutManager that is responsible
/// for laying out its child controls. When a layout is required the <see cref="LayoutNeeded"/> /// for laying out its child controls. When a layout is required the <see cref="LayoutNeeded"/>
/// observable will fire and the root element should respond by calling /// observable will fire and the root element should respond by calling
/// <see cref="ExecuteLayoutPass"/> at the earliest opportunity to carry out the layout. /// <see cref="ExecuteLayoutPass"/> at the earliest opportunity to carry out the layout.
/// </remarks> /// </remarks>
public interface ILayoutManager public interface ILayoutManager
@ -42,7 +42,7 @@ namespace Perspex.Layout
/// Gets a value indicating whether a layout is queued. /// Gets a value indicating whether a layout is queued.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Returns true when <see cref="LayoutNeeded"/> has been fired, but /// Returns true when <see cref="LayoutNeeded"/> has been fired, but
/// <see cref="ExecuteLayoutPass"/> has not yet been called. /// <see cref="ExecuteLayoutPass"/> has not yet been called.
/// </remarks> /// </remarks>
bool LayoutQueued { get; } bool LayoutQueued { get; }

6
Perspex.Layout/LayoutManager.cs

@ -8,12 +8,12 @@ namespace Perspex.Layout
{ {
using System; using System;
using System.Reactive; using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Subjects; using System.Reactive.Subjects;
using NGenerics.DataStructures.General; using NGenerics.DataStructures.General;
using Perspex.VisualTree; using Perspex.VisualTree;
using Serilog; using Serilog;
using Serilog.Core.Enrichers; using Serilog.Core.Enrichers;
using System.Reactive.Disposables;
/// <summary> /// <summary>
/// Manages measuring and arranging of controls. /// Manages measuring and arranging of controls.
@ -21,7 +21,7 @@ namespace Perspex.Layout
/// <remarks> /// <remarks>
/// Each layout root element such as a window has its own LayoutManager that is responsible /// Each layout root element such as a window has its own LayoutManager that is responsible
/// for laying out its child controls. When a layout is required the <see cref="LayoutNeeded"/> /// for laying out its child controls. When a layout is required the <see cref="LayoutNeeded"/>
/// observable will fire and the root element should respond by calling /// observable will fire and the root element should respond by calling
/// <see cref="ExecuteLayoutPass"/> at the earliest opportunity to carry out the layout. /// <see cref="ExecuteLayoutPass"/> at the earliest opportunity to carry out the layout.
/// </remarks> /// </remarks>
public class LayoutManager : ILayoutManager public class LayoutManager : ILayoutManager
@ -108,7 +108,7 @@ namespace Perspex.Layout
/// Gets a value indicating whether a layout is queued. /// Gets a value indicating whether a layout is queued.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Returns true when <see cref="LayoutNeeded"/> has been fired, but /// Returns true when <see cref="LayoutNeeded"/> has been fired, but
/// <see cref="ExecuteLayoutPass"/> has not yet been called. /// <see cref="ExecuteLayoutPass"/> has not yet been called.
/// </remarks> /// </remarks>
public bool LayoutQueued public bool LayoutQueued

2
Perspex.Layout/Layoutable.cs

@ -218,7 +218,7 @@ namespace Perspex.Layout
throw new InvalidOperationException("Invalid Arrange rectangle."); throw new InvalidOperationException("Invalid Arrange rectangle.");
} }
// If the measure was invalidated during an arrange pass, wait for the measure pass to // If the measure was invalidated during an arrange pass, wait for the measure pass to
// be re-run. // be re-run.
if (!this.IsMeasureValid) if (!this.IsMeasureValid)
{ {

6
Perspex.Layout/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Layout")] [assembly: AssemblyTitle("Perspex.Layout")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

1
Perspex.SceneGraph/IVisual.cs

@ -8,6 +8,7 @@ namespace Perspex
{ {
using Perspex.Collections; using Perspex.Collections;
using Perspex.Media; using Perspex.Media;
using Perspex.VisualTree;
/// <summary> /// <summary>
/// Represents a node in the visual scene graph. /// Represents a node in the visual scene graph.

30
Perspex.SceneGraph/Matrix.cs

@ -94,6 +94,21 @@ namespace Perspex
(left.offsetX * right.M12) + (left.offsetY * right.M22) + right.offsetY); (left.offsetX * right.M12) + (left.offsetY * right.M22) + right.offsetY);
} }
public static Matrix operator -(Matrix matrix)
{
return matrix.Invert();
}
public static bool operator ==(Matrix matrix1, Matrix matrix2)
{
return matrix1.Equals(matrix2);
}
public static bool operator !=(Matrix matrix1, Matrix matrix2)
{
return !matrix1.Equals(matrix2);
}
public static bool Equals(Matrix matrix1, Matrix matrix2) public static bool Equals(Matrix matrix1, Matrix matrix2)
{ {
return matrix1.Equals(matrix2); return matrix1.Equals(matrix2);
@ -131,21 +146,6 @@ namespace Perspex
return angle * 0.0174532925; return angle * 0.0174532925;
} }
public static Matrix operator -(Matrix matrix)
{
return matrix.Invert();
}
public static bool operator ==(Matrix matrix1, Matrix matrix2)
{
return matrix1.Equals(matrix2);
}
public static bool operator !=(Matrix matrix1, Matrix matrix2)
{
return !matrix1.Equals(matrix2);
}
public bool Equals(Matrix value) public bool Equals(Matrix value)
{ {
return this.m11 == value.M11 && return this.m11 == value.M11 &&

10
Perspex.SceneGraph/Media/FormattedText.cs

@ -31,10 +31,10 @@ namespace Perspex.Media
var platform = Locator.Current.GetService<IPlatformRenderInterface>(); var platform = Locator.Current.GetService<IPlatformRenderInterface>();
this.PlatformImpl = platform.CreateFormattedText( this.PlatformImpl = platform.CreateFormattedText(
text, text,
fontFamilyName, fontFamilyName,
fontSize, fontSize,
fontStyle, fontStyle,
textAlignment, textAlignment,
fontWeight); fontWeight);
} }
@ -122,4 +122,4 @@ namespace Perspex.Media
this.PlatformImpl.SetForegroundBrush(brush, startIndex, count); this.PlatformImpl.SetForegroundBrush(brush, startIndex, count);
} }
} }
} }

2
Perspex.SceneGraph/Media/FormattedTextLine.cs

@ -18,4 +18,4 @@ namespace Perspex.Media
public double Height { get; private set; } public double Height { get; private set; }
} }
} }

14
Perspex.SceneGraph/Media/IDrawingContext.cs

@ -14,8 +14,18 @@ namespace Perspex.Media
/// </summary> /// </summary>
public interface IDrawingContext : IDisposable public interface IDrawingContext : IDisposable
{ {
/// <summary>
/// Gets the current transform of the drawing context.
/// </summary>
Matrix CurrentTransform { get; } Matrix CurrentTransform { get; }
/// <summary>
/// Draws a bitmap image.
/// </summary>
/// <param name="source">The bitmap image.</param>
/// <param name="opacity">The opacity to draw with.</param>
/// <param name="sourceRect">The rect in the image to draw.</param>
/// <param name="destRect">The rect in the output to draw to.</param>
void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect); void DrawImage(IBitmap source, double opacity, Rect sourceRect, Rect destRect);
/// <summary> /// <summary>
@ -23,7 +33,7 @@ namespace Perspex.Media
/// </summary> /// </summary>
/// <param name="pen">The stroke pen.</param> /// <param name="pen">The stroke pen.</param>
/// <param name="p1">The first point of the line.</param> /// <param name="p1">The first point of the line.</param>
/// <param name="p1">The second point of the line.</param> /// <param name="p2">The second point of the line.</param>
void DrawLine(Pen pen, Point p1, Point p2); void DrawLine(Pen pen, Point p1, Point p2);
/// <summary> /// <summary>
@ -39,6 +49,7 @@ namespace Perspex.Media
/// </summary> /// </summary>
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="rect">The rectangle bounds.</param> /// <param name="rect">The rectangle bounds.</param>
/// <param name="cornerRadius">The corner radius.</param>
void DrawRectange(Pen pen, Rect rect, float cornerRadius = 0.0f); void DrawRectange(Pen pen, Rect rect, float cornerRadius = 0.0f);
/// <summary> /// <summary>
@ -54,6 +65,7 @@ namespace Perspex.Media
/// </summary> /// </summary>
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="rect">The rectangle bounds.</param> /// <param name="rect">The rectangle bounds.</param>
/// <param name="cornerRadius">The corner radius.</param>
void FillRectange(Brush brush, Rect rect, float cornerRadius = 0.0f); void FillRectange(Brush brush, Rect rect, float cornerRadius = 0.0f);
/// <summary> /// <summary>

4
Perspex.SceneGraph/Media/PathMarkupParser.cs

@ -174,7 +174,7 @@ namespace Perspex.Media
if (!Commands.TryGetValue(c, out command)) if (!Commands.TryGetValue(c, out command))
{ {
if ((char.IsDigit(c) || c == '.' || c == '+' || c == '-') && if ((char.IsDigit(c) || c == '.' || c == '+' || c == '-') &&
(lastCommand != Command.None)) (lastCommand != Command.None))
{ {
return lastCommand; return lastCommand;
@ -198,7 +198,7 @@ namespace Perspex.Media
bool readPoint = false; bool readPoint = false;
bool readExponent = false; bool readExponent = false;
int i; int i;
while ((i = reader.Peek()) != -1) while ((i = reader.Peek()) != -1)
{ {
char c = char.ToUpperInvariant((char)i); char c = char.ToUpperInvariant((char)i);

8
Perspex.SceneGraph/Media/SolidColorBrush.cs

@ -32,10 +32,10 @@ namespace Perspex.Media
/// <summary> /// <summary>
/// Gets the color of the brush. /// Gets the color of the brush.
/// </summary> /// </summary>
public Color Color public Color Color
{ {
get; get;
private set; private set;
} }
public override string ToString() public override string ToString()

4
Perspex.SceneGraph/Origin.cs

@ -46,8 +46,8 @@ namespace Perspex
public Point ToPixels(Size size) public Point ToPixels(Size size)
{ {
return this.unit == OriginUnit.Pixels ? return this.unit == OriginUnit.Pixels ?
this.point : this.point :
new Point(this.point.X * size.Width, this.point.Y * size.Height); new Point(this.point.X * size.Width, this.point.Y * size.Height);
} }
} }

6
Perspex.SceneGraph/Platform/IPlatformRenderInterface.cs

@ -13,9 +13,9 @@ namespace Perspex.Platform
IBitmapImpl CreateBitmap(int width, int height); IBitmapImpl CreateBitmap(int width, int height);
IFormattedTextImpl CreateFormattedText( IFormattedTextImpl CreateFormattedText(
string text, string text,
string fontFamily, string fontFamily,
double fontSize, double fontSize,
FontStyle fontStyle, FontStyle fontStyle,
TextAlignment textAlignment, TextAlignment textAlignment,
FontWeight fontWeight); FontWeight fontWeight);

65
Perspex.SceneGraph/Point.cs

@ -50,6 +50,15 @@ namespace Perspex
get { return this.y; } get { return this.y; }
} }
/// <summary>
/// Converts the <see cref="Point"/> to a <see cref="Vector"/>.
/// </summary>
/// <param name="p">The point.</param>
public static implicit operator Vector(Point p)
{
return new Vector(p.x, p.y);
}
/// <summary> /// <summary>
/// Checks for equality between two <see cref="Point"/>s. /// Checks for equality between two <see cref="Point"/>s.
/// </summary> /// </summary>
@ -72,26 +81,56 @@ namespace Perspex
return !(left == right); return !(left == right);
} }
/// <summary>
/// Adds two points.
/// </summary>
/// <param name="a">The first point.</param>
/// <param name="b">The second point.</param>
/// <returns>A point that is the result of the addition.</returns>
public static Point operator +(Point a, Point b) public static Point operator +(Point a, Point b)
{ {
return new Point(a.x + b.x, a.y + b.y); return new Point(a.x + b.x, a.y + b.y);
} }
/// <summary>
/// Adds a vector to a point.
/// </summary>
/// <param name="a">The point.</param>
/// <param name="b">The vector.</param>
/// <returns>A point that is the result of the addition.</returns>
public static Point operator +(Point a, Vector b) public static Point operator +(Point a, Vector b)
{ {
return new Point(a.x + b.X, a.y + b.Y); return new Point(a.x + b.X, a.y + b.Y);
} }
/// <summary>
/// Subtracts two points.
/// </summary>
/// <param name="a">The first point.</param>
/// <param name="b">The second point.</param>
/// <returns>A point that is the result of the subtraction.</returns>
public static Point operator -(Point a, Point b) public static Point operator -(Point a, Point b)
{ {
return new Point(a.x - b.x, a.y - b.y); return new Point(a.x - b.x, a.y - b.y);
} }
/// <summary>
/// Subtracts a vector from a point.
/// </summary>
/// <param name="a">The point.</param>
/// <param name="b">The vector.</param>
/// <returns>A point that is the result of the subtraction.</returns>
public static Point operator -(Point a, Vector b) public static Point operator -(Point a, Vector b)
{ {
return new Point(a.x - b.X, a.y - b.Y); return new Point(a.x - b.X, a.y - b.Y);
} }
/// <summary>
/// Applies a matrix to a point.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="matrix">The matrix.</param>
/// <returns>The resulting point.</returns>
public static Point operator *(Point point, Matrix matrix) public static Point operator *(Point point, Matrix matrix)
{ {
return new Point( return new Point(
@ -99,11 +138,13 @@ namespace Perspex
(point.X * matrix.M12) + (point.Y * matrix.M22) + matrix.OffsetY); (point.X * matrix.M12) + (point.Y * matrix.M22) + matrix.OffsetY);
} }
public static implicit operator Vector(Point p) /// <summary>
{ /// Checks for equality between a point and an object.
return new Vector(p.x, p.y); /// </summary>
} /// <param name="obj">The object.</param>
/// <returns>
/// True if <paramref name="obj"/> is a point that equals the current point.
/// </returns>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is Point) if (obj is Point)
@ -115,6 +156,10 @@ namespace Perspex
return false; return false;
} }
/// <summary>
/// Returns a hash code for a <see cref="Point"/>.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode() public override int GetHashCode()
{ {
unchecked unchecked
@ -135,11 +180,21 @@ namespace Perspex
return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.x, this.y); return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.x, this.y);
} }
/// <summary>
/// Returns a new point with the specified X coordinate.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <returns>The new point.</returns>
public Point WithX(double x) public Point WithX(double x)
{ {
return new Point(x, this.y); return new Point(x, this.y);
} }
/// <summary>
/// Returns a new point with the specified Y coordinate.
/// </summary>
/// <param name="y">The Y coordinate.</param>
/// <returns>The new point.</returns>
public Point WithY(double y) public Point WithY(double y)
{ {
return new Point(this.x, y); return new Point(this.x, y);

6
Perspex.SceneGraph/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.SceneGraph")] [assembly: AssemblyTitle("Perspex.SceneGraph")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

10
Perspex.SceneGraph/Rect.cs

@ -77,8 +77,8 @@ namespace Perspex
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rect"/> structure. /// Initializes a new instance of the <see cref="Rect"/> structure.
/// </summary> /// </summary>
/// <param name="position">The top left position of the rectangle.</param> /// <param name="topLeft">The top left position of the rectangle.</param>
/// <param name="buttonRight">The bottom right position of the rectangle.</param> /// <param name="bottomRight">The bottom right position of the rectangle.</param>
public Rect(Point topLeft, Point bottomRight) public Rect(Point topLeft, Point bottomRight)
{ {
this.x = topLeft.X; this.x = topLeft.X;
@ -369,11 +369,11 @@ namespace Perspex
public override string ToString() public override string ToString()
{ {
return string.Format( return string.Format(
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,
"{0}, {1}, {2}, {3}", "{0}, {1}, {2}, {3}",
this.x, this.x,
this.y, this.y,
this.width, this.width,
this.height); this.height);
} }
} }

6
Perspex.SceneGraph/Rendering/RendererBase.cs

@ -19,7 +19,7 @@ namespace Perspex.Rendering
public abstract class RendererBase : IRenderer public abstract class RendererBase : IRenderer
{ {
/// <summary> /// <summary>
/// Gets the number of times <see cref="Render"/> has been called. /// Gets the number of times <see cref="Render(IVisual, IPlatformHandle)"/> has been called.
/// </summary> /// </summary>
public int RenderCount public int RenderCount
{ {
@ -50,7 +50,7 @@ namespace Perspex.Rendering
public abstract void Resize(int width, int height); public abstract void Resize(int width, int height);
/// <summary> /// <summary>
/// When overriden by a derived class creates an <see cref="IDrawingContext"/> for a /// When overriden by a derived class creates an <see cref="IDrawingContext"/> for a
/// rendering session. /// rendering session.
/// </summary> /// </summary>
/// <param name="handle">The handle to use to create the context.</param> /// <param name="handle">The handle to use to create the context.</param>
@ -62,6 +62,8 @@ namespace Perspex.Rendering
/// </summary> /// </summary>
/// <param name="visual">The visual to render.</param> /// <param name="visual">The visual to render.</param>
/// <param name="context">The drawing context.</param> /// <param name="context">The drawing context.</param>
/// <param name="translation">The current translation.</param>
/// <param name="transform">The current transform.</param>
protected virtual void Render(IVisual visual, IDrawingContext context, Matrix translation, Matrix transform) protected virtual void Render(IVisual visual, IDrawingContext context, Matrix translation, Matrix transform)
{ {
var opacity = visual.Opacity; var opacity = visual.Opacity;

15
Perspex.SceneGraph/Size.cs

@ -81,7 +81,7 @@ namespace Perspex
/// <summary> /// <summary>
/// Scales a size. /// Scales a size.
/// </summary> /// </summary>
/// <param name="rect">The size</param> /// <param name="size">The size</param>
/// <param name="scale">The scaling factor.</param> /// <param name="scale">The scaling factor.</param>
/// <returns>The scaled size.</returns> /// <returns>The scaled size.</returns>
public static Size operator *(Size size, Vector scale) public static Size operator *(Size size, Vector scale)
@ -92,7 +92,7 @@ namespace Perspex
/// <summary> /// <summary>
/// Scales a size. /// Scales a size.
/// </summary> /// </summary>
/// <param name="rect">The size</param> /// <param name="size">The size</param>
/// <param name="scale">The scaling factor.</param> /// <param name="scale">The scaling factor.</param>
/// <returns>The scaled size.</returns> /// <returns>The scaled size.</returns>
public static Size operator /(Size size, Vector scale) public static Size operator /(Size size, Vector scale)
@ -125,6 +125,13 @@ namespace Perspex
Math.Max(0, this.height - thickness.Top - thickness.Bottom)); Math.Max(0, this.height - thickness.Top - thickness.Bottom));
} }
/// <summary>
/// Checks for equality between a size and an object.
/// </summary>
/// <param name="obj">The object.</param>
/// <returns>
/// True if <paramref name="obj"/> is a size that equals the current size.
/// </returns>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
if (obj is Size) if (obj is Size)
@ -136,6 +143,10 @@ namespace Perspex
return false; return false;
} }
/// <summary>
/// Returns a hash code for a <see cref="Size"/>.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode() public override int GetHashCode()
{ {
unchecked unchecked

2
Perspex.SceneGraph/Thickness.cs

@ -45,7 +45,7 @@ namespace Perspex
/// Initializes a new instance of the <see cref="Thickness"/> structure. /// Initializes a new instance of the <see cref="Thickness"/> structure.
/// </summary> /// </summary>
/// <param name="horizontal">The thickness on the left and right.</param> /// <param name="horizontal">The thickness on the left and right.</param>
/// <param name="top">The thickness on the top and bottom.</param> /// <param name="vertical">The thickness on the top and bottom.</param>
public Thickness(double horizontal, double vertical) public Thickness(double horizontal, double vertical)
{ {
Contract.Requires<ArgumentException>(horizontal >= 0); Contract.Requires<ArgumentException>(horizontal >= 0);

41
Perspex.SceneGraph/Vector.cs

@ -51,26 +51,47 @@ namespace Perspex
get { return this.y; } get { return this.y; }
} }
/// <summary>
/// Converts the <see cref="Vector"/> to a <see cref="Point"/>.
/// </summary>
/// <param name="a">The vector.</param>
public static explicit operator Point(Vector a)
{
return new Point(a.x, a.y);
}
/// <summary>
/// Negates a vector.
/// </summary>
/// <param name="a">The vector.</param>
/// <returns>The negated vector.</returns>
public static Vector operator -(Vector a) public static Vector operator -(Vector a)
{ {
return new Vector(-a.x, -a.y); return new Vector(-a.x, -a.y);
} }
/// <summary>
/// Adds two vectors.
/// </summary>
/// <param name="a">The first vector.</param>
/// <param name="b">The second vector.</param>
/// <returns>A vector that is the result of the addition.</returns>
public static Vector operator +(Vector a, Vector b) public static Vector operator +(Vector a, Vector b)
{ {
return new Vector(a.x + b.x, a.y + b.y); return new Vector(a.x + b.x, a.y + b.y);
} }
/// <summary>
/// Subtracts two vectors.
/// </summary>
/// <param name="a">The first vector.</param>
/// <param name="b">The second vector.</param>
/// <returns>A vector that is the result of the subtraction.</returns>
public static Vector operator -(Vector a, Vector b) public static Vector operator -(Vector a, Vector b)
{ {
return new Vector(a.x - b.x, a.y - b.y); return new Vector(a.x - b.x, a.y - b.y);
} }
public static explicit operator Point(Vector a)
{
return new Point(a.x, a.y);
}
/// <summary> /// <summary>
/// Returns the string representation of the point. /// Returns the string representation of the point.
/// </summary> /// </summary>
@ -80,11 +101,21 @@ namespace Perspex
return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.x, this.y); return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.x, this.y);
} }
/// <summary>
/// Returns a new vector with the specified X coordinate.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <returns>The new vector.</returns>
public Vector WithX(double x) public Vector WithX(double x)
{ {
return new Vector(x, this.y); return new Vector(x, this.y);
} }
/// <summary>
/// Returns a new vector with the specified Y coordinate.
/// </summary>
/// <param name="y">The Y coordinate.</param>
/// <returns>The new vector.</returns>
public Vector WithY(double y) public Vector WithY(double y)
{ {
return new Vector(this.x, y); return new Vector(this.x, y);

6
Perspex.SceneGraph/Visual.cs

@ -198,7 +198,6 @@ namespace Perspex
get { return this.isAttachedToVisualTree; } get { return this.isAttachedToVisualTree; }
} }
/// <summary> /// <summary>
/// Gets the scene graph node's child nodes. /// Gets the scene graph node's child nodes.
/// </summary> /// </summary>
@ -417,7 +416,8 @@ namespace Perspex
} }
/// <summary> /// <summary>
/// Called when the <see cref="RenderTransform.Changed"/> event is fired. /// Called when the <see cref="RenderTransform"/>'s <see cref="Transform.Changed"/> event
/// is fired.
/// </summary> /// </summary>
/// <param name="sender">The sender.</param> /// <param name="sender">The sender.</param>
/// <param name="e">The event args.</param> /// <param name="e">The event args.</param>
@ -508,7 +508,7 @@ namespace Perspex
} }
/// <summary> /// <summary>
/// Calls the <see cref="OnDetachedToVisualTree(IRenderRoot)"/> method for this control /// Calls the <see cref="OnDetachedFromVisualTree(IRenderRoot)"/> method for this control
/// and all of its visual descendents. /// and all of its visual descendents.
/// </summary> /// </summary>
/// <param name="root">The root of the visual tree.</param> /// <param name="root">The root of the visual tree.</param>

2
Perspex.SceneGraph/VisualTree/IHostedVisualTreeRoot.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="IVisualTreeHost.cs" company="Steven Kirk"> // <copyright file="IHostedVisualTreeRoot.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

6
Perspex.Styling/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Styling")] [assembly: AssemblyTitle("Perspex.Styling")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

2
Perspex.Styling/Styling/INamed.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="TemplateExtensions.cs" company="Steven Kirk"> // <copyright file="INamed.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

2
Perspex.Styling/Styling/Selector.cs

@ -62,7 +62,7 @@ namespace Perspex.Styling
{ {
List<IObservable<bool>> inputs = new List<IObservable<bool>>(); List<IObservable<bool>> inputs = new List<IObservable<bool>>();
Selector selector = this; Selector selector = this;
while (selector != null) while (selector != null)
{ {
if (selector.inTemplate && control.TemplatedParent == null) if (selector.inTemplate && control.TemplatedParent == null)

6
Perspex.Styling/Styling/SelectorMatch.cs

@ -12,8 +12,8 @@ namespace Perspex.Styling
/// Holds the result of a <see cref="Selector"/> match. /// Holds the result of a <see cref="Selector"/> match.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// There are two types of selectors - ones whose match can never change for a particular /// There are two types of selectors - ones whose match can never change for a particular
/// control (such as <see cref="Selectors.OfType{T}(Selector)"/>) and ones whose result can /// control (such as <see cref="Selectors.OfType{T}(Selector)"/>) and ones whose result can
/// change over time (such as <see cref="Selectors.Class(Selector, string)"/>. For the first /// change over time (such as <see cref="Selectors.Class(Selector, string)"/>. For the first
/// category of selectors, the value of <see cref="ImmediateResult"/> will be set but for the /// category of selectors, the value of <see cref="ImmediateResult"/> will be set but for the
/// second, <see cref="ImmediateResult"/> will be null and <see cref="ObservableResult"/> will /// second, <see cref="ImmediateResult"/> will be null and <see cref="ObservableResult"/> will
@ -44,7 +44,7 @@ namespace Perspex.Styling
} }
/// <summary> /// <summary>
/// Gets the immedate result of the selector match, in the case of selectors that cannot /// Gets the immedate result of the selector match, in the case of selectors that cannot
/// change over time. /// change over time.
/// </summary> /// </summary>
public bool? ImmediateResult { get; } public bool? ImmediateResult { get; }

8
Perspex.Styling/Styling/Selectors.cs

@ -79,10 +79,10 @@ namespace Perspex.Styling
Contract.Requires<ArgumentNullException>(previous != null); Contract.Requires<ArgumentNullException>(previous != null);
return new Selector( return new Selector(
previous, previous,
x => MatchTemplate(x, previous), x => MatchTemplate(x, previous),
" /deep/ ", " /deep/ ",
inTemplate: true, inTemplate: true,
stopTraversal: true); stopTraversal: true);
} }

8
Perspex.Styling/Styling/StyleActivator.cs

@ -28,7 +28,7 @@ namespace Perspex.Styling
private List<IObserver<bool>> observers = new List<IObserver<bool>>(); private List<IObserver<bool>> observers = new List<IObserver<bool>>();
public StyleActivator( public StyleActivator(
IList<IObservable<bool>> inputs, IList<IObservable<bool>> inputs,
ActivatorMode mode = ActivatorMode.And) ActivatorMode mode = ActivatorMode.And)
{ {
int i = 0; int i = 0;
@ -97,7 +97,7 @@ namespace Perspex.Styling
this.values[index] = value; this.values[index] = value;
bool current; bool current;
switch (this.mode) switch (this.mode)
{ {
case ActivatorMode.And: case ActivatorMode.And:
@ -121,10 +121,10 @@ namespace Perspex.Styling
{ {
// We can unsubscribe from everything if the completed observable: // We can unsubscribe from everything if the completed observable:
// - Is the only subscription. // - Is the only subscription.
// - Has finished on 'false' and we're in And mode // - Has finished on 'false' and we're in And mode
// - Has finished on 'true' and we're in Or mode // - Has finished on 'true' and we're in Or mode
var value = this.values[i]; var value = this.values[i];
var unsubscribe = var unsubscribe =
(this.values.Length == 1) || (this.values.Length == 1) ||
(this.mode == ActivatorMode.And ? !value : value); (this.mode == ActivatorMode.And ? !value : value);

5
Perspex.Styling/Styling/StyleBinding.cs

@ -14,8 +14,9 @@ namespace Perspex.Styling
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This class takes an activator and a value. The activator is an observable which produces /// This class takes an activator and a value. The activator is an observable which produces
/// a bool. When the activator produces true, this observable will produce <see cref="Value"/>. /// a bool. When the activator produces true, this observable will produce
/// When the activator produces false it will produce <see cref="PerspexProperty.UnsetValue"/>. /// <see cref="ActivatedValue"/>. When the activator produces false it will produce
/// <see cref="PerspexProperty.UnsetValue"/>.
/// </remarks> /// </remarks>
internal class StyleBinding : ObservableBase<object>, IDescription internal class StyleBinding : ObservableBase<object>, IDescription
{ {

2
Perspex.Themes.Default/ContentControlStyle.cs

@ -31,7 +31,7 @@ namespace Perspex.Themes.Default
private Control Template(ContentControl control) private Control Template(ContentControl control)
{ {
return new ContentPresenter return new ContentPresenter
{ {
Name = "contentPresenter", Name = "contentPresenter",
[~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty], [~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
}; };

3
Perspex.Themes.Default/DropDownStyle.cs

@ -120,7 +120,8 @@ namespace Perspex.Themes.Default
PlacementTarget = control, PlacementTarget = control,
StaysOpen = false, StaysOpen = false,
[~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty], [~~Popup.IsOpenProperty] = control[~~DropDown.IsDropDownOpenProperty],
[~Popup.MinWidthProperty] = control[~DropDown.BoundsProperty].Cast<Rect>().Select(x => (object)x.Width), } [~Popup.MinWidthProperty] = control[~DropDown.BoundsProperty].Cast<Rect>().Select(x => (object)x.Width),
}
}, },
}, },
}; };

6
Perspex.Themes.Default/Properties/AssemblyInfo.cs

@ -7,7 +7,7 @@
using System.Reflection; using System.Reflection;
using System.Resources; using System.Resources;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Themes.Default")] [assembly: AssemblyTitle("Perspex.Themes.Default")]
@ -23,11 +23,11 @@ using System.Resources;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

2
Tests/Perspex.Base.UnitTests/PerspexObjectTests_SetValue.cs

@ -203,7 +203,7 @@ namespace Perspex.Base.UnitTests
public double Value { get; } public double Value { get; }
public static implicit operator double (ImplictDouble v) public static implicit operator double(ImplictDouble v)
{ {
return v.Value; return v.Value;
} }

2
Tests/Perspex.Base.UnitTests/PerspexPropertyTests.cs

@ -118,7 +118,7 @@ namespace Perspex.Base.UnitTests
private class Class1 : PerspexObject private class Class1 : PerspexObject
{ {
public static readonly PerspexProperty<string> FooProperty = public static readonly PerspexProperty<string> FooProperty =
PerspexProperty.Register<Class1, string>("Foo", "default"); PerspexProperty.Register<Class1, string>("Foo", "default");
} }

4
Tests/Perspex.Base.UnitTests/PriorityValueTests.cs

@ -177,7 +177,7 @@ namespace Perspex.Base.UnitTests
var target = new PriorityValue("Test", typeof(string)); var target = new PriorityValue("Test", typeof(string));
bool called = false; bool called = false;
target.Changed.Subscribe(value => called = (value.Item1 == PerspexProperty.UnsetValue && (string)value.Item2 == "foo")); target.Changed.Subscribe(value => called = value.Item1 == PerspexProperty.UnsetValue && (string)value.Item2 == "foo");
target.Add(this.Single("foo"), 0); target.Add(this.Single("foo"), 0);
Assert.True(called); Assert.True(called);
@ -191,7 +191,7 @@ namespace Perspex.Base.UnitTests
bool called = false; bool called = false;
target.Add(subject, 0); target.Add(subject, 0);
target.Changed.Subscribe(value => called = ((string)value.Item1 == "foo" && (string)value.Item2 == "bar")); target.Changed.Subscribe(value => called = (string)value.Item1 == "foo" && (string)value.Item2 == "bar");
subject.OnNext("bar"); subject.OnNext("bar");
Assert.True(called); Assert.True(called);

10
Tests/Perspex.Base.UnitTests/Properties/AssemblyInfo.cs

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.UnitTests")] [assembly: AssemblyTitle("Perspex.UnitTests")]
@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

3
Tests/Perspex.Controls.UnitTests/ContentControlTests.cs

@ -9,12 +9,11 @@ namespace Perspex.Controls.UnitTests
using System; using System;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using LogicalTree;
using Moq; using Moq;
using Perspex.Controls; using Perspex.Controls;
using Perspex.Controls.Presenters; using Perspex.Controls.Presenters;
using Perspex.Controls.Templates; using Perspex.Controls.Templates;
using Perspex.Layout;
using LogicalTree;
using Perspex.Platform; using Perspex.Platform;
using Perspex.Styling; using Perspex.Styling;
using Perspex.VisualTree; using Perspex.VisualTree;

30
Tests/Perspex.Controls.UnitTests/Presenters/ScrollContentPresenterTests.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="ScrollPresenterTests.cs" company="Steven Kirk"> // <copyright file="ScrollContentPresenterTests.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -10,8 +10,8 @@ namespace Perspex.Controls.UnitTests.Presenters
using System.Collections.Generic; using System.Collections.Generic;
using System.Reactive.Linq; using System.Reactive.Linq;
using Perspex.Controls.Presenters; using Perspex.Controls.Presenters;
using Xunit;
using Perspex.Layout; using Perspex.Layout;
using Xunit;
public class ScrollContentPresenterTests public class ScrollContentPresenterTests
{ {
@ -21,11 +21,11 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Padding = new Thickness(8), Padding = new Thickness(8),
HorizontalAlignment = HorizontalAlignment.Left HorizontalAlignment = HorizontalAlignment.Left
}), },
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -40,10 +40,10 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Padding = new Thickness(8), Padding = new Thickness(8),
}), },
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -58,11 +58,11 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Padding = new Thickness(8), Padding = new Thickness(8),
HorizontalAlignment = HorizontalAlignment.Right HorizontalAlignment = HorizontalAlignment.Right
}), },
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -77,11 +77,11 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Padding = new Thickness(8), Padding = new Thickness(8),
VerticalAlignment = VerticalAlignment.Bottom, VerticalAlignment = VerticalAlignment.Bottom,
}), },
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -96,12 +96,12 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Padding = new Thickness(8), Padding = new Thickness(8),
HorizontalAlignment = HorizontalAlignment.Right, HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Top, VerticalAlignment = VerticalAlignment.Top,
}), },
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -116,7 +116,7 @@ namespace Perspex.Controls.UnitTests.Presenters
TestControl content; TestControl content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new TestControl()), Content = content = new TestControl(),
}; };
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
@ -131,11 +131,11 @@ namespace Perspex.Controls.UnitTests.Presenters
Border content; Border content;
var target = new ScrollContentPresenter var target = new ScrollContentPresenter
{ {
Content = (content = new Border Content = content = new Border
{ {
Width = 150, Width = 150,
Height = 150, Height = 150,
}), },
Offset = new Vector(25, 25), Offset = new Vector(25, 25),
}; };

10
Tests/Perspex.Controls.UnitTests/Properties/AssemblyInfo.cs

@ -2,7 +2,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Perspex.Controls.UnitTests")] [assembly: AssemblyTitle("Perspex.Controls.UnitTests")]
@ -14,8 +14,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
@ -25,11 +25,11 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values: // Version information for an assembly consists of the following four values:
// //
// Major Version // Major Version
// Minor Version // Minor Version
// Build Number // Build Number
// Revision // Revision
// //
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

1
Tests/Perspex.Controls.UnitTests/ScrollViewerTests.cs

@ -13,7 +13,6 @@ namespace Perspex.Controls.UnitTests
using Perspex.Controls.Templates; using Perspex.Controls.Templates;
using Perspex.VisualTree; using Perspex.VisualTree;
using Xunit; using Xunit;
using Perspex.Layout;
public class ScrollViewerTests public class ScrollViewerTests
{ {

2
Tests/Perspex.Controls.UnitTests/TabControlTests.cs

@ -6,13 +6,13 @@
namespace Perspex.Controls.UnitTests namespace Perspex.Controls.UnitTests
{ {
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using Perspex.Controls.Presenters; using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives; using Perspex.Controls.Primitives;
using Perspex.Controls.Templates; using Perspex.Controls.Templates;
using Perspex.LogicalTree; using Perspex.LogicalTree;
using Xunit; using Xunit;
using System.Collections.ObjectModel;
public class TabControlTests public class TabControlTests
{ {

12
Tests/Perspex.Controls.UnitTests/TemplatedControlTests.cs

@ -23,8 +23,8 @@ namespace Perspex.Controls.UnitTests
public void Template_Doesnt_Get_Executed_On_Set() public void Template_Doesnt_Get_Executed_On_Set()
{ {
bool executed = false; bool executed = false;
var template = new ControlTemplate(_ => var template = new ControlTemplate(_ =>
{ {
executed = true; executed = true;
return new Control(); return new Control();
@ -155,7 +155,7 @@ namespace Perspex.Controls.UnitTests
var root = new TestRoot var root = new TestRoot
{ {
Child = (target = new TestTemplatedControl Child = target = new TestTemplatedControl
{ {
Template = new ControlTemplate(_ => Template = new ControlTemplate(_ =>
{ {
@ -169,10 +169,9 @@ namespace Perspex.Controls.UnitTests
} }
}; };
}), }),
}) }
}; };
target.ApplyTemplate(); target.ApplyTemplate();
styler.Verify(x => x.ApplyStyles(It.IsAny<TestTemplatedControl>()), Times.Once()); styler.Verify(x => x.ApplyStyles(It.IsAny<TestTemplatedControl>()), Times.Once());
@ -218,7 +217,7 @@ namespace Perspex.Controls.UnitTests
{ {
return new ContentPresenter return new ContentPresenter
{ {
Content = new TextBlock Content = new TextBlock
{ {
} }
}; };
@ -274,4 +273,3 @@ namespace Perspex.Controls.UnitTests
} }
} }
} }

4
Tests/Perspex.Controls.UnitTests/TestTemplatedControl.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="TestRoot.cs" company="Steven Kirk"> // <copyright file="TestTemplatedControl.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information. // Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -12,7 +12,7 @@ namespace Perspex.Controls.UnitTests
{ {
public bool OnTemplateAppliedCalled { get; private set; } public bool OnTemplateAppliedCalled { get; private set; }
public new void AddVisualChild(Visual visual) public new void AddVisualChild(IVisual visual)
{ {
base.AddVisualChild(visual); base.AddVisualChild(visual);
} }

8
Tests/Perspex.Controls.UnitTests/TopLevelTests.cs

@ -295,10 +295,10 @@ namespace Perspex.Controls.UnitTests
var target = new TestTopLevel(impl.Object); var target = new TestTopLevel(impl.Object);
var input = new RawKeyEventArgs( var input = new RawKeyEventArgs(
new Mock<IKeyboardDevice>().Object, new Mock<IKeyboardDevice>().Object,
0, 0,
RawKeyEventType.KeyDown, RawKeyEventType.KeyDown,
Key.A, Key.A,
"A"); "A");
impl.Object.Input(input); impl.Object.Input(input);

12
Tests/Perspex.Direct2D1.UnitTests/Controls/Shapes/PathTests.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="GeometryTests.cs" company="Steven Kirk"> // <copyright file="PathTests.cs" company="Steven Kirk">
// Copyright 2015 MIT Licence. See licence.md for more information. // Copyright 2015 MIT Licence. See licence.md for more information.
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -14,10 +14,10 @@ namespace Perspex.Direct2D1.UnitTests.Controls.Shapes
public class PathTests public class PathTests
{ {
private static readonly RectComparer compare = new RectComparer(); private static readonly RectComparer Compare = new RectComparer();
[Fact] [Fact]
void Should_Measure_Expander_Triangle_Correctly() public void Should_Measure_Expander_Triangle_Correctly()
{ {
using (Locator.CurrentMutable.WithResolver()) using (Locator.CurrentMutable.WithResolver())
{ {
@ -35,12 +35,12 @@ namespace Perspex.Direct2D1.UnitTests.Controls.Shapes
target.Measure(new Size(100, 100)); target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100)); target.Arrange(new Rect(0, 0, 100, 100));
Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, compare); Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, Compare);
} }
} }
[Fact] [Fact]
void Should_Measure_Expander_Triangle_With_Stroke_Correctly() public void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
{ {
using (Locator.CurrentMutable.WithResolver()) using (Locator.CurrentMutable.WithResolver())
{ {
@ -69,7 +69,7 @@ namespace Perspex.Direct2D1.UnitTests.Controls.Shapes
// //
// However Path.Measure doesn't correctly handle strokes currently, so testing for // However Path.Measure doesn't correctly handle strokes currently, so testing for
// the (incorrect) current output for now... // the (incorrect) current output for now...
Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, compare); Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, Compare);
} }
} }
} }

10
Tests/Perspex.Direct2D1.UnitTests/Media/GeometryTests.cs

@ -12,10 +12,10 @@ namespace Perspex.Direct2D1.UnitTests.Media
public class GeometryTests public class GeometryTests
{ {
private static readonly RectComparer compare = new RectComparer(); private static readonly RectComparer Compare = new RectComparer();
[Fact] [Fact]
void Should_Measure_Expander_Triangle_Correctly() public void Should_Measure_Expander_Triangle_Correctly()
{ {
using (Locator.CurrentMutable.WithResolver()) using (Locator.CurrentMutable.WithResolver())
{ {
@ -23,12 +23,12 @@ namespace Perspex.Direct2D1.UnitTests.Media
var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"); var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");
Assert.Equal(new Rect(0, 2, 4, 8), target.Bounds, compare); Assert.Equal(new Rect(0, 2, 4, 8), target.Bounds, Compare);
} }
} }
[Fact] [Fact]
void Should_Measure_Expander_Triangle_With_Stroke_Correctly() public void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
{ {
using (Locator.CurrentMutable.WithResolver()) using (Locator.CurrentMutable.WithResolver())
{ {
@ -36,7 +36,7 @@ namespace Perspex.Direct2D1.UnitTests.Media
var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"); var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");
Assert.Equal(new Rect(-1, -0.414, 6.414, 12.828), target.GetRenderBounds(2), compare); Assert.Equal(new Rect(-1, -0.414, 6.414, 12.828), target.GetRenderBounds(2), Compare);
} }
} }
} }

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save