FolderTreeViewItem.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if (this.IsSelected)
  30. {
  31. panel.Background = Brushes.Aqua;
  32. }
  33. }
  34. public string FileName
  35. {
  36. get;
  37. set;
  38. }
  39. }
  40. public class TreeViewFolderItem : TreeViewItem
  41. {
  42. public string FolderName
  43. {
  44. set;
  45. get;
  46. }
  47. public TreeViewFolderItem(string folderName)
  48. {
  49. FolderName = folderName;
  50. Image image = new Image();
  51. image.Stretch = Stretch.Fill;
  52. image.Source = new BitmapImage(new Uri(@"/MECF.Framework.Common;component/Resources/RecipeFolder.png", UriKind.Relative));
  53. TextBlock txtBNode = new TextBlock();
  54. txtBNode.Text = folderName;
  55. StackPanel panel = new StackPanel();
  56. panel.Children.Add(image);
  57. panel.Children.Add(txtBNode);
  58. panel.Orientation = Orientation.Horizontal;
  59. this.Header = panel;
  60. }
  61. }
  62. }