internal void RefreshSameContent(IBehaviorItem item) { foreach (TreeViewFolder tvf in _TreeView.Controls) { tvf.RefreshSameContent(item); } }
public void RefreshChildren() { // check if any changes happened bool change = false; if (Data.Count != this.Controls.Count) { change = true; } else { for (int i = 0; i < this.Controls.Count; i++) { if (((IBehaviorItem)this.Controls[i]).Data != Data[i]) { change = true; break; } } } if (change) { List <IBehaviorItem> controls = new List <IBehaviorItem>(); for (int i = 0; i < this.Controls.Count; i++) { controls.Add(this.Controls[i] as IBehaviorItem); } this.Controls.Clear(); for (int i = 0; i < Data.Count; i++) { IBehaviorItem item = Find(controls, Data[i]); if (item == null) { item = CreateItem(Data[i]) as IBehaviorItem; } if (item != null) { controls.Remove(item); this.Controls.Add(item as Skill.Framework.UI.BaseControl); } } } foreach (var item in this.Controls) { if (item is TreeViewFolder) { ((TreeViewFolder)item).RefreshChildren(); } } }
private void CheckMenuAvailable() { IBehaviorItem selected = null; if (_TreeView.SelectedItem != null) { selected = _TreeView.SelectedItem as IBehaviorItem; } bool canDelete = true; bool canNew = false; bool canMoveUp = false; bool canMoveDown = false; if (selected != null) { if (selected.Data.BehaviorType == Framework.AI.BehaviorType.Composite) { CompositeData composite = (CompositeData)selected.Data; if (composite.CompositeType == Framework.AI.CompositeType.State) { canDelete = false; } canNew = true; } else if (selected.Data.BehaviorType == Framework.AI.BehaviorType.Decorator) { DecoratorData decorator = (DecoratorData)selected.Data; canNew = decorator.Count == 0; } else { canNew = false; } canMoveUp = selected.CanMoveUp; canMoveDown = selected.CanMoveDown; } else { canDelete = false; canNew = false; canMoveUp = false; canMoveDown = false; } _BtnMoveUp.IsEnabled = canMoveUp; _BtnMoveDown.IsEnabled = canMoveDown; _BtnRemoveBehavior.IsEnabled = canDelete; //_BtnCopyBehavior.IsEnabled = canDelete; _AddBehaviorMenuItem.IsEnabled = canNew; _InsertBehaviorMenuItem.IsEnabled = canNew; }
private void RemoveSelectedBehavior() { if (_TreeView.SelectedItem == null) { return; } IBehaviorItem item = _TreeView.SelectedItem as IBehaviorItem; TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem.Parent; tvf.RemoveBehavior(item); SelectItem(null); }
/// <summary> /// Remove specyfied child /// </summary> /// <param name="child">child to remove</param> /// <returns>true if sucess, otherwise false</returns> public bool RemoveBehavior(IBehaviorItem child) { //int index = this.Controls.IndexOf((Skill.Framework.UI.BaseControl)child); if (this.Controls.Remove((Skill.Framework.UI.BaseControl)child)) { this.Data.Remove(child.Data); Editor.RefreshTree(); //Tree.History.Insert(new AddBehaviorUnDoRedo(child, parameters, this, index, true)); return(true); } return(false); }
private void MoveDown() { if (_TreeView.SelectedItem == null) { return; } IBehaviorItem item = _TreeView.SelectedItem as IBehaviorItem; if (item.CanMoveDown) { TreeViewFolder tvf = (TreeViewFolder)_TreeView.SelectedItem.Parent; tvf.MoveDown(item); SelectItem(tvf, item.Data); } }
/// <summary> /// Move given child down (index + 1) /// </summary> /// <param name="child">child to move</param> public void MoveDown(IBehaviorItem child) { if (child.CanMoveDown) { int index = Controls.IndexOf((Skill.Framework.UI.BaseControl)child); if (index >= 0) { this.Controls.Remove((Skill.Framework.UI.BaseControl)child); this.Controls.Insert(index + 1, (Skill.Framework.UI.BaseControl)child); this.Data.Move(index, index + 1); Editor.RefreshTree(); //Tree.History.Insert(new MoveUpBehaviorUnDoRedo(child, this, true)); } } }
private void SelectItem(TreeViewFolder folder, BehaviorData behavior) { foreach (var control in folder.Controls) { IBehaviorItem item = (IBehaviorItem)control; if (item.Data == behavior) { _TreeView.SelectedItem = control; return; } if (control is TreeViewFolder) { SelectItem((TreeViewFolder)control, behavior); } } }
/// <summary> /// Move given child up (index - 1) /// </summary> /// <param name="child">child to move</param> public void MoveUp(IBehaviorItem child) { if (child.CanMoveUp) { int index = Controls.IndexOf((Skill.Framework.UI.BaseControl)child); if (index > 0 && index < this.Controls.Count) { // decrease index one unit this.Controls.Remove((Skill.Framework.UI.BaseControl)child); this.Controls.Insert(index - 1, (Skill.Framework.UI.BaseControl)child); this.Data.Move(index, index - 1); Editor.RefreshTree(); //Tree.History.Insert(new MoveUpBehaviorUnDoRedo(child, this)); } } }
public virtual void RefreshSameContent(IBehaviorItem bi) { if (this.Data == bi.Data) { base.Foldout.Content.text = AppendParameters(Data.Name); } foreach (IBehaviorItem item in this.Controls) { if (item is TreeViewItem) { if (item.Data == bi.Data) { item.RefreshContent(); } } else if (item is TreeViewFolder) { ((TreeViewFolder)item).RefreshSameContent(bi); } } }
public ParameterEditor(IBehaviorItem item, ParameterDataCollection dataDifinition, ParameterDataCollection data) { _Item = item; _DataDifinition = dataDifinition; _Data = data; this._RefreshStyle = true; this.RowDefinitions.Add(16, Skill.Framework.UI.GridUnitType.Pixel); // title this.RowDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); // list this.RowDefinitions.Add(16, Skill.Framework.UI.GridUnitType.Pixel); // buttons _Title = new Framework.UI.Label { Row = 0, Text = "Parameters" }; this.Controls.Add(_Title); _FieldsList = new Skill.Framework.UI.ListBox() { Row = 1 }; _FieldsList.DisableFocusable(); _FieldsList.BackgroundVisible = true; this.Controls.Add(_FieldsList); _ButtonsPanel = new Framework.UI.Grid() { Row = 2 }; _ButtonsPanel.ColumnDefinitions.Add(1, Skill.Framework.UI.GridUnitType.Star); _ButtonsPanel.ColumnDefinitions.Add(20, Skill.Framework.UI.GridUnitType.Pixel); _ButtonsPanel.ColumnDefinitions.Add(20, Skill.Framework.UI.GridUnitType.Pixel); this.Controls.Add(_ButtonsPanel); _BtnAddImage = new Framework.UI.Image() { Column = 1 }; _ButtonsPanel.Controls.Add(_BtnAddImage); _BtnAdd = new UI.IntPopup() { Column = 1 }; _BtnAdd.Options.Add(new UI.PopupOption(1, "float")); _BtnAdd.Options.Add(new UI.PopupOption(2, "int")); _BtnAdd.Options.Add(new UI.PopupOption(3, "bool")); _BtnAdd.Options.Add(new UI.PopupOption(4, "string")); _ButtonsPanel.Controls.Add(_BtnAdd); _BtnRemove = new Framework.UI.Button() { Column = 2, IsEnabled = false }; _ButtonsPanel.Controls.Add(_BtnRemove); _BtnAdd.OptionChanged += _BtnAdd_OptionChanged; _BtnRemove.Click += _BtnRemove_Click; _FieldsList.SelectionChanged += _FieldsList_SelectionChanged; Rebuild(); }
internal void RefreshSameContent(IBehaviorItem item) { _TreeViewEditor.RefreshSameContent(item); }