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);
         }
     });
 }
Ejemplo n.º 2
0
 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);
         }
     });
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 private void OnChildSourceRemoved(SourceEventArgs args)
 {
     RemoveSource(args.Source);
 }
Ejemplo n.º 5
0
 private void OnChildSourceAdded(SourceEventArgs args)
 {
     AddSource(args.Source);
 }
Ejemplo n.º 6
0
        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);
                }
            });
        }