コード例 #1
0
        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);
        }
コード例 #2
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     _isHost = false;
     StopStartupTimer();
     StopMemoryTimer();
     _spideyWindow = null;
     StartStartupTimer();
 }
コード例 #3
0
ファイル: WindowManager.cs プロジェクト: erezwanderman/nsasmo
 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);
     }
 }
コード例 #4
0
        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);
                }
            }));
        }
コード例 #5
0
ファイル: WindowManager.cs プロジェクト: erezwanderman/nsasmo
 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);
 }