diff --git a/Perspex.Controls/Border.cs b/Perspex.Controls/Border.cs index 89b5b78886..cf8f25ac71 100644 --- a/Perspex.Controls/Border.cs +++ b/Perspex.Controls/Border.cs @@ -51,7 +51,7 @@ namespace Perspex.Controls Brush background = this.Background; Brush borderBrush = this.BorderBrush; double borderThickness = this.BorderThickness; - Rect rect = new Rect(this.ActualSize).Deflate(BorderThickness / 2); + Rect rect = new Rect(this.ActualSize).Deflate(this.BorderThickness / 2); if (background != null) { diff --git a/Perspex.Controls/ColumnDefinitions.cs b/Perspex.Controls/ColumnDefinitions.cs index 636db00c36..f8c9928eb8 100644 --- a/Perspex.Controls/ColumnDefinitions.cs +++ b/Perspex.Controls/ColumnDefinitions.cs @@ -4,8 +4,6 @@ // // ----------------------------------------------------------------------- -using Perspex.Collections; - namespace Perspex.Controls { using Perspex.Collections; diff --git a/Perspex.Controls/IContentControl.cs b/Perspex.Controls/IContentControl.cs index 9007110b9c..56aea20d37 100644 --- a/Perspex.Controls/IContentControl.cs +++ b/Perspex.Controls/IContentControl.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Controls/Platform/ITopLevelImpl.cs b/Perspex.Controls/Platform/ITopLevelImpl.cs index 4bd03cdc2f..96c642d158 100644 --- a/Perspex.Controls/Platform/ITopLevelImpl.cs +++ b/Perspex.Controls/Platform/ITopLevelImpl.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Controls/Popup.cs b/Perspex.Controls/Popup.cs index ef4b4c2856..d2f87a1562 100644 --- a/Perspex.Controls/Popup.cs +++ b/Perspex.Controls/Popup.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- @@ -47,6 +47,7 @@ namespace Perspex.Controls } }); } + public Control Child { get { return this.GetValue(ChildProperty); } diff --git a/Perspex.Controls/Presenters/ContentPresenter.cs b/Perspex.Controls/Presenters/ContentPresenter.cs index 6a121dbb71..734e61709e 100644 --- a/Perspex.Controls/Presenters/ContentPresenter.cs +++ b/Perspex.Controls/Presenters/ContentPresenter.cs @@ -103,7 +103,6 @@ namespace Perspex.Controls.Presenters if (content != null) { - if (content is Control) { result = (Control)content; diff --git a/Perspex.Controls/Presenters/TextPresenter.cs b/Perspex.Controls/Presenters/TextPresenter.cs index 6a1af946fe..5a8c5d8a76 100644 --- a/Perspex.Controls/Presenters/TextPresenter.cs +++ b/Perspex.Controls/Presenters/TextPresenter.cs @@ -147,6 +147,20 @@ namespace Perspex.Controls } } + internal void CaretIndexChanged(int caretIndex) + { + if (this.GetVisualParent() != null) + { + this.caretBlink = true; + this.caretTimer.Stop(); + this.caretTimer.Start(); + this.InvalidateVisual(); + + var rect = this.FormattedText.HitTestTextPosition(caretIndex); + this.BringIntoView(rect); + } + } + protected override FormattedText CreateFormattedText() { var result = base.CreateFormattedText(); @@ -159,6 +173,7 @@ namespace Perspex.Controls { result.SetForegroundBrush(Brushes.White, start, length); } + return result; } @@ -197,7 +212,7 @@ namespace Perspex.Controls case Key.A: if (modifiers == ModifierKeys.Control) { - SelectAll(); + this.SelectAll(); } else { @@ -295,12 +310,6 @@ namespace Perspex.Controls e.Handled = true; } - private void SelectAll() - { - this.SelectionStart = 0; - this.SelectionEnd = this.Text.Length; - } - protected override void OnPointerPressed(PointerPressEventArgs e) { var point = e.GetPosition(this); @@ -346,20 +355,6 @@ namespace Perspex.Controls } } - internal void CaretIndexChanged(int caretIndex) - { - if (this.GetVisualParent() != null) - { - this.caretBlink = true; - this.caretTimer.Stop(); - this.caretTimer.Start(); - this.InvalidateVisual(); - - var rect = this.FormattedText.HitTestTextPosition(caretIndex); - this.BringIntoView(rect); - } - } - private void MoveHorizontal(int count, ModifierKeys modifiers) { var text = this.Text ?? string.Empty; @@ -463,6 +458,12 @@ namespace Perspex.Controls this.CaretIndex = caretIndex; } + private void SelectAll() + { + this.SelectionStart = 0; + this.SelectionEnd = this.Text.Length; + } + private bool DeleteSelection() { var selectionStart = this.SelectionStart; diff --git a/Perspex.Controls/Primitives/ScrollBar.cs b/Perspex.Controls/Primitives/ScrollBar.cs index 16b0f13eb6..523edba956 100644 --- a/Perspex.Controls/Primitives/ScrollBar.cs +++ b/Perspex.Controls/Primitives/ScrollBar.cs @@ -44,7 +44,7 @@ namespace Perspex.Controls.Primitives this.GetObservable(ViewportSizeProperty).Select(_ => Unit.Default), this.GetObservable(VisibilityProperty).Select(_ => Unit.Default)) .Select(_ => this.CalculateIsVisible()); - this.Bind(IsVisibleProperty, isVisible, BindingPriority.Style); + this.Bind(ScrollBar.IsVisibleProperty, isVisible, BindingPriority.Style); } public double Minimum diff --git a/Perspex.Controls/RequestBringIntoViewEventArgs.cs b/Perspex.Controls/RequestBringIntoViewEventArgs.cs index 00de55c6f3..7c06e32eed 100644 --- a/Perspex.Controls/RequestBringIntoViewEventArgs.cs +++ b/Perspex.Controls/RequestBringIntoViewEventArgs.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2013 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Controls/ScrollViewer.cs b/Perspex.Controls/ScrollViewer.cs index dfecc3ae79..c46c9e0606 100644 --- a/Perspex.Controls/ScrollViewer.cs +++ b/Perspex.Controls/ScrollViewer.cs @@ -51,8 +51,8 @@ namespace Perspex.Controls static ScrollViewer() { - AffectsCoercion(ExtentProperty, OffsetProperty); - AffectsCoercion(ViewportProperty, OffsetProperty); + PerspexObject.AffectsCoercion(ExtentProperty, OffsetProperty); + PerspexObject.AffectsCoercion(ViewportProperty, OffsetProperty); } public ScrollViewer() diff --git a/Perspex.Controls/Shapes/Ellipse.cs b/Perspex.Controls/Shapes/Ellipse.cs index 00098f3991..edbacc02f0 100644 --- a/Perspex.Controls/Shapes/Ellipse.cs +++ b/Perspex.Controls/Shapes/Ellipse.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Controls/Shapes/Shape.cs b/Perspex.Controls/Shapes/Shape.cs index 7a03cafcba..8125473cc2 100644 --- a/Perspex.Controls/Shapes/Shape.cs +++ b/Perspex.Controls/Shapes/Shape.cs @@ -50,7 +50,6 @@ namespace Perspex.Controls.Shapes this.renderedGeometry = this.DefiningGeometry.Clone(); this.renderedGeometry.Transform = new MatrixTransform(this.transform); } - } return this.renderedGeometry; diff --git a/Perspex.Controls/TextBlock.cs b/Perspex.Controls/TextBlock.cs index aad14067d2..5a845462bd 100644 --- a/Perspex.Controls/TextBlock.cs +++ b/Perspex.Controls/TextBlock.cs @@ -124,7 +124,7 @@ namespace Perspex.Controls this.FontFamily, this.FontSize, this.FontStyle); - result.Constraint = constraint; + result.Constraint = this.constraint; return result; } diff --git a/Perspex.Controls/TextWrapping.cs b/Perspex.Controls/TextWrapping.cs index d514872991..f23281d047 100644 --- a/Perspex.Controls/TextWrapping.cs +++ b/Perspex.Controls/TextWrapping.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Controls/Utils/StringUtils.cs b/Perspex.Controls/Utils/StringUtils.cs index da2e9ba706..0fbd3363a6 100644 --- a/Perspex.Controls/Utils/StringUtils.cs +++ b/Perspex.Controls/Utils/StringUtils.cs @@ -4,12 +4,19 @@ // // ----------------------------------------------------------------------- -using System.Globalization; - namespace Perspex.Controls.Utils { + using System.Globalization; + internal static class StringUtils { + private enum CharClass + { + CharClassUnknown, + CharClassWhitespace, + CharClassAlphaNumeric, + } + public static bool IsEol(char c) { return c == '\r' || c == '\n'; @@ -38,8 +45,9 @@ namespace Perspex.Controls.Utils case UnicodeCategory.CurrencySymbol: case UnicodeCategory.MathSymbol: return true; + // TODO: How do you do this in .NET? - //case UnicodeCategory.OtherPunctuation: + // case UnicodeCategory.OtherPunctuation: // // words cannot start with '.', but they can start with '&' or '*' (for example) // return g_unichar_break_type(buffer->text[index]) == G_UNICODE_BREAK_ALPHABETIC; default: @@ -249,13 +257,5 @@ namespace Perspex.Controls.Utils return cursor; } - - - private enum CharClass - { - CharClassUnknown, - CharClassWhitespace, - CharClassAlphaNumeric, - } } } diff --git a/Perspex.Controls/Window.cs b/Perspex.Controls/Window.cs index 879b4fdbdb..8314b8192b 100644 --- a/Perspex.Controls/Window.cs +++ b/Perspex.Controls/Window.cs @@ -15,7 +15,6 @@ namespace Perspex.Controls public static readonly PerspexProperty TitleProperty = PerspexProperty.Register("Title", "Window"); - static Window() { BackgroundProperty.OverrideDefaultValue(typeof(Window), Brushes.White); diff --git a/Perspex.Diagnostics/ViewModels/TreeNode.cs b/Perspex.Diagnostics/ViewModels/TreeNode.cs index c0ecfbb395..3b45546b36 100644 --- a/Perspex.Diagnostics/ViewModels/TreeNode.cs +++ b/Perspex.Diagnostics/ViewModels/TreeNode.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Input/PointerPressEventArgs.cs b/Perspex.Input/PointerPressEventArgs.cs index b48c82fd7e..4a9ff24d4f 100644 --- a/Perspex.Input/PointerPressEventArgs.cs +++ b/Perspex.Input/PointerPressEventArgs.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2013 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.Interactivity/RoutedEvent.cs b/Perspex.Interactivity/RoutedEvent.cs index 7696a512f6..1a9d34728a 100644 --- a/Perspex.Interactivity/RoutedEvent.cs +++ b/Perspex.Interactivity/RoutedEvent.cs @@ -37,6 +37,8 @@ namespace Perspex.Interactivity this.RoutingStrategy = routingStrategy; } + public event EventHandler Raised; + public Type EventArgsType { get; @@ -61,8 +63,6 @@ namespace Perspex.Interactivity private set; } - public event EventHandler Raised; - public static RoutedEvent Register( string name, RoutingStrategy routingStrategy) diff --git a/Perspex.SceneGraph/LogicalTree/LogicalExtensions.cs b/Perspex.SceneGraph/LogicalTree/LogicalExtensions.cs index 98c7ec6a70..b362efb64c 100644 --- a/Perspex.SceneGraph/LogicalTree/LogicalExtensions.cs +++ b/Perspex.SceneGraph/LogicalTree/LogicalExtensions.cs @@ -35,7 +35,6 @@ namespace Perspex.LogicalTree } } - public static IEnumerable GetLogicalChildren(this ILogical logical) { return logical.LogicalChildren; diff --git a/Perspex.SceneGraph/Media/EllipseGeometry.cs b/Perspex.SceneGraph/Media/EllipseGeometry.cs index 90610ce574..625ad176dd 100644 --- a/Perspex.SceneGraph/Media/EllipseGeometry.cs +++ b/Perspex.SceneGraph/Media/EllipseGeometry.cs @@ -19,20 +19,20 @@ namespace Perspex.Media using (IStreamGeometryContextImpl ctx = impl.Open()) { - double ControlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3; + double controlPointRatio = (Math.Sqrt(2) - 1) * 4 / 3; var center = rect.Center; var radius = new Vector(rect.Width / 2, rect.Height / 2); var x0 = center.X - radius.X; - var x1 = center.X - radius.X * ControlPointRatio; + var x1 = center.X - (radius.X * controlPointRatio); var x2 = center.X; - var x3 = center.X + radius.X * ControlPointRatio; + var x3 = center.X + (radius.X * controlPointRatio); var x4 = center.X + radius.X; var y0 = center.Y - radius.Y; - var y1 = center.Y - radius.Y * ControlPointRatio; + var y1 = center.Y - (radius.Y * controlPointRatio); var y2 = center.Y; - var y3 = center.Y + radius.Y * ControlPointRatio; + var y3 = center.Y + (radius.Y * controlPointRatio); var y4 = center.Y + radius.Y; ctx.BeginFigure(new Point(x2, y0), true); diff --git a/Perspex.SceneGraph/Media/MatrixTransform.cs b/Perspex.SceneGraph/Media/MatrixTransform.cs index af9373ab4a..16e8f5f59d 100644 --- a/Perspex.SceneGraph/Media/MatrixTransform.cs +++ b/Perspex.SceneGraph/Media/MatrixTransform.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2013 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex.SceneGraph/Media/StreamGeometry.cs b/Perspex.SceneGraph/Media/StreamGeometry.cs index be0abcc07e..9407d9ff22 100644 --- a/Perspex.SceneGraph/Media/StreamGeometry.cs +++ b/Perspex.SceneGraph/Media/StreamGeometry.cs @@ -35,6 +35,11 @@ namespace Perspex.Media } } + private StreamGeometry(IGeometryImpl impl) + { + this.PlatformImpl = impl; + } + public override Geometry Clone() { return new StreamGeometry(((IStreamGeometryImpl)this.PlatformImpl).Clone()); @@ -44,10 +49,5 @@ namespace Perspex.Media { return new StreamGeometryContext(((IStreamGeometryImpl)this.PlatformImpl).Open()); } - - private StreamGeometry(IGeometryImpl impl) - { - this.PlatformImpl = impl; - } } } diff --git a/Perspex.SceneGraph/Media/SweepDirection.cs b/Perspex.SceneGraph/Media/SweepDirection.cs index 14cd7d2f3c..22d51788a7 100644 --- a/Perspex.SceneGraph/Media/SweepDirection.cs +++ b/Perspex.SceneGraph/Media/SweepDirection.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2013 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Windows/Perspex.Direct2D1/Media/BrushWrapper.cs b/Windows/Perspex.Direct2D1/Media/BrushWrapper.cs index 43f8e5c21e..1ebe53606a 100644 --- a/Windows/Perspex.Direct2D1/Media/BrushWrapper.cs +++ b/Windows/Perspex.Direct2D1/Media/BrushWrapper.cs @@ -1,4 +1,10 @@ -namespace Perspex.Direct2D1.Media +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex.Direct2D1.Media { using Perspex.Media; using SharpDX; diff --git a/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs b/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs index 157051a743..747be56ff9 100644 --- a/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs +++ b/Windows/Perspex.Direct2D1/Media/FormattedTextImpl.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs b/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs index 2567f937c7..9bd9082844 100644 --- a/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs +++ b/Windows/Perspex.Direct2D1/Media/StreamGeometryImpl.cs @@ -24,6 +24,11 @@ namespace Perspex.Direct2D1.Media this.path = new PathGeometry(factory); } + protected StreamGeometryImpl(PathGeometry geometry) + { + this.path = geometry; + } + public override Rect Bounds { get { return this.path.GetBounds().ToPerspex(); } @@ -48,10 +53,5 @@ namespace Perspex.Direct2D1.Media { return new StreamGeometryContextImpl(this.path.Open()); } - - protected StreamGeometryImpl(PathGeometry geometry) - { - this.path = geometry; - } } } diff --git a/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs b/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs index c2512b7edb..997cd51f0a 100644 --- a/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs +++ b/Windows/Perspex.Direct2D1/PrimitiveExtensions.cs @@ -110,6 +110,5 @@ namespace Perspex.Direct2D1 (float)rect.Width, (float)rect.Height); } - } } diff --git a/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs b/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs index e51753fac0..2dde3b6a53 100644 --- a/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs +++ b/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs @@ -484,7 +484,7 @@ namespace Perspex.Win32.Interop } [DllImport("user32.dll", SetLastError = true)] - public static extern Boolean AdjustWindowRectEx(ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle); + public static extern bool AdjustWindowRectEx(ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle); [DllImport("user32.dll")] public static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint); diff --git a/Windows/Perspex.Win32/PopupImpl.cs b/Windows/Perspex.Win32/PopupImpl.cs index 13ccf24a8c..3674fb619a 100644 --- a/Windows/Perspex.Win32/PopupImpl.cs +++ b/Windows/Perspex.Win32/PopupImpl.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- @@ -24,7 +24,6 @@ namespace Perspex.Win32 UnmanagedMethods.SetWindowPosFlags.SWP_NOSIZE | UnmanagedMethods.SetWindowPosFlags.SWP_NOACTIVATE); } - public override void Show() { UnmanagedMethods.ShowWindow(this.Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate); diff --git a/Windows/Perspex.Win32/WindowImpl.cs b/Windows/Perspex.Win32/WindowImpl.cs index 01b0d31e29..dbf138a459 100644 --- a/Windows/Perspex.Win32/WindowImpl.cs +++ b/Windows/Perspex.Win32/WindowImpl.cs @@ -277,6 +277,7 @@ namespace Perspex.Win32 UnmanagedMethods.EndPaint(this.hwnd, ref ps); } } + return IntPtr.Zero; case UnmanagedMethods.WindowsMessage.WM_SIZE: @@ -298,7 +299,6 @@ namespace Perspex.Win32 return UnmanagedMethods.DefWindowProc(hWnd, msg, wParam, lParam); } - private void CreateWindow() { // Ensure that the delegate doesn't get garbage collected by storing it as a field.