コード例 #1
0
        protected void ShowVirtualMachineInfo(bool closeParentWindow)
        {
            if (this.InvokeRequired == true)
            {
                this.Invoke(new ShowVirtualMachineInfoDelegate(ShowVirtualMachineInfo), closeParentWindow);
                return;
            }

            var virtualMachineInfo = new VirtualMachineInfo();

            virtualMachineInfo.TopMost = true;
            virtualMachineInfo.ShowDialog();

            if (closeParentWindow == true)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                //this.CloseForm();
            }
        }
コード例 #2
0
ファイル: PlayControl.cs プロジェクト: AllegianceZone/Auth
        internal void LoginToLobby(LobbyType lobbyType)
        {
            //Verify the form is filled out
            if (string.IsNullOrEmpty(_loginComboBox.Text))
            {
                return;
            }

            // TODO: Figure out where the alleg exe is and send it to the launcher.

            //Create a new session
            var signal = new TaskDelegate(delegate(object input)
            {
                var parameters = input as object[];
                var status     = (CheckInStatus)parameters[0];
                var message    = parameters[1] as string;
                var alias      = parameters[2] as string;
                var ticket     = parameters[3] as string;

                int rank = 0;

                if (parameters[4] != null)
                {
                    rank = (int)parameters[4];
                }

                Regex aliasFinder = new Regex(
                    "(?<callsign>.*?)(\\(\\d+\\))?$",
                    RegexOptions.ExplicitCapture
                    | RegexOptions.CultureInvariant
                    | RegexOptions.Compiled
                    );

                var match = aliasFinder.Match(alias);
                if (match.Success == true)
                {
                    alias = match.Groups["callsign"].Value;
                }

                if (status == CheckInStatus.AccountLinked)
                {
                    if (ReloadCallsigns != null)
                    {
                        ReloadCallsigns();
                    }
                }

                if (status == CheckInStatus.Ok || status == CheckInStatus.AccountLinked)
                {
                    //Initialize check-in interval
                    CheckInTimer          = new Timer();
                    CheckInTimer.Interval = CheckInInterval;
                    CheckInTimer.Tick    += new EventHandler(CheckInTimer_Tick);
                    CheckInTimer.Start();

                    //Launch Allegiance
                    MainForm.SetStatusBar("Launching Allegiance...");

                    //Store last-used alias
                    if (!string.Equals(DataStore.LastAlias, alias))
                    {
                        DataStore.LastAlias = alias;
                        DataStore.Instance.Save();
                    }

                    if (rank <= 5)
                    {
                        alias += "(" + rank + ")";
                    }


                    AllegianceLoader.StartAllegiance(ticket, lobbyType, alias, delegate(object param)
                    {
                        var result = (bool)param;

                        if (!result)
                        {
                            Logout();

                            MainForm.SetStatusBar("Failed to launch Allegiance.");
                        }
                        else
                        {
                            //AllegianceLoader.AllegianceProcess.OnExiting
                            //  += new EventHandler(AllegianceProcess_OnExiting);

                            AllegianceLoader.AllegianceExit
                                += new EventHandler(AllegianceProcess_OnExiting);
                        }
                    });

                    SetLoggedIn(true);

                    if (DataStore.Preferences.AutoLogin)
                    {
                        MainForm.HideForm();
                    }
                }
                else
                {
                    MainForm.SetStatusBar(message);

                    if (status == CheckInStatus.VirtualMachineBlocked)
                    {
                        VirtualMachineInfo virtualMachineInfo = new VirtualMachineInfo();
                        virtualMachineInfo.ShowDialog();
                    }

                    this.Enabled = true;

                    SystemWatcher.Close();
                }
            });

            SessionNegotiator.Login(_loginComboBox.Text, lobbyType.ToString(), delegate(object input)
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(signal, input);
                }
                else
                {
                    signal(input);
                }
            });
        }