/// <summary> /// Handles when the new behaviour button is clicked. /// </summary> private void newBehaviorButton_Click(object sender, EventArgs e) { // create a new behaviour node with a unique label Nodes.Behavior node= new Nodes.Behavior( GetUniqueLabel("New Behavior", _lastNewBehavior, out _lastNewBehavior) ); // get updated when the behaviour changes node.WasSaved+= new Behavior.WasSavedEventDelegate(behavior_WasSaved); node.WasModified+= new Node.WasModifiedEventDelegate(behavior_WasModified); // mark node as being modified node.FileManager= null; // add the behaviour to the list _newBehaviors.Add(node); // update behaviours shown in the node explorer RebuildBehaviorList(); // trigger the ShowBehavior event if(ShowBehavior !=null) ShowBehavior(node); }
/// <summary> /// Loads a behaviour from the given filename /// </summary> public override void Load() { try { if (_filename.StartsWith("http://")) { string behaviorText = HttpGet(_filename); _xmlfile.LoadXml(behaviorText); } else { _xmlfile.Load(_filename); } XmlNode root=null; if (_xmlfile.ChildNodes.Count>1) root = _xmlfile.ChildNodes[1].ChildNodes[0]; else root = _xmlfile.ChildNodes[0]; if (_filename.ToLower ().EndsWith(".btx")) { Node node = new Behavior(); node.AddChild(node.DefaultConnector, CreateNode(root)); _node = (BehaviorNode)node; } else { _node = (BehaviorNode)CreateNode(root); } _node.FileManager = this; DoPostLoad((Node)_node); } catch { _xmlfile.RemoveAll(); throw; } }