Example #1
0
        private void frmOriginalImg_Load(object sender, EventArgs e)
        {
            //this.pic_Loading.ImageLocation = "Skin\\SysImg\\loading.gif";

            if (_thumbnailID != 0)
            {
                pic_Loading.Visible = true;

                //dlService.GetOriginalImageByThumbnailAsync(_thumbnailID);
                //dlService.GetOriginalImageByThumbnailCompleted += new Entity.CarWebService.GetOriginalImageByThumbnailCompletedEventHandler(dlService_GetOriginalImageByThumbnailCompleted);

                IUploadService us      = FactoryService.CreateInstance();
                byte[]         imgByte = us.GetOriginalImage(_thumbnailID);
                if (imgByte != null)
                {
                    Stream s    = new MemoryStream(imgByte);
                    Image  _pic = Image.FromStream(s);
                    pictureBox1.Image = _pic;


                    this.Width  = _pic.Width;
                    this.Height = _pic.Height;

                    if (_pic.Width > 800 && _pic.Height > 600)
                    {
                        this.Width  = 800;
                        this.Height = 600;
                    }

                    pic_Loading.Visible = false;
                }
            }
        }
Example #2
0
        private void btn_Download_Click(object sender, EventArgs e)
        {
            try
            {
                folderBrowserDialog1.ShowDialog();
                if (Directory.Exists(folderBrowserDialog1.SelectedPath))
                {
                    IUploadService us = FactoryService.CreateInstance();

                    List <int> imgList = new List <int>();
                    foreach (Control cmain in panel1.Controls)
                    {
                        if (cmain is Panel)
                        {
                            bool needOutPut = false;
                            foreach (Control c in cmain.Controls)
                            {
                                if (c is CheckBox && ((CheckBox)c).Checked)
                                {
                                    needOutPut = true;
                                    break;
                                }
                            }
                            if (needOutPut)
                            {
                                foreach (Control c in cmain.Controls)
                                {
                                    if (c is PictureBox)
                                    {
                                        PictureBox pic = (PictureBox)c;
                                        if (pic.Image != null)
                                        {
                                            int picID = Convert.ToInt32(pic.Tag);

                                            byte[] BytImg = us.GetOriginalImage(picID);
                                            //byte[] BytImg = dlService.GetOriginalImageByThumbnail(picID);
                                            if (BytImg != null)
                                            {
                                                Stream s   = new MemoryStream(BytImg);
                                                Image  img = Image.FromStream(s);
                                                img.Save(folderBrowserDialog1.SelectedPath + "\\" + _carID + "_" + picID + ".jpg");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                MessageBox.Show("导出完成");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            List <int> imgList = new List <int>();

            foreach (Control cmain in panel1.Controls)
            {
                if (cmain is Panel)
                {
                    bool isChecked = false;
                    foreach (Control c in cmain.Controls)
                    {
                        if (c is CheckBox && ((CheckBox)c).Checked)
                        {
                            isChecked = true;
                            break;
                        }
                    }
                    if (isChecked)
                    {
                        foreach (Control c in cmain.Controls)
                        {
                            if (c is PictureBox)
                            {
                                PictureBox pic = (PictureBox)c;
                                if (pic.Image != null)
                                {
                                    int id = Convert.ToInt32(pic.Tag);
                                    imgList.Add(id);
                                }
                            }
                        }
                    }
                }
            }
            if (imgList.Count > 0)
            {
                IUploadService us         = FactoryService.CreateInstance();
                int            _failCount = us.DeleteImage(imgList.ToArray());
                //int _failCount = dlService.RemoveImgsByThumbnail(imgList.ToArray());
                if (_failCount > 0)
                {
                    MessageBox.Show("删除完成,失败'" + _failCount + "'张");
                }
                else
                {
                    MessageBox.Show("删除完成");
                }
                LoadService();
            }
        }
Example #4
0
        private void LoadService()
        {
            foreach (Control cmain in panel1.Controls)
            {
                if (cmain is Panel)
                {
                    foreach (Control c in cmain.Controls)
                    {
                        if (c is PictureBox && ((PictureBox)c).Image != null)
                        {
                            ((PictureBox)c).Image = null;
                            ((PictureBox)c).Tag   = null;
                        }
                        if (c is CheckBox)
                        {
                            ((CheckBox)c).Checked = false;
                        }
                        c.Refresh();
                    }
                }
            }

            imgList = null;

            //dlService.GetAttachmentByBatchIDAsync(_batchID, _carID);
            //dlService.GetAttachmentByBatchIDCompleted += new Entity.CarWebService.GetAttachmentByBatchIDCompletedEventHandler(dlService_GetAttachmentByBatchIDCompleted);

            IUploadService us = FactoryService.CreateInstance();

            imgList = us.GetCarImages(_carID, _shopCode);
            if (imgList != null)
            {
                int            row = 0;
                List <Control> cc  = new List <Control>();
                foreach (Control cmain in panel1.Controls)
                {
                    cc.Add(cmain);
                }
                CommonService.QuickSort <Control>(cc, "TabIndex");
                foreach (Control cmain in cc)
                {
                    if (cmain is Panel)
                    {
                        if (row < imgList.Rows.Count)
                        {
                            DataRow dr = imgList.Rows[row];
                            if (DBNull.Value != dr["ThumbnailIMG"])
                            {
                                foreach (Control c in cmain.Controls)
                                {
                                    if (c is PictureBox && ((PictureBox)c).Image == null)
                                    {
                                        Stream s = new MemoryStream(Convert.FromBase64String(dr["ThumbnailIMG"].ToString()));
                                        ((PictureBox)c).Image = Image.FromStream(s);
                                        ((PictureBox)c).Tag   = dr["ID"];

                                        toolTip1.SetToolTip(c, "点击查看原图");
                                    }
                                    else if (c is CheckBox)
                                    {
                                        CheckBox cb = (CheckBox)c;
                                        cb.Text = dr["CreateTime"].ToString();
                                    }
                                }
                            }
                            row++;
                        }
                    }
                }
            }
        }