示例#1
0
        public void Delete(Component ComponentToDelete)
        {
            // ---------------------------------------------------------------------
            // Delete the specified child component. We need to scan all components
            // recursively looking for a shortcut that points to this component or
            // any of our children that we're about to delete. If found then make
            // the shortcut node concrete.
            // ---------------------------------------------------------------------
            List <Component> AllChildNodes = new List <Component>();

            ComponentToDelete.ChildNodesRecursively(AllChildNodes);
            AllChildNodes.Add(ComponentToDelete);
            MyFile.RootComponent.MakeShortCutsConrete(AllChildNodes);
            ChildNodes.Remove(ComponentToDelete);
            MyFile.PublishComponentChanged(this);
        }
        public static void GetComponentPathsWithinScopeOf(Component C, ref List<string> Paths)
        {
            if (C != null)
            {
                // Find the containing area, simulation or folder whichever comes first.
                Component Paddock = C;
                while (Paddock != null && Paddock.Type != "area" && Paddock.Type != "simulation" && Paddock.Type != "folder")
                    Paddock = Paddock.Parent;

                List<Component> AllComponents = new List<Component>();
                Paddock.ChildNodesRecursively(AllComponents);

                foreach (Component Comp in AllComponents)
                    Paths.Add(Comp.FullPath);
            }
        }
示例#3
0
        public Component FindComponentInPaddock(Component To, string Name)
        {
            // Find a component in the paddockthe nearest component to "To" that has the specified "Name".
            // It won't look down the simulation hierarchy and won't look
            // outside the paddock.
            Component Paddock = FindContainingPaddock();

            if (Paddock != null)
            {
                List <Component> ComponentsInPaddock = new List <Component>();
                Paddock.ChildNodesRecursively(ComponentsInPaddock);
                foreach (Component ChildComponent in ComponentsInPaddock)
                {
                    if (ChildComponent.Name.ToLower() == Name.ToLower() && ChildComponent.Type != "SoilCrop")
                    {
                        return(ChildComponent);
                    }
                }
            }
            return(null);
        }