public void SetActiveSource(Source source, bool notify) { Banshee.Base.ThreadAssist.AssertInMainThread(); if (source == null || !source.CanActivate || active_source == source) { return; } if (active_source != null) { active_source.Deactivate(); } active_source = source; if (!notify) { source.Activate(); return; } SourceEventHandler handler = ActiveSourceChanged; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = active_source; handler(args); } source.Activate(); }
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); 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(); } } Banshee.Base.ThreadAssist.ProxyToMain(delegate { if (source == active_source) { SetActiveSource(default_source); } SourceEventHandler handler = SourceRemoved; if (handler != null) { SourceEventArgs args = new SourceEventArgs(); args.Source = source; handler(args); } }); }
private void OnSourceUpdated(object o, EventArgs args) { Banshee.Base.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 StartDragAndDrop(View sourceView, View shadowView, DragData dragData, SourceEventHandler callback) { if (null == shadowView) { throw new ArgumentNullException(nameof(shadowView)); } if (null == mDragWindow) { mDragWindow = new Window("DragWindow", new Rectangle(-shadowWidth, -shadowHeight, shadowWidth, shadowHeight), true) { BackgroundColor = Color.Transparent, }; } shadowView.SetSize(shadowWidth, shadowHeight); shadowView.SetOpacity(0.9f); mDragWindow.Add(shadowView); mDragWindow.Show(); sourceEventCb = (sourceEventType) => { callback((SourceEventType)sourceEventType); }; if (!Interop.DragAndDrop.StartDragAndDrop(SwigCPtr, View.getCPtr(sourceView), Window.getCPtr(mDragWindow), dragData.MimeType, dragData.Data, new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate <Delegate>(sourceEventCb)))) { throw new InvalidOperationException("Fail to StartDragAndDrop"); } }
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); } }); }
public void StartDragAndDrop(View sourceView, View shadowView, DragData dragData, SourceEventHandler callback) { if (null == shadowView) { throw new ArgumentNullException(nameof(shadowView)); } shadowWidth = (int)shadowView.Size.Width; shadowHeight = (int)shadowView.Size.Height; // Prevents shadowView size from being smaller than 100 pixel if (shadowView.Size.Width < 100) { shadowWidth = 100; } if (shadowView.Size.Height < 100) { shadowHeight = 100; } if (null == mDragWindow) { mDragWindow = new Window("DragWindow", new Rectangle(-shadowWidth, -shadowHeight, shadowWidth, shadowHeight), true) { BackgroundColor = Color.Transparent, }; } //Initialize Drag Window Position and Size based on Shadow View Position and Size mDragWindow.SetPosition(new Position2D((int)shadowView.Position.X, (int)shadowView.Position.Y)); mDragWindow.SetWindowSize(new Size(shadowWidth, shadowHeight)); //Make Shadow View Transparent shadowView.SetOpacity(0.9f); //Make Position 0, 0 for Moving into Drag Window shadowView.Position = new Position(0, 0); if (mShadowView) { mShadowView.Hide(); mDragWindow.Remove(mShadowView); mShadowView.Dispose(); } mShadowView = shadowView; mDragWindow.Add(mShadowView); //Update Window Directly mDragWindow.VisibiltyChangedSignalEmit(true); mDragWindow.RenderOnce(); sourceEventCb = (sourceEventType) => { if ((SourceEventType)sourceEventType == SourceEventType.Finish) { if (mShadowView) { mShadowView.Hide(); mDragWindow.Remove(mShadowView); mShadowView.Dispose(); } //Update Window Directly mDragWindow.VisibiltyChangedSignalEmit(true); mDragWindow.RenderOnce(); } callback((SourceEventType)sourceEventType); }; if (!Interop.DragAndDrop.StartDragAndDrop(SwigCPtr, View.getCPtr(sourceView), Window.getCPtr(mDragWindow), dragData.MimeType, dragData.Data, new global::System.Runtime.InteropServices.HandleRef(this, Marshal.GetFunctionPointerForDelegate <Delegate>(sourceEventCb)))) { throw new InvalidOperationException("Fail to StartDragAndDrop"); } mDragWindow.Show(); }