FolderTreeViewItem.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Controls;
  6. using System.Windows.Media;
  7. using System.Windows.Media.Imaging;
  8. namespace Aitex.Core.UI.View.Common
  9. {
  10. public class TreeViewFileItem : TreeViewItem
  11. {
  12. public TreeViewFileItem(string fileName)
  13. {
  14. FileName = fileName;
  15. Image image = new Image();
  16. image.Stretch = Stretch.Fill;
  17. image.Source = new BitmapImage(new Uri(@"/MECF.Framework.Common;component/Resources/RecipeFile.png", UriKind.Relative));
  18. TextBlock txtBNode = new TextBlock();
  19. int lastIndex = FileName.LastIndexOf('\\');
  20. if (lastIndex >= 0)
  21. txtBNode.Text = fileName.Substring(lastIndex + 1);
  22. else
  23. txtBNode.Text = fileName;
  24. StackPanel panel = new StackPanel();
  25. panel.Children.Add(image);
  26. panel.Children.Add(txtBNode);
  27. panel.Orientation = Orientation.Horizontal;
  28. this.Header = panel;
  29. }
  30. public string FileName
  31. {
  32. get;
  33. set;
  34. }
  35. }
  36. public class TreeViewFolderItem : TreeViewItem
  37. {
  38. public string FolderName
  39. {
  40. set;
  41. get;
  42. }
  43. public TreeViewFolderItem(string folderName)
  44. {
  45. FolderName = folderName;
  46. Image image = new Image();
  47. image.Stretch = Stretch.Fill;
  48. image.Source = new BitmapImage(new Uri(@"/MECF.Framework.Common;component/Resources/RecipeFolder.png", UriKind.Relative));
  49. TextBlock txtBNode = new TextBlock();
  50. txtBNode.Text = folderName;
  51. StackPanel panel = new StackPanel();
  52. panel.Children.Add(image);
  53. panel.Children.Add(txtBNode);
  54. panel.Orientation = Orientation.Horizontal;
  55. this.Header = panel;
  56. }
  57. }
  58. }