Beispiel #1
0
        private void GetData()
        {
            if (string.IsNullOrWhiteSpace(username))
            {
                return;
            }

            var currentStreams = api.Streams(username);

            if (!currentStreams.HasError)
            {
                var streamsbuffer = new ObservableCollection <LiveStreamViewModel>();

                foreach (var stream in currentStreams.Data.Streams)
                {
                    var temp = new LiveStreamViewModel()
                    {
                        Logo            = stream.Channel.Logo,
                        DisplayName     = stream.Channel.DisplayName,
                        Preview         = stream.Preview.Small,
                        LiveUrl         = stream.Channel.Url,
                        GameName        = stream.Game,
                        PreviewLarge    = stream.Preview.Large,
                        GameLogo        = stream.Preview.Medium,
                        PreviewTemplate = StreamPreviewTemplateUrl.Convert(stream.Preview.Template),
                        ViewerCount     = stream.Viewers,
                    };

                    streamsbuffer.Add(temp);
                }
                StreamViewModel.LiveStreams = new ObservableCollection <LiveStreamViewModel>(streamsbuffer.OrderBy(o => o.ViewerCount));
                StreamViewModel.RaisePropertyChangedOn(() => StreamViewModel.LiveStreams);
            }
        }