#pragma warning disable 4014

        private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            if (Settings.Default.warnClose || Client.curentlyRecording.Count > 0 || Client.IsInGame)
            {
                _warn = new Warning();
                e.Cancel = true;
                _warn.Header.Content = "Quit";
                _warn.MessageText.Text = "Are You Sure You Want To Quit?";
                _warn.ReturnButton.Click += HideButtonWarning;
                _warn.ExitButton.Click += Quit;
                _warn.HideButton.Click += HideButtonWarning;
                if (Client.curentlyRecording.Count > 0)
                    _warn.MessageText.Text = "Game recorder is still running.\nIf you exit now then the replay won't be playable.\n" + _warn.MessageText.Text;
                Client.FullNotificationOverlayContainer.Content = _warn.Content;
                Client.FullNotificationOverlayContainer.Visibility = Visibility.Visible;
            }
            else
            {
                if (Client.IsLoggedIn)
                {
                    RiotCalls.PurgeFromQueues();
                    RiotCalls.Leave();
                    Client.RiotConnection.Close();
                }
                Environment.Exit(0);
            }
        }
 public void LogoutButton_Click(object sender, RoutedEventArgs e)
 {
     Settings.Default.AutoLogin = false;
     if (Client.IsLoggedIn && !string.Equals(Client.GameStatus, "championSelect", StringComparison.CurrentCultureIgnoreCase))
     {
         Client.ReturnButton.Visibility = Visibility.Hidden;
         // ReSharper disable once PossibleNullReferenceException
         (Client.MainWin as MainWindow).FullNotificationOverlayContainer.Visibility = Visibility.Hidden;
         Client.Pages.Clear();
         RiotCalls.QuitGame();
         Client.RiotConnection.Disconnected -= Client.RiotConnection_Disconnected;
         Client.RiotConnection.Close();
         Client.XmppConnection.OnError -= Client.XmppConnection_OnError;
         Client.XmppConnection.Close();
         Client.XmppConnection = null;
         Client.chatlistview.Children.Clear();
         Client.IsLoggedIn = false;
         Client.StatusContainer.Visibility = Visibility.Hidden;
         Client.Container.Margin = new Thickness(0, 0, 0, 0);
         Client.SwitchPage(new LoginPage());
         Client.ClearPage(typeof (MainPage));
     }
     else if (Settings.Default.warnClose && Client.IsInGame)
     {
         _warn = new Warning {Header = {Content = "Logout while in Game"}, MessageText = {Text = "Are You Sure You Want To Quit? This will result in a dodge."}};
         _warn.ReturnButton.Click += HideButtonWarning;
         _warn.ExitButton.Click += Quit;
         _warn.HideButton.Click += HideButtonWarning;
         _warn.ReturnButton.Content = "Return to Champ Select";
         _warn.ExitButton.Content = "Dodge game and logout";
         Client.FullNotificationOverlayContainer.Content = _warn.Content;
         Client.FullNotificationOverlayContainer.Visibility = Visibility.Visible;
     }
 }
Beispiel #3
0
#pragma warning disable 4014

        internal static void OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            Log("Message received! The type is: " + message.Body.GetType());
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                var balance = message.Body as StoreAccountBalanceNotification;
                if (balance != null)
                {
                    StoreAccountBalanceNotification newBalance = balance;
                    InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
                    LoginPacket.IpBalance = newBalance.Ip;
                    LoginPacket.RpBalance = newBalance.Rp;
                }
                else
                {
                    var gameNotification = message.Body as GameNotification;
                    if (gameNotification != null)
                    {
                        GameNotification notification = gameNotification;
                        var messageOver = new MessageOverlay { MessageTitle = { Content = notification.Type } };
                        switch (notification.Type)
                        {
                            case "PLAYER_BANNED_FROM_GAME":
                                messageOver.MessageTitle.Content = "Banned from custom game";
                                messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                                break;
                            case "PLAYER_QUIT":
                                messageOver.MessageTitle.Content = "Player quit";
                                var name = await RiotCalls.GetSummonerNames(new[] { Convert.ToDouble(notification.MessageArgument) });
                                messageOver.MessageTextBox.Text = name[0] + " quit from queue!";
                                break;
                            default:
                                messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                                messageOver.MessageTextBox.Text = System.Convert.ToString(notification.MessageArgument);
                                break;
                        }
                        OverlayContainer.Content = messageOver.Content;
                        OverlayContainer.Visibility = Visibility.Visible;
                        ClearPage(typeof(CustomGameLobbyPage));
                        if (notification.Type != "PLAYER_QUIT")
                            SwitchPage(Client.MainPage);
                    }
                    else if (message.Body is EndOfGameStats)
                    {
                        var stats = (EndOfGameStats)message.Body;
                        var EndOfGame = new EndOfGamePage(stats);
                        ClearPage(typeof(TeamQueuePage));
                        OverlayContainer.Visibility = Visibility.Visible;
                        OverlayContainer.Content = EndOfGame.Content;
                    }
                    else if (message.Body is StoreFulfillmentNotification)
                    {
                        PlayerChampions = await RiotCalls.GetAvailableChampions();
                    }
                    else if (message.Body is Inviter)
                    {
                        var stats = (Inviter)message.Body;
                        //CurrentInviter = stats;
                    }
                    else if (message.Body is InvitationRequest)
                    {
                        var stats = (InvitationRequest)message.Body;
                        if (stats.Inviter == null)
                            return;


                        if (InviteData.ContainsKey(stats.InvitationId))
                        {
                            InviteInfo x = InviteData[stats.InvitationId];
                            if (x.Inviter != null)
                                return;
                        }
                        
                        MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            var pop = new GameInvitePopup(stats)
                            {
                                HorizontalAlignment = HorizontalAlignment.Right,
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Height = 230
                            };

                            NotificationGrid.Children.Add(pop);
                        }));
                        MainWin.FlashWindow();
                    }
                    else if (message.Body is ClientLoginKickNotification)
                    {
                        var kick = (ClientLoginKickNotification)message.Body;
                        if (kick.sessionToken == null)
                            return;

                        Warning Warn = new Warning
                        {
                            Header = { Content = "Kicked from server" },
                            MessageText = { Text = "This account has been logged in from another location" }
                        };
                        Warn.backtochampselect.Click += (MainWin as MainWindow).LogoutButton_Click;
                        Warn.AcceptButton.Click += QuitClient;
                        Warn.hide.Visibility = Visibility.Hidden;
                        Warn.backtochampselect.Content = "Logout(Work in progress)";
                        Warn.AcceptButton.Content = "Quit";
                        FullNotificationOverlayContainer.Content = Warn.Content;
                        FullNotificationOverlayContainer.Visibility = Visibility.Visible;
                    }
                    else if (message.Body is SimpleDialogMessage)
                    {
                        var leagueInfo = message.Body as SimpleDialogMessage;
                        if (leagueInfo.Type == "leagues")
                        {
                            var promote = LeaguePromote.LeaguesPromote(leagueInfo.Params.ToString());
                            var messageOver = new MessageOverlay();
                            messageOver.MessageTitle.Content = "Leagues updated";
                            messageOver.MessageTextBox.Text = promote.leagueItem.PlayerOrTeamName + " have been promoted to " + promote.leagueItem.Rank;
                            var response = new SimpleDialogMessageResponse
                            {
                                Command = "ack",
                                AccountId = leagueInfo.AccountId,
                                MessageId = leagueInfo.MessageId
                            };
                            messageOver.AcceptButton.Click += (o, e) => { RiotCalls.CallPersistenceMessaging(response); };
                        }
                    }
                }
            }));
        }
 private void DodgeButton_Click(object sender, RoutedEventArgs e)
 {
     if (Settings.Default.warnClose)
     {
         Warning Warn = new Warning();
         Warn.Header.Content = "Dodge Game";
         Warn.MessageText.Text = "Are You Sure You Want To Dodge? You will still have to spend the time penalty";
         Warn.backtochampselect.Click += (o, m) =>
         {
             Client.FullNotificationOverlayContainer.Visibility = Visibility.Hidden;
         };
         Warn.AcceptButton.Click += (o, m) =>
         {
             QuitCurrentGame();
             Client.FullNotificationOverlayContainer.Visibility = Visibility.Hidden;
         };
         Warn.hide.Click += (o, m) =>
         {
             Client.FullNotificationOverlayContainer.Visibility = Visibility.Hidden;
         };
         Warn.backtochampselect.Content = "Return to Champ Select";
         Warn.AcceptButton.Content = "Dodge game";
         Client.FullNotificationOverlayContainer.Content = Warn.Content;
         Client.FullNotificationOverlayContainer.Visibility = Visibility.Visible;
     }
     else
     {
         QuitCurrentGame();
     }
 }
 private void DodgeButton_Click(object sender, RoutedEventArgs e)
 {
     //TODO - add messagebox
     Warning pop = new Warning();
     //pop.hide.Click =
     Client.PVPNet.OnMessageReceived -= ChampSelect_OnMessageReceived;
     QuitCurrentGame();
 }
        private void UpdateRegionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (UpdateRegionComboBox.SelectedValue != null)
            {
                Settings.Default.updateRegion = (string) UpdateRegionComboBox.SelectedValue;
                ClientRegionLocation(Settings.Default.updateRegion);
                Settings.Default.Save();

                var warn = new Warning();
                warn.Header.Content = "Restart";
                warn.MessageText.Text = "Please restart LegendaryClient to apply the changes!";

                warn.ReturnButton.Content = "Do not close";
                warn.ReturnButton.Click += (o, args) => Client.FullNotificationOverlayContainer.Visibility = Visibility.Hidden;

                warn.ExitButton.Content = "Close";
                warn.ExitButton.Click += (o, args) => Environment.Exit(0);

                warn.HideButton.Click += (o, args) => Client.FullNotificationOverlayContainer.Visibility = Visibility.Hidden;

                Client.FullNotificationOverlayContainer.Content = warn.Content;
                Client.FullNotificationOverlayContainer.Visibility = Visibility.Visible;
            }
        }