public void CheckButtonEnabled() { if (App._global._treeName == null || App._global._treeName == "") { SaveButton.IsEnabled = false; App._wnd.MenuSave.IsEnabled = false; } else { SaveButton.IsEnabled = true; App._wnd.MenuSave.IsEnabled = true; } TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); if (treeedit._tree.Count == 0) { SaveButton.IsEnabled = false; App._wnd.MenuSave.IsEnabled = false; SaveAsButton.IsEnabled = false; App._wnd.MenuSaveAs.IsEnabled = false; } else { SaveAsButton.IsEnabled = true; App._wnd.MenuSaveAs.IsEnabled = true; } }
// save tree to new file public void SaveToNewFile() { if (ValidateTree() == false) { return; } TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.OverwritePrompt = true; saveFileDialog.Filter = "Behavior Tree files (*.bht)|*.bht"; //saveFileDialog.InitialDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location + App._resourcesDir; saveFileDialog.InitialDirectory = App._projectDir + App._resourcesDir; if (saveFileDialog.ShowDialog() == true) { // get tree name from file string treename = saveFileDialog.SafeFileName; App._global._treeName = treename.Substring(0, treename.IndexOf('.')); treeedit.SaveTreeToFile(saveFileDialog.FileName); } }
// validate tree public bool ValidateTree() { TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); bool isvalid = treeedit.ValidateTree(); treeedit.OutputMessageBinding(); return(isvalid); }
public void LoadButton_Click(object sender, RoutedEventArgs e) { TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); if ((treeedit._tree.Count > 0) && (!Confirmation("Tree Not Empty.\nClear Old Tree?"))) { return; } LoadFromFile(); }
private void OKButton_Click(object sender, RoutedEventArgs e) { if (InputText.Text != null && InputText.Text != "") { App._global._treeName = InputText.Text; } TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); treeedit.UpdateTreeNameLabel(); this.Close(); }
// save tree to file public void SaveToFile() { if (ValidateTree() == false) { return; } if (App._global._treeName != null) { TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); string filename = App._projectDir + App._resourcesDir + App._global._treeName + ".bht"; treeedit.SaveTreeToFile(filename); } }
// load tree file public void LoadFromFile() { TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(App._wnd, "MyTreeEdit"); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Behavior Tree files (*.bht)|*.bht"; //openFileDialog.InitialDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location; openFileDialog.InitialDirectory = App._projectDir + App._resourcesDir; if (openFileDialog.ShowDialog() == true) { // get tree name from file string treename = openFileDialog.SafeFileName; App._global._treeName = treename.Substring(0, treename.IndexOf('.')); treeedit.LoadTreeFromFile(openFileDialog.FileName); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MyTreeEdit = ((BehaviorTreeEditor.TreeEdit)(target)); return; case 2: this.TreeNameLabel = ((System.Windows.Controls.Label)(target)); return; case 3: this.BTTree = ((System.Windows.Controls.TreeView)(target)); #line 33 "..\..\TreeEdit.xaml" this.BTTree.DragEnter += new System.Windows.DragEventHandler(this.BTTree_DragEnter); #line default #line hidden #line 34 "..\..\TreeEdit.xaml" this.BTTree.DragOver += new System.Windows.DragEventHandler(this.BTTree_DragOver); #line default #line hidden #line 35 "..\..\TreeEdit.xaml" this.BTTree.DragLeave += new System.Windows.DragEventHandler(this.BTTree_DragLeave); #line default #line hidden #line 36 "..\..\TreeEdit.xaml" this.BTTree.Drop += new System.Windows.DragEventHandler(this.BTTree_Drop); #line default #line hidden #line 37 "..\..\TreeEdit.xaml" this.BTTree.PreviewKeyDown += new System.Windows.Input.KeyEventHandler(this.BTTree_PreviewKeyDown); #line default #line hidden return; case 4: this.BTNodes = ((System.Windows.Controls.ListBox)(target)); #line 81 "..\..\TreeEdit.xaml" this.BTNodes.PreviewMouseMove += new System.Windows.Input.MouseEventHandler(this.BTNodes_PreviewMouseMove); #line default #line hidden #line 82 "..\..\TreeEdit.xaml" this.BTNodes.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.BTNodes_PreviewMouseLeftButtonUp); #line default #line hidden #line 83 "..\..\TreeEdit.xaml" this.BTNodes.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.BTNodes_SelectionChanged); #line default #line hidden #line 84 "..\..\TreeEdit.xaml" this.BTNodes.Loaded += new System.Windows.RoutedEventHandler(this.BTNodes_Loaded); #line default #line hidden return; case 5: this.OutputMessage = ((System.Windows.Controls.ListBox)(target)); #line 119 "..\..\TreeEdit.xaml" this.OutputMessage.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.OutputMessage_SelectionChanged); #line default #line hidden return; } this._contentLoaded = true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { TreeEdit treeedit = UIHelper.FindChild <TreeEdit>(this, "MyTreeEdit"); treeedit.UpdateTreeNameLabel(); }