protected override void Cleanup() { if (m_gdkWrapperOfForm != null) { m_gdkWrapperOfForm.Reparent(m_popupWindow.GdkWindow, 0, 0); } if (m_popupWindow.GdkWindow != null) { if (_filterAdded) { m_popupWindow.GdkWindow.RemoveFilter(FilterFunc); } _filterAdded = false; m_popupWindow.GdkWindow.Destroy(); } m_parent.HandleCreated -= HandleParentCreated; m_parent.Resize -= HandleParentResize; m_parent = null; m_popupWindow.Destroy(); m_popupWindow.Dispose(); m_popupWindow = null; m_xDisplayPointer = IntPtr.Zero; base.Cleanup(); }
private void InitializeRunner() { StartGuiThread(); RunMWFThread(); while (_mwfContainer == null) { } while (!_mwfContainer.IsHandleCreated) { } // wait for the mwf handle // Hopefully by the time LoadGui is done the MWF Application.Run // will be done with whatever it's doing, because else strange things // might happen. Gtk.Application.Invoke(delegate { InitializeGTK(); }); while (_gtkContainer == null) { } while (_gtkContainer.Handle == IntPtr.Zero) { } // wait for the gtk handle bool parented = false; Gtk.Application.Invoke(delegate { Gdk.Window window = Gdk.Window.ForeignNew((uint)_mwfContainer.Handle); window.Reparent(_gtkContainer.GdkWindow, 0, 0); parented = true; }); while (!parented) { } EventHandler loadSurfaceDelegate = delegate { DesignSurface surface = new DesignSurface(); ((IServiceContainer)surface.GetService(typeof(IServiceContainer))).AddService(typeof(ITypeResolutionService), new TypeResolutionService()); surface.BeginLoad(new MDDesignerLoader(_designerFile)); if (surface.IsLoaded) { _mwfContainer.Controls.Add((Control)surface.View); _mwfContainer.Refresh(); } }; _mwfContainer.Invoke(loadSurfaceDelegate); _gtkContainer.SizeAllocated += delegate(object o, SizeAllocatedArgs args) { EventHandler resizeDelegate = delegate { _mwfContainer.Width = args.Allocation.Width; _mwfContainer.Height = args.Allocation.Height; }; _mwfContainer.Invoke(resizeDelegate); }; EventHandler resizeNow = delegate { _mwfContainer.Width = _gtkContainer.Allocation.Width; _mwfContainer.Height = _gtkContainer.Allocation.Height; }; _mwfContainer.Invoke(resizeNow); }