public SurrogateMdiChildControl(SurrogateMdiChild parent) { Contract.Requires(parent != null); this.Proxy = parent; this.stpLastPing = Stopwatch.StartNew(); }
public void NotifyClosed(SurrogateMdiChild child) { Contract.Requires(child != null); lock (syncSurrogatedChildren) { SurrogatedChildren.Remove(child); } }
public ISurrogateMdiChild CreateChild(string title, Rectangle location, bool isResizable, bool isMovable, ISurrogateMdiChildContent childContent) { lock (syncSurrogatedChildren) { var newChild = new SurrogateMdiChild(this, title, location, isResizable, isMovable, childContent); SurrogatedChildren.Add(newChild); return(newChild); } }
protected override void WndProc(ref Message m) { if (Proxy == null) { // we're already destroyed, no-op } else if (m.Msg == WM_SYSCHAR) { // for some reason, we get a deadlock when Ctrl+Spacebar is pressed with a // foreign window focused. That happens on processing of WM_SYSCHAR return; } else if (m.Msg == WM_SYSCOMMAND) { if (SC_FROM_WPARAM(m.WParam) == SC_MOVE && !Proxy.IsMovable) { // WM_SYSCOMMAND SC_MOVE == start move operation. Which we cancel by not calling DefWndProc. return; } } else if (m.Msg == WM_CLOSE) { try { this.Proxy.ChildContent.Close(); } catch (OperationCanceledException) { return; } catch (Exception ex) { Debug.WriteLine("Exception while calling cross process MDI Close handler"); Debug.WriteLine(ex); // no-op, allow the close } } else if (m.Msg == WM_DESTROY) { this.Proxy.OnDestroy(); this.Proxy = null; } else if (m.Msg == WM_EXITSIZEMOVE) { try { this.Proxy.ChildContent.SizeChanged(ClientSize); } catch (Exception ex) { Debug.WriteLine("Exception while calling cross process MDI size changed handler"); Debug.WriteLine(ex); } } else if (m.Msg == WM_ERASEBKGND && stpLastPing.Elapsed > TimeSpan.FromMilliseconds(100)) { try { this.Proxy.ChildContent.Ping(); } // Something in Framework is using SendMessage, which does not play nicely with COM catch (COMException cex) when(cex.HResult == Esatto.Win32.Com.NativeMethods.RPC_E_CANTCALLOUT_ININPUTSYNCCALL) { // no-op, we will ping next time around. } catch (Exception ex) { Debug.WriteLine("Ping failed, closing form"); Debug.WriteLine(ex); this.Visible = false; } stpLastPing.Restart(); } base.WndProc(ref m); }