예제 #1
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);
                }
            }
        }
예제 #2
0
        private void UpdateFlows()
        {
            if (this.tabControl1.SelectedTab is DiabloTab)
            {
                ((DiabloTab)this.tabControl1.SelectedTab).Activate();
            }
            else // main tab
            {
                foreach (TabPage tab in tabControl1.TabPages)
                {
                    if (dhpActiveMain.DiabloWindow != null && tab.Text == dhpActiveMain.DiabloWindow.Text)
                    {
                    }
                    else if (tab is DiabloTab)
                    {
                        // Look through the current panels to see if we have added it already.
                        DiabloHostPanel existingPanel = null;

                        foreach (Panel panel in flpDiabloWindows.Controls)
                        {
                            if (panel.Controls.Count > 0 && ((DiabloTab)tab).DiabloWindow == ((DiabloHostPanel)panel.Controls[0]).DiabloWindow)
                            {
                                existingPanel = (DiabloHostPanel)panel.Controls[0];
                                break;
                            }
                        }

                        // If we have, activate it.
                        if (existingPanel != null)
                        {
                            existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                            existingPanel.DiabloWindow.Activate();
                        }
                        // If we havnt, Add it.
                        else
                        {
                            if (((DiabloTab)tab).DiabloWindow != null)
                            {
                                existingPanel          = new DiabloHostPanel();
                                existingPanel.Width    = 334; // Convert.ToInt32(400m * 1);
                                existingPanel.Height   = 250; // Convert.ToInt32(300m * 1);
                                existingPanel.Location = new Point(10, 10);
                                ((Panel)flpDiabloWindows.Controls[((DiabloTab)tab).Text]).Controls.Add(existingPanel);
                                //flpDiabloWindows.Controls.Add(existingPanel);
                                //main.Controls.Add(existingPanel); // here
                                existingPanel.BindDiabloWindow(((DiabloTab)tab).DiabloWindow);
                                existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                                existingPanel.DiabloWindow.Activate();
                            }
                        }
                    }
                }

                // Remove any inactive panels
                for (int i = flpDiabloWindows.Controls.Count; i > 0; i--)
                {
                    if (((Panel)flpDiabloWindows.Controls[i - 1]).Controls.Count > 0)
                    {
                        DiabloHostPanel panel = ((Panel)flpDiabloWindows.Controls[i - 1]).Controls[0] as DiabloHostPanel;
                        if (panel != null)
                        {
                            if (panel.DiabloWindow == null || panel.DiabloWindow.Disposed)
                            {
                                ((Panel)flpDiabloWindows.Controls[0]).Controls.Remove(panel);
                                //flpDiabloButtons
                            }
                        }
                    }
                }
            }
        }