private void OnSourceUpdated(object o, EventArgs args) { ThreadAssist.ProxyToMain(delegate { SourceEventHandler handler = SourceUpdated; if (handler != null) { SourceEventArgs evargs = new SourceEventArgs(); evargs.Source = o as Source; handler(evargs); } }); }
protected virtual void OnChildSourceRemoved(Source source) { source.Updated -= OnChildSourceUpdated; ThreadAssist.ProxyToMain(delegate { SourceEventHandler handler = ChildSourceRemoved; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = source; handler(args); } }); }
public void SetActiveSource(Source source, bool notify) { ThreadAssist.AssertInMainThread(); if (source == null || !source.CanActivate || active_source == source) { return; } if (active_source != null) { active_source.Deactivate(); } active_source = source; if (source.Parent != null) { source.Parent.Expanded = true; } if (!notify) { source.Activate(); return; } SourceEventHandler handler = ActiveSourceChanged; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = active_source; handler(args); } source.Activate(); }
private void OnChildSourceRemoved(SourceEventArgs args) { RemoveSource(args.Source); }
private void OnChildSourceAdded(SourceEventArgs args) { AddSource(args.Source); }
public void RemoveSource(Source source, bool recursivelyDispose) { if (source == null || !ContainsSource(source)) { return; } if (source == default_source) { default_source = null; } source.Updated -= OnSourceUpdated; source.ChildSourceAdded -= OnChildSourceAdded; source.ChildSourceRemoved -= OnChildSourceRemoved; sources.Remove(source); GroupSource associated_groupsource = FindAssociatedGroupSource(source.Order); if (!GroupSourceHasMembers(associated_groupsource)) { RemoveSource(associated_groupsource, recursivelyDispose); } foreach (Source child_source in source.Children) { RemoveSource(child_source, recursivelyDispose); } IDBusExportable exportable = source as IDBusExportable; if (exportable != null) { ServiceManager.DBusServiceManager.UnregisterObject(exportable); } if (recursivelyDispose) { IDisposable disposable = source as IDisposable; if (disposable != null) { disposable.Dispose(); } } ThreadAssist.ProxyToMain(delegate { if (source == active_source) { if (source.Parent != null && source.Parent.CanActivate) { SetActiveSource(source.Parent); } else { SetActiveSource(default_source); } } SourceEventHandler handler = SourceRemoved; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = source; handler(args); } }); }