Browse Source

Stylecop fixes.

Also added solution-wide stylecop settings.
pull/10/head
Steven Kirk 11 years ago
parent
commit
a833a5e883
  1. 14
      Perspex.Application/Application.cs
  2. 10
      Perspex.Application/Properties/AssemblyInfo.cs
  3. 1
      Perspex.Base/Settings.StyleCop
  4. 4
      Perspex.Controls/Border.cs
  5. 6
      Perspex.Controls/Control.cs
  6. 4
      Perspex.Controls/Controls.cs
  7. 12
      Perspex.Controls/DataTemplate.cs
  8. 8
      Perspex.Controls/Grid.cs
  9. 6
      Perspex.Controls/GridSplitter.cs
  10. 48
      Perspex.Controls/Image.cs
  11. 20
      Perspex.Controls/ItemsControl.cs
  12. 12
      Perspex.Controls/ItemsPanelTemplate.cs
  13. 2
      Perspex.Controls/ListBoxItem.cs
  14. 6
      Perspex.Controls/Panel.cs
  15. 6
      Perspex.Controls/Presenters/ItemsPresenter.cs
  16. 10
      Perspex.Controls/Presenters/ScrollContentPresenter.cs
  17. 2
      Perspex.Controls/Primitives/HeaderedContentControl.cs
  18. 4
      Perspex.Controls/Primitives/ScrollBar.cs
  19. 2
      Perspex.Controls/Primitives/TabStrip.cs
  20. 2
      Perspex.Controls/Primitives/Thumb.cs
  21. 2
      Perspex.Controls/Primitives/ToggleButton.cs
  22. 15
      Perspex.Controls/Primitives/Track.cs
  23. 10
      Perspex.Controls/Properties/AssemblyInfo.cs
  24. 20
      Perspex.Controls/ScrollViewer.cs
  25. 16
      Perspex.Controls/Shapes/Shape.cs
  26. 2
      Perspex.Controls/TabControl.cs
  27. 4
      Perspex.Controls/TabItem.cs
  28. 2
      Perspex.Controls/TextBlock.cs
  29. 16
      Perspex.Controls/TextBoxView.cs
  30. 26
      Perspex.Controls/TreeDataTemplate.cs
  31. 6
      Perspex.Controls/TreeView.cs
  32. 6
      Perspex.Controls/TreeViewItem.cs
  33. 8
      Perspex.Controls/Window.cs
  34. 10
      Perspex.Themes.Default/Properties/AssemblyInfo.cs
  35. 184
      Settings.StyleCop
  36. 5
      Windows/Perspex.Win32/Input/WindowsMouseDevice.cs
  37. 26
      Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
  38. 8
      Windows/Perspex.Win32/Properties/AssemblyInfo.cs
  39. 2
      Windows/Perspex.Win32/Win32Platform.cs
  40. 1
      Windows/Perspex.Win32/WindowImpl.cs

14
Perspex.Application/Application.cs

@ -76,6 +76,13 @@ namespace Perspex
private set; private set;
} }
public void Run(ICloseable closable)
{
var source = new CancellationTokenSource();
closable.Closed += (s, e) => source.Cancel();
Dispatcher.UIThread.MainLoop(source.Token);
}
protected virtual void RegisterServices() protected virtual void RegisterServices()
{ {
Locator.CurrentMutable.Register(() => this, typeof(IGlobalDataTemplates)); Locator.CurrentMutable.Register(() => this, typeof(IGlobalDataTemplates));
@ -84,12 +91,5 @@ namespace Perspex
Locator.CurrentMutable.Register(() => this.InputManager, typeof(IInputManager)); Locator.CurrentMutable.Register(() => this.InputManager, typeof(IInputManager));
Locator.CurrentMutable.Register(() => this.styler, typeof(IStyler)); Locator.CurrentMutable.Register(() => this.styler, typeof(IStyler));
} }
public void Run(ICloseable closable)
{
var source = new CancellationTokenSource();
closable.Closed += (s, e) => source.Cancel();
Dispatcher.UIThread.MainLoop(source.Token);
}
} }
} }

10
Perspex.Application/Properties/AssemblyInfo.cs

@ -1,7 +1,11 @@
using System.Resources; // -----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
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

1
Perspex.Base/Settings.StyleCop

@ -0,0 +1 @@
<StyleCopSettings Version="105" />

4
Perspex.Controls/Border.cs

@ -15,8 +15,8 @@ namespace Perspex.Controls
{ {
static Border() static Border()
{ {
AffectsRender(BackgroundProperty); Control.AffectsRender(Border.BackgroundProperty);
AffectsRender(BorderBrushProperty); Control.AffectsRender(Border.BorderBrushProperty);
} }
public override void Render(IDrawingContext context) public override void Render(IDrawingContext context)

6
Perspex.Controls/Control.cs

@ -43,9 +43,9 @@ namespace Perspex.Controls
static Control() static Control()
{ {
AffectsMeasure(IsVisibleProperty); Control.AffectsMeasure(Control.IsVisibleProperty);
PseudoClass(IsPointerOverProperty, ":pointerover"); PseudoClass(Control.IsPointerOverProperty, ":pointerover");
PseudoClass(IsFocusedProperty, ":focus"); PseudoClass(Control.IsFocusedProperty, ":focus");
} }
public Brush Background public Brush Background

4
Perspex.Controls/Controls.cs

@ -4,10 +4,10 @@
// </copyright> // </copyright>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System.Collections.Generic;
namespace Perspex.Controls namespace Perspex.Controls
{ {
using System.Collections.Generic;
public class Controls : PerspexList<Control> public class Controls : PerspexList<Control>
{ {
public Controls() public Controls()

12
Perspex.Controls/DataTemplate.cs

@ -33,25 +33,25 @@ namespace Perspex.Controls
this.Build = build; this.Build = build;
} }
public Func<object, bool> Match { get; private set; }
public Func<object, Control> Build { get; private set; }
public static bool IsInstance(object o, Type t) public static bool IsInstance(object o, Type t)
{ {
return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo()); return t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
} }
public Func<object, bool> Match { get; private set; }
public Func<object, Control> Build { get; private set; }
} }
public class DataTemplate<T> : DataTemplate public class DataTemplate<T> : DataTemplate
{ {
public DataTemplate(Func<T, Control> build) public DataTemplate(Func<T, Control> build)
: base(typeof(T), Cast(build)) : base(typeof(T), DataTemplate<T>.Cast(build))
{ {
} }
public DataTemplate(Func<T, bool> match, Func<T, Control> build) public DataTemplate(Func<T, bool> match, Func<T, Control> build)
: base(CastMatch(match), Cast(build)) : base(CastMatch(match), DataTemplate<T>.Cast(build))
{ {
} }

8
Perspex.Controls/Grid.cs

@ -605,10 +605,10 @@ namespace Perspex.Controls
// we need to count the number of stars instead. // we need to count the number of stars instead.
for (int i = start; i <= end; i++) for (int i = start; i <= end; i++)
{ {
double segmentSize = desiredSize ? (matrix[i, i].DesiredSize) : matrix[i, i].OfferedSize; double segmentSize = desiredSize ? (matrix[i, i].DesiredSize) : matrix[i, i].OfferedSize;
if (segmentSize < matrix[i, i].Max) if (segmentSize < matrix[i, i].Max)
{ {
count += type == GridUnitType.Star ? (matrix[i, i].Stars) : 1; count += type == GridUnitType.Star ? (matrix[i, i].Stars) : 1;
} }
} }
@ -620,7 +620,7 @@ namespace Perspex.Controls
for (int i = start; i <= end; i++) for (int i = start; i <= end; i++)
{ {
double segmentSize = desiredSize ? (matrix[i, i].DesiredSize) : matrix[i, i].OfferedSize; double segmentSize = desiredSize ? (matrix[i, i].DesiredSize) : matrix[i, i].OfferedSize;
if (!(matrix[i, i].Type == type && segmentSize < matrix[i, i].Max)) if (!(matrix[i, i].Type == type && segmentSize < matrix[i, i].Max))
{ {
@ -628,7 +628,7 @@ namespace Perspex.Controls
} }
double newsize = segmentSize; double newsize = segmentSize;
newsize += contribution * (type == GridUnitType.Star ? (matrix[i, i].Stars) : 1); newsize += contribution * (type == GridUnitType.Star ? (matrix[i, i].Stars) : 1);
newsize = Math.Min(newsize, matrix[i, i].Max); newsize = Math.Min(newsize, matrix[i, i].Max);
assigned |= newsize > segmentSize; assigned |= newsize > segmentSize;
size -= newsize - segmentSize; size -= newsize - segmentSize;

6
Perspex.Controls/GridSplitter.cs

@ -18,10 +18,10 @@ namespace Perspex.Controls
{ {
int col = this.GetValue(Grid.ColumnProperty); int col = this.GetValue(Grid.ColumnProperty);
if (grid != null && col > 0) if (this.grid != null && col > 0)
{ {
grid.ColumnDefinitions[col - 1].Width = new GridLength( this.grid.ColumnDefinitions[col - 1].Width = new GridLength(
grid.ColumnDefinitions[col - 1].ActualWidth + e.Vector.X, this.grid.ColumnDefinitions[col - 1].ActualWidth + e.Vector.X,
GridUnitType.Pixel); GridUnitType.Pixel);
} }
} }

48
Perspex.Controls/Image.cs

@ -56,30 +56,6 @@ namespace Perspex.Controls
} }
} }
private static Vector CalculateScaling(Size availableSize, Size imageSize, Stretch stretch)
{
double scaleX = 1;
double scaleY = 1;
if (stretch != Stretch.None)
{
scaleX = availableSize.Width / imageSize.Width;
scaleY = availableSize.Height / imageSize.Height;
switch (stretch)
{
case Stretch.Uniform:
scaleX = scaleY = Math.Min(scaleX, scaleY);
break;
case Stretch.UniformToFill:
scaleX = scaleY = Math.Max(scaleX, scaleY);
break;
}
}
return new Vector(scaleX, scaleY);
}
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
double width = 0; double width = 0;
@ -111,5 +87,29 @@ namespace Perspex.Controls
{ {
return finalSize; return finalSize;
} }
private static Vector CalculateScaling(Size availableSize, Size imageSize, Stretch stretch)
{
double scaleX = 1;
double scaleY = 1;
if (stretch != Stretch.None)
{
scaleX = availableSize.Width / imageSize.Width;
scaleY = availableSize.Height / imageSize.Height;
switch (stretch)
{
case Stretch.Uniform:
scaleX = scaleY = Math.Min(scaleX, scaleY);
break;
case Stretch.UniformToFill:
scaleX = scaleY = Math.Max(scaleX, scaleY);
break;
}
}
return new Vector(scaleX, scaleY);
}
} }
} }

20
Perspex.Controls/ItemsControl.cs

@ -15,15 +15,15 @@ namespace Perspex.Controls
public class ItemsControl : TemplatedControl public class ItemsControl : TemplatedControl
{ {
private static readonly ItemsPanelTemplate DefaultPanel =
new ItemsPanelTemplate(() => new StackPanel { Orientation = Orientation.Vertical });
public static readonly PerspexProperty<IEnumerable> ItemsProperty = public static readonly PerspexProperty<IEnumerable> ItemsProperty =
PerspexProperty.Register<ItemsControl, IEnumerable>("Items"); PerspexProperty.Register<ItemsControl, IEnumerable>("Items");
public static readonly PerspexProperty<ItemsPanelTemplate> ItemsPanelProperty = public static readonly PerspexProperty<ItemsPanelTemplate> ItemsPanelProperty =
PerspexProperty.Register<ItemsControl, ItemsPanelTemplate>("ItemsPanel", defaultValue: DefaultPanel); PerspexProperty.Register<ItemsControl, ItemsPanelTemplate>("ItemsPanel", defaultValue: DefaultPanel);
private static readonly ItemsPanelTemplate DefaultPanel =
new ItemsPanelTemplate(() => new StackPanel { Orientation = Orientation.Vertical });
private ItemContainerGenerator itemContainerGenerator; private ItemContainerGenerator itemContainerGenerator;
public ItemsControl() public ItemsControl()
@ -44,11 +44,6 @@ namespace Perspex.Controls
} }
} }
protected virtual ItemContainerGenerator CreateItemContainerGenerator()
{
return new ItemContainerGenerator(this);
}
public IEnumerable Items public IEnumerable Items
{ {
get { return this.GetValue(ItemsProperty); } get { return this.GetValue(ItemsProperty); }
@ -61,13 +56,18 @@ namespace Perspex.Controls
set { this.SetValue(ItemsPanelProperty, value); } set { this.SetValue(ItemsPanelProperty, value); }
} }
protected virtual ItemContainerGenerator CreateItemContainerGenerator()
{
return new ItemContainerGenerator(this);
}
private void ItemsChanged(Tuple<IEnumerable, IEnumerable> value) private void ItemsChanged(Tuple<IEnumerable, IEnumerable> value)
{ {
INotifyPropertyChanged inpc = value.Item1 as INotifyPropertyChanged; INotifyPropertyChanged inpc = value.Item1 as INotifyPropertyChanged;
if (inpc != null) if (inpc != null)
{ {
inpc.PropertyChanged -= ItemsPropertyChanged; inpc.PropertyChanged -= this.ItemsPropertyChanged;
} }
if (value.Item2 == null || !value.Item2.OfType<object>().Any()) if (value.Item2 == null || !value.Item2.OfType<object>().Any())
@ -83,7 +83,7 @@ namespace Perspex.Controls
if (inpc != null) if (inpc != null)
{ {
inpc.PropertyChanged += ItemsPropertyChanged; inpc.PropertyChanged += this.ItemsPropertyChanged;
} }
} }

12
Perspex.Controls/ItemsPanelTemplate.cs

@ -1,11 +1,13 @@
using System; // -----------------------------------------------------------------------
using System.Collections.Generic; // <copyright file="ItemsPanelTemplate.cs" company="Steven Kirk">
using System.Linq; // Copyright 2013 MIT Licence. See licence.md for more information.
using System.Text; // </copyright>
using System.Threading.Tasks; // -----------------------------------------------------------------------
namespace Perspex.Controls namespace Perspex.Controls
{ {
using System;
public class ItemsPanelTemplate public class ItemsPanelTemplate
{ {
public ItemsPanelTemplate(Func<Panel> build) public ItemsPanelTemplate(Func<Panel> build)

2
Perspex.Controls/ListBoxItem.cs

@ -13,7 +13,7 @@ namespace Perspex.Controls
static ListBoxItem() static ListBoxItem()
{ {
PseudoClass(IsSelectedProperty, ":selected"); Control.PseudoClass(IsSelectedProperty, ":selected");
} }
public bool IsSelected public bool IsSelected

6
Perspex.Controls/Panel.cs

@ -24,7 +24,7 @@ namespace Perspex.Controls
if (this.children == null) if (this.children == null)
{ {
this.children = new Controls(); this.children = new Controls();
this.children.CollectionChanged += ChildrenChanged; this.children.CollectionChanged += this.ChildrenChanged;
} }
return this.children; return this.children;
@ -38,7 +38,7 @@ namespace Perspex.Controls
{ {
if (this.children != null) if (this.children != null)
{ {
this.children.CollectionChanged -= ChildrenChanged; this.children.CollectionChanged -= this.ChildrenChanged;
} }
this.children = value; this.children = value;
@ -46,7 +46,7 @@ namespace Perspex.Controls
if (this.children != null) if (this.children != null)
{ {
this.children.CollectionChanged += ChildrenChanged; this.children.CollectionChanged += this.ChildrenChanged;
this.AddVisualChildren(value); this.AddVisualChildren(value);
this.InvalidateMeasure(); this.InvalidateMeasure();
} }

6
Perspex.Controls/Presenters/ItemsPresenter.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="ItemsControl.cs" company="Steven Kirk"> // <copyright file="ItemsPresenter.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -51,8 +51,8 @@ namespace Perspex.Controls.Presenters
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
panel.Measure(availableSize); this.panel.Measure(availableSize);
return panel.DesiredSize.Value; return this.panel.DesiredSize.Value;
} }
protected override Size ArrangeOverride(Size finalSize) protected override Size ArrangeOverride(Size finalSize)

10
Perspex.Controls/Presenters/ScrollContentPresenter.cs

@ -9,20 +9,20 @@ namespace Perspex.Controls.Presenters
using System.Linq; using System.Linq;
using Perspex.Layout; using Perspex.Layout;
public class ScrollContentPresenter : ContentPresenter public class ScrollContentPresenter : ContentPresenter
{ {
public static PerspexProperty<Size> ExtentProperty = public static readonly PerspexProperty<Size> ExtentProperty =
ScrollViewer.ExtentProperty.AddOwner<ScrollContentPresenter>(); ScrollViewer.ExtentProperty.AddOwner<ScrollContentPresenter>();
public static PerspexProperty<Vector> OffsetProperty = public static readonly PerspexProperty<Vector> OffsetProperty =
ScrollViewer.OffsetProperty.AddOwner<ScrollContentPresenter>(); ScrollViewer.OffsetProperty.AddOwner<ScrollContentPresenter>();
public static PerspexProperty<Size> ViewportProperty = public static readonly PerspexProperty<Size> ViewportProperty =
ScrollViewer.ViewportProperty.AddOwner<ScrollContentPresenter>(); ScrollViewer.ViewportProperty.AddOwner<ScrollContentPresenter>();
public ScrollContentPresenter() public ScrollContentPresenter()
{ {
AffectsRender(OffsetProperty); Control.AffectsRender(OffsetProperty);
} }
public Size Extent public Size Extent

2
Perspex.Controls/Primitives/HeaderedContentControl.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="ContentControl.cs" company="Steven Kirk"> // <copyright file="HeaderedContentControl.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

4
Perspex.Controls/Primitives/ScrollBar.cs

@ -28,8 +28,8 @@ namespace Perspex.Controls.Primitives
static ScrollBar() static ScrollBar()
{ {
PseudoClass(OrientationProperty, x => x == Orientation.Horizontal, ":horizontal"); Control.PseudoClass(OrientationProperty, x => x == Orientation.Horizontal, ":horizontal");
PseudoClass(OrientationProperty, x => x == Orientation.Vertical, ":vertical"); Control.PseudoClass(OrientationProperty, x => x == Orientation.Vertical, ":vertical");
} }
public double Minimum public double Minimum

2
Perspex.Controls/Primitives/TabStrip.cs

@ -37,7 +37,7 @@ namespace Perspex.Controls.Primitives
result = new TypedItemContainerGenerator<TabItem>(this); result = new TypedItemContainerGenerator<TabItem>(this);
} }
result.StateChanged += ItemsContainerGeneratorStateChanged; result.StateChanged += this.ItemsContainerGeneratorStateChanged;
return result; return result;
} }

2
Perspex.Controls/Primitives/Thumb.cs

@ -21,7 +21,7 @@ namespace Perspex.Controls.Primitives
public static readonly RoutedEvent<VectorEventArgs> DragCompletedEvent = public static readonly RoutedEvent<VectorEventArgs> DragCompletedEvent =
RoutedEvent.Register<Thumb, VectorEventArgs>("DragCompleted", RoutingStrategy.Bubble); RoutedEvent.Register<Thumb, VectorEventArgs>("DragCompleted", RoutingStrategy.Bubble);
Point? lastPoint; private Point? lastPoint;
public Thumb() public Thumb()
{ {

2
Perspex.Controls/Primitives/ToggleButton.cs

@ -15,7 +15,7 @@ namespace Perspex.Controls.Primitives
static ToggleButton() static ToggleButton()
{ {
PseudoClass(IsCheckedProperty, ":checked"); Control.PseudoClass(IsCheckedProperty, ":checked");
} }
public ToggleButton() public ToggleButton()

15
Perspex.Controls/Primitives/Track.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="Thumb.cs" company="Steven Kirk"> // <copyright file="Track.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -30,6 +30,14 @@ namespace Perspex.Controls.Primitives
public static readonly PerspexProperty<Thumb> ThumbProperty = public static readonly PerspexProperty<Thumb> ThumbProperty =
PerspexProperty.Register<Track, Thumb>("Thumb"); PerspexProperty.Register<Track, Thumb>("Thumb");
static Track()
{
Control.AffectsArrange(MinimumProperty);
Control.AffectsArrange(MaximumProperty);
Control.AffectsArrange(ValueProperty);
Control.AffectsMeasure(OrientationProperty);
}
public Track() public Track()
{ {
this.GetObservableWithHistory(ThumbProperty).Subscribe(val => this.GetObservableWithHistory(ThumbProperty).Subscribe(val =>
@ -47,11 +55,6 @@ namespace Perspex.Controls.Primitives
this.AddVisualChild(val.Item2); this.AddVisualChild(val.Item2);
} }
}); });
AffectsArrange(MinimumProperty);
AffectsArrange(MaximumProperty);
AffectsArrange(ValueProperty);
AffectsMeasure(OrientationProperty);
} }
public double Minimum public double Minimum

10
Perspex.Controls/Properties/AssemblyInfo.cs

@ -1,7 +1,11 @@
using System.Resources; // -----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
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

20
Perspex.Controls/ScrollViewer.cs

@ -1,24 +1,24 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="DefinitionBase.cs" company="Steven Kirk"> // <copyright file="ScrollViewer.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
using System.Reactive.Linq;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
namespace Perspex.Controls namespace Perspex.Controls
{ {
using System.Reactive.Linq;
using Perspex.Controls.Presenters;
using Perspex.Controls.Primitives;
public class ScrollViewer : ContentControl public class ScrollViewer : ContentControl
{ {
public static PerspexProperty<Size> ExtentProperty = public static readonly PerspexProperty<Size> ExtentProperty =
PerspexProperty.Register<ScrollViewer, Size>("Extent"); PerspexProperty.Register<ScrollViewer, Size>("Extent");
public static PerspexProperty<Vector> OffsetProperty = public static readonly PerspexProperty<Vector> OffsetProperty =
PerspexProperty.Register<ScrollViewer, Vector>("Offset"); PerspexProperty.Register<ScrollViewer, Vector>("Offset");
public static PerspexProperty<Size> ViewportProperty = public static readonly PerspexProperty<Size> ViewportProperty =
PerspexProperty.Register<ScrollViewer, Size>("Viewport"); PerspexProperty.Register<ScrollViewer, Size>("Viewport");
private ScrollContentPresenter presenter; private ScrollContentPresenter presenter;
@ -61,7 +61,7 @@ namespace Perspex.Controls
.Select(x => new { Extent = x[0], Viewport = x[1] }); .Select(x => new { Extent = x[0], Viewport = x[1] });
this.horizontalScrollBar.Bind( this.horizontalScrollBar.Bind(
IsVisibleProperty, Visual.IsVisibleProperty,
extentAndViewport.Select(x => x.Extent.Width > x.Viewport.Width)); extentAndViewport.Select(x => x.Extent.Width > x.Viewport.Width));
this.horizontalScrollBar.Bind( this.horizontalScrollBar.Bind(
@ -73,7 +73,7 @@ namespace Perspex.Controls
extentAndViewport.Select(x => (x.Viewport.Width / x.Extent.Width) * (x.Extent.Width - x.Viewport.Width))); extentAndViewport.Select(x => (x.Viewport.Width / x.Extent.Width) * (x.Extent.Width - x.Viewport.Width)));
this.verticalScrollBar.Bind( this.verticalScrollBar.Bind(
IsVisibleProperty, Visual.IsVisibleProperty,
extentAndViewport.Select(x => x.Extent.Height > x.Viewport.Height)); extentAndViewport.Select(x => x.Extent.Height > x.Viewport.Height));
this.verticalScrollBar.Bind( this.verticalScrollBar.Bind(

16
Perspex.Controls/Shapes/Shape.cs

@ -58,6 +58,14 @@ namespace Perspex.Controls.Shapes
set { this.SetValue(StrokeThicknessProperty, value); } set { this.SetValue(StrokeThicknessProperty, value); }
} }
public override void Render(IDrawingContext context)
{
if (this.RenderedGeometry != null)
{
context.DrawGeometry(this.Fill, new Pen(this.Stroke, this.StrokeThickness), this.RenderedGeometry);
}
}
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
Rect shapeBounds = this.RenderedGeometry.GetRenderBounds(this.StrokeThickness); Rect shapeBounds = this.RenderedGeometry.GetRenderBounds(this.StrokeThickness);
@ -127,13 +135,5 @@ namespace Perspex.Controls.Shapes
double finalY = (height > 0) ? height : shapeBounds.Bottom * sy; double finalY = (height > 0) ? height : shapeBounds.Bottom * sy;
return new Size(finalX, finalY); return new Size(finalX, finalY);
} }
public override void Render(IDrawingContext context)
{
if (this.RenderedGeometry != null)
{
context.DrawGeometry(this.Fill, new Pen(this.Stroke, this.StrokeThickness), this.RenderedGeometry);
}
}
} }
} }

2
Perspex.Controls/TabControl.cs

@ -37,7 +37,7 @@ namespace Perspex.Controls
protected override void OnTemplateApplied() protected override void OnTemplateApplied()
{ {
this.tabStrip = this.GetTemplateControls().OfType<TabStrip>().FirstOrDefault(); this.tabStrip = this.GetTemplateControls().OfType<TabStrip>().FirstOrDefault();
this.BindTwoWay(SelectedItemProperty, this.tabStrip, SelectedItemProperty); this.BindTwoWay(TabControl.SelectedItemProperty, this.tabStrip, TabControl.SelectedItemProperty);
} }
} }
} }

4
Perspex.Controls/TabItem.cs

@ -15,8 +15,8 @@ namespace Perspex.Controls
static TabItem() static TabItem()
{ {
AffectsRender(IsSelectedProperty); Control.AffectsRender(IsSelectedProperty);
PseudoClass(IsSelectedProperty, ":selected"); Control.PseudoClass(IsSelectedProperty, ":selected");
} }
public bool IsSelected public bool IsSelected

2
Perspex.Controls/TextBlock.cs

@ -27,7 +27,7 @@ namespace Perspex.Controls
static TextBlock() static TextBlock()
{ {
AffectsMeasure(TextProperty); Control.AffectsMeasure(TextProperty);
} }
public string Text public string Text

16
Perspex.Controls/TextBoxView.cs

@ -61,14 +61,6 @@ namespace Perspex.Controls
this.InvalidateMeasure(); this.InvalidateMeasure();
} }
internal void CaretMoved()
{
this.caretBlink = true;
this.caretTimer.Stop();
this.caretTimer.Start();
this.InvalidateVisual();
}
public override void Render(IDrawingContext context) public override void Render(IDrawingContext context)
{ {
Rect rect = new Rect(this.ActualSize); Rect rect = new Rect(this.ActualSize);
@ -95,6 +87,14 @@ namespace Perspex.Controls
} }
} }
internal void CaretMoved()
{
this.caretBlink = true;
this.caretTimer.Stop();
this.caretTimer.Start();
this.InvalidateVisual();
}
protected override Size MeasureOverride(Size constraint) protected override Size MeasureOverride(Size constraint)
{ {
if (!string.IsNullOrEmpty(this.parent.Text)) if (!string.IsNullOrEmpty(this.parent.Text))

26
Perspex.Controls/TreeDataTemplate.cs

@ -22,7 +22,7 @@ namespace Perspex.Controls
Type type, Type type,
Func<object, Control> build, Func<object, Control> build,
Func<object, IEnumerable> itemsSelector) Func<object, IEnumerable> itemsSelector)
: this(o => IsInstance(o, type), build, itemsSelector) : this(o => DataTemplate.IsInstance(o, type), build, itemsSelector)
{ {
} }
@ -31,7 +31,7 @@ namespace Perspex.Controls
Func<object, Control> build, Func<object, Control> build,
Func<object, IEnumerable> itemsSelector, Func<object, IEnumerable> itemsSelector,
Func<object, bool> isExpanded) Func<object, bool> isExpanded)
: this(o => IsInstance(o, type), build, itemsSelector, isExpanded) : this(o => DataTemplate.IsInstance(o, type), build, itemsSelector, isExpanded)
{ {
} }
@ -65,7 +65,10 @@ namespace Perspex.Controls
public TreeDataTemplate( public TreeDataTemplate(
Func<T, Control> build, Func<T, Control> build,
Func<T, IEnumerable> itemsSelector) Func<T, IEnumerable> itemsSelector)
: base(typeof(T), Cast(build), Cast(itemsSelector)) : base(
typeof(T),
TreeDataTemplate<T>.Cast(build),
TreeDataTemplate<T>.Cast(itemsSelector))
{ {
} }
@ -73,7 +76,11 @@ namespace Perspex.Controls
Func<T, Control> build, Func<T, Control> build,
Func<T, IEnumerable> itemsSelector, Func<T, IEnumerable> itemsSelector,
Func<T, bool> isExpanded) Func<T, bool> isExpanded)
: base(typeof(T), Cast(build), Cast(itemsSelector), Cast(isExpanded)) : base(
typeof(T),
TreeDataTemplate<T>.Cast(build),
TreeDataTemplate<T>.Cast(itemsSelector),
TreeDataTemplate<T>.Cast(isExpanded))
{ {
} }
@ -81,7 +88,10 @@ namespace Perspex.Controls
Func<T, bool> match, Func<T, bool> match,
Func<T, Control> build, Func<T, Control> build,
Func<T, IEnumerable> itemsSelector) Func<T, IEnumerable> itemsSelector)
: base(CastMatch(match), Cast(build), Cast(itemsSelector)) : base(
TreeDataTemplate<T>.CastMatch(match),
TreeDataTemplate<T>.Cast(build),
TreeDataTemplate<T>.Cast(itemsSelector))
{ {
} }
@ -90,7 +100,11 @@ namespace Perspex.Controls
Func<T, Control> build, Func<T, Control> build,
Func<T, IEnumerable> itemsSelector, Func<T, IEnumerable> itemsSelector,
Func<T, bool> isExpanded) Func<T, bool> isExpanded)
: base(CastMatch(match), Cast(build), Cast(itemsSelector), Cast(isExpanded)) : base(
TreeDataTemplate<T>.CastMatch(match),
TreeDataTemplate<T>.Cast(build),
TreeDataTemplate<T>.Cast(itemsSelector),
TreeDataTemplate<T>.Cast(isExpanded))
{ {
} }

6
Perspex.Controls/TreeView.cs

@ -36,6 +36,7 @@ namespace Perspex.Controls
{ {
this.SelectedItem = list[index - 1]; this.SelectedItem = list[index - 1];
} }
break; break;
} }
@ -48,6 +49,7 @@ namespace Perspex.Controls
{ {
this.SelectedItem = list[index + 1]; this.SelectedItem = list[index + 1];
} }
break; break;
} }
@ -68,14 +70,14 @@ namespace Perspex.Controls
} }
} }
List<object> Flatten() private List<object> Flatten()
{ {
var result = new List<object>(); var result = new List<object>();
this.Flatten(this.Items, result); this.Flatten(this.Items, result);
return result; return result;
} }
void Flatten(IEnumerable items, List<object> result) private void Flatten(IEnumerable items, List<object> result)
{ {
if (items != null) if (items != null)
{ {

6
Perspex.Controls/TreeViewItem.cs

@ -19,16 +19,16 @@ namespace Perspex.Controls
public static readonly PerspexProperty<bool> IsSelectedProperty = public static readonly PerspexProperty<bool> IsSelectedProperty =
ListBoxItem.IsSelectedProperty.AddOwner<TreeViewItem>(); ListBoxItem.IsSelectedProperty.AddOwner<TreeViewItem>();
TreeView treeView; private TreeView treeView;
static TreeViewItem() static TreeViewItem()
{ {
PseudoClass(IsSelectedProperty, ":selected"); Control.PseudoClass(IsSelectedProperty, ":selected");
} }
public TreeViewItem() public TreeViewItem()
{ {
AffectsRender(IsSelectedProperty); Control.AffectsRender(IsSelectedProperty);
} }
public bool IsExpanded public bool IsExpanded

8
Perspex.Controls/Window.cs

@ -34,10 +34,6 @@ namespace Perspex.Controls
private IInputManager inputManager; private IInputManager inputManager;
public event EventHandler Activated;
public event EventHandler Closed;
static Window() static Window()
{ {
BackgroundProperty.OverrideDefaultValue(typeof(Window), Brushes.White); BackgroundProperty.OverrideDefaultValue(typeof(Window), Brushes.White);
@ -85,6 +81,10 @@ namespace Perspex.Controls
styler.ApplyStyles(this); styler.ApplyStyles(this);
} }
public event EventHandler Activated;
public event EventHandler Closed;
public Size ClientSize public Size ClientSize
{ {
get { return this.GetValue(ClientSizeProperty); } get { return this.GetValue(ClientSizeProperty); }

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

@ -1,7 +1,11 @@
using System.Resources; // -----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
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

184
Settings.StyleCop

@ -0,0 +1,184 @@
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustContainValidXml">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustMatchElementParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="VoidReturnValueMustNotBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumentedPartialClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustMatchTypeParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustMatchAccessors">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotBeCopiedAndPasted">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SingleLineCommentsMustNotUseDocumentationStyleSlashes">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustNotBeEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustMeetCharacterPercentage">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DestructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationHeadersMustNotContainBlankLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludedDocumentationXPathDoesNotExist">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludeNodeDoesNotContainValidFileAndPath">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="InheritDocMustBeUsedWithInheritingClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>

5
Windows/Perspex.Win32/Input/WindowsMouseDevice.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="MouseDevice.cs" company="Steven Kirk"> // <copyright file="WindowsMouseDevice.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -39,5 +39,4 @@ namespace Perspex.Win32.Input
return new Point(p.X, p.Y); return new Point(p.X, p.Y);
} }
} }
} }

26
Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

@ -42,18 +42,6 @@ namespace Perspex.Win32.Interop
IDC_HELP = 32651 IDC_HELP = 32651
} }
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
public bool fErase;
public RECT rcPaint;
public bool fRestore;
public bool fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] rgbReserved;
}
[Flags] [Flags]
public enum SetWindowPosFlags : uint public enum SetWindowPosFlags : uint
{ {
@ -469,7 +457,7 @@ namespace Perspex.Win32.Interop
IntPtr lpParam); IntPtr lpParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString); public static extern bool SetWindowText(IntPtr hwnd, string lpString);
public struct MSG public struct MSG
{ {
@ -481,6 +469,18 @@ namespace Perspex.Win32.Interop
public POINT pt; public POINT pt;
} }
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
public bool fErase;
public RECT rcPaint;
public bool fRestore;
public bool fIncUpdate;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] rgbReserved;
}
public struct POINT public struct POINT
{ {
public int X; public int X;

8
Windows/Perspex.Win32/Properties/AssemblyInfo.cs

@ -1,4 +1,10 @@
using System.Reflection; // -----------------------------------------------------------------------
// <copyright file="AssemblyInfo.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;

2
Windows/Perspex.Win32/Win32Platform.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="WindowsPlatform.cs" company="Steven Kirk"> // <copyright file="Win32Platform.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
Windows/Perspex.Win32/WindowImpl.cs

@ -202,6 +202,7 @@ namespace Perspex.Win32
{ {
this.Resized(new Size((int)lParam & 0xffff, (int)lParam >> 16)); this.Resized(new Size((int)lParam & 0xffff, (int)lParam >> 16));
} }
return IntPtr.Zero; return IntPtr.Zero;
} }

Loading…
Cancel
Save