Пример #1
0
        /// <summary>
        /// 加入到图片队列
        /// </summary>
        public void PushImages(Image img, string imgPath, string imgType)
        {
            var detailW = this.detailPic.Size.Width;
            var detailH = this.detailPic.Size.Height;
            //构建Pic容器
            var x       = 90;
            var y       = 3;
            var marginY = 170;
            var tag     = 0;
            //获取最后一个Pic
            var lastPic = this.PicList.LastOrDefault();

            if (lastPic != null)
            {
                x   = lastPic.Location.X;
                y   = lastPic.Location.Y + marginY;
                tag = Convert.ToInt16(lastPic.Tag) + 1;
            }
            PictureBox pic = new PictureBox();

            pic.Location = new System.Drawing.Point(x, y);
            pic.Name     = "pic" + tag;
            pic.Tag      = tag;
            pic.Size     = new System.Drawing.Size(width, height);
            pic.TabIndex = 0;
            pic.TabStop  = false;
            pic.Cursor   = Cursors.Hand;
            pic.Click   += picPicBox_Click;
            pic.Paint   += picPicBox_Paint;
            var imgParam = new ImageEditParam
            {
                YuanImg       = img,
                SuoImg        = ImageUtil.CreateThumbnailImage(img, width, height),
                DetailImg     = ImageUtil.CreateThumbnailImage(img, detailW, detailH),
                ImagePath     = imgPath,
                ImageType     = imgType,
                ScreenshotImg = img
            };

            pic.Image = imgParam.SuoImg;
            this.PicList.Add(pic);
            this.Images.Add(imgParam);
            //添加缩略图
            if (this.picPanel.InvokeRequired)
            {
                ThreadMethood t = () => {
                    this.picPanel.Controls.Add(pic);
                };
                this.picPanel.Invoke(t);
                this.SetDetailImg();
            }
            else
            {
                this.picPanel.Controls.Add(pic);
                this.SetDetailImg();
            }
        }
Пример #2
0
 /// <summary>
 /// 加载尺寸按钮
 /// </summary>
 private async void LoadSizeBtn()
 {
     await Task.Run(() => {
         int maxCount    = 7;
         int y           = 25;
         int x           = 30;
         int rightY      = 21;
         ThreadMethood t = () => {
             var btnList   = new List <Button>();
             var backColor = System.Drawing.Color.Teal;
             var font      = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             var foreColor = System.Drawing.Color.White;
             var tabIndex  = 0;
             var useVisualStyleBackColor = false;
             var cursor  = Cursors.Hand;
             int width   = 120;
             int height  = 70;
             int marginY = 110;
             int marginX = 40;
             //先竖后横
             for (int i = 0; i < maxCount; i++)
             {
                 Button btn    = new Button();
                 btn.BackColor = backColor;
                 btn.Font      = font;
                 btn.ForeColor = foreColor;
                 btn.Location  = new System.Drawing.Point(x, y);
                 btn.Name      = "sizeBtn" + i;
                 btn.Size      = new System.Drawing.Size(width, height);
                 btn.TabIndex  = tabIndex;
                 btn.Cursor    = cursor;
                 btn.Tag       = "PrintSize";
                 if (i < 4)
                 {
                     btn.Text = $"{i + 1}寸";
                 }
                 else
                 {
                     btn.Text = $"{i + 2}寸";
                 }
                 btn.UseVisualStyleBackColor = useVisualStyleBackColor;
                 btn.Click += sizeBtn_Click;
                 btnList.Add(btn);
                 //前四个 画两列
                 if (i != 4 && i != 6)
                 {
                     Button btnRight    = new Button();
                     btnRight.BackColor = backColor;
                     btnRight.Font      = font;
                     btnRight.ForeColor = foreColor;
                     btnRight.Cursor    = cursor;
                     if (i == 3)
                     {
                         btnRight.Size = new System.Drawing.Size(width, height * 2 + 30);
                     }
                     else if (i == 5)
                     {
                         btnRight.Size = new System.Drawing.Size(width, height * 2 + 30);
                     }
                     else
                     {
                         btnRight.Size = new System.Drawing.Size(width, height);
                     }
                     btnRight.Location = new System.Drawing.Point(x + width + marginX, y);
                     btnRight.Name     = "sizeBtn_Right";
                     btnRight.TabIndex = tabIndex;
                     if (i == 0)
                     {
                         btnRight.Text = "10寸";
                         btnRight.Tag  = "PrintSize";
                     }
                     else if (i == 1)
                     {
                         btnRight.Text = "A3";
                         btnRight.Tag  = "PaperSize";
                     }
                     else if (i == 2)
                     {
                         btnRight.Text = "A4";
                         btnRight.Tag  = "PaperSize";
                     }
                     else if (i == 3)
                     {
                         btnRight.Text = "自定义尺寸";
                         btnRight.Tag  = "PrintSizeSet";
                     }
                     else if (i == 5)
                     {
                         btnRight.Text = "自定义大小";
                         btnRight.Tag  = "PaperSizeSet";
                     }
                     btnRight.UseVisualStyleBackColor = useVisualStyleBackColor;
                     btnRight.Click += sizeBtn_Click;
                     btnList.Add(btnRight);
                 }
                 y += marginY;
             }
             this.SizeList = btnList;
             this.btnPanel.Controls.AddRange(btnList.ToArray());
         };
         if (this.btnPanel.InvokeRequired)
         {
             this.btnPanel.Invoke(t);
         }
         else
         {
             t();
         }
     });
 }
Пример #3
0
        /// <summary>
        /// 加载尺寸按钮(读配置)
        /// </summary>
        private async void LoadSizeBtnbyJson()
        {
            var btndetails = ConfigUtil.FormConfig.ButtonDeatils;

            if (btndetails == null || btndetails.Count == 0)
            {
                return;
            }
            await Task.Run(() => {
                ThreadMethood t = () => {
                    var btnList   = new List <Button>();
                    var backColor = System.Drawing.Color.Black;
                    var font      = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                    var foreColor = System.Drawing.Color.White;
                    var tabIndex  = 0;
                    var useVisualStyleBackColor = false;
                    var cursor   = Cursors.Hand;
                    var startBtn = btndetails.Find(j => j.IsStartPosition);
                    int startx   = startBtn.X != null ? (int)startBtn.X : 120;
                    int starty   = startBtn.Y != null ? (int)startBtn.Y : 70;
                    int x        = startx;
                    int y        = starty;
                    for (int i = 0; i < btndetails.Count; i++)
                    {
                        var btndetail = btndetails[i];
                        int width     = btndetail.Width != null ? (int)btndetail.Width : 70;
                        int height    = btndetail.Height != null ? (int)btndetail.Height : 50;
                        Button btn    = new Button();
                        btn.BackColor = backColor;
                        btn.Font      = font;
                        btn.ForeColor = foreColor;
                        btn.TabIndex  = tabIndex;
                        btn.Cursor    = cursor;
                        btn.UseVisualStyleBackColor = useVisualStyleBackColor;
                        btn.Click   += sizeBtn_Click;
                        btn.Name     = "sizeBtn" + i;
                        btn.Text     = btndetail.Text;
                        btn.Size     = new System.Drawing.Size(width, height);
                        btn.Location = new System.Drawing.Point(x, y);
                        var btnType  = btndetail.BtnType;
                        if (btnType == "PrintSize")
                        {
                            btn.Tag = "PrintSize";
                        }
                        else if (btnType == "PaperSize")
                        {
                            btn.Tag = "PaperSize";
                        }
                        else if (btnType == "PrintSizeSet")
                        {
                            btn.Tag = "PrintSizeSet";
                        }
                        else if (btnType == "PaperSizeSet")
                        {
                            btn.Tag = "PaperSizeSet";
                        }
                        if (btndetail.IsLast)
                        {
                            y  = starty;
                            x += width + (int)btndetail.MarginX;
                        }
                        else
                        {
                            y += height + (int)btndetail.MarginY;
                        }
                        btnList.Add(btn);
                    }
                    this.SizeList = btnList;
                    this.btnPanel.Controls.AddRange(btnList.ToArray());
                };
                if (this.btnPanel.InvokeRequired)
                {
                    this.btnPanel.Invoke(t);
                }
                else
                {
                    t();
                }
            });
        }
Пример #4
0
        /// <summary>
        /// 加入到图片队列
        /// </summary>
        public void PushImages(Image img, string imgPath, string imgType, ResoponseResult resoponse = null)
        {
            if (resoponse != null)
            {
                resoponse.Count++;
                resoponse.Code    = "ok";
                resoponse.Message = $"上传{resoponse.Count}张图片成功!";
            }
            var detailW = this.detailPic.Size.Width;
            var detailH = this.detailPic.Size.Height;
            var width   = 150;
            var height  = 150;
            //构建Pic容器
            var x   = 20;
            var y   = 0;
            var tag = 0;
            //获取最后一个Pic
            var lastPic = this.PicList.LastOrDefault();

            if (lastPic != null)
            {
                x   = lastPic.Location.X + 170;
                y   = lastPic.Location.Y;
                tag = Convert.ToInt16(lastPic.Tag) + 1;
            }
            PictureBox pic = new PictureBox();

            pic.Location = new System.Drawing.Point(x, y);
            pic.Name     = "pic" + tag;
            pic.Tag      = tag;
            pic.Size     = new System.Drawing.Size(width, height);
            pic.TabIndex = 0;
            pic.TabStop  = false;
            pic.Cursor   = Cursors.Hand;
            pic.Click   += picPicBox_Click;
            pic.Paint   += picPicBox_Paint;
            var imgParam = new ImageParamEdit
            {
                YuanImg   = img,
                SuoImg    = ImageUtil.CreateThumbnailImage(img, width, height),
                DetailImg = ImageUtil.CreateThumbnailImage(img, detailW, detailH),
                IsUpImg   = true,
                ImagePath = imgPath,
                ImageType = imgType
            };

            pic.Image = imgParam.SuoImg;
            this.PicList.Add(pic);
            this.Images.Add(imgParam);
            //添加缩略图
            if (this.picPanel.InvokeRequired)
            {
                ThreadMethood t = () => {
                    this.picPanel.Controls.Add(pic);
                    this.SetDetailImg();
                };
                this.picPanel.Invoke(t);
            }
            else
            {
                this.picPanel.Controls.Add(pic);
                this.SetDetailImg();
            }
        }