コード例 #1
0
        /// <summary>
        /// 图片打勾时触发
        /// </summary>
        private void Picture_CheckChanged(userCtrPicture ctr)
        {
            if (this.isInit)
            {
                return;
            }
            //userCtrPicture ctr = (userCtrPicture)sender;
            string FilePath = ctr.FilePath;

            if (!GetConfig.IsAddLocMap)
            {
                if (ctr.GetCheck())
                {
                    word.InsertImg(FilePath);
                }
                else
                {
                    word.DelImg(FilePath);
                }
            }
            else
            {
                if (ctr.GetCheck())
                {
                    word.InsertImgWithLocMap(FilePath, ctr.LocMapPath);
                }
                else
                {
                    word.DelImgWithLocMap(FilePath, ctr.LocMapPath);
                }
            }
        }
コード例 #2
0
ファイル: frmRptImages.cs プロジェクト: xuanximoming/PIC
        /// <summary>
        /// 删除图像
        /// </summary>
        /// <param name="DelAll">是否删除全部</param>
        public void DeleteImage(bool DelAll)
        {
            List <Control> delControl   = new List <Control>();
            List <Control> printControl = new List <Control>();
            bool           HadCheck     = false;

            if (this.p_RptImages.Controls.Count > 0)
            {
                //提示
                int delImgCount = 0;
                for (int i = 0; i < this.p_RptImages.Controls.Count; i++)
                {
                    userCtrPictureEx axf    = (userCtrPictureEx)this.p_RptImages.Controls[i];
                    ImgObj           imgobj = (ImgObj)axf.Picture.ImgObj;
                    if (axf.Picture.IsSelecting || axf.Picture.IsSelected || DelAll == true)
                    {
                        delImgCount++;
                    }
                }
                if (delImgCount > 1)
                {
                    if (DialogResult.No == MessageBoxEx.Show("已选择" + delImgCount.ToString() + "幅图片,确定删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                        return;
                    }
                }
                //提示
                for (int i = 0; i < this.p_RptImages.Controls.Count; i++)
                {
                    try
                    {
                        userCtrPictureEx axf    = (userCtrPictureEx)this.p_RptImages.Controls[i];
                        ImgObj           imgobj = (ImgObj)axf.Picture.ImgObj;
                        if (axf.Picture.IsSelecting || axf.Picture.IsSelected || DelAll == true)
                        {
                            if (!axf.Picture.GetCheck())
                            {
                                imgobj.IsDeleted = true;
                                delControl.Add(axf);
                                if (!this.arrayImgDel.Contains(imgobj))
                                {
                                    this.arrayImgDel.Add(imgobj);
                                }
                                this.arrayImg.RemoveAt(i);
                            }
                            else
                            {
                                printControl.Add(axf);
                                HadCheck = true;
                            }
                        }
                    }
                    catch { }
                }
            }
            for (int i = 0; i < delControl.Count; i++)
            {
                this.p_RptImages.Controls.Remove(delControl[i]);
            }
            if (HadCheck)
            {
                if (DialogResult.Yes == MessageBoxEx.Show("选择图像包含打印图像,是否删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                {
                    for (int i = 0; i < printControl.Count; i++)
                    {
                        userCtrPicture ctr    = ((userCtrPictureEx)printControl[i]).Picture;
                        ImgObj         imgobj = (ImgObj)ctr.ImgObj;
                        imgobj.IsDeleted = true;
                        if (!this.arrayImgDel.Contains(imgobj))
                        {
                            this.arrayImgDel.Add(imgobj);
                        }
                        this.arrayImg.Remove(imgobj);
                        if (ctr.LocMapPath == "")
                        {
                            word.DelImg(ctr.FilePath);
                        }
                        else
                        {
                            word.DelImgWithLocMap(ctr.FilePath, ctr.LocMapPath);
                        }
                        this.p_RptImages.Controls.Remove(printControl[i]);
                    }
                }
            }
            this.l_Count.Text = "共 " + this.p_RptImages.Controls.Count.ToString() + " 张";
        }