예제 #1
0
 public void Deactivate()
 {
     if (diabloWindow != null)
     {
         diabloWindow.Deactivate();
     }
 }
예제 #2
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);
                }
            }
        }