/// <summary>Subscribe</summary> /// <returns>Handle to unsubscribe with</returns> public IDisposable Subscribe(IObserver <IOperationEvent> observer) { ObserverHandle handle = new ObserverHandle(this, observer); observers.Add(handle); return(handle); }
public void CloseObserver(ObserverDefinition definition) { ObserverHandle handle = Observers.FirstOrDefault(observerForm => Equals(observerForm.Observer.Definition, definition)); if (handle == null) { Log.Warn("Observer with {@definition} not found, cannot close", definition); return; } handle.Dispose(); Observers.Remove(handle); RefreshObserverRequests(); }
public void OpenObserver(NeuronModel neuron, Scene scene) { ObserverDefinition definition = CreateObserverDefinition(neuron); // TODO(HonzaS): Factory + injection. var observer = new CanvasObserver(definition, Conductor.ModelProvider); observer.Log = Log; var form = new ObserverForm(this, observer); form.Text = $"Neuron {neuron.Index}, region {neuron.RegionModel.Index} - '{definition.Type}'"; var handle = new ObserverHandle(observer, form, scene); Observers.Add(handle); form.Show(); RefreshObserverRequests(); }