コード例 #1
0
        public bool Join(string webServiceUrl, string userName, string sessionKey, out string message)
        {
            SessionId = sessionKey;
            _seWs     = new SeNetworkService(webServiceUrl);
            Users     = new List <SeNetworkService.SeUser>();
            var joinRequest = new SeNetworkService.JoinRequest()
            {
                SessionId = sessionKey,
                UserName  = userName
            };
            var joinResponse = _seWs.Join(joinRequest);

            message = joinResponse.Message;
            if (joinResponse.Message != "OK")
            {
                return(false);
            }

            Subtitle = new Subtitle();
            var getSubtitleRequest = new SeNetworkService.GetSubtitleRequest
            {
                SessionId = sessionKey
            };
            var getSubtitleResponse = _seWs.GetSubtitle(getSubtitleRequest);

            foreach (var sequence in getSubtitleResponse.Subtitle)
            {
                Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
            }

            _fileName = getSubtitleResponse.FileName;

            OriginalSubtitle = new Subtitle();
            var getOriginalSubtitleRequest = new SeNetworkService.GetOriginalSubtitleRequest
            {
                SessionId = sessionKey
            };
            var getOriginalSubtitleResponse = _seWs.GetOriginalSubtitle(getOriginalSubtitleRequest);

            if (getOriginalSubtitleResponse.Subtitle != null)
            {
                foreach (var sequence in getOriginalSubtitleResponse.Subtitle)
                {
                    OriginalSubtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
                }
            }

            SessionId   = sessionKey;
            CurrentUser = joinResponse.Users.Last();
            foreach (var user in joinResponse.Users)
            {
                Users.Add(user);
            }

            ReloadFromWs();
            _timerWebService.Start();
            return(true);
        }
コード例 #2
0
        public Subtitle ReloadSubtitle()
        {
            Subtitle.Paragraphs.Clear();
            var request = new SeNetworkService.GetSubtitleRequest
            {
                SessionId = SessionId,
            };
            var response = _seWs.GetSubtitle(request);

            _fileName       = response.FileName;
            _seWsLastUpdate = response.UpdateTime;
            if (response.Subtitle != null)
            {
                foreach (var sequence in response.Subtitle)
                {
                    Subtitle.Paragraphs.Add(new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds));
                }
            }
            return(Subtitle);
        }
コード例 #3
0
        private void ReloadFromWs()
        {
            if (_seWs == null)
            {
                return;
            }

            Subtitle = new Subtitle();
            var request = new SeNetworkService.GetSubtitleRequest
            {
                SessionId = SessionId,
            };
            var response = _seWs.GetSubtitle(request);

            _fileName       = response.FileName;
            _seWsLastUpdate = response.UpdateTime;
            foreach (var sequence in response.Subtitle)
            {
                var p = new Paragraph(WebUtility.HtmlDecode(sequence.Text).Replace("<br />", Environment.NewLine), sequence.StartMilliseconds, sequence.EndMilliseconds);
                Subtitle.Paragraphs.Add(p);
            }
            Subtitle.Renumber();
            LastSubtitle = new Subtitle(Subtitle);
        }