Add() public method

public Add ( System.Windows.Forms.ListViewItem value ) : System.Windows.Forms.ListViewItem
value System.Windows.Forms.ListViewItem
return System.Windows.Forms.ListViewItem
Esempio n. 1
0
        private ListViewGroup(SerializationInfo info, StreamingContext context)
        {
            header           = info.GetString("Header");
            name             = info.GetString("Name");
            header_alignment = (HorizontalAlignment)info.GetInt32("HeaderAlignment");
            tag = info.GetValue("Tag", typeof(object));

            int count = 0;

            try {
                count = info.GetInt32("ItemsCount");
            } catch (SerializationException e) {
                // Mono backwards compat
                try {
                    count = info.GetInt32("ListViewItemCount");
                } catch (SerializationException e2) {}
            }

            if (items == null)
            {
                items = new ListView.ListViewItemCollection(list_view_owner);
            }

            for (int i = 0; i < count; i++)
            {
                items.Add((ListViewItem)info.GetValue(string.Format("ListViewItem_{0}", i), typeof(ListViewItem)));
            }
        }
Esempio n. 2
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            statusLabel.Text = "Scanning domain " + WindowsCred.GetDomain() + " for computers... Please Wait.";
            Application.DoEvents();

            // Enumerate computers in domain, add to listviewComputers control
            listviewComputers.Items.Clear();

            ListView.ListViewItemCollection listItems = new ListView.ListViewItemCollection(listviewComputers);
            if (DEBUG)
            {
                String[] debugComputers = new String[] { "DCMAIN", "ROBTEST-PC", "ROB-PC" };
                foreach (String computer in debugComputers)
                {
                    ListViewItem newItem = new ListViewItem(computer);
                    listItems.Add(newItem);
                }
            }
            else
            {
                foreach (SearchResult computer in WindowsCred.EnumerateComputers())
                {

                    ListViewItem newItem = new ListViewItem(computer.GetDirectoryEntry().Name.Substring(3).ToUpper());
                    listItems.Add(newItem);

                }

            }

            // Update label to display domain
            lblDomain.Text = "Computers in domain: " + WindowsCred.GetDomain();
            statusLabel.Text = "Scan Domain complete.";

            Application.DoEvents();

            PingListView.PingAll();

            label4.Text = "Computers: " + listviewComputers.Items.Count.ToString();
        }
Esempio n. 3
0
        // Used for getting the ListView items from within the BackgroundWorker thread.
        private ListView.ListViewItemCollection GetListViewItems(ListView listView)
        {
            ListView.ListViewItemCollection tmpListViewColl = new ListView.ListViewItemCollection(new ListView());

            if (!listView.InvokeRequired)
            {
                foreach (ListViewItem item in listView.Items)
                    tmpListViewColl.Add((ListViewItem)item.Clone());

                return tmpListViewColl;
            }
            else
                return (ListView.ListViewItemCollection)this.Invoke(new GetItems(GetListViewItems), new object[] { listView });
        }
 private ListView.ListViewItemCollection getListViewItems(ListView lstview)
 {
     ListView.ListViewItemCollection temp = new ListView.ListViewItemCollection(new ListView());
     if (!lstview.InvokeRequired)
     {
         MessageBox.Show("yolo");
         foreach (ListViewItem item in lstview.Items)
             temp.Add((ListViewItem)item.Clone());
         return temp;
     }
     else
         return (ListView.ListViewItemCollection)this.Invoke(new GetItems(getListViewItems), new object[] { lstview });
 }
Esempio n. 5
0
        public void RefreshSearchResults(int mode)
        {
            ulong x = 0;
            bool reloadDump = false;
            ListView.ListViewItemCollection items = new ListView.ListViewItemCollection(lvSch);
            //lvSch.Items.

            switch (mode)
            {
                case 0: /* Refresh by reloading everything from the dump */
                    lvSch.Items.Clear();

                    if (Form1.SchResCnt == 0)
                        reloadDump = true;

                    if (reloadDump)
                    {
                        lvSch.BeginUpdate();
                        while (true)
                        {
                            String Addr = "";

                            CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, (MaxRes - 1) + (int)x, (int)GlobAlign);
                            if (retRes == null)
                                return;

                            GlobAlign = (ulong)retRes[0].align;
                            NextSAlign = (int)retRes[0].align;

                            for (int z = 0; z < retRes.Length; z++)
                            {

                                if (retRes[z].val == null)
                                    goto nextZ;

                                ListRes a = misc.GetlvVals((int)GlobAlign, retRes[z].val, 0);

                                Addr = (retRes[z].addr).ToString("X8");

                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                //lvSch.Items.Add(listViewItem);
                                items.Add(listViewItem);

                            nextZ:
                                if ((x % 1000) == 0)
                                {
                                    statusLabel1.Text = "Results: " + x.ToString();
                                    Application.DoEvents();
                                }
                                if (retRes[z].val == null && reloadDump)
                                {
                                    Form1.SchResCnt = x;
                                    statusLabel1.Text = "Results: " + x.ToString();
                                    lvSch.EndUpdate();
                                    NewSearch = false;
                                    schNSearch.Enabled = true;
                                    return;
                                }
                                x++;
                            }
                        }
                    }
                    else
                    {
                        lvSch.BeginUpdate();
                        //for (x = 0; x < Form1.SchResCnt; x++)
                        while (x < Form1.SchResCnt)
                        {
                            String Addr = "";

                            CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, (MaxRes - 1) + (int)x, (int)GlobAlign);
                            if (retRes == null)
                                return;

                            if ((int)x < retRes.Length)
                            {
                                GlobAlign = (ulong)retRes[x].align;
                                NextSAlign = (int)retRes[x].align;
                            }

                            int z = 0;
                            for (z = 0; z < retRes.Length; z++)
                            {
                                if (retRes[z].val == null)
                                    goto nextZ;

                                ListRes a = misc.GetlvVals((int)GlobAlign, retRes[z].val, 0);

                                Addr = (retRes[z].addr).ToString("X8");

                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                items.Add(listViewItem);

                            nextZ:
                                if ((z % 1000) == 0)
                                    Application.DoEvents();
                            }
                            x += (ulong)z;
                        }
                        lvSch.EndUpdate();
                    }

                    break;
                case 1: /* Refresh everything by grabbing the values from the PS3 */
                    lvSch.BeginUpdate();
                    for (x = 0; x < Form1.SchResCnt; x++)
                    {
                        String Addr = "";
                        int align = (int)GlobAlign;

                        CodeRes[] retRes = fileio.ReadDumpArray(dFileName, (int)x, MaxRes + (int)x, (int)GlobAlign);
                        if (retRes == null)
                            return;

                        for (int z = 0; z < retRes.Length; z++)
                        {

                            if (x >= Form1.SchResCnt)
                                break;

                            if ((int)GlobAlign == -1 || (int)GlobAlign == -2)
                                align = retRes[z].val.Length;

                            byte[] ret = new byte[align];
                            apiGetMem(retRes[z].addr, ref ret);

                            ListRes a = new ListRes();
                            a = misc.GetlvVals((int)GlobAlign, ret, 0);

                            Addr = (retRes[z].addr).ToString("X8");

                            if ((int)x < lvSch.Items.Count)
                            {
                                items[(int)x].SubItems[0].Text = Addr;
                                items[(int)x].SubItems[1].Text = a.HexVal;
                                items[(int)x].SubItems[2].Text = a.DecVal;
                                items[(int)x].SubItems[3].Text = a.AlignStr;
                            }
                            else
                            {
                                string[] row = { Addr, a.HexVal, a.DecVal, a.AlignStr };
                                var listViewItem = new ListViewItem(row);
                                items.Add(listViewItem);
                            }

                            x++;
                            if ((x % 500) == 0)
                                Application.DoEvents();
                        }
                    }
                    lvSch.EndUpdate();
                    break;
            }
        }
Esempio n. 6
0
        private void LoadNodeDir(TreeNode node)
        {
            if (!Directory.Exists(((tree_tag)node.Tag).strPath))
            {
                return;
            }

            Control ctrl_parent = lv1.Parent;
            ctrl_parent.Controls.Remove(lv1);

            if (((tree_tag)node.Tag).listv != null)
            {
                lv1 = ((tree_tag)node.Tag).listv;
                ctrl_parent.Controls.Add(lv1);
                lv1.Enabled = true;
                lv1.Visible = true;
                lv1.Select();
                autoSelect(lv1);
                return;
            }

            fl.Show();
            fl.Enabled = false;

            tv1.Enabled = false;

            lv1 = new ListView();

            lv1.SelectedIndexChanged    += new System.EventHandler(lv1_SelectedIndexChanged);
            lv1.DoubleClick             += new EventHandler(lv1_DoubleClick);
            lv1.LargeImageList          = imageList1;
            lv1.Dock                    = DockStyle.Fill;
            lv1.MultiSelect             = false;

            ctrl_parent.Controls.Add(lv1);
            //lv1.Clear();

            DirectoryInfo di = new DirectoryInfo(((tree_tag)node.Tag).strPath);
            fl.pbar.Maximum = di.GetFiles().Length;
            fl.pbar.Value = 0;
            ListView.ListViewItemCollection lvc = new ListView.ListViewItemCollection(lv1);
            lv1.Visible = false;
            lv2.Visible = true;

            if(this.showFolder == true)
            {
                string stroutout = string.Empty;
                foreach (DirectoryInfo d in di.GetDirectories())
                {
                    if (d.Name == ".svn" || d.Name == "Texture") continue;

                    Application.DoEvents();
                    fl.label1.Text = d.FullName;
                    if (imageList1.Images.ContainsKey(d.FullName))
                    {
                        lvc.Add(d.Name, d.FullName).Tag = "folder";
                        continue;
                    }
                    Image imgFolder = imageList3.Images["folder.bmp"];
                    FileInfo[] files = d.GetFiles(this.strFolderPreviewFilter);
                    if(files.Length == 0)
                    {
                        DirectoryInfo[] d111 = d.GetDirectories("模型");
                        if (d111.Length > 0)
                            files = d111[0].GetFiles(this.strFolderPreviewFilter);
                    }
                    //    
                    if(files.Length == 0)   //普通目录
                    {
                        imageList1.Images.Add(d.FullName, imgFolder);
                        lvc.Add(d.Name, d.FullName).Tag = "folder";
                        continue;
                    }
                    Debug.WriteLine(files[0].FullName);
                    stroutout += files[0].FullName + "\r\n";
                    sprViewer.SPRItem si = new sprViewer.SPRItem(files[0].FullName, sprViewer.SPRItem.PIC_TYPE.MDL, m_engine);

                    //check cache
                    if (File.Exists(si.tgaFileName + "!.BMP")
                        && d.LastWriteTime.ToString() == sprViewer.IniIO.IniReadValue("cache", "time", si.tgaFileName + "_tb.ini"))
                    {
                        Image img = new Bitmap(si.tgaFileName + "!.BMP");
                        imageList1.Images.Add(d.FullName, img);
                    }
                    else
                    {
                        int ind = si.TGAList.Count / 2;
                        ind = ind == 0 ? 1 : ind;
                        string strFile = si.TGAList[ind.ToString()].ToString();
                        if (File.Exists(strFile))
                        {
                            Image img = Image.FromFile(strFile);
                            Image imgsmall = img.GetThumbnailImage(80, 80, null, IntPtr.Zero);
                            //imgsmall.Save(@"C:\Documents and Settings\kuangsihao\桌面\newtools\_cache\mdl\folder.bmp");
                            Image imgCombo = new Bitmap(imgFolder);
                            Graphics g = Graphics.FromImage(imgCombo);
                            //g.DrawImage(imgsmall, new Point(0, 0));
                            g.DrawImage(imgsmall, new Rectangle(6, 8, imgsmall.Width, imgsmall.Height));
                            //g.DrawImage(img, new Rectangle(0, 0, img.Width, img.Height));
                            imgCombo.Save(si.tgaFileName + "!.BMP");
                            imageList1.Images.Add(d.FullName, imgCombo);
                            sprViewer.IniIO.IniWriteValue("cache", "time", d.LastWriteTime.ToString(), si.tgaFileName + "_tb.ini");
                        }
                    }
                    ListViewItem lvi = lvc.Add(d.Name, d.FullName);
                    lvi.Tag = "folder";
                }
            }

            foreach (FileInfo f in di.GetFiles())
            {
                Application.DoEvents();
                fl.pbar.Value++;
                fl.label1.Text = f.FullName;

                if (strFilter.IndexOf(";" + f.Extension.ToLower() + ";") == -1)
                {
                    continue;
                }

                if (imageList1.Images.ContainsKey(f.FullName))
                {
                    lvc.Add(f.Name, f.FullName).Tag = "file";
                    continue;
                }

                if (!multi_load)
                {
                    sprViewer.SPRItem.PIC_TYPE pt = sprViewer.SPRItem.PIC_TYPE.NULL;

                    switch (f.Extension.ToLower())
                    {
                        case ".mdl":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.MDL;
                                break;
                            }                            
                        case ".mtl":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.MTL;
                                break;
                            }                            
                        case ".mesh":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.MESH;
                                break;
                            }                            
                        case ".ani":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.ANI;
                                break;
                            }                            
                        case ".tani":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.ANI;
                                break;
                            }                            
                        case ".spr":
                            {
                                pt = sprViewer.SPRItem.PIC_TYPE.NULL;
                                break;
                            }                            
                    }

                    sprViewer.SPRItem si;

                    if (pt != sprViewer.SPRItem.PIC_TYPE.NULL)
                    {
                        si = new sprViewer.SPRItem(f.FullName, pt, m_engine, true);
                    }
                    else
                    {
                        si = new sprViewer.SPRItem(f.FullName);
                    }

                    //check cache
                    if (File.Exists(si.tgaFileName + ".BMP")
                     && f.LastWriteTime.ToString() == sprViewer.IniIO.IniReadValue("cache", "time", si.tgaFileName + "_tb.ini"))
                    {
                        Image img = new Bitmap(si.tgaFileName + ".BMP");
                        imageList1.Images.Add(f.FullName, img);
                    }
                    else
                    {
                        int ind = si.TGAList.Count / 2;
                        ind = ind == 0 ? 1 : ind;

                        if (ind <= si.TGAList.Count)
                        {
                            string file = si.TGAList[ind.ToString()].ToString();
                            if (File.Exists(file))
                            {
                                Image img = Image.FromFile(file);
                                Image imgsmall = img.GetThumbnailImage(48, 48, null, IntPtr.Zero);
                                imgsmall.Save(si.tgaFileName + ".BMP");
                                imageList1.Images.Add(f.FullName, imgsmall);
                                sprViewer.IniIO.IniWriteValue("cache", "time", f.LastWriteTime.ToString(), si.tgaFileName + "_tb.ini");
                            }
                        }
                    }
                }

                ListViewItem lvi = lvc.Add(f.Name, f.FullName);
                lvi.Tag = "file";
            }

            if (multi_load)
            {
                m_thread = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
                m_thread.Start();
            }

            ((tree_tag)node.Tag).listv = lv1;

            //清多于nQueMax个ListView的缓存
            tag_que.Enqueue((tree_tag)node.Tag);
            while (tag_que.Count > nQueMax)
            {
                tree_tag tt = tag_que.Dequeue();
                tt.listv = null;
            }

            fl.Hide();
            tv1.Enabled = true;
            lv1.Visible = true;
            lv2.Visible = false;
            lv1.Select();
            autoSelect(lv1);

            OldLVC.Clear();
        }
Esempio n. 7
0
        /// <summary>
        /// 通过listview 空间显示案件编号信息
        /// </summary>
        /// <param name="regNoList"></param>
        /// <param name="listView"></param>
        private void ShowListView(IList<EY_RegNo_DI> regNoList,ListViewEx listView)
        {
            listView.Items.Clear();
                ListView.ListViewItemCollection collection = new ListView.ListViewItemCollection(listView);
                foreach (EY_RegNo_DI t in regNoList)
                {
                    ListViewItem lv = new ListViewItem(t.toArray());

                    collection.Add(lv);
                }
        }
Esempio n. 8
0
        private void selectImages() 
        {
            lvImages.Items.Clear();
            if (lvImages.LargeImageList != null)
                lvImages.LargeImageList.Dispose();

            int lowerIdx = (int)Math.Min(_selectionA, _selectionB);
            int upperIdx = (int)Math.Max(_selectionA, _selectionB);

            _imageList = new ImageList();
            _imageList.ColorDepth = ColorDepth.Depth24Bit;
            _imageList.ImageSize = new Size(128, 128);

            ListView.ListViewItemCollection items = new ListView.ListViewItemCollection(lvImages);
            lvImages.LargeImageList = _imageList;

            for (int i = lowerIdx; i <= upperIdx; ++i)
            {
                string path = _imagePaths[_OPTICSMapping[i]];
                _imageList.Images.Add(Image.FromFile(path));
            }

            for (int i = lowerIdx; i <= upperIdx; ++i)
            {
                ListViewItem item = new ListViewItem();
                item.Text = _imagePaths[_OPTICSMapping[i]];
                item.Tag = _rDistances[i];
                item.ImageIndex = i - lowerIdx;
                item.StateImageIndex = _rDistances[i] > _thresh || _rDistances[i] < 0 ? 1 : 0;
                items.Add(item);
            }
        }
Esempio n. 9
0
 public ListView.ListViewItemCollection getSessionList(ListView owner)
 {
     ListView.ListViewItemCollection colListVItem = new ListView.ListViewItemCollection(owner);
     int i = 1;
     ListViewItem t;
     foreach (Session s in Sessions)
     {
         t = new ListViewItem(i.ToString());
         t.SubItems.AddRange(s.getSubItems());
         t.Tag = s;
         colListVItem.Add(t);
         i++;
     }
     return colListVItem;
 }
        private void PopulateListView()
        {
            var itemCollection = new ListView.ListViewItemCollection(listView1);

            var articles = from c in GlobalValiables.Db.Table_Articles
                           where c.CategoryId == _categoryId
                           select c;

            foreach (Table_Article article in articles)
            {
                var item = new ListViewItem();
                item.SubItems.Add(article.ArticleId.ToString());
                item.SubItems.Add(article.Title);
                item.SubItems.Add(article.UpdateDate.ToShortDateString());
                item.SubItems.Add(article.CountViews.ToString());
                itemCollection.Add(item);
            }
            listView1.Refresh();
        }
Esempio n. 11
0
        private void buttonLoadFromArchive_Click(object sender, EventArgs e)
        {
            var form1 = new Form()
                            {
                                RightToLeft = RightToLeft.Yes,
                                RightToLeftLayout = true,
                                Height = 500,
                                Width = 700,
                                Name = String.Format(comboBox1.SelectedText + "רשימת תמונות מקטגוריה")
            };
            var listView = new ListView
            {
                View = View.Details,
                GridLines = true,
                FullRowSelect = true,
                CheckBoxes = false,
                AllowColumnReorder = true,
                LabelEdit = false,
                RightToLeftLayout = true,
                MultiSelect = false,
                Dock = DockStyle.Fill,
                Visible = true
            };

            listView.DoubleClick += SelectPhotoDoubleClick;

            listView.Columns.Add("מספר", 50, HorizontalAlignment.Center);
            listView.Columns.Add("שם התמונה", 650, HorizontalAlignment.Center);
            //listView.Columns.Add("שם הווידאו", 600, HorizontalAlignment.Center);

            var itemCollection = new ListView.ListViewItemCollection(listView);

            var photos = from c in Lookup.Db.Table_OriginalPhotosArchives
                         select c;
            foreach (Table_OriginalPhotosArchive photo in photos)
            {
                var item = new ListViewItem();
                item.SubItems.Add(photo.PhotoId.ToString());
                item.SubItems.Add(photo.Caption);
                itemCollection.Add(item);
            }
            
            form1.Controls.Add(listView);
            listView.Refresh();

            form1.Show();

        }