예제 #1
0
        void diabloProcess_Exited(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                try
                {
                    this.Invoke(new ProcessExitedDelegate(diabloProcess_Exited), sender, e);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                diabloPanel.ReleaseDiabloWindow();

                if (diabloWindow != null)
                {
                    diabloWindow.Close();
                    diabloWindow = null;
                }

                //ConsoleTab.WriteLine("Closed " + ((Process)sender).StartInfo.FileName);
            }
        }
 public void ReleaseDiabloWindow()
 {
     if (this.diabloWindow != null)
     {
         this.diabloWindow.Show();
         this.diabloWindow.UnRegisterThumbnail();
         this.diabloWindow = null;
     }
 }
예제 #3
0
        public void LoadDiablo2()
        {
            if (diabloWindow == null)
            {
                if (!string.IsNullOrEmpty(exePath) && System.IO.File.Exists(exePath))
                {
                    Process          diabloProcess = new Process();
                    ProcessStartInfo info          = new ProcessStartInfo();
                    info.FileName = exePath;
                    if (((CheckBox)this.Controls[2]).Checked)
                    {
                        info.Arguments = "-w -sndbkg";
                    }
                    else
                    {
                        info.Arguments = "-w -ns";
                    }


                    diabloProcess = Process.Start(info);
                    diabloProcess.EnableRaisingEvents = true;
                    diabloProcess.Exited += new EventHandler(diabloProcess_Exited);

                    // Wait for the app to load
                    diabloProcess.WaitForInputIdle();

                    diabloHandle = diabloProcess.MainWindowHandle;

                    // If greater than Windows XP
                    if (Environment.OSVersion.Version.Major > 5)
                    {
                        diabloWindow = new DiabloWindow(Application.OpenForms[0], diabloPanel, diabloHandle, Text);
                        diabloPanel.BindDiabloWindow(diabloWindow);

                        if (((TabControl)this.Parent).SelectedTab == this)
                        {
                            diabloWindow.Activate();
                        }
                        else
                        {
                            diabloWindow.Deactivate();
                        }
                    }
                }
                else
                {
                    //ConsoleTab.WriteLine("Could not find diablo 2 game.exe " + exePath);
                }
            }
        }
 public void BindDiabloWindow(DiabloWindow diabloWindow)
 {
     this.diabloWindow = diabloWindow;
 }