private void RunCustomD2(string path, D2HostPanel diabloPanel) { if (diabloWindow == null) { if (!string.IsNullOrEmpty(path) && System.IO.File.Exists(path)) { Process diabloProcess = new Process(); ProcessStartInfo info = new ProcessStartInfo(); info.FileName = path; info.Arguments = "-w"; 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 (System.Environment.OSVersion.Version.Major > 5) { diabloWindow = new D2Window(Application.OpenForms[0], diabloPanel, diabloHandle); diabloPanel.BindDiabloWindow(diabloWindow); } } } //diabloPanel.DiabloWindow.Activate(); }
public void ReleaseDiabloWindow() { if (this.d2window != null) { this.d2window.Show(); this.d2window.UnRegisterThumbnail(); this.d2window = null; } }
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; } } }
public void BindDiabloWindow(D2Window diabloWindow) { this.d2window = diabloWindow; }