示例#1
0
        private void tvX9_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            x9Rec rec = x9Stuff[Convert.ToInt32(e.Node.Name)];

            tvX9_AfterSelect_cur25Rec = 0;
            txtRec.Text = rec.recData;
            int iRecType = 0;

            int.TryParse(rec.recType, out iRecType);
            dgvFields.Rows.Clear();
            XmlNodeList fieldNodes = null;
            int         fieldStart = 0;
            int         fieldLen   = 0;

            fieldNodes = xmlFields.SelectNodes("records/record[@type='" + rec.recType + "']/field");
            if (fieldNodes != null)
            {
                foreach (XmlNode n in fieldNodes)
                {
                    fieldStart = System.Convert.ToInt32(n.Attributes["start"].Value) - 1;
                    fieldLen   = System.Convert.ToInt32(n.Attributes["end"].Value) - fieldStart;
                    dgvFields.Rows.Add(n.Attributes["name"].Value, rec.recData.Substring(fieldStart, fieldLen), n.Attributes["type"].Value, n.Attributes["comments"].Value);
                }
                onSetImage(null, null);
            }
            if (iRecType >= 25 && iRecType < 70 && Properties.Settings.Default.checkImage)
            {
                int    curRec   = 0;
                string frontImg = null;
                string backImg  = null;
                int.TryParse(e.Node.Name, out curRec);
                x9Rec imgRec = x9Stuff[curRec];
                while (!(imgRec.recType == "25" || imgRec.recType == "61" || curRec < 0))
                {
                    curRec -= 1;
                    imgRec  = x9Stuff[curRec];
                }
                if (curRec < 0 || curRec == tvX9_AfterSelect_cur25Rec)
                {
                    return;
                }
                if (curRec >= 0)
                {
                    tvX9_AfterSelect_cur25Rec = curRec;
                    // move forward to first 52
                    while (!(imgRec.recType == "52" || curRec > x9Stuff.Count))
                    {
                        curRec += 1;
                        imgRec  = x9Stuff[curRec];
                    }
                    if (curRec < x9Stuff.Count)
                    {
                        frontImg = imgRec.recImage;
                        // move forward to second 52
                        curRec += 1;
                        imgRec  = x9Stuff[curRec];
                        while (!(imgRec.recType == "52" || curRec > x9Stuff.Count))
                        {
                            curRec += 1;
                            imgRec  = x9Stuff[curRec];
                        }
                        if (curRec < x9Stuff.Count)
                        {
                            backImg = imgRec.recImage;
                        }
                    }
                }
                if (tcX9.TabPages.Count < 2)
                {
                    tcX9.TabPages.Add(tpImg);
                }
                pbCheck.Visible = false;
                pbFront.Visible = true;
                Image  fImg     = null;
                Image  bImg     = null;
                int    startPos = System.Convert.ToInt32(frontImg.Substring(0, frontImg.IndexOf(",")));
                int    imgLen   = System.Convert.ToInt32(frontImg.Substring(frontImg.IndexOf(",") + 1));
                byte[] recB     = new byte[imgLen + 1];
                checkImageBR.BaseStream.Seek(startPos, SeekOrigin.Begin);
                recB = checkImageBR.ReadBytes(imgLen);
                Byte2Image(ref fImg, recB, 0);
                pbFront.Image  = fImg;
                pbBack.Visible = true;
                startPos       = System.Convert.ToInt32(backImg.Substring(0, backImg.IndexOf(",")));
                imgLen         = System.Convert.ToInt32(backImg.Substring(backImg.IndexOf(",") + 1));
                recB           = new byte[imgLen + 1];
                checkImageBR.BaseStream.Seek(startPos, SeekOrigin.Begin);
                recB = checkImageBR.ReadBytes(imgLen);
                Byte2Image(ref bImg, recB, 0);
                pbBack.Image = bImg;
                onSetImage(fImg, bImg);
            }
            else
            {
                pbBack.Visible  = false;
                pbFront.Visible = false;
                pbCheck.Visible = true;
                if (rec.recImage.Length == 0)
                {
                    if (tcX9.TabPages.Count > 1)
                    {
                        tcX9.TabPages.RemoveAt(1);
                    }
                }
                else
                {
                    if (tcX9.TabPages.Count < 2)
                    {
                        tcX9.TabPages.Add(tpImg);
                    }
                    Image  cImg     = null;
                    int    startPos = System.Convert.ToInt32(rec.recImage.Substring(0, rec.recImage.IndexOf(",")));
                    int    imgLen   = System.Convert.ToInt32(rec.recImage.Substring(rec.recImage.IndexOf(",") + 1));
                    byte[] recB     = new byte[imgLen + 1];
                    checkImageBR.BaseStream.Seek(startPos, SeekOrigin.Begin);
                    recB = checkImageBR.ReadBytes(imgLen);
                    Byte2Image(ref cImg, recB, 0);
                    pbFront.Image = cImg;
                }
            }
        }
示例#2
0
 public int Add(x9Rec newX9Rec)
 {
     return List.Add(newX9Rec);
 }