Exemple #1
0
        public void Activate()
        {
            foreach (TabPage tab in ((TabControl)this.Parent).TabPages)
            {
                if (tab is DiabloTab)
                {
                    // Look through the current panels to see if we have added it already.
                    DiabloHostPanel existingPanel = null;

                    foreach (DiabloHostPanel panel in this.flowPanel.Controls)
                    {
                        if (((DiabloTab)tab).DiabloWindow == panel.DiabloWindow)
                        {
                            existingPanel = panel;
                            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 = Convert.ToInt32(400m * BlueVex2.Properties.Settings.Default.ResolutionScale);
                            existingPanel.Height = Convert.ToInt32(300m * BlueVex2.Properties.Settings.Default.ResolutionScale);
                            existingPanel.Location = new Point(10, 10);
                            this.flowPanel.Controls.Add(existingPanel);
                            existingPanel.BindDiabloWindow(((DiabloTab)tab).DiabloWindow);
                            existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                            existingPanel.DiabloWindow.Activate();
                        }
                    }
                }
            }

            // Remove any inactive panels
            for (int i = this.flowPanel.Controls.Count; i > 0; i--)
            {
                DiabloHostPanel panel = this.flowPanel.Controls[i - 1] as DiabloHostPanel;
                if (panel != null)
                {
                    if (panel.DiabloWindow == null || panel.DiabloWindow.Disposed)
                    {
                        this.flowPanel.Controls.Remove(panel);
                    }
                }
            }
        }
        public void Activate()
        {
            foreach (TabPage tab in ((TabControl)this.Parent).TabPages)
            {
                if (tab is DiabloTab)
                {
                    // Look through the current panels to see if we have added it already.
                    DiabloHostPanel existingPanel = null;

                    foreach (DiabloHostPanel panel in this.flowPanel.Controls)
                    {
                        if (((DiabloTab)tab).DiabloWindow == panel.DiabloWindow)
                        {
                            existingPanel = panel;
                            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    = Convert.ToInt32(400m * BlueVex2.Properties.Settings.Default.ResolutionScale);
                            existingPanel.Height   = Convert.ToInt32(300m * BlueVex2.Properties.Settings.Default.ResolutionScale);
                            existingPanel.Location = new Point(10, 10);
                            this.flowPanel.Controls.Add(existingPanel);
                            existingPanel.BindDiabloWindow(((DiabloTab)tab).DiabloWindow);
                            existingPanel.DiabloWindow.SetHostPanel(existingPanel);
                            existingPanel.DiabloWindow.Activate();
                        }
                    }
                }
            }

            // Remove any inactive panels
            for (int i = this.flowPanel.Controls.Count; i > 0; i--)
            {
                DiabloHostPanel panel = this.flowPanel.Controls[i - 1] as DiabloHostPanel;
                if (panel != null)
                {
                    if (panel.DiabloWindow == null || panel.DiabloWindow.Disposed)
                    {
                        this.flowPanel.Controls.Remove(panel);
                    }
                }
            }
        }
Exemple #3
0
        public void LoadDiablo2(int loginDelay)
        {
            if (diabloWindow == null)
            {
                if (!string.IsNullOrEmpty(exePath) && System.IO.File.Exists(exePath))
                {
                    Process          diabloProcess = new Process();
                    ProcessStartInfo info          = new ProcessStartInfo();
                    info.FileName  = exePath;
                    info.Arguments = "-w -ns";

                    // Crap Fett007 added to bring master variable
                    string username = string.Empty;
                    string password = string.Empty;
                    string charslot = string.Empty;
                    string master   = string.Empty;

                    foreach (string accountString in BlueVex2.Properties.Settings.Default.Accounts)
                    {
                        if (accountString.StartsWith(defaultAccount + ","))
                        {
                            string[] parts = accountString.Split(',');
                            username = parts[0];
                            password = parts[1];
                            charslot = parts[2];
                            master   = parts[3];
                        }
                    }


                    switch (master)
                    {
                    case "True":
                        info.Arguments = "-w -sndbkg";
                        break;

                    case "False":
                        info.Arguments = "-w -ns";
                        break;
                    }

                    ConsoleTab.WriteLine("Loading " + exePath);

                    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 DiabloWindow(Application.OpenForms[0], diabloPanel, diabloHandle, this.Text);
                        diabloPanel.BindDiabloWindow(diabloWindow);

                        if (((TabControl)this.Parent).SelectedTab == this)
                        {
                            diabloWindow.Activate();
                        }
                        else
                        {
                            diabloWindow.Deactivate();
                        }
                    }
                    if (BlueVex2.Properties.Settings.Default.UseBV2AutoLogin)
                    {
                        ((IDiabloWindow)diabloWindow).LoginToBattleNet(this.defaultAccount);
                    }
                }
                else
                {
                    ConsoleTab.WriteLine("Could not find diablo 2 game.exe " + exePath);
                }
            }
        }