| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Windows;
- using System.Windows.Controls;
- using Common.Helper;
- using Model;
- namespace Modules.BehaviorTreeModule
- {
- /// <summary>
- /// NodeDataEditor.xaml 的交互逻辑
- /// </summary>
- public partial class NodeDataEditor
- {
- private readonly string[] nodeTypes;
- public NodeDataEditor()
- {
- this.InitializeComponent();
- this.nodeTypes = Enum.GetNames(typeof (NodeType));
- Array.Sort(this.nodeTypes);
- this.cbType.ItemsSource = this.nodeTypes;
- }
- public AllTreeView AllTreeView { get; set; }
- public TreeNodeViewModel TreeNodeViewModel
- {
- get
- {
- return this.DataContext as TreeNodeViewModel;
- }
- set
- {
- this.DataContext = value;
- }
- }
- private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (this.TreeNodeViewModel == null)
- {
- return;
- }
- string typeStr = ((NodeType) this.TreeNodeViewModel.Type).ToString();
- int selectIndex = Array.IndexOf(this.nodeTypes, typeStr);
- this.cbType.SelectedIndex = selectIndex;
- }
- private void CbType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this.TreeNodeViewModel == null)
- {
- return;
- }
- if (this.cbType.SelectedValue == null)
- {
- this.TreeNodeViewModel.Type = 0;
- return;
- }
- this.TreeNodeViewModel.Type =
- (int) EnumHelper.FromString<NodeType>(this.cbType.SelectedValue.ToString().Trim());
- }
- }
- }
|