BehaviorTreeView.xaml.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using System.ComponentModel.Composition;
  15. using Infrastructure;
  16. namespace BehaviorTree
  17. {
  18. /// <summary>
  19. /// TreeCanvasView.xaml 的交互逻辑
  20. /// </summary>
  21. [ViewExport(RegionName = "TreeCanvasRegion")]
  22. [PartCreationPolicy(CreationPolicy.NonShared)]
  23. public partial class BehaviorTreeView : UserControl
  24. {
  25. public BehaviorTreeView()
  26. {
  27. InitializeComponent();
  28. }
  29. [Import]
  30. BehaviorTreeViewModel ViewModel
  31. {
  32. get
  33. {
  34. return this.DataContext as BehaviorTreeViewModel;
  35. }
  36. set
  37. {
  38. this.DataContext = value;
  39. }
  40. }
  41. private void NewNode_Executed(object sender, ExecutedRoutedEventArgs e)
  42. {
  43. Point point = Mouse.GetPosition(lstTree);
  44. var treeNode = new TreeNode(point.X, point.Y);
  45. this.ViewModel.Add(treeNode, null);
  46. }
  47. }
  48. }