protected override void OnHandleDestroyed(EventArgs e) { StopStartupTimer(); StopMemoryTimer(); _spideyWindow = null; // TODO - figure out why I can't just call .Wait() here and await inside Stop() // It seems to wait forever even though the task completes if (_udpClient != null) { _udpClient.Stop(); } if (_udpServer != null) { _udpServer.Stop(); } if (_tcpClient != null) { _tcpClient.Stop(); } if (_tcpServer != null) { _tcpServer.Stop(); } MemoryScanner.CloseDosBoxHandle(); base.OnHandleDestroyed(e); }
private void btnReset_Click(object sender, EventArgs e) { _isHost = false; StopStartupTimer(); StopMemoryTimer(); _spideyWindow = null; StartStartupTimer(); }
public static void UpdateSpideyWindow(SpideyWindow spideyWindow) { if (spideyWindow != null && spideyWindow.Handle != null && spideyWindow.Handle != IntPtr.Zero) { // Have move it off 0, 0 first otherwise it won't update MoveWindow(spideyWindow.Handle, 1, 1, spideyWindow.Width, spideyWindow.Height, true); MoveWindow(spideyWindow.Handle, 0, 0, spideyWindow.Width, spideyWindow.Height, true); } }
private void AttachToDosbox(object state) { IEnumerable <IntPtr> handles; lock (_startupTimerLock) { var timer = state as Timer; if (timer != _startupTimer || _startupTimer == null) { return; } handles = WindowManager.FindSpideyWindows(); if (handles == null || handles.Count() == 0 || handles.All(h => h == IntPtr.Zero)) { return; } StopStartupTimer(); } Invoke(new Action(() => { var chosenHandle = IntPtr.Zero; foreach (var handle in handles) { var result = MessageBox.Show("Connect to SPIDEY#" + handle.ToString() + "?", "DOSBox found", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { chosenHandle = handle; break; } } if (chosenHandle == IntPtr.Zero) { btnRescan.Enabled = true; SetLoadStatus(LoadStatus.NotStarted); return; } _spideyWindow = WindowManager.GetSpideyWindow(chosenHandle); SetLoadStatus(LoadStatus.WaitingForPlayer); lock (_startupTimerLock) { _startupTimer = new Timer(FindPlayerInMemory); _startupTimer.Change(0, 1000); } })); }
public static bool DetachSpideyWindow(SpideyWindow spideyWindow) { // Don't check if OriginalParentHandle is IntPtr.Zero as it will be if (spideyWindow != null && spideyWindow.Handle != null && spideyWindow.Handle != IntPtr.Zero && spideyWindow.OriginalParentHandle != null && spideyWindow.OriginalWindowInformation != 0) { SetParent(spideyWindow.Handle, spideyWindow.OriginalParentHandle); SetWindowLong(spideyWindow.Handle, GWL_STYLE, spideyWindow.OriginalWindowInformation); MoveWindow(spideyWindow.Handle, 0, 0, spideyWindow.Width, spideyWindow.Height, true); return(true); } return(false); }