예제 #1
0
        public StationGroup AddStation(Station station)
        {
            StationGroup new_group = FindGroupForStation(station);
            StationGroup old_group = station.Parent as StationGroup;

            if (new_group == old_group && old_group != null)
            {
                return(new_group);
            }

            if (old_group != null)
            {
                old_group.RemoveChild(station);

                if (old_group.ChildCount == 0)
                {
                    RemoveNode(old_group);
                }
            }

            if (new_group == null || old_group == null)
            {
                new_group = CreateGroup(station.Group);
                AddNode(new_group);
            }

            new_group.AddChild(station);
            return(new_group);
        }
예제 #2
0
        public StationStore(Stations stations) : base(typeof(Station))
        {
            this.stations = stations;

            foreach (Station station in stations.List)
            {
                StationGroup group = FindGroupForStation(station);
                if (group == null)
                {
                    group = CreateGroup(station.Group);
                    AddNode(group);
                }

                group.AddChild(station);
            }
        }