public void download()
        {
            AccessCmd cmd = new AccessCmd();
            AccessCmd comd = new AccessCmd(0);
            //下载界面元素信息
            try
            {
                request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/TemplateParam?strTerminalNo=" + GlobalVariables.StrTerminalNo, "");
                XmlDocument doc = new XmlDocument();
                string strXml = request.HtmlDocument;
                Console.WriteLine(strXml);
                if (strXml.IndexOf("<templates>") >= 0)
                {
                    //加载服务器信息
                    doc.LoadXml(strXml);
                    //加载顶部框架信息
                    XmlNodeList xnlTop = doc.GetElementsByTagName("top").Item(0).ChildNodes;
                    XmlNodeList xnlBottom = doc.GetElementsByTagName("bottom").Item(0).ChildNodes;
                    XmlNodeList xnlMiddle = doc.GetElementsByTagName("middle").Item(0).ChildNodes;

                    List<XmlNodeList> lst_xnl = new List<XmlNodeList>();
                    lst_xnl.Add(xnlTop);
                    for (int j = 0; j < xnlMiddle.Count; j++)
                    {
                        lst_xnl.Add(xnlMiddle[j].ChildNodes);
                    }
                    lst_xnl.Add(xnlBottom);

                    //加载本地信息
                    string strSql = "select * from t_bz_templates order by strId asc";
                    OleDbDataReader reader = comd.ExecuteReader(strSql);
                    List<Element> lstLocal = new List<Element>();
                    while (reader.Read())
                    {
                        Element element = new Element(reader);
                        lstLocal.Add(element);
                    }
                    reader.Close();

                    int index = 0;
                    //依次对比服务器与本地信息,保证两者一致
                    for (int t = 0; t < lst_xnl.Count; t++)
                    {
                        XmlNodeList xnlTemp = lst_xnl[t];
                        for (int i = 0; i < xnlTemp.Count; i++)
                        {
                            try
                            {
                                //获得服务器记录信息
                                XmlElement  xe = (XmlElement)xnlTemp[i];
                                String strLocation, strSize, strBgImage, strFontFamily, strContent, strFontSize, strFontColor, strSort;
                                getTemplateProps(xe, out strLocation, out strSize, out strBgImage, out strFontFamily, out strContent, out strFontSize, out strFontColor, out strSort);
                                //比对本地信息
                                Element localtemplate = lstLocal.ElementAt(Convert.ToInt16(strSort) - 1);

                                //找到本地信息,先更新图片
                                bool bolImg = true;
                                bolImg = createImg("template", strBgImage);

                                //图片操作正常,删除原图片并更新数据库
                                if (bolImg)
                                {
                                    comd.ExecuteNonQuery("update t_bz_templates set strLocation='" + strLocation + "',strSize='" + strSize + "',strFontFamily='" + strFontFamily +
                                        "',strContent='" + strContent + "',intFontSize=" + Convert.ToInt16(strFontSize) + ",strFontColor='" + strFontColor + "' where strName='"+localtemplate.strName+"'");
                                }
                                index++;
                                continue;
                            }
                            catch (Exception e)
                            {
                                ErrorLog.log(e);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.log(e);

            }
            comd.Close();

            //下载商家信息
            try
            {
                request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/ShopDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, "");
                XmlDocument doc = new XmlDocument();
                string strXml = request.HtmlDocument;
                if (strXml.IndexOf("<shops>") > 0)
                {
                    //加载服务器信息
                    doc.LoadXml(strXml);
                    XmlNodeList xnlShop = doc.GetElementsByTagName("shop");
                    //加载本地信息
                    string strSql = "select strId,strSmallImg,strLargeImg from t_bz_shop";
                    OleDbDataReader reader = cmd.ExecuteReader(strSql);
                    List<Shop> lstShop = new List<Shop>();
                    while (reader.Read())
                    {
                        Shop shop = new Shop(reader);
                        lstShop.Add(shop);
                    }
                    reader.Close();
                    //依次对比服务器与本地信息,保证两者一致
                    for (int i = 0; i < xnlShop.Count; i++)
                    {
                        try
                        {
                            //获得服务器记录信息
                            XmlElement xeShop = (XmlElement)xnlShop.Item(i);
                            String strId, strBizName, strShopName, strTrade, strAddr, strIntro, strSmallImg, strLargeImg, intType, intSort;
                            getShopProps(xeShop, out strId, out strBizName, out strShopName, out strTrade, out strAddr, out strIntro, out strSmallImg, out strLargeImg, out intType, out intSort);
                            //比对本地信息
                            for (int j = 0; j < lstShop.Count; j++)
                            {
                                Shop localShop = lstShop.ElementAt(j);
                                if (localShop.StrId.Equals(strId))
                                {
                                    //找到本地信息,先更新图片
                                    bool bolImg = true;
                                    if (strSmallImg.Length > 0 && !strSmallImg.Equals(localShop.StrSmallImg))
                                    {
                                        bolImg = createImg("shop", strSmallImg);
                                    }
                                    if (bolImg && strLargeImg.Length > 0 && !strLargeImg.Equals(localShop.StrLargeImg))
                                    {
                                        bolImg = createImg("shop", strLargeImg);
                                    }
                                    //考虑数据库中有记录,但图片不存在的情况
                                    if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\shop\\" + strSmallImg))
                                    {
                                        bolImg = bolImg && createImg("shop", strSmallImg);
                                    }
                                    if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\shop\\" + strLargeImg))
                                    {
                                        bolImg = bolImg && createImg("shop", strLargeImg);
                                    }
                                    //图片操作正常,删除原图片并更新数据库
                                    if (bolImg)
                                    {
                                        cmd.ExecuteNonQuery("update t_bz_shop set strBizName='" + strBizName + "',strShopName='" + strShopName + "',strTrade='" + strTrade + "',strAddr='" + strAddr +
                                            "',strIntro='" + strIntro + "',strSmallImg='" + strSmallImg + "',strLargeImg='" + strLargeImg + "',intType=" + intType + ",intSort=" + intSort +
                                            " where strId='" + strId + "'");
                                        if (!strSmallImg.Equals(localShop.StrSmallImg))
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrSmallImg);
                                        if (!strLargeImg.Equals(localShop.StrLargeImg))
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrLargeImg);
                                    }
                                    strId = "";
                                    lstShop.Remove(localShop);
                                    break;
                                }
                            }
                            if (strId.Length > 0)
                            {
                                //本地没有找到,先增加图片
                                bool bolImg = true;
                                if (strSmallImg.Length > 0)
                                {
                                    bolImg = createImg("shop", strSmallImg);
                                }
                                if (bolImg && strLargeImg.Length > 0)
                                {
                                    bolImg = createImg("shop", strLargeImg);
                                }
                                //图片操作正常,更新数据库
                                if (bolImg)
                                {
                                    cmd.ExecuteNonQuery("insert into t_bz_shop(strId,strBizName,strShopName,strTrade,strAddr,strIntro,strSmallImg,strLargeImg,intType,intSort) values('" +
                                        strId + "','" + strBizName + "','" + strShopName + "','" + strTrade + "','" + strAddr + "','" + strIntro + "','" + strSmallImg + "','" + strLargeImg +
                                        "'," + intType + "," + intSort + ")");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLog.log(e);
                        }
                    }
                    //删除本地没有匹配的记录
                    for (int i = 0; i < lstShop.Count; i++)
                    {
                        Shop localShop = lstShop.ElementAt(i);
                        cmd.ExecuteNonQuery("delete from t_bz_shop where strId='" + localShop.StrId + "'");
                        if (localShop.StrSmallImg.Length > 0)
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrSmallImg);
                        if (localShop.StrLargeImg.Length > 0)
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\shop\\" + localShop.StrLargeImg);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.log(e);
            }

            //下载优惠券信息
            try
            {
                request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/CouponDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, "");
                XmlDocument doc = new XmlDocument();
                string strXml = request.HtmlDocument;
                if (strXml.IndexOf("<coupons>") > 0)
                {
                    //加载服务器信息
                    doc.LoadXml(strXml);
                    XmlNodeList xnlCoupon = doc.GetElementsByTagName("coupon");
                    //加载本地信息
                    string strSql = "select strId,strSmallImg,strLargeImg,strPrintImg from t_bz_coupon";
                    OleDbDataReader reader = cmd.ExecuteReader(strSql);
                    List<Coupon> lstCoupon = new List<Coupon>();
                    while (reader.Read())
                    {
                        Coupon coupon = new Coupon(reader);
                        lstCoupon.Add(coupon);
                    }
                    reader.Close();
                    //依次对比服务器与本地信息,保证两者一致
                    for (int i = 0; i < xnlCoupon.Count; i++)
                    {
                        try
                        {
                            //获得服务器记录信息
                            XmlElement xeCoupon = (XmlElement)xnlCoupon.Item(i);
                            String strId, strName, dtActiveTime, dtExpireTime, strShopId, strSmallImg, strLargeImg, strPrintImg, strIntro, strInstruction;
                            int intVip, intRecommend, intSendBySM;
                            float flaPrice;
                            getCouponProps(xeCoupon, out strId, out strName, out dtActiveTime, out dtExpireTime, out strShopId, out intVip, out flaPrice, out intRecommend,
                                out strSmallImg, out strLargeImg, out strPrintImg, out strIntro, out strInstruction,out intSendBySM);

                            //比对本地信息
                            for (int j = 0; j < lstCoupon.Count; j++)
                            {
                                Coupon localCoupon = lstCoupon.ElementAt(j);
                                if (localCoupon.StrId.Equals(strId))
                                {
                                    //找到本地信息,先更新图片
                                    bool bolImg = true;
                                    if (strSmallImg.Length > 0 && !strSmallImg.Equals(localCoupon.StrSmallImg))
                                    {
                                        bolImg = createImg("coupon", strSmallImg);
                                    }
                                    if (bolImg && strLargeImg.Length > 0 && !strLargeImg.Equals(localCoupon.StrLargeImg))
                                    {
                                        bolImg = createImg("coupon", strLargeImg);
                                    }
                                    if (bolImg && strPrintImg.Length > 0 && !strPrintImg.Equals(localCoupon.StrPrintImg))
                                    {
                                        bolImg = createImg("coupon", strPrintImg);
                                    }
                                    //考虑数据库中有记录,但图片不存在的情况
                                    if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strSmallImg))
                                    {
                                        bolImg = bolImg && createImg("coupon", strSmallImg);
                                    }
                                    if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strLargeImg))
                                    {
                                        bolImg = bolImg && createImg("coupon", strLargeImg);
                                    }
                                    if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + strPrintImg))
                                    {
                                        bolImg = bolImg && createImg("coupon", strPrintImg);
                                    }
                                    //图片操作正常,删除原图片并更新数据库
                                    if (bolImg)
                                    {
                                        cmd.ExecuteNonQuery("update t_bz_coupon set strName='" + strName + "',dtActiveTime='" + dtActiveTime + "',dtExpireTime='" + dtExpireTime +
                                            "',strShopId='" + strShopId + "',intVip=" + intVip + ",intRecommend=" + intRecommend + ",flaPrice=" + flaPrice + ",strSmallImg='" + strSmallImg +
                                            "',strLargeImg='" + strLargeImg + "',strPrintImg='" + strPrintImg + "',strIntro='" + strIntro + "',strInstruction='" + strInstruction + "',intSendBySM=" + intSendBySM +
                                            " where strId='" + strId + "'");
                                        if (!strSmallImg.Equals(localCoupon.StrSmallImg))
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrSmallImg);
                                        if (!strLargeImg.Equals(localCoupon.StrLargeImg))
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrLargeImg);
                                        if (!strPrintImg.Equals(localCoupon.StrPrintImg))
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrPrintImg);
                                    }
                                    strId = "";
                                    lstCoupon.Remove(localCoupon);
                                    break;
                                }
                            }
                            if (strId.Length > 0)
                            {
                                //本地没有找到,先增加图片
                                bool bolImg = true;
                                if (strSmallImg.Length > 0)
                                {
                                    bolImg = createImg("coupon", strSmallImg);
                                }
                                if (bolImg && strLargeImg.Length > 0)
                                {
                                    bolImg = createImg("coupon", strLargeImg);
                                }
                                if (bolImg && strPrintImg.Length > 0)
                                {
                                    bolImg = createImg("coupon", strPrintImg);
                                }
                                //图片操作正常,更新数据库
                                if (bolImg)
                                {
                                    cmd.ExecuteNonQuery("insert into t_bz_coupon(strId,strName,dtActiveTime,dtExpireTime,strShopId,intVip,intRecommend,flaPrice,strSmallImg,strLargeImg," +
                                        "strPrintImg,strIntro,strInstruction) values('" + strId + "','" + strName + "','" + dtActiveTime + "','" + dtExpireTime + "','" + strShopId + "'," +
                                        intVip + "," + intRecommend + "," + flaPrice + ",'" + strSmallImg + "','" + strLargeImg + "','" + strPrintImg + "','" + strIntro + "','" +
                                        strInstruction + "')");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLog.log(e);
                        }
                    }
                    //删除本地没有匹配的记录
                    for (int i = 0; i < lstCoupon.Count; i++)
                    {
                        Coupon localCoupon = lstCoupon.ElementAt(i);
                        cmd.ExecuteNonQuery("delete from t_bz_coupon where strId='" + localCoupon.StrId + "'");
                        if (localCoupon.StrSmallImg.Length > 0)
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrSmallImg);
                        if (localCoupon.StrLargeImg.Length > 0)
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrLargeImg);
                        if (localCoupon.StrPrintImg.Length > 0)
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\coupon\\" + localCoupon.StrPrintImg);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.log(e);
            }

            //下载广告信息
            try
            {
                request.OpenRequest(GlobalVariables.StrServerUrl + "/servlet/AdDownload?strTerminalNo=" + GlobalVariables.StrTerminalNo, "");
                XmlDocument doc = new XmlDocument();
                string strXml = request.HtmlDocument;
                if (strXml.IndexOf("<ads>") > 0)
                {
                    //加载服务器信息
                    doc.LoadXml(strXml);
                    XmlNodeList xnlAd = doc.GetElementsByTagName("ad");
                    //加载本地信息
                    string strSql = "select strId,intType,strContent from t_bz_advertisement";
                    OleDbDataReader reader = cmd.ExecuteReader(strSql);
                    List<Advertisement> lstAd = new List<Advertisement>();
                    while (reader.Read())
                    {
                        Advertisement ad = new Advertisement(reader);
                        lstAd.Add(ad);
                    }
                    reader.Close();
                    //依次对比服务器与本地信息,保证两者一致
                    for (int i = 0; i < xnlAd.Count; i++)
                    {
                        try
                        {
                            //获得服务器记录信息
                            XmlElement xeAd = (XmlElement)xnlAd.Item(i);
                            String strId, strName, strContent, dtStartTime, dtEndTime;
                            int intType;
                            getAdProps(xeAd, out strId, out strName, out intType, out strContent, out dtStartTime, out dtEndTime);
                            //比对本地信息
                            for (int j = 0; j < lstAd.Count; j++)
                            {
                                Advertisement localAd = lstAd.ElementAt(j);
                                if (localAd.StrId.Equals(strId))
                                {
                                    //找到本地信息,先更新图片
                                    bool bolImg = true;
                                    if (intType < 3 && strContent.Length > 0 && !strContent.Equals(localAd.StrContent))
                                    {
                                        if (intType == 1)
                                        {
                                            bolImg = createImg("ad", strContent);
                                        }
                                        else if (intType == 2)
                                        {
                                            string[] aryFile = strContent.Split(new char[] { ',' });
                                            for (int k = 0; k < aryFile.Length; k++)
                                            {
                                                bolImg = bolImg && createImg("ad", aryFile[k]);
                                            }
                                        }
                                    }
                                    //考虑数据库中有记录,但图片不存在的情况
                                    if (intType == 1 && !File.Exists(System.Windows.Forms.Application.StartupPath + "\\ad\\" + strContent))
                                    {
                                        bolImg = bolImg && createImg("ad", strContent);
                                    }
                                    else if (intType == 2)
                                    {
                                        string[] aryFile = strContent.Split(new char[] { ',' });
                                        for (int k = 0; k < aryFile.Length; k++)
                                        {
                                            if (!File.Exists(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k]))
                                            {
                                                bolImg = bolImg && createImg("ad", aryFile[k]);
                                            }
                                        }

                                    }
                                    //图片操作正常,删除原图片并更新数据库
                                    if (bolImg)
                                    {
                                        cmd.ExecuteNonQuery("update t_bz_advertisement set strName='" + strName + "',intType=" + intType + ",strContent='" + strContent +
                                            "',dtStartTime='" + dtStartTime + "',dtEndTime='" + dtEndTime + "' where strId='" + strId + "'");
                                        if (localAd.IntType == 1 && !strContent.Equals(localAd.StrContent))
                                        {
                                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + localAd.StrContent);
                                        }
                                        else if (localAd.IntType == 2 && !strContent.Equals(localAd.StrContent))
                                        {
                                            string[] aryFile = localAd.StrContent.Split(new char[] { ',' });
                                            for (int k = 0; k < aryFile.Length; k++)
                                            {
                                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k]);
                                            }
                                        }
                                    }
                                    strId = "";
                                    lstAd.Remove(localAd);
                                    break;
                                }
                            }
                            if (strId.Length > 0)
                            {
                                //本地没有找到,先增加图片
                                bool bolImg = true;
                                if (intType < 3 && strContent.Length > 0)
                                {
                                    if (intType == 1)
                                    {
                                        bolImg = createImg("ad", strContent);
                                    }
                                    else if (intType == 2)
                                    {
                                        string[] aryFile = strContent.Split(new char[] { ',' });
                                        for (int k = 0; k < aryFile.Length; k++)
                                        {
                                            bolImg = bolImg && createImg("ad", aryFile[k]);
                                        }
                                    }
                                }
                                //图片操作正常,更新数据库
                                if (bolImg)
                                {
                                    cmd.ExecuteNonQuery("insert into t_bz_advertisement(strId,strName,intType,strContent,dtStartTime,dtEndTime) values('" + strId + "','" + strName + "'," +
                                        intType + ",'" + strContent + "','" + dtStartTime + "','" + dtEndTime + "')");
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLog.log(e);
                        }
                    }
                    //删除本地没有匹配的记录
                    for (int i = 0; i < lstAd.Count; i++)
                    {
                        Advertisement localAd = lstAd.ElementAt(i);
                        cmd.ExecuteNonQuery("delete from t_bz_advertisement where strId='" + localAd.StrId + "'");
                        if (localAd.StrContent.Length > 0)
                        {
                            if (localAd.IntType == 1)
                            {
                                File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + localAd.StrContent);
                            }
                            else if (localAd.IntType == 2)
                            {
                                string[] aryFile = localAd.StrContent.Split(new char[] { ',' });
                                for (int k = 0; k < aryFile.Length; k++)
                                {
                                    File.Delete(System.Windows.Forms.Application.StartupPath + "\\ad\\" + aryFile[k]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.log(e);
            }
            cmd.Close();
        }
        /// <summary>
        /// 加载界面元素
        /// </summary>
        private void LoadTemplates()
        {
            string sql = "select * from t_bz_templates order by strId asc";
            AccessCmd cmd = new AccessCmd(0);
            OleDbDataReader reader = cmd.ExecuteReader(sql);
            List<Element> lstlocal = new List<Element>();

            while (reader.Read())
            {
                Element element = new Element(reader);
                lstlocal.Add(element);
            }

            reader.Close();
            cmd.Close();
            for (int i = 0; i < lstlocal.Count; i++)
            {
                Element element = lstlocal.ElementAt(i);
                if (element.strCtlName == "PB_Shop_Type2_NextPage")
                {
                    Console.WriteLine("");
                }
                Control ctl = GetControl(element.strCtlName);
                if (ctl == null)
                    continue;

                try
                {
                    if (!element.strLocation.Equals(""))
                    {
                        Point old_P = ctl.Location;
                        try
                        {
                            ctl.Location = new Point(Convert.ToInt32(element.strLocation.Split(',')[0]), Convert.ToInt32(element.strLocation.Split(',')[1]));
                        }
                        catch
                        {
                            ctl.Location = old_P;
                        }

                        Size old_S = ctl.Size;
                        try
                        {
                            ctl.Size = new Size(Convert.ToInt32(element.strSize.Split(',')[0]), Convert.ToInt32(element.strSize.Split(',')[1]));
                        }
                        catch
                        {
                            ctl.Size = old_S;
                        }

                        if (!element.strBgImage.Equals(""))
                        {
                            if ((ctl is PictureBox) && (ctl as PictureBox).Image == null)
                                continue;
                            FileStream pFileStream;
                            try
                            {
                                pFileStream = new FileStream(path + "\\template\\" + element.strBgImage, FileMode.Open, FileAccess.Read);
                                if (ctl is Label)
                                {
                                    Label lb = ctl as Label;
                                    lb.Image = new Bitmap(Image.FromStream(pFileStream), ctl.Size);

                                }
                                else
                                {
                                    ctl.BackgroundImage = new Bitmap(Image.FromStream(pFileStream), ctl.Size);
                                }
                                pFileStream.Close();
                                pFileStream.Dispose();
                            }
                            catch
                            {
                                pFileStream = new FileStream(path + "\\defalut\\" + element.strBgImage, FileMode.Open, FileAccess.Read);
                                if (ctl is Label)
                                    (ctl as Label).Image = new Bitmap(Image.FromStream(pFileStream), ctl.Size);
                                else
                                    ctl.BackgroundImage = new Bitmap(Image.FromStream(pFileStream), ctl.Size);
                                pFileStream.Close();
                                pFileStream.Dispose();
                            }
                        }

                        if (!element.strFontFamily.Equals(""))
                        {
                            //if (ctl.Name == "Label_Countdown")
                            //    Console.WriteLine("get it");
                            if (ctl is Panel || ctl is PictureBox)
                                continue;

                            Font old_F = ctl.Font;
                            Label lb = ctl as Label;

                            if (element.strContent != "")
                                lb.Text = element.strContent;
                            if (element.strFontFamily != "" & element.intFontSize != 0)
                                lb.Font = new Font(new FontFamily(element.strFontFamily), element.intFontSize, old_F.Style);

                            if (element.strFontColor != "")
                            {
                                try
                                {
                                    string[] color = element.strFontColor.Split(',');
                                    int[] intcolor = { Convert.ToInt32(color[0]), Convert.ToInt32(color[1]), Convert.ToInt32(color[2]) };

                                    for (int t = 0; t < 3; t++)
                                    {
                                        if (intcolor[t] < 0)
                                            intcolor[t] = 0;
                                        if (intcolor[t] > 255)
                                            intcolor[t] = 255;
                                    }

                                    lb.ForeColor = Color.FromArgb(intcolor[0], intcolor[1], intcolor[2]);
                                }
                                catch
                                {
                                    lb.ForeColor = Color.FromArgb(255, 255, 255);
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    ErrorLog.log(e);
                }
            }
        }