Browse Source

Stylecop fixes

pull/4/head
Steven Kirk 12 years ago
parent
commit
d680fdb76d
  1. 1
      Perspex.Windows/DrawingContext.cs
  2. 13
      Perspex/Application.cs
  3. 2
      Perspex/BindingExtensions.cs
  4. 26
      Perspex/Classes.cs
  5. 12
      Perspex/Contract.cs
  6. 16
      Perspex/Controls/ControlTemplate.cs
  7. 4
      Perspex/Controls/ITemplatedControl.cs
  8. 2
      Perspex/Controls/LogicalChildren.cs
  9. 2
      Perspex/Input/InputManager.cs
  10. 13
      Perspex/PerspexList.cs
  11. 32
      Perspex/PerspexObject.cs
  12. 18
      Perspex/PriorityValue.cs
  13. 2
      Perspex/Styling/IStyler.cs
  14. 2
      Perspex/Styling/Selector.cs
  15. 24
      Perspex/Styling/StyleActivator.cs
  16. 26
      Perspex/Themes/Default/ButtonStyle.cs
  17. 13
      Perspex/Themes/Default/DefaultTheme.cs

1
Perspex.Windows/DrawingContext.cs

@ -71,6 +71,7 @@ namespace Perspex.Windows
/// Draws text. /// Draws text.
/// </summary> /// </summary>
/// <param name="foreground">The foreground brush.</param> /// <param name="foreground">The foreground brush.</param>
/// <param name="rect">The output rectangle.</param>
/// <param name="text">The text.</param> /// <param name="text">The text.</param>
public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text) public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text)
{ {

13
Perspex/Application.cs

@ -1,12 +1,13 @@
using System; // -----------------------------------------------------------------------
using System.Collections.Generic; // <copyright file="Application.cs" company="Steven Kirk">
using System.Linq; // Copyright 2014 MIT Licence. See licence.md for more information.
using System.Text; // </copyright>
using System.Threading.Tasks; // -----------------------------------------------------------------------
using Perspex.Styling;
namespace Perspex namespace Perspex
{ {
using Perspex.Styling;
public class Application public class Application
{ {
private Styles styles; private Styles styles;

2
Perspex/BindingExtensions.cs

@ -11,7 +11,7 @@ namespace Perspex
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Perspex.Controls; using Perspex.Controls;
/// <summary> /// <summary>
/// Provides binding utility extension methods. /// Provides binding utility extension methods.

26
Perspex/Classes.cs

@ -92,17 +92,6 @@ namespace Perspex
this.RaiseChanged(e); this.RaiseChanged(e);
} }
private void RaiseChanged(NotifyCollectionChangedEventArgs e)
{
if (this.CollectionChanged != null)
{
this.CollectionChanged(this, e);
}
this.changed.OnNext(e);
this.afterChanged.OnNext(e);
}
public void Clear() public void Clear()
{ {
NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs( NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(
@ -125,7 +114,7 @@ namespace Perspex
public IEnumerator<string> GetEnumerator() public IEnumerator<string> GetEnumerator()
{ {
return inner.GetEnumerator(); return this.inner.GetEnumerator();
} }
public override string ToString() public override string ToString()
@ -135,7 +124,7 @@ namespace Perspex
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
{ {
return inner.GetEnumerator(); return this.inner.GetEnumerator();
} }
public bool Remove(string item) public bool Remove(string item)
@ -173,5 +162,16 @@ namespace Perspex
return false; return false;
} }
} }
private void RaiseChanged(NotifyCollectionChangedEventArgs e)
{
if (this.CollectionChanged != null)
{
this.CollectionChanged(this, e);
}
this.changed.OnNext(e);
this.afterChanged.OnNext(e);
}
} }
} }

12
Perspex/Contract.cs

@ -1,11 +1,13 @@
using System; // -----------------------------------------------------------------------
using System.Collections.Generic; // <copyright file="Contract.cs" company="Steven Kirk">
using System.Linq; // Copyright 2014 MIT Licence. See licence.md for more information.
using System.Text; // </copyright>
using System.Threading.Tasks; // -----------------------------------------------------------------------
namespace Perspex namespace Perspex
{ {
using System;
internal static class Contract internal static class Contract
{ {
public static void Requires<TException>(bool condition) where TException : Exception, new() public static void Requires<TException>(bool condition) where TException : Exception, new()

16
Perspex/Controls/ControlTemplate.cs

@ -21,6 +21,14 @@ namespace Perspex.Controls
this.build = build; this.build = build;
} }
public static ControlTemplate Create<TControl>(Func<TControl, Control> build)
where TControl : ITemplatedControl
{
Contract.Requires<NullReferenceException>(build != null);
return new ControlTemplate(c => build((TControl)c));
}
public Control Build(ITemplatedControl templatedParent) public Control Build(ITemplatedControl templatedParent)
{ {
Contract.Requires<NullReferenceException>(templatedParent != null); Contract.Requires<NullReferenceException>(templatedParent != null);
@ -30,14 +38,6 @@ namespace Perspex.Controls
return root; return root;
} }
public static ControlTemplate Create<TControl>(Func<TControl, Control> build)
where TControl : ITemplatedControl
{
Contract.Requires<NullReferenceException>(build != null);
return new ControlTemplate(c => build((TControl)c));
}
private void SetTemplatedParent(Control control, ITemplatedControl templatedParent) private void SetTemplatedParent(Control control, ITemplatedControl templatedParent)
{ {
Contract.Requires<NullReferenceException>(control != null); Contract.Requires<NullReferenceException>(control != null);

4
Perspex/Controls/ITemplatedControl.cs

@ -11,6 +11,8 @@ namespace Perspex.Controls
public interface ITemplatedControl public interface ITemplatedControl
{ {
IEnumerable<IVisual> VisualChildren { get; }
/// <summary> /// <summary>
/// Gets an observable for a <see cref="PerspexProperty"/>. /// Gets an observable for a <see cref="PerspexProperty"/>.
/// </summary> /// </summary>
@ -18,7 +20,5 @@ namespace Perspex.Controls
/// <param name="property">The property to get the observable for.</param> /// <param name="property">The property to get the observable for.</param>
/// <returns>The observable.</returns> /// <returns>The observable.</returns>
IObservable<T> GetObservable<T>(PerspexProperty<T> property); IObservable<T> GetObservable<T>(PerspexProperty<T> property);
IEnumerable<IVisual> VisualChildren { get; }
} }
} }

2
Perspex/Controls/LogicalChildren.cs

@ -41,7 +41,7 @@ namespace Perspex.Controls
public void Change(PerspexList<T> childrenCollection) public void Change(PerspexList<T> childrenCollection)
{ {
this.childrenCollection.CollectionChanged -= this.CollectionChanged; this.childrenCollection.CollectionChanged -= this.CollectionChanged;
this.Remove(inner.ToList()); this.Remove(this.inner.ToList());
this.childrenCollection = childrenCollection; this.childrenCollection = childrenCollection;
this.Add(childrenCollection); this.Add(childrenCollection);
childrenCollection.CollectionChanged += this.CollectionChanged; childrenCollection.CollectionChanged += this.CollectionChanged;

2
Perspex/Input/InputManager.cs

@ -13,7 +13,7 @@ namespace Perspex.Input
public class InputManager : IInputManager public class InputManager : IInputManager
{ {
List<Control> pointerOvers = new List<Control>(); private List<Control> pointerOvers = new List<Control>();
public void Process(RawInputEventArgs e) public void Process(RawInputEventArgs e)
{ {

13
Perspex/PerspexList.cs

@ -1,15 +1,16 @@
namespace Perspex // -----------------------------------------------------------------------
// <copyright file="PerspexList.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
{ {
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
public class PerspexList<T> : ObservableCollection<T> public class PerspexList<T> : ObservableCollection<T>
{ {

32
Perspex/PerspexObject.cs

@ -186,19 +186,19 @@ namespace Perspex
public void ClearBinding(PerspexProperty property) public void ClearBinding(PerspexProperty property)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
//Contract.Requires<NullReferenceException>(property != null); ////Contract.Requires<NullReferenceException>(property != null);
//PriorityValue value; ////PriorityValue value;
//if (this.values.TryGetValue(property, out value)) ////if (this.values.TryGetValue(property, out value))
//{ ////{
// value.ClearLocalBinding(); //// value.ClearLocalBinding();
// this.Log().Debug(string.Format( //// this.Log().Debug(string.Format(
// "Cleared binding on {0}.{1} (#{2:x8})", //// "Cleared binding on {0}.{1} (#{2:x8})",
// this.GetType().Name, //// this.GetType().Name,
// property.Name, //// property.Name,
// this.GetHashCode())); //// this.GetHashCode()));
//} ////}
} }
/// <summary> /// <summary>
@ -344,7 +344,7 @@ namespace Perspex
{ {
Contract.Requires<NullReferenceException>(property != null); Contract.Requires<NullReferenceException>(property != null);
const int priority = (int)BindingPriority.LocalValue; const int Priority = (int)BindingPriority.LocalValue;
PriorityValue v; PriorityValue v;
if (!this.values.TryGetValue(property, out v)) if (!this.values.TryGetValue(property, out v))
@ -365,8 +365,8 @@ namespace Perspex
this.GetHashCode(), this.GetHashCode(),
value)); value));
v.Clear(priority); v.Clear(Priority);
v.Add(Observable.Never<object>().StartWith(value), priority); v.Add(Observable.Never<object>().StartWith(value), Priority);
} }
/// <summary> /// <summary>

18
Perspex/PriorityValue.cs

@ -219,6 +219,15 @@ namespace Perspex
/// </summary> /// </summary>
private IDisposable subscription; private IDisposable subscription;
/// <summary>
/// Gets a description of the binding.
/// </summary>
public string Description
{
get;
private set;
}
/// <summary> /// <summary>
/// The priority of the binding. /// The priority of the binding.
/// </summary> /// </summary>
@ -276,15 +285,6 @@ namespace Perspex
() => completed(this)); () => completed(this));
} }
/// <summary>
/// Gets a description of the binding.
/// </summary>
public string Description
{
get;
private set;
}
/// <summary> /// <summary>
/// Ends the binding subscription. /// Ends the binding subscription.
/// </summary> /// </summary>

2
Perspex/Styling/IStyler.cs

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

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

24
Perspex/Styling/StyleActivator.cs

@ -1,5 +1,5 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// <copyright file="Activator.cs" company="Steven Kirk"> // <copyright file="StyleActivator.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>
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -19,13 +19,13 @@ namespace Perspex.Styling
public class StyleActivator : IObservable<bool>, IDisposable public class StyleActivator : IObservable<bool>, IDisposable
{ {
ActivatorMode mode; private ActivatorMode mode;
List<bool> values = new List<bool>(); private List<bool> values = new List<bool>();
List<IDisposable> subscriptions = new List<IDisposable>(); private List<IDisposable> subscriptions = new List<IDisposable>();
List<IObserver<bool>> observers = new List<IObserver<bool>>(); private List<IObserver<bool>> observers = new List<IObserver<bool>>();
public StyleActivator( public StyleActivator(
IEnumerable<IObservable<bool>> inputs, IEnumerable<IObservable<bool>> inputs,
@ -37,14 +37,14 @@ namespace Perspex.Styling
foreach (IObservable<bool> input in inputs) foreach (IObservable<bool> input in inputs)
{ {
int iCaptured = i; int capturedIndex = i;
this.values.Add(false); this.values.Add(false);
IDisposable subscription = input.Subscribe( IDisposable subscription = input.Subscribe(
x => this.Update(iCaptured, x), x => this.Update(capturedIndex, x),
x => this.Finish(iCaptured), x => this.Finish(capturedIndex),
() => this.Finish(iCaptured)); () => this.Finish(capturedIndex));
this.subscriptions.Add(subscription); this.subscriptions.Add(subscription);
++i; ++i;
} }
@ -80,7 +80,7 @@ namespace Perspex.Styling
Contract.Requires<ArgumentNullException>(observer != null); Contract.Requires<ArgumentNullException>(observer != null);
this.observers.Add(observer); this.observers.Add(observer);
observer.OnNext(CurrentValue); observer.OnNext(this.CurrentValue);
return Disposable.Create(() => this.observers.Remove(observer)); return Disposable.Create(() => this.observers.Remove(observer));
} }
@ -102,10 +102,10 @@ namespace Perspex.Styling
throw new InvalidOperationException("Invalid Activator mode."); throw new InvalidOperationException("Invalid Activator mode.");
} }
if (current != CurrentValue) if (current != this.CurrentValue)
{ {
this.Push(current); this.Push(current);
CurrentValue = current; this.CurrentValue = current;
} }
} }

26
Perspex/Themes/Default/ButtonStyle.cs

@ -1,14 +1,16 @@
using System; // -----------------------------------------------------------------------
using System.Collections.Generic; // <copyright file="ButtonStyle.cs" company="Steven Kirk">
using System.Linq; // Copyright 2014 MIT Licence. See licence.md for more information.
using System.Text; // </copyright>
using System.Threading.Tasks; // -----------------------------------------------------------------------
using Perspex.Controls;
using Perspex.Media;
using Perspex.Styling;
namespace Perspex.Themes.Default namespace Perspex.Themes.Default
{ {
using System.Linq;
using Perspex.Controls;
using Perspex.Media;
using Perspex.Styling;
public class ButtonStyle : Styles public class ButtonStyle : Styles
{ {
public ButtonStyle() public ButtonStyle()
@ -36,22 +38,22 @@ namespace Perspex.Themes.Default
{ {
Setters = new[] Setters = new[]
{ {
new Setter (Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)), new Setter(Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)),
new Setter (Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)), new Setter(Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)),
}, },
}, },
new Style(x => x.OfType<Button>().Class(":pointerover").Class(":pressed").Template().Id("border")) new Style(x => x.OfType<Button>().Class(":pointerover").Class(":pressed").Template().Id("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter (Button.BackgroundProperty, new SolidColorBrush(0xffc4e5f6)), new Setter(Button.BackgroundProperty, new SolidColorBrush(0xffc4e5f6)),
}, },
}, },
new Style(x => x.OfType<Button>().Class(":pressed").Template().Id("border")) new Style(x => x.OfType<Button>().Class(":pressed").Template().Id("border"))
{ {
Setters = new[] Setters = new[]
{ {
new Setter (Button.BorderBrushProperty, new SolidColorBrush(0xffff628b)), new Setter(Button.BorderBrushProperty, new SolidColorBrush(0xffff628b)),
}, },
}, },
}); });

13
Perspex/Themes/Default/DefaultTheme.cs

@ -1,12 +1,13 @@
using System; // -----------------------------------------------------------------------
using System.Collections.Generic; // <copyright file="DefaultTheme.cs" company="Steven Kirk">
using System.Linq; // Copyright 2014 MIT Licence. See licence.md for more information.
using System.Text; // </copyright>
using System.Threading.Tasks; // -----------------------------------------------------------------------
using Perspex.Styling;
namespace Perspex.Themes.Default namespace Perspex.Themes.Default
{ {
using Perspex.Styling;
public class DefaultTheme : Styles public class DefaultTheme : Styles
{ {
public DefaultTheme() public DefaultTheme()

Loading…
Cancel
Save