Beispiel #1
0
		/// <summary>
		/// Метод для отображения файлов и деректорий в ListView
		/// </summary>
		/// <param name="data"></param>
		/// <returns></returns>
		public static async Task<bool> ViewFiles(Info data)
		{
			List<ListViewItem> lst = new List<ListViewItem>();
			ListOfType listType = ListOfType.GetInstance();

			#region old
			//         if (Directory.Exists(data.path))
			//{                    
			//	DirectoryInfo dir = new DirectoryInfo(data.path);
			//	DirectoryInfo[] dirs = dir.GetDirectories();
			//	FileInfo[] files = dir.GetFiles();

			//	if (data.path.Substring(data.path.Length - 2, 2) != ":\\")
			//	{
			//		ListViewItem lvitem = new ListViewItem();
			//		IOView tmp = new IOView();
			//		tmp.img = null;
			//                 tmp.Name = "..";
			//		tmp.Type = "";
			//		tmp.Size = "<DIR>";
			//		tmp.Time = "";
			//		lvitem.Content = tmp;
			//		lst.Add(lvitem);
			//	}

			//	foreach (DirectoryInfo item in dirs)
			//	{
			//		ListViewItem lvitem = new ListViewItem();
			//		IOView tmp = new IOView();
			//		tmp.img = GetIcon.Icon(item.Name, true, true);
			//		tmp.Name = item.Name;
			//		tmp.Type = "";
			//		tmp.Size = "<DIR>";
			//		tmp.Time = item.LastWriteTime.ToString();
			//		lvitem.Content = tmp;
			//		lst.Add(lvitem);

			//	}

			//	foreach (FileInfo item in files)
			//	{
			//		ListViewItem lvitem = new ListViewItem();
			//		IOView tmp = new IOView();
			//		tmp.img=GetIcon.Icon(item.Name,true,false);
			//		tmp.Name = WorkPath.GetNameFile(item.Name);
			//		tmp.Type = WorkPath.GetTypeFile(item.Name);

			//		//if (listType.TypeImage().Contains(tmp.Type))
			//		//{
			//		//	try
			//		//	{
			//		//		#region tooltip image
			//		//		Image img = new Image();
			//		//		img.Height = 320;

			//		//		BitmapImage t = new BitmapImage();
			//		//		t.BeginInit();
			//		//		t.UriSource = new Uri(data.path + tmp.Name + "." + tmp.Type);
			//		//		t.DecodePixelHeight = 320;
			//		//		t.EndInit();

			//		//		img.Source = t;
			//		//		ToolTip tp = new ToolTip();
			//		//		tp.Content = img;
			//		//		lvitem.ToolTip = tp;
			//		//		#endregion
			//		//	}
			//		//	catch (Exception error)
			//		//	{
			//		//		MessageBox.Show(error.ToString());
			//		//	}
			//		//}                            

			//		tmp.Size = Size.Convert(item.Length);
			//		tmp.Time = item.LastWriteTime.ToString();
			//		lvitem.Content = tmp;
			//		lst.Add(lvitem);
			//	}
			//}
			#endregion
			List<IOView> tmp = new List<IOView>();
			IOView a = new IOView();
			a.Name = "loading..";
			tmp.Add(a);
			data.lv.ItemsSource = tmp;
			data.lv.IsEnabled = false;
			data.lv.ItemsSource = await loading(data.path);
			data.lv.IsEnabled = true;

			#region Сортировка списка
			ListCollectionView dataView = (ListCollectionView)CollectionViewSource.GetDefaultView(data.lv.ItemsSource);
			SortLogic sort = new SortLogic(data);
			dataView.CustomSort = sort;
			#endregion

			return true;
		}
        /// <summary>
        /// Сортировка по полю
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GridViewColumnHeader_Click_1(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader column = sender as GridViewColumnHeader;
            string field = column.Tag as string;
            SortColumn sc = Work.ConvertColumns(field);
            if (PathR.SortColumn == sc)
            {
                if (PathR.direction == ListSortDirection.Ascending) PathR.direction = ListSortDirection.Descending;
                else PathR.direction = ListSortDirection.Ascending;
            }
            else PathR.direction = ListSortDirection.Ascending;
            PathR.SortColumn = sc;

            ListCollectionView dataView = (ListCollectionView)CollectionViewSource.GetDefaultView(FileViewR.ItemsSource);
            SortLogic sort = new SortLogic(PathR);
            dataView.CustomSort = sort;
        }