Exemple #1
0
        /// <summary>
        /// Creates node with existing hierarchy
        /// </summary>
        /// <param name="group">Group in the hierarchy</param>
        /// <param name="groups">Group collection</param>
        /// <param name="layerMap">Selected layer map details</param>
        /// <returns>Last created group children</returns>
        private static GroupChildren CreateNode(Group group, List <GroupChildren> groups, LayerMap layerMap)
        {
            GroupChildren groupChildren = null;

            if (group.Parent != null)
            {
                GroupChildren parent = CreateNode(group.Parent, groups, layerMap);

                groupChildren = parent.Children.Where(child => child.Group != null && child.Group.Equals(group)).FirstOrDefault();
                if (groupChildren == null)
                {
                    groupChildren           = new GroupChildren();
                    groupChildren.Group     = group;
                    groupChildren.Name      = group.Name;
                    groupChildren.IsDeleted = group.IsDeleted;

                    parent.AllChildren.Add(groupChildren);
                    parent.Children.Add(groupChildren);
                }
            }
            else
            {
                groupChildren = groups.Where(groupValue => groupValue.Group != null && groupValue.Group.Equals(group)).FirstOrDefault();
                if (groupChildren == null)
                {
                    groupChildren           = new GroupChildren();
                    groupChildren.Group     = group;
                    groupChildren.Name      = group.Name;
                    groupChildren.IsDeleted = group.IsDeleted;
                    groups.Add(groupChildren);
                }
            }

            return(groupChildren);
        }
Exemple #2
0
 /// <summary>
 /// Builds group collection with the current layer map and groups
 /// </summary>
 /// <param name="layerMap">Selected layer map</param>
 /// <param name="groups">Collection of groups</param>
 /// <returns>Collection of groups with reference frame and layers</returns>
 internal static List <GroupChildren> BuildGroupCollection(this LayerMap layerMap, List <GroupChildren> groups)
 {
     if (layerMap != null && layerMap.LayerDetails.Group != null && groups != null)
     {
         if (layerMap.LayerDetails.Group.Parent != null)
         {
             GroupChildren groupItem = groups.Where(groupValue => groupValue.Group != null && groupValue.Group.Equals(layerMap.LayerDetails.Group.Parent)).FirstOrDefault();
             if (groupItem != null)
             {
                 GroupChildren groupChildNode = groupItem.Children.Where(childNodes => childNodes.Group.Equals(layerMap.LayerDetails.Group)).FirstOrDefault();
                 if (groupChildNode != null)
                 {
                     layerMap.Name = LayerDetailsViewModel.GetLayerNameOnMapType(layerMap, layerMap.LayerDetails.Name);
                     groupChildNode.AllChildren.Add(layerMap);
                 }
                 else
                 {
                     GroupChildren childNode = AddChildNodesToGroup(layerMap);
                     groupItem.Children.Add(childNode);
                     groupItem.AllChildren.Add(childNode);
                 }
             }
             else
             {
                 AddLayerNode(groups, layerMap);
             }
         }
         else
         {
             AddLayerNode(groups, layerMap);
         }
     }
     return(groups);
 }
Exemple #3
0
        /// <summary>
        /// Creates nodes and add layer to the existing node
        /// </summary>
        /// <param name="groups">Group collection with layer and reference frame groups</param>
        /// <param name="layerMap">Selected layer map details</param>
        private static void AddLayerNode(List <GroupChildren> groups, LayerMap layerMap)
        {
            if (layerMap != null && groups != null)
            {
                GroupChildren parent = CreateNode(layerMap.LayerDetails.Group, groups, layerMap);
                layerMap.Name = LayerDetailsViewModel.GetLayerNameOnMapType(layerMap, layerMap.LayerDetails.Name);

                // Add Layer to the parent group.
                parent.AllChildren.Add(layerMap);
            }
        }
Exemple #4
0
        /// <summary>
        /// Add child node to existing group
        /// </summary>
        /// <param name="layerMap">Selected layer map</param>
        /// <returns>Child node for group children</returns>
        private static GroupChildren AddChildNodesToGroup(LayerMap layerMap)
        {
            GroupChildren childNode = new GroupChildren();

            if (layerMap != null)
            {
                childNode.Group = layerMap.LayerDetails.Group;
                childNode.Name  = layerMap.LayerDetails.Group.Name;
                childNode.Layers.Add(layerMap.LayerDetails);
                layerMap.Name = LayerDetailsViewModel.GetLayerNameOnMapType(layerMap, layerMap.LayerDetails.Name);
                childNode.AllChildren.Add(layerMap);
                childNode.IsDeleted = layerMap.LayerDetails.Group.IsDeleted;
            }
            return(childNode);
        }
        public void BuildGroupCollectionTest()
        {
            Application application = new Application();

            try
            {
                Group parentGroup = new Group("Sun", GroupType.ReferenceFrame, null);
                Group childGroup = new Group("Earth", GroupType.ReferenceFrame, parentGroup);
                Layer layer = new Layer();
                layer.Name = "Layer1";
                layer.Group = childGroup;
                Layer layerMap = new Layer();
                layerMap.Name = "Layer2";
                layerMap.Group = new Group("Sun", GroupType.ReferenceFrame, null);
                LayerMap localLayerMap = new LayerMap(layer);
                localLayerMap.MapType = LayerMapType.Local;
                LayerMap wwtLayerMap = new LayerMap(layerMap);
                wwtLayerMap.MapType = LayerMapType.WWT;

                List<GroupChildren> wwtGroups = new List<GroupChildren>();
                List<GroupChildren> localGroups = new List<GroupChildren>();
                List<GroupChildren> existingGroups = new List<GroupChildren>();
                List<GroupChildren> groupwithChildren = new List<GroupChildren>();
                GroupChildren children = new GroupChildren();
                children.Group = parentGroup;
                GroupChildren children1 = new GroupChildren();
                children1.Group = childGroup;
                GroupChildren childNode = new GroupChildren();
                childNode.Group = parentGroup;
                childNode.Children.Add(children1);
                existingGroups.Add(children);
                groupwithChildren.Add(childNode);
                LayerMapExtensions.BuildGroupCollection(wwtLayerMap, wwtGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, localGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, existingGroups);
                LayerMapExtensions.BuildGroupCollection(localLayerMap, groupwithChildren);

                Assert.AreEqual(1, wwtGroups.Count);
                foreach (GroupChildren child in wwtGroups)
                {
                    Assert.AreEqual(1, child.AllChildren.Count);
                    Assert.AreEqual("Sun", child.Name);
                }

                Assert.AreEqual(1, localGroups.Count);
                foreach (GroupChildren child in localGroups)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    Assert.AreEqual("Sun", child.Name);
                }

                Assert.AreEqual(1, existingGroups.Count);
                foreach (GroupChildren child in existingGroups)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    foreach (GroupChildren childrenVal in child.Children)
                    {
                        Assert.AreEqual("Earth", childrenVal.Name);
                    }
                }

                Assert.AreEqual(1, groupwithChildren.Count);
                foreach (GroupChildren child in groupwithChildren)
                {
                    Assert.AreEqual(1, child.Children.Count);
                    foreach (GroupChildren childrenVal in child.Children)
                    {
                        Assert.AreEqual(1, childrenVal.AllChildren.Count);
                    }
                }
            }
            finally
            {
                application.Close();
            }
        }
        /// <summary>
        /// Creates node with existing hierarchy
        /// </summary>
        /// <param name="group">Group in the hierarchy</param>
        /// <param name="groups">Group collection</param>
        /// <param name="layerMap">Selected layer map details</param>
        /// <returns>Last created group children</returns>
        private static GroupChildren CreateNode(Group group, List<GroupChildren> groups, LayerMap layerMap)
        {
            GroupChildren groupChildren = null;
            if (group.Parent != null)
            {
                GroupChildren parent = CreateNode(group.Parent, groups, layerMap);

                groupChildren = parent.Children.Where(child => child.Group != null && child.Group.Equals(group)).FirstOrDefault();
                if (groupChildren == null)
                {
                    groupChildren = new GroupChildren();
                    groupChildren.Group = group;
                    groupChildren.Name = group.Name;
                    groupChildren.IsDeleted = group.IsDeleted;

                    parent.AllChildren.Add(groupChildren);
                    parent.Children.Add(groupChildren);
                }
            }
            else
            {
                groupChildren = groups.Where(groupValue => groupValue.Group != null && groupValue.Group.Equals(group)).FirstOrDefault();
                if (groupChildren == null)
                {
                    groupChildren = new GroupChildren();
                    groupChildren.Group = group;
                    groupChildren.Name = group.Name;
                    groupChildren.IsDeleted = group.IsDeleted;
                    groups.Add(groupChildren);
                }
            }

            return groupChildren;
        }
 /// <summary>
 /// Add child node to existing group
 /// </summary>
 /// <param name="layerMap">Selected layer map</param>
 /// <returns>Child node for group children</returns>
 private static GroupChildren AddChildNodesToGroup(LayerMap layerMap)
 {
     GroupChildren childNode = new GroupChildren();
     if (layerMap != null)
     {
         childNode.Group = layerMap.LayerDetails.Group;
         childNode.Name = layerMap.LayerDetails.Group.Name;
         childNode.Layers.Add(layerMap.LayerDetails);
         layerMap.Name = LayerDetailsViewModel.GetLayerNameOnMapType(layerMap, layerMap.LayerDetails.Name);
         childNode.AllChildren.Add(layerMap);
         childNode.IsDeleted = layerMap.LayerDetails.Group.IsDeleted;
     }
     return childNode;
 }