Exemple #1
0
 private void SetPageing(MovieSearchRslt aMsr)
 {
     if (aMsr.total < 1)
     {
         this.ucPaging.Visible = false;
     }
     else
     {
         this.ucPaging.Visible = true;
         this.ucPaging.Setting(aMsr.total);
     }
 }
Exemple #2
0
        private void CreateSearchRsltCtrl(MovieSearchRslt aMsr)
        {
            if (aMsr != null)
            {
                this.SetSearchRsltInfo(aMsr.start, aMsr.display, aMsr.total);

                foreach (MovieItem itm in aMsr.items)
                {
                    MovieControl mc = new MovieControl();

                    mc.Width = this.flpSearchRslt.Width - 25;
                    mc.SetValue(itm);

                    this.flpSearchRslt.Controls.Add(mc);
                }
            }
        }
Exemple #3
0
        public void Search(bool aNewSearchState)
        {
            if (!this.CheckBeforeSearch())
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                this.ClearSearchBefore(aNewSearchState);

                string subUrl = string.Format("query={0}&display=10&start={1}", this.tbxMovieTitle.Text, (this.ucPaging.CurPage.Equals(1) ? 1 : ((this.ucPaging.CurPage - 1) * 10) + 1));
                string url    = "https://openapi.naver.com/v1/search/movie.json?" + subUrl;
                string text   = string.Empty;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Headers.Add("X-Naver-Client-Id", Definition.ConstValue.ConstValue.NaverClintInfo.ID);
                request.Headers.Add("X-Naver-Client-Secret", Definition.ConstValue.ConstValue.NaverClintInfo.PASS);

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    string status = response.StatusCode.ToString();

                    if (status == "OK")
                    {
                        using (Stream stream = response.GetResponseStream())
                        {
                            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                            {
                                text = reader.ReadToEnd();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("에러 발생! {0}", status), "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                MovieSearchRslt msr = Newtonsoft.Json.JsonConvert.DeserializeObject <MovieSearchRslt>(text);

                if (msr.total < 1)
                {
                    MessageBox.Show("검색결과가 존재하지 않습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                this.CreateSearchRsltCtrl(msr);
                this.SetPageing(msr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }