コード例 #1
0
        private async void Download_Click(object sender, RoutedEventArgs e)
        {
            if (User)
            {
                PublicSummoner summoner = await RiotCalls.GetSummonerByName(Command.Text);
                if (string.IsNullOrWhiteSpace(summoner.Name))
                {
                    var overlay = new MessageOverlay
                    {
                        MessageTitle = { Content = "No Summoner Found" },
                        MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" does not exist." }
                    };
                    Client.OverlayContainer.Content = overlay.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;

                    return;
                }
                HintLabel.Content = "retrieving replay";
                HintLabel.Visibility = Visibility.Visible;
                var fadeLabelInAnimationx = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1));
                HintLabel.BeginAnimation(OpacityProperty, fadeLabelInAnimationx);
                PlatformGameLifecycleDTO n = await RiotCalls.RetrieveInProgressSpectatorGameInfo(Command.Text);
                if (n == null)
                {
                    var overlay = new MessageOverlay
                    {
                        MessageTitle = { Content = "No Game Found" },
                        MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" is not currently in game." }
                    };
                    Client.OverlayContainer.Content = overlay.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;

                    return;
                }
                if (n.GameName != null)
                {
                    string ip = n.PlayerCredentials.ObserverServerIp + ":" + n.PlayerCredentials.ObserverServerPort;
                    string key = n.PlayerCredentials.ObserverEncryptionKey;
                    var gameId = (int)n.PlayerCredentials.GameId;
                    recorder = new ReplayRecorder(ip, gameId, Client.Region.InternalName, key);
                    recorder.OnReplayRecorded += recorder_OnReplayRecorded;
                    recorder.OnGotChunk += recorder_OnGotChunk;

                    var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));
                    Command.Visibility = Visibility.Hidden;
                    Download.Visibility = Visibility.Hidden;
                    HintLabel.Visibility = Visibility.Visible;
                    HintLabel.Content = "Starting replay download";
                }
                HintLabel.Content = "That player is not in a game";
                HintLabel.Visibility = Visibility.Visible;
            }
        }
コード例 #2
0
        private void Download_Click(object sender, RoutedEventArgs e)
        {
            HintLabel.Content = "retrieving replay";
            HintLabel.Visibility = Visibility.Visible;
            var fadeLabelInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1));
            HintLabel.BeginAnimation(Label.OpacityProperty, fadeLabelInAnimation);

            string SpectatorCommand = Command.Text;
            string[] RemoveExcessInfo = SpectatorCommand.Split(new string[1] { "spectator " }, StringSplitOptions.None);

            if (RemoveExcessInfo.Length != 2)
            {
                HintLabel.Content = "invalid command";
                HintLabel.Visibility = Visibility.Visible;
                return;
            }

            string[] Info = RemoveExcessInfo[1].Replace("\"", "").Split(' ');

            if (Info.Length != 4)
            {
                HintLabel.Content = "invalid command";
                HintLabel.Visibility = Visibility.Visible;
                return;
            }

            Command.Text = "";

            int GameId = Convert.ToInt32(Info[2]);

            recorder = new ReplayRecorder(Info[0], GameId, Info[3], Info[1]);
            recorder.OnReplayRecorded += recorder_OnReplayRecorded;
            recorder.OnGotChunk += recorder_OnGotChunk;

            var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));
            Command.Visibility = Visibility.Hidden;
            Download.Visibility = Visibility.Hidden;
        }