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.
/// </summary>
/// <param name="foreground">The foreground brush.</param>
/// <param name="rect">The output rectangle.</param>
/// <param name="text">The text.</param>
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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Perspex.Styling;
// -----------------------------------------------------------------------
// <copyright file="Application.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
{
using Perspex.Styling;
public class Application
{
private Styles styles;

2
Perspex/BindingExtensions.cs

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

26
Perspex/Classes.cs

@ -92,17 +92,6 @@ namespace Perspex
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()
{
NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(
@ -125,7 +114,7 @@ namespace Perspex
public IEnumerator<string> GetEnumerator()
{
return inner.GetEnumerator();
return this.inner.GetEnumerator();
}
public override string ToString()
@ -135,7 +124,7 @@ namespace Perspex
IEnumerator IEnumerable.GetEnumerator()
{
return inner.GetEnumerator();
return this.inner.GetEnumerator();
}
public bool Remove(string item)
@ -173,5 +162,16 @@ namespace Perspex
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;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// -----------------------------------------------------------------------
// <copyright file="Contract.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex
{
using System;
internal static class Contract
{
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;
}
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)
{
Contract.Requires<NullReferenceException>(templatedParent != null);
@ -30,14 +38,6 @@ namespace Perspex.Controls
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)
{
Contract.Requires<NullReferenceException>(control != null);

4
Perspex/Controls/ITemplatedControl.cs

@ -11,6 +11,8 @@ namespace Perspex.Controls
public interface ITemplatedControl
{
IEnumerable<IVisual> VisualChildren { get; }
/// <summary>
/// Gets an observable for a <see cref="PerspexProperty"/>.
/// </summary>
@ -18,7 +20,5 @@ namespace Perspex.Controls
/// <param name="property">The property to get the observable for.</param>
/// <returns>The observable.</returns>
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)
{
this.childrenCollection.CollectionChanged -= this.CollectionChanged;
this.Remove(inner.ToList());
this.Remove(this.inner.ToList());
this.childrenCollection = childrenCollection;
this.Add(childrenCollection);
childrenCollection.CollectionChanged += this.CollectionChanged;

2
Perspex/Input/InputManager.cs

@ -13,7 +13,7 @@ namespace Perspex.Input
public class InputManager : IInputManager
{
List<Control> pointerOvers = new List<Control>();
private List<Control> pointerOvers = new List<Control>();
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.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
public class PerspexList<T> : ObservableCollection<T>
{

32
Perspex/PerspexObject.cs

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

18
Perspex/PriorityValue.cs

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

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>
// -----------------------------------------------------------------------

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

26
Perspex/Themes/Default/ButtonStyle.cs

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

Loading…
Cancel
Save