Browse Source

Make Activator work only in observables.

pull/4/head
Steven Kirk 12 years ago
parent
commit
f937ac642d
  1. 23
      Perspex/Styling/Activator.cs
  2. 15
      Perspex/Styling/Match.cs

23
Perspex/Styling/Activator.cs

@ -21,27 +21,22 @@ namespace Perspex.Styling
bool last = false;
public Activator(Match match)
public Activator(IEnumerable<IObservable<bool>> inputs)
{
int i = 0;
while (match != null)
foreach (IObservable<bool> input in inputs)
{
int iCaptured = i;
if (match.Observable != null)
{
this.values.Add(false);
IDisposable subscription = match.Observable.Subscribe(
x => this.Update(iCaptured, x),
x => this.Finish(iCaptured),
() => this.Finish(iCaptured));
this.subscriptions.Add(subscription);
++i;
}
this.values.Add(false);
match = match.Previous;
IDisposable subscription = input.Subscribe(
x => this.Update(iCaptured, x),
x => this.Finish(iCaptured),
() => this.Finish(iCaptured));
this.subscriptions.Add(subscription);
++i;
}
}

15
Perspex/Styling/Match.cs

@ -76,7 +76,20 @@ namespace Perspex.Styling
public Activator GetActivator()
{
return new Activator(this);
List<IObservable<bool>> inputs = new List<IObservable<bool>>();
Match match = this;
while (match != null)
{
if (match.Observable != null)
{
inputs.Add(match.Observable);
}
match = match.Previous;
}
return new Activator(inputs);
}
public override string ToString()

Loading…
Cancel
Save