Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            string[] titles = { "文件名", "路径", "大小" };
            for (var i = 0; i < titles.Length; i++)
            {
                ColumnHeader ch = new ColumnHeader
                {
                    Text      = titles[i],
                    Width     = 120,
                    TextAlign = HorizontalAlignment.Left
                };
                FileListView.Columns.Add(ch);
                FileListView.BeginUpdate();
            }
            FileListView.View = View.Details;
        }
Esempio n. 2
0
 private void UpdateListView(FileInfo[] files)
 {
     if (files != null && files.Length > 0)
     {
         FileListView.BeginUpdate();
         FileListView.Items.Clear();
         foreach (var file in files)
         {
             var          index = FileListView.Items.Count + 1;
             ListViewItem lvi   = new ListViewItem
             {
                 ImageIndex = index,
                 Text       = file.Name
             };
             lvi.SubItems.Add(file.Directory.FullName);
             lvi.SubItems.Add(Files.GetFileSizeFormat(file.Length));
             FileListView.Items.Add(lvi);
         }
         FileListView.EndUpdate();
     }
 }
Esempio n. 3
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case WM_WORKER_DONE:
            {
                try
                {
                    pictureBox1.Image = null;

                    if ((items != null) && (items.Count > 0))
                    {
                        FileListView.BeginUpdate();
                        FileListView.Items.AddRange(items.ToArray());
                        FileListView.EndUpdate();

                        if (input != "")
                        {
                            int select_index = -1;
                            for (int index = 0; index < items.Count; ++index)
                            {
                                if (String.Equals(FileListView.Items[index].Text, input, StringComparison.OrdinalIgnoreCase))                                          // if there's an exact match, select it
                                {
                                    select_index = index;
                                    break;
                                }
                            }

                            if (select_index == -1)                                      // if we didn't find an exact match, find the first string that begins with the input text and select it
                            {
                                for (int index = 0; index < items.Count; ++index)
                                {
                                    if (FileListView.Items[index].Text.IndexOf(input, StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        select_index = index;
                                        break;
                                    }
                                }
                            }

                            if (select_index >= 0)
                            {
                                FileListView.Items[select_index].Selected = true;
                                FileListView.Items[select_index].Focused  = true;
                                FileListView.EnsureVisible(select_index);
                            }
                        }

                        SetListViewLastColumnWidth();
                    }
                }
                catch
                {
                }

                WorkerThread.Join();
                WorkerThread = null;
            }
            break;
            }

            base.WndProc(ref m);
        }