コード例 #1
0
ファイル: Rectangle.cs プロジェクト: Kryxzael/CleanNodeTree
        public HierarchyNode SerializeNode()
        {
            var _ = new HierarchyNode("Rect");

            _.Add("x", X);
            _.Add("y", Y);
            _.Add("w", Width);
            _.Add("h", Height);

            return(_);
        }
コード例 #2
0
        /// <summary>
        /// Creates a hierarchy node instance from the data in the to-time tab
        /// </summary>
        /// <returns></returns>
        protected HierarchyNode CreateNodeFromToTime()
        {
            HierarchyNode node = new HierarchyNode("CountdownPreset");

            //We are saving a to-time preset
            //Create header
            node.Add("PresetType", "toTime");

            //Advanced mode
            node.Add("EnableExtendedSelector", chkAdv.Checked);

            //Create target structure
            HierarchyNode targetNode = node.Add("Target");

            {
                if (chkAdv.Checked)
                {
                    //Date node
                    targetNode.Add("Date");
                    {
                        targetNode["Date"].Add("Year", numYear.Value);
                        targetNode["Date"].Add("Month", knbMonth.Value);
                        targetNode["Date"].Add("Day", knbDay.Value);
                    }
                }

                //Time node
                targetNode.Add("Time");
                {
                    targetNode["Time"].Add("Hour", knbHour.Value);
                    targetNode["Time"].Add("Minute", knbMin.Value);
                    if (chkAdv.Checked)
                    {
                        targetNode["Time"].Add("Second", knbSec.Value);
                    }
                }
            }

            //Create color scheme node
            node.Add("ColorScheme", cboxColors.SelectedIndex);

            //Create Stop at Zero node
            node.Add("StopAtZero", chkStopAtZero.Checked);
            return(node);
        }
コード例 #3
0
        /// <summary>
        /// Creates a hierarchy node instance from the data in the duration tab
        /// </summary>
        /// <returns></returns>
        protected HierarchyNode CreateNodeFromDuration()
        {
            HierarchyNode node = new HierarchyNode("CountdownPreset");

            //Create header
            node.Add("PresetType", "duration");

            //Create target structure
            HierarchyNode targetNode = node.Add("Target");

            {
                targetNode.Add("Hours", knbDurHour.Value);
                targetNode.Add("Minutes", knbDurMin.Value);
                targetNode.Add("Seconds", knbDurSec.Value);
            }

            //Create color scheme node
            node.Add("ColorScheme", cboxColors.SelectedIndex);
            return(node);
        }
コード例 #4
0
        public HierarchyNode Serialize()
        {
            HierarchyNode node = new HierarchyNode("mpsMap");

            foreach (AssetRepresentation i in FindObjectsOfType <AssetRepresentation>())
            {
                i.Serialize(node.Add(i.Id));
            }

            return(node);
        }
コード例 #5
0
 private static void AddEditorsToContainers <T>(HierarchyNode <IContainable> rootContainer, IEnumerable <HierarchyNode <IContainable> > containers, IEnumerable <T> editables, string defaultContainerName) where T : IContainable
 {
     foreach (T editable in editables)
     {
         string containerName = editable.ContainerName ?? defaultContainerName;
         var    container     = containers.FirstOrDefault(c => string.Equals(c.Current.Name, containerName, StringComparison.InvariantCultureIgnoreCase));
         if (container != null)
         {
             container.Add(new HierarchyNode <IContainable>(editable));
         }
         else
         {
             rootContainer.Add(new HierarchyNode <IContainable>(editable));
         }
     }
 }
コード例 #6
0
 private static void AddEditorsToContainers <T>(HierarchyNode <IContainable> rootContainer, IEnumerable <HierarchyNode <IContainable> > containers, IEnumerable <T> editables, string defaultContainerName) where T : IContainable
 {
     foreach (T editable in editables)
     {
         string containerName = editable.ContainerName ?? defaultContainerName;
         var    container     = containers.FirstOrDefault(c => c.Current.Name == containerName);
         if (container != null)
         {
             container.Add(new HierarchyNode <IContainable>(editable));
         }
         else
         {
             rootContainer.Add(new HierarchyNode <IContainable>(editable));
         }
     }
 }
コード例 #7
0
        private IEnumerable <HierarchyNode <IContainable> > AddContainersToRootContainer(HierarchyNode <IContainable> rootContainer, IEnumerable <IContainable> containersToProcess)
        {
            var addedContainers = new List <HierarchyNode <IContainable> >(new HierarchyNode <IContainable>[] { rootContainer });
            var queue           = new Queue <IContainable>(containersToProcess);

            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                if (current.ContainerName == current.Name)
                {
                    throw new N2Exception("The container '{0}' cannot reference itself as containing container. Change the ContainerName property.", current.Name);
                }

                string containerName = current.ContainerName;
                var    container     = addedContainers.FirstOrDefault(c => c.Current.Name == containerName);
                if (container != null)
                {
                    // the container was previously in the loop
                    var node = new HierarchyNode <IContainable>(current);
                    container.Add(node);
                    addedContainers.Add(node);
                }
                else if (!queue.Any(c => c.Name == containerName))
                {
                    // no container - add to root
                    var node = new HierarchyNode <IContainable>(current);
                    rootContainer.Add(node);
                    addedContainers.Add(node);
                }
                else
                {
                    // the container is in the queue - add this to end
                    queue.Enqueue(current);
                }
            }
            return(addedContainers);
        }
コード例 #8
0
 public virtual void Serialize(HierarchyNode n)
 {
     n.Add("x", (int)(transform.position.x + 0.5f));
     n.Add("y", (int)(transform.position.y - 0.5f));
     n.Add("r", (int)transform.eulerAngles.z);
 }