diff --git a/src/Perspex.Controls/Canvas.cs b/src/Perspex.Controls/Canvas.cs index 51db44a5ab..99b7cdd37d 100644 --- a/src/Perspex.Controls/Canvas.cs +++ b/src/Perspex.Controls/Canvas.cs @@ -6,126 +6,126 @@ using Perspex.Input; namespace Perspex.Controls { - public class Canvas : Panel, INavigableContainer - { - /// - /// Defines the property. - /// - public static readonly PerspexProperty LeftProperty = - PerspexProperty.RegisterAttached("Left"); - - /// - /// Defines the property. - /// - public static readonly PerspexProperty TopProperty = - PerspexProperty.RegisterAttached("Top"); - - /// - /// Initializes static members of the class. - /// - static Canvas() - { - AffectsArrange(LeftProperty); - AffectsArrange(TopProperty); - } - - /// - /// Gets the value of the Left attached property for a control. - /// - /// The control. - /// The control's left coordinate. - public static double GetLeft(PerspexObject element) - { - return element.GetValue(LeftProperty); - } - - /// - /// Sets the value of the Left attached property for a control. - /// - /// The control. - /// The left value. - public static void SetLeft(PerspexObject element, double value) - { - element.SetValue(LeftProperty, value); - } - - /// - /// Gets the value of the Top attached property for a control. - /// - /// The control. - /// The control's top coordinate. - public static double GetTop(PerspexObject element) - { - return element.GetValue(TopProperty); - } - - /// - /// Sets the value of the Top attached property for a control. - /// - /// The control. - /// The top value. - public static void SetTop(PerspexObject element, double value) - { - element.SetValue(TopProperty, value); - } - - /// - /// Gets the next control in the specified direction. - /// - /// The movement direction. - /// The control from which movement begins. - /// The control. - IInputElement INavigableContainer.GetControl(FocusNavigationDirection direction, IInputElement from) - { - // TODO: Implement this - return null; - } - - /// - /// Measures the control. - /// - /// The available size. - /// The desired size of the control. - protected override Size MeasureOverride(Size availableSize) - { - availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); - - foreach (Control child in Children) - { - child.Measure(availableSize); - } - - return new Size(); - } - - /// - /// Arranges the control's children. - /// - /// The size allocated to the control. - /// The space taken. - protected override Size ArrangeOverride(Size finalSize) - { - foreach (Control child in Children) - { - double x = 0.0; - double y = 0.0; - double elementLeft = GetLeft(child); - - if (double.IsNaN(elementLeft) == false) - { - x = elementLeft; - } - - double elementTop = GetTop(child); - if (double.IsNaN(elementTop) == false) - { - y = elementTop; - } - - child.Arrange(new Rect(new Point(x, y), child.DesiredSize)); - } - - return finalSize; - } - } -} \ No newline at end of file + public class Canvas : Panel, INavigableContainer + { + /// + /// Defines the property. + /// + public static readonly PerspexProperty LeftProperty = + PerspexProperty.RegisterAttached("Left"); + + /// + /// Defines the property. + /// + public static readonly PerspexProperty TopProperty = + PerspexProperty.RegisterAttached("Top"); + + /// + /// Initializes static members of the class. + /// + static Canvas() + { + AffectsArrange(LeftProperty); + AffectsArrange(TopProperty); + } + + /// + /// Gets the value of the Left attached property for a control. + /// + /// The control. + /// The control's left coordinate. + public static double GetLeft(PerspexObject element) + { + return element.GetValue(LeftProperty); + } + + /// + /// Sets the value of the Left attached property for a control. + /// + /// The control. + /// The left value. + public static void SetLeft(PerspexObject element, double value) + { + element.SetValue(LeftProperty, value); + } + + /// + /// Gets the value of the Top attached property for a control. + /// + /// The control. + /// The control's top coordinate. + public static double GetTop(PerspexObject element) + { + return element.GetValue(TopProperty); + } + + /// + /// Sets the value of the Top attached property for a control. + /// + /// The control. + /// The top value. + public static void SetTop(PerspexObject element, double value) + { + element.SetValue(TopProperty, value); + } + + /// + /// Gets the next control in the specified direction. + /// + /// The movement direction. + /// The control from which movement begins. + /// The control. + IInputElement INavigableContainer.GetControl(FocusNavigationDirection direction, IInputElement from) + { + // TODO: Implement this + return null; + } + + /// + /// Measures the control. + /// + /// The available size. + /// The desired size of the control. + protected override Size MeasureOverride(Size availableSize) + { + availableSize = new Size(double.PositiveInfinity, double.PositiveInfinity); + + foreach (Control child in Children) + { + child.Measure(availableSize); + } + + return new Size(); + } + + /// + /// Arranges the control's children. + /// + /// The size allocated to the control. + /// The space taken. + protected override Size ArrangeOverride(Size finalSize) + { + foreach (Control child in Children) + { + double x = 0.0; + double y = 0.0; + double elementLeft = GetLeft(child); + + if (double.IsNaN(elementLeft) == false) + { + x = elementLeft; + } + + double elementTop = GetTop(child); + if (double.IsNaN(elementTop) == false) + { + y = elementTop; + } + + child.Arrange(new Rect(new Point(x, y), child.DesiredSize)); + } + + return finalSize; + } + } +}