private void Added() { LifetimeManager.Manage(Application.SetInterval(() => { var fore = r.NextDouble() < .4; var pixel = Add(new PixelControl() { CanFocus = false, Value = new ConsoleCharacter((char)r.Next((int)'a', (int)'z'), foregroundColor: fore ? ConsoleColor.Green : ConsoleColor.Black, backgroundColor: fore ? ConsoleColor.Black : (r.NextDouble() < .5 ? ConsoleColor.Green : ConsoleColor.DarkGreen)), X = r.Next(0, Width) }); LifetimeManager.Manage(Application.SetInterval(() => { if (pixel.Y < Height) { pixel.Y++; } else { this.Controls.Remove(pixel); } }, TimeSpan.FromMilliseconds(r.Next(20, 100)))); }, TimeSpan.FromMilliseconds(r.Next(10, 15)))); }
/// <summary> /// Subscribes to be notified when the given property changes and also fires an initial notification. The subscription expires when /// the given lifetime manager's lifetime ends. /// </summary> /// <param name="propertyName">The name of the property to subscribe to or ObservableObject.AnyProperty if you want to be notified of any property change.</param> /// <param name="handler">The action to call for notifications</param> /// <param name="lifetimeManager">the lifetime manager that determines when the subscription ends</param> public void SynchronizeForLifetime(string propertyName, Action handler, LifetimeManager lifetimeManager) { var sub = SynchronizeUnmanaged(propertyName, handler); lifetimeManager.Manage(sub); }
public void SubscribeForLifetime(Action handler, LifetimeManager lifetimeManager) { var sub = SubscribeUnmanaged(handler); lifetimeManager.Manage(sub); }
public void PushForLifetime(ConsoleKey key, ConsoleModifiers?modifier, Action <ConsoleKeyInfo> handler, LifetimeManager manager) { manager.Manage(PushUnmanaged(key, modifier, handler)); }
public void PushForLifetime(ConsoleKey key, ConsoleModifiers? modifier, Action<ConsoleKeyInfo> handler, LifetimeManager manager) { manager.Manage(PushUnmanaged(key, modifier, handler)); }