public void Execute()
        {
            if (tree == null)
            {
                tree = new Tree(name, filename, scale, scaleVariance, instances, forest, app);
            }
            this.forest.Add(tree);

            for (int i = app.SelectedObject.Count - 1; i >= 0; i--)
            {
                app.SelectedObject[i].Node.UnSelect();
            }
            if (tree.Node != null)
            {
                tree.Node.Select();
            }
        }
        public void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                    case "Name":
                        this.name = r.Value;
                        break;
                    case "Filename":
                        this.filename = r.Value;
                        break;
                    case "WindSpeed":
                        this.windSpeed = float.Parse(r.Value);
                        break;
                    case "Seed":
                        this.seed = int.Parse(r.Value);
                        break;
                    case "WindDirection":
                        windDirection = XmlHelperClass.ParseVectorAttributes(r);
                        break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            if (!r.IsEmptyElement)
            {
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                            case "Tree":
                                Tree t = new Tree(r, this, app);
                                Add(t);
                                break;
                        }
                    }
                }
            }
        }
        protected void LoadOldBoundary(XmlNode node, WorldObjectCollection collection)
        {
            string name = null;
            XmlNode pointsNode = null;
            XmlNode semanticsNode = null;
            // int priority;

            // get the name
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "Name":
                        name = childNode.InnerText;
                        break;
                    case "Points":
                        pointsNode = childNode;
                        break;
                    case "Attributes":
                        semanticsNode = childNode;
                        break;
                    default:
                        break;
                }
            }

            // if the boundary has no points, just call it bogus and return
            if (pointsNode == null)
            {
                return;
            }

            // create and add the boundary to the world
            Boundary boundary = new Boundary(collection, this, name, 100);
            collection.Add(boundary);

            // set up the points
            foreach (XmlNode pointNode in pointsNode.ChildNodes)
            {
                if (pointNode.Name == "Point")
                {
                    XmlNode locNode = pointNode.SelectSingleNode("Position");
                    Vector3 pointPos = GetVectorAttributes(locNode);

                    int pointNum;
                    boundary.Points.AddPoint(pointPos, out pointNum);
                }
            }

            if (semanticsNode != null)
            {
                // handle boundary semantics
                foreach (XmlNode semanticNode in semanticsNode.ChildNodes)
                {
                    switch (semanticNode.Name)
                    {
                        case "WaterAttribute":
                            XmlNode heightNode = semanticNode.SelectSingleNode("Height");
                            float height = float.Parse(heightNode.InnerText);
                            Water water = new Water(height, boundary, this);
                            boundary.Add(water);
                            break;
                        case "ForestAttribute":
                            XmlNode seedNode = semanticNode.SelectSingleNode("Seed");
                            int seed = int.Parse(seedNode.InnerText);

                            XmlNode speedWindNode = semanticNode.SelectSingleNode("SpeedWindFile");
                            string speedWindFile = speedWindNode.InnerText;

                            XmlNode windSpeedNode = semanticNode.SelectSingleNode("WindSpeed");
                            float windSpeed = float.Parse(windSpeedNode.InnerText);

                            XmlNode windDirNode = semanticNode.SelectSingleNode("WindDirection");
                            Vector3 windDir = GetVectorAttributes(windDirNode);

                            // Add the forest object
                            Forest forest = new Forest(speedWindFile, windSpeed, windDir, seed, boundary, this);
                            boundary.Add(forest);

                            XmlNode treeTypesNode = semanticNode.SelectSingleNode("TreeTypes");
                            if (treeTypesNode != null)
                            {
                                foreach (XmlNode treeTypeNode in treeTypesNode.ChildNodes)
                                {
                                    XmlNode treeNameNode = treeTypeNode.SelectSingleNode("TreeName");
                                    string treeName = treeNameNode.InnerText;

                                    XmlNode treeFilenameNode = treeTypeNode.SelectSingleNode("TreeDescriptionFilename");
                                    string treeFilename = treeFilenameNode.InnerText;

                                    XmlNode scaleNode = treeTypeNode.SelectSingleNode("Scale");
                                    float scale = float.Parse(scaleNode.InnerText);

                                    XmlNode scaleVarianceNode = treeTypeNode.SelectSingleNode("ScaleVariance");
                                    float scaleVariance = float.Parse(scaleVarianceNode.InnerText);

                                    XmlNode instancesNode = treeTypeNode.SelectSingleNode("Instances");
                                    uint instances = uint.Parse(instancesNode.InnerText);

                                    Tree tree = new Tree(treeName, treeFilename, scale, scaleVariance, instances, forest, this);
                                    forest.Add(tree);
                                }
                            }

                            break;
                        case "Fog":
                            XmlNode redNode = semanticNode.SelectSingleNode("ColorRed");
                            int red = int.Parse(redNode.InnerText);

                            XmlNode greenNode = semanticNode.SelectSingleNode("ColorGreen");
                            int green = int.Parse(greenNode.InnerText);

                            XmlNode blueNode = semanticNode.SelectSingleNode("ColorBlue");
                            int blue = int.Parse(blueNode.InnerText);

                            XmlNode nearNode = semanticNode.SelectSingleNode("Near");
                            float near = float.Parse(nearNode.InnerText);

                            XmlNode farNode = semanticNode.SelectSingleNode("Far");
                            float far = int.Parse(farNode.InnerText);

                            ColorEx fogColor = new ColorEx(((float)red) / 255f, ((float)green) / 255f, ((float)blue) / 255f);
                            Fog fog = new Fog(this, boundary, fogColor, near, far);
                            boundary.Add(fog);

                            break;
                        case "Sound":
                            break;
                        default:
                            break;
                    }
                }
            }
        }
 public void Clone(IWorldContainer copyParent)
 {
     Tree clone = new Tree(name, descriptionFilename, scale, scaleVariance, instances, copyParent as Forest, app);
     copyParent.Add(clone);
 }
        public void Clone(IWorldContainer copyParent)
        {
            Tree clone = new Tree(name, descriptionFilename, scale, scaleVariance, instances, copyParent as Forest, app);

            copyParent.Add(clone);
        }