Пример #1
0
        private void Img_Click(object sender, EventArgs e)
        {
            var img = sender as ImgControl1;

            if (img == null)
            {
                img = (sender as PictureBox).Parent as ImgControl1;
            }

            if (PreviousSelected != null)
            {
                PreviousSelected.pbxImg.BorderStyle = BorderStyle.None;
            }
            img.pbxImg.BorderStyle = BorderStyle.FixedSingle;
            CurrentSelected        = img;
            PreviousSelected       = img;
        }
Пример #2
0
        private void InitImg(int type)
        {
            if (type == 0)
            {
                doc = yc.InforManagerNews(SelectExsitPic);
            }

            var viewstate = doc.GetElementbyId("__VIEWSTATE");

            if (viewstate != null)
            {
                str_viewstate = HttpHelper.URLEncode(viewstate.GetAttributeValue("value", ""));
            }

            var viewstategenerator = doc.GetElementbyId("__VIEWSTATEGENERATOR");

            if (viewstategenerator != null)
            {
                str_viewstategenerator = viewstategenerator.GetAttributeValue("value", "");
            }

            var eventvalidation = doc.GetElementbyId("__EVENTVALIDATION");

            if (eventvalidation != null)
            {
                str_eventvalidation = HttpHelper.URLEncode(eventvalidation.GetAttributeValue("value", ""));
            }

            var imgs = doc.GetElementbyId("alert_imgs_mng");

            if (imgs != null)
            {
                panel1.Controls.Clear();
                var imgList = imgs.SelectNodes(".//li");
                int xstep   = 143;
                int ystep   = 116;
                int xstart  = 3;
                int ystart  = 3;
                for (int i = 0; i < imgList.Count; i++)
                {
                    var thumb   = imgList[i].SelectSingleNode(".//img").GetAttributeValue("src", "");
                    var artwork = imgList[i].SelectSingleNode(".//div/a[contains(@href, 'http')]").GetAttributeValue("href", "");
                    var id      = imgList[i].SelectSingleNode(".//div/a[contains(@href, 'java')]").GetAttributeValue("href", "").Replace("javascript:deleteWindow(", "").Replace(");", "");
                    var name    = imgList[i].SelectSingleNode(".//input[@name='hiddenclid']").GetAttributeValue("value", "");
                    int x       = xstart;
                    int y       = ystart;

                    if (i > 0)
                    {
                        x = xstart + (xstep * (i % 4));
                        y = ystart + (ystep * (i / 4));
                    }

                    var img = new ImgControl1();
                    img.Location             = new System.Drawing.Point(x, y);
                    img.Name                 = string.Format("img{0}", i);
                    img.Tag                  = name;
                    img.Size                 = new System.Drawing.Size(122, 98);
                    img.pbxImg.ImageLocation = thumb;
                    img.lblFocusImg.Tag      = artwork;
                    img.lblDel.Tag           = id;
                    img.Click               += Img_Click;
                    img.pbxImg.Click        += Img_Click;
                    img.lblDel.Click        += LblDel_Click;
                    panel1.Controls.Add(img);
                }

                if (type == 0)
                {
                    int count = 0;
                    if (!doc.DocumentNode.OuterHtml.Contains("此分类下没有图片"))
                    {
                        var pager = doc.GetElementbyId("pager1");
                        if (pager != null)
                        {
                            var pagerLinks  = pager.SelectNodes(".//a");
                            var recordCount = pagerLinks[pagerLinks.Count - 1].GetAttributeValue("href", "").Replace("javascript:__doPostBack('pager1','", "").Replace("'", "").Replace(")", "");
                            count = Convert.ToInt32(recordCount) * 8;
                        }
                    }
                    ucPager.RecordCount = count;
                    ucPager.PageIndex   = 1;
                    ucPager.InitPageInfo();
                    ucPager.PageChanged -= UcPager_PageChanged;
                    ucPager.PageChanged += UcPager_PageChanged;
                }
            }
        }