Exemplo n.º 1
0
        //private void ShowMessbutton_Click(object sender, EventArgs e)
        //{
        //    #region
        //    /*for (int i = 0; i < 10; i++)   //添加10行数据
        //    {
        //        ListViewItem lvi = new ListViewItem();

        //        //lvi.ImageIndex = i;     //通过与imageList绑定,显示imageList中第i项图标

        //        lvi.Text = "subitem" + i; //第一列

        //        lvi.SubItems.Add("第2列,第" + i + "行");

        //        lvi.SubItems.Add("第3列,第" + i + "行");

        //        CanMesslistView.Items.Add(lvi);
        //    }*/
        //    #endregion

        //    Analysis ay = new Analysis();
        //    List<string> Cangets = new List<string>();
        //    Cangets.Add("t8561122334455667788");

        //    flushMesslist(Cangets,0);
        //    textBox1.Text = "tttttttt";
        //}

        public void flushMesslist(List <string> Cangets, int flushtype)
        {
            #region
            //CanMesslistView.Clear();
            //CanMesslistView.Items.Clear();

            //string Canget = "t8561122334455667788\r";

            /*foreach (string Canget in Cangets) //此处疑似有重复
             * {
             *  ListViewItem listv = new ListViewItem();
             *  listv.Text = Canget;
             *  CanMesslistView.Items.Add(listv);
             * }*/
            #endregion

            Analysis ay = new Analysis();
            foreach (string Canget in Cangets)
            {
                if (string.Equals("t", Canget.Substring(0, 1)) || string.Equals("T", Canget.Substring(0, 1)))
                {
                    //ArrayList pList = new ArrayList();
                    //string idnumber= ay.get16IDNumber(Canget);
                    TreeCanInfo Tcinfo = new TreeCanInfo();
                    string      thisid = ay.convert16to10(ay.get16IDNumber(Canget));
                    Tcinfo.ID   = thisid;
                    Tcinfo.Name = ay.getCanMessName(thisid);
                    Tcinfo.DLC  = ay.getDLC(Canget);
                    Tcinfo.Data = ay.getData(Canget);

                    foreach (string CanData in ay.canReceiptAnalysis(Canget))
                    {
                        string[] Data = CanData.Split(',');
                        //Console.WriteLine(Data[0] + "----------" + Data[1]);
                        ListViewItem listv = new ListViewItem();
                        listv.Text = Data[0];        //第一列
                        listv.SubItems.Add(Data[1]); //没有报错提示
                        CanMesslistView.Items.Add(listv);
                        Tcinfo.block.Add(Data[0] + " " + Data[1]);
                        //textBox1.Text = Data[0];
                        #region
                        //增加ID Name Dir DLC Data


                        /*ListTree2 rottree1 = new ListTree2();
                         * rottree1.ParentID = idnumber;
                         * rottree1.GetID = ay.get16IDNumber(Canget);
                         * rottree1.GetName = "stand";
                         * rottree1.DLC = ay.getDLC(Canget);
                         * rottree1.GetData = ay.getData(Canget);
                         * pList.Add(rottree1);*/

                        /*int i = 0, t = 0;
                         * ArrayList pList = new ArrayList();
                         * List<string> CanAllInfos = ay.getCanAllInfoFromDatabase();
                         * foreach (string CanAllInfo in CanAllInfos)
                         * {
                         *  string[] canblock = CanAllInfo.Split(' ');
                         *  ListTree2 p = new ListTree2();
                         *  p.GetID = i;
                         *  t = i;
                         *  i++;
                         *  p.GetName = canblock[0] + canblock[1];
                         *  pList.Add(p);
                         *  for (int j = 2; j < canblock.Length; j++)
                         *  {
                         *      ListTree2 q = new ListTree2();
                         *      q.ParentID = t;
                         *      q.GetID = i;
                         *      i++;
                         *      q.GetName = canblock[j];
                         *      pList.Add(q);
                         *  }
                         * }
                         * this.treeList1.DataSource = pList;
                         * this.treeList1.RefreshDataSource();
                         */
                        #endregion
                    }
                    #region

                    //ArrayList pList = new ArrayList();

                    /*ListTree2 rottree = new ListTree2();
                     * rottree.GetID = ay.get16IDNumber(Canget);
                     * rottree.GetName = "stand";
                     * rottree.DLC = ay.getDLC(Canget);
                     * rottree.GetData = ay.getData(Canget);
                     * pList.Add(rottree);
                     * this.treeList2.DataSource = pList;
                     * this.treeList2.RefreshDataSource();
                     * pList.Clear();*/
                    #endregion
                    if (hshTable.Contains(thisid))
                    {
                        hshTable.Remove(thisid);  //删除旧数据
                    }
                    hshTable.Add(thisid, Tcinfo); //在hashtable中放入ID DLC Data 器件name phy
                }
                else
                {
                    ListViewItem listv = new ListViewItem();
                    listv.Text = Canget;
                    CanMesslistView.Items.Add(listv);
                }
            }

            //textBox1.Text = "***************";
        }
Exemplo n.º 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //根据选择的ID刷新树状图
            #region

            /*if (test1)
             * {
             *  ArrayList pList = new ArrayList();
             *  //传入一个有所有内容的对象
             *  //读取该对象值
             *
             *  int i = 0, t = 0;
             *  foreach (string key in hshTable.Keys)
             *  {
             *      TreeCanInfo tcinfo = (TreeCanInfo)hshTable[key];
             *      ListTree2 rottree = new ListTree2();
             *      rottree.ID = i;
             *      t = i;
             *      i++;
             *      rottree.GetID = tcinfo.ID;
             *      rottree.GetName = "defult";
             *      rottree.GetData = tcinfo.Data;
             *      pList.Add(rottree);
             *      foreach (string block in tcinfo.block)
             *      {
             *          ListTree2 rottree1 = new ListTree2();
             *          rottree1.ParentID = t;
             *          rottree1.ID = i;
             *          i++;
             *          rottree1.GetName = block;
             *          pList.Add(rottree1);
             *      }
             *  }
             *  this.treeList2.DataSource = pList;
             *  this.treeList2.RefreshDataSource();
             *  test1= false;
             * }*/
            #endregion

            ArrayList pList = new ArrayList();
            //传入一个有所有内容的对象
            //读取该对象值

            int i = 0, t = 0;
            foreach (string key in hshTable.Keys)
            {
                TreeCanInfo tcinfo  = (TreeCanInfo)hshTable[key];
                ListTree2   rottree = new ListTree2();
                rottree.ID = i;
                t          = i;
                i++;
                rottree.GetID   = tcinfo.ID;
                rottree.GetName = tcinfo.Name;
                rottree.DLC     = "8";
                rottree.GetData = tcinfo.Data;
                pList.Add(rottree);
                foreach (string block in tcinfo.block)
                {
                    ListTree2 rottree1 = new ListTree2();
                    rottree1.ParentID = t;
                    rottree1.ID       = i;
                    string[] toolIDandData = block.Split(' ');
                    rottree1.GetName = toolIDandData[0];
                    rottree1.GetData = toolIDandData[1];
                    i++;
                    pList.Add(rottree1);
                }
            }
            this.treeList2.DataSource = pList;
            this.treeList2.RefreshDataSource();



            //ArrayList pList = new ArrayList();
            //传入一个有所有内容的对象
            //读取该对象值

            /*ListTree2 rottree = new ListTree2();
             * rottree.GetID = ay.get16IDNumber(Canget);
             * rottree.GetName = "stand";
             * rottree.DLC = ay.getDLC(Canget);
             * rottree.GetData = ay.getData(Canget);
             * pList.Add(rottree);
             *
             * pList.Clear();
             *
             * for(int i=0;i<10;i++)
             * {
             *  //add
             * }
             * this.treeList2.DataSource = pList;
             * this.treeList2.RefreshDataSource();*/
        }