private void dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            try
            {
                DataGridView grid = sender as DataGridView;
                if (grid == null)
                {
                    return;
                }
                System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
                                                                                  e.RowBounds.Location.Y,
                                                                                  grid.RowHeadersWidth - 4,
                                                                                  e.RowBounds.Height);

                TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                                      grid.RowHeadersDefaultCellStyle.Font,
                                      rectangle,
                                      grid.RowHeadersDefaultCellStyle.ForeColor,
                                      TextFormatFlags.VerticalCenter | TextFormatFlags.Right);

                if (grid.Columns.Count > 0)
                {
                    grid.Columns[grid.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
            }
            catch (Exception exp)
            {
                Logger.AddLog(this.GetType(), "dgv_RowPostPaint", "", exp);
            }
        }
Esempio n. 2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "JPG|*.jpg|BMP|*.bmp|JPEG|*.jpeg";
                DialogResult result = dialog.ShowDialog();
                dialog.RestoreDirectory = false;
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    txtPicPath.Text = dialog.FileName;

                    Image imgtmp = pic1.Image;
                    pic1.Image = null;
                    if (imgtmp != null)
                    {
                        imgtmp.Dispose();
                    }

                    Image imgtmp2 = pic2.Image;
                    pic2.Image = null;
                    if (imgtmp2 != null)
                    {
                        imgtmp2.Dispose();
                    }

                    pic1.Image = Image.FromFile(dialog.FileName);
                }
            }
            catch (Exception exp)
            {
                Logger.AddLog(this.GetType(), "btnSelect_Click", "", exp);
            }
        }
Esempio n. 3
0
 private VerifyResult PostImage2(string guid)
 {
     if (string.IsNullOrWhiteSpace(guid))
     {
         guid = Guid.NewGuid().ToString();
     }
     try
     {
         VerifyResult result = verProcess.VerifyImage(urlTmp, guid, imgData2);
         ImageFlag    flag   = null;
         if (result != null)
         {
             flag = result.Flags;
         }
         if (flag != null && flag.targets != null)
         {
             DrawFlag(flag);
         }
         return(result);
     }
     catch (Exception exp)
     {
         Logger.AddLog(this.GetType(), "PostImage2", "", exp);
         return(null);
     }
     finally
     {
     }
 }
Esempio n. 4
0
        private void PostImage()
        {
            try
            {
                string filePath = "";
                string url      = "";
                this.Invoke(new MethodInvoker(delegate()
                {
                    filePath           = txtPicPath.Text;
                    url                = txtUrl.Text;
                    btnExecute.Enabled = false;
                }));

                if (!File.Exists(filePath))
                {
                    return;
                }
                var          fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                byte[]       imgData  = File.ReadAllBytes(filePath);
                VerifyResult result   = verProcess.VerifyImage(txtUrl.Text, fileName, imgData);
                ImageFlag    flag     = null;
                if (result != null)
                {
                    flag = result.Flags;
                }

                if (flag != null && flag.targets != null)
                {
                    DrawFlag(flag);
                }
            }
            catch (Exception exp)
            {
                Logger.AddLog(this.GetType(), "PostImage", "", exp);
            }
            finally
            {
                this.Invoke(new MethodInvoker(delegate()
                {
                    btnExecute.Enabled = true;
                }));
            }
        }
Esempio n. 5
0
        public void StartSubThd()
        {
            try
            {
                string     guid   = Guid.NewGuid().ToString();
                SendRecord record = new SendRecord()
                {
                    SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"), GUID = guid
                };

                VerifyResult result = PostImage2(guid);

                record.CompleteTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff");
                record.RespString   = result != null ? result.AnnexData : "";
                times.Add(record);
                Interlocked.Increment(ref completeCnt);
                if (result == null)
                {
                    Interlocked.Increment(ref otherErrCnt);
                }
                else
                {
                    string respString = result.AnnexData.ToLower();
                    if (respString.Contains("targets"))
                    {
                        Interlocked.Increment(ref successCnt);
                    }
                    else if (respString.Contains("time is out"))
                    {
                        Interlocked.Increment(ref timeoutCnt);
                    }
                    else if (respString.Contains("image is invalid"))
                    {
                        Interlocked.Increment(ref errorCnt);
                    }
                    else if (respString.Contains("error"))
                    {
                        Interlocked.Increment(ref otherErrCnt);
                    }
                    else
                    {
                        Interlocked.Increment(ref unKnow);
                        Logger.AddLog(this.GetType(), "StartSubThd", respString);
                    }
                }

                if ((Interval < 100 && completeCnt % 10 == 0) || Interval >= 100 || completeCnt == total)
                {
                    this.Invoke(new MethodInvoker(delegate()
                    {
                        lbSuccessCnt.Text = successCnt.ToString();
                        lbTimeout.Text    = timeoutCnt.ToString();
                        lbErrorCnt.Text   = errorCnt.ToString();
                        lbOtherErr.Text   = otherErrCnt.ToString();
                        lbundnow.Text     = unKnow.ToString();
                        if (completeCnt == total)
                        {
                            lbHdTimes.Text  = "处理完成,共耗时:" + (DateTime.Now - dt1).TotalSeconds.ToString() + " 秒";
                            button1.Enabled = true;
                        }
                    }));
                }
            }
            catch (Exception exp)
            {
                Logger.AddLog(this.GetType(), "StartSubThd", "", exp);
            }
        }