/// <summary> /// Handles when a behaviour is supposed to be presented to the user. /// </summary> /// <param name="node">The behaviour which will be presented to the user.</param> private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node) { // check if there is a tab for the behaviour BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDock(node); BehaviorTreeView control = dock == null ? null : dock.BehaviorTreeView; // if not create one. if (control == null) { control = new BehaviorTreeView(); control.Dock = DockStyle.Fill; control.RootNode = node; control.EdgePen = _edgePen; control.EdgePenReadOnly = _edgePenReadOnly; control.BehaviorTreeList = behaviorTreeList; control.ClickNode += new BehaviorTreeView.ClickNodeEventDelegate(control_ClickNode); control.ClickEvent += new BehaviorTreeView.ClickEventEventDelegate(control_ClickEvent); control.DoubleClickNode += new BehaviorTreeView.ClickNodeEventDelegate(control_DoubleClickNode); dock = new BehaviorTreeViewDock(); dock.Text = ((Node)node).Label; dock.TabText = ((Node)node).Label; dock.BehaviorTreeView = control; dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document); } dock.Focus(); return(dock); }
/// <summary> /// Handles when a behaviour is supposed to be presented to the user. /// </summary> /// <param name="node">The behaviour which will be presented to the user.</param> private BehaviorTreeViewDock behaviorTreeList_ShowBehavior(BehaviorNode node) { // check if there is a tab for the behaviour BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDock(node); BehaviorTreeView control = dock == null ? null : dock.BehaviorTreeView; // if not create one. if (control == null) { dock = new BehaviorTreeViewDock(); dock.Title = ((Node)node).Label; control = dock.BehaviorTreeView; control.RootNode = node; control.EdgePen = _edgePen; control.EdgePenReadOnly = _edgePenReadOnly; control.BehaviorTreeList = behaviorTreeList; control.ClickNode += control_ClickNode; control.ClickEvent += control_ClickEvent; control.DoubleClickNode += control_DoubleClickNode; dock.Show(dockManager); dock.Activate(); } dock.Focus(); return(dock); }
/// <summary> /// Handles when a behaviour was renamed. /// </summary> /// <param name="node">The behaviour which was renamed.</param> private void behaviorTreeList_BehaviorRenamed(BehaviorNode node) { ((Node)node).DoWasModified(); BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDock(node); if (dock != null) { dock.Title = ((Node)node).Label; } }
/// <summary> /// Handles when behaviours must be cleared. /// </summary> /// <param name="nodes">The nodes which must be saved and closed.</param> /// <param name="result">Returns which behaviours could be saved or discarded.</param> /// <param name="error">Is true if there was an error and result contains any false.</param> private void behaviorTreeList_ClearBehaviors(List <BehaviorNode> nodes, out bool[] result, out bool error) { // try to save the behaviours SaveResult saveres = SaveBehaviors(nodes, out result); // update the error value error = saveres != SaveResult.Succeeded; // for each behaviour which was... for (int i = 0; i < nodes.Count; ++i) { // successfully saved... if (result[i]) { BehaviorTreeViewDock dock = BehaviorTreeViewDock.GetBehaviorTreeViewDock(nodes[i]); //if(dock !=null) // dock.Close(); } } }