Example #1
0
        private void AddViewExecute(object obj)
        {
            AdaptivVieweNode node = new AdaptivVieweNode();

            node.Name = GetAdaptiveViewName();

            //all parent node is base now.
            node.ParentNode = RootNode;
            RootNode.Add(node);

            /*
             * if (null == SelectValue)
             * {
             *  node.ParentNode = RootNode;
             *  RootNode.Add(node);
             * }
             * else
             * {
             *  node.ParentNode = SelectValue;
             *  SelectValue.Add(node);
             * }
             * */
            SelectValue = node;
            LoadInherit();

            RootNode.Fire();
            UpdateUI();
        }
Example #2
0
        void CreateDefaultPages()
        {
            IDocumentService doc = ServiceLocator.Current.GetInstance <IDocumentService>();

            if (doc.Document == null)
            {
                doc.NewDocument(DocumentType.Standard);
            }

            RootNode.UpdateDocument(doc.Document);

            if (doc.Document.DocumentType == DocumentType.Library)
            {
                INodeViewModel defaultNode = RootNode.Add(GetNextDataName(TreeNodeType.Page));
                _ListEventAggregator.GetEvent <OpenNormalPageEvent>().Publish(defaultNode.Guid);
                defaultNode.IsSelected = true;
            }
            else
            {
                INodeViewModel homeNode = RootNode.Add("Home");
                _ListEventAggregator.GetEvent <OpenNormalPageEvent>().Publish(homeNode.Guid);
                homeNode.IsSelected = true;
                homeNode.AddChild(GetNextDataName(TreeNodeType.Page));
                homeNode.AddChild(GetNextDataName(TreeNodeType.Page));
                homeNode.AddChild(GetNextDataName(TreeNodeType.Page));
            }

            doc.Document.IsDirty = false;
        }
Example #3
0
        public void ShouldHaveChildren()
        {
            var root = new RootNode(_evaluator.Object, _simpleChildCalc);

            root.Add(new MinNode(root, root));

            Assert.AreEqual(1, root.Children.Count);
        }
Example #4
0
        void CreateDefaultMasters()
        {
            RootNode.Add(GetNextDataName());
            RootNode.Add(GetNextDataName());
            RootNode.Add(GetNextDataName());

            IDocumentService doc = ServiceLocator.Current.GetInstance <IDocumentService>();

            doc.Document.IsDirty = false;
        }
Example #5
0
 public void Add(T value)
 {
     if (RootNode == null)
     {
         RootNode = new AVLTreeNode(value, this);
     }
     else
     {
         RootNode.Add(value);
     }
 }
Example #6
0
        public static void Add <T>(this RoutingEngine <T> engine, Activation <T> activation)
            where T : class
        {
            RootNode <T> match = engine.Match <RootNode <T> >().FirstOrDefault();

            if (match == null)
            {
                return;
            }

            match.Add(activation);
        }
Example #7
0
        /// <summary>
        /// Add data to the binary tree
        /// </summary>
        /// <param name="data">Data to be added in tree</param>
        public void Add(T data)
        {
            Count++;

            // if there is no elements in tree
            if (RootNode == null)
            {
                RootNode = new BinaryTreeNode <T>(data);
                return;
            }

            RootNode.Add(data);
        }
        public void Parse()
        {
            logger.Info("Parsing file {0}", SourceFileName);

            if (RootNode == null)
            {
                RootNode = new XElement(XMLRootName);
            }


            Dbf dbf = new Dbf();

            try
            {
                dbf.Read(this.SourceFileName);
                ParseHeader(dbf);

                logger.Trace("Parsing dbf records");

                for (int row = 0; row < dbf.Records.Count; row++)
                {
                    RecordCount = row;

                    XElement node = new XElement("Item");
                    RootNode.Add(node);

                    for (int column = 0; column < dbf.Records[row].Data.Count; column++)
                    {
                        string cell = null;
                        if (dbf.Records[row].Data[column] == null)
                        {
                            cell = "null";
                        }
                        else
                        {
                            cell = dbf.Records[row].Data[column].ToString();
                        }

                        node.Add(new XElement(Headers[column], cell));
                    }
                }

                logger.Trace("DBF file is parsed successfully RecordCount {0}", RecordCount);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"DBF file parsing error {SourceFileName}");
                throw new Exception($"DBF file parsing error {SourceFileName} Error:" + ex.Message);
            }
        }
Example #9
0
        /// <summary>
        /// Add Item(Key & Value) to the proper location on B-Tree.
        /// </summary>
        /// <param name="item"></param>
        public void Add(BTreeItemOnDisk item)
        {
#if (DEBUG)
            Log.Logger.Instance.Verbose("BTreeAlgorithm.Add.");
#endif

            if (RootNode == null)
            {
                throw new InvalidOperationException("Can't Add item to a Close ObjectStore.");
            }
            if (HintSequentialRead)
            {
                HintSequentialRead = false;
            }
            BeginTreeMaintenance();
            bool dataSaved = false;
            if (!IsUnique)
            {
                if (AutoFlush)
                {
                    SetBigDataValue(item);
                    dataSaved = true;
                }
            }
            if (RootNode.Add(this, item))
            {
                if (!dataSaved && AutoFlush)
                {
                    SetBigDataValue(item);
                }
            }
            else
            {
                EndTreeMaintenance();
                SetCurrentItemAddress(-1, 0);
                throw new DuplicateKeyException(string.Format("Item with key {0} already exists.", item.Key));
            }

            Distribute();
            Promote();
            EndTreeMaintenance();
            UpdateCount(UpdateCountType.Increment);
            SaveBlocks(MaxBlocks, false);
            RegisterChange(true);
            // Current item pointer points to null after add of an item.
            SetCurrentItemAddress(-1, 0);
        }
Example #10
0
        public void Parse()
        {
            if (RootNode == null)
            {
                RootNode = new XElement(XMLRootName);
            }

            if (FirstLineHasHeaders)
            {
                ParseHeader();
                LogHeaders();
            }

            using (Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(SourceFileName, FileEncoding))
            {
                parser.Delimiters = new string[] { Delimiter };

                if (SkipFirstLine || FirstLineHasHeaders)
                {
                    parser.ReadFields();
                }


                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();

                    if (Headers.Count == 0)
                    {
                        InitializeHeaders(fields.Count());
                        LogHeaders();
                    }

                    XElement node = new XElement("Item");
                    RootNode.Add(node);
                    for (int i = 0; i < Headers.Count; i++)
                    {
                        node.Add(new XElement(Headers[i], fields[i]));
                    }
                }
            }
        }
Example #11
0
        /// <summary>
        /// Adds a point data range to the data structure.
        /// </summary>
        /// <param name="data">The data to add</param>
        /// <param name="pt">The botom left corner for the point to add</param>
        /// <param name="range">The optimal size of the box</param>
        /// <returns>True if a new point was added, false if it was a replacement or failure to add.</returns>
        public bool Add(QTPoint pt, N range, D data)
        {
            if (RootNode == null)
            {
                RootNode = new QTNode <N, D>();
                return(RootNode.Add(pt, range, data));
            }
            // If the point to add is in the current bounds, then add it.
            if (RootNode.Contains(pt)) // TODO: do i need to check if it overlaps as well or something?
            {
                return(RootNode.Add(pt, range, data));
            }
            else
            {
                // The point is out of the current bounds, we need to move the root down a level.

                // Get the range and the point for the new root node
                QTPoint NewRootPt    = new QTPoint();
                dynamic NewRootRange = 0;
                QTPoint.Capture(RootNode.Point, RootNode.Range, pt, range, ref NewRootPt, ref NewRootRange);

                // Add the current root to the new node
                QTNode <N, D> NewRoot = new QTNode <N, D>();
                if (!NewRoot.Add(pt, range, data))
                {
                    throw new Exception("How did we get here? I thought we were adding to an empty node?");
                }
                bool worked = NewRoot.Append(RootNode);
                // Update out root node
                // TODO: can optimize some lines out once we pass testing
                if (worked)
                {
                    RootNode = NewRoot;
                    return(true);
                }
                else
                {
                    throw new Exception("Why did that not work?");
                }
            }
        }
Example #12
0
        public bool AddIfNotExist(BTreeItemOnDisk item)
        {
            if (RootNode == null)
            {
                throw new InvalidOperationException("Can't Add item to a Close ObjectStore.");
            }
            if (HintSequentialRead)
            {
                HintSequentialRead = false;
            }
            BeginTreeMaintenance();

            bool uniqueSetting = IsUnique;

            IsUnique = true;
            bool r = RootNode.Add(this, item);

            IsUnique = uniqueSetting;
            if (r)
            {
                if (AutoFlush)
                {
                    SetBigDataValue(item);
                }
            }
            else
            {
                EndTreeMaintenance();
                return(r);
            }

            Distribute();
            Promote();
            EndTreeMaintenance();
            UpdateCount(UpdateCountType.Increment);
            SaveBlocks(MaxBlocks, false);
            RegisterChange(true);
            // Current item pointer points to null after add of an item.
            SetCurrentItemAddress(-1, 0);
            return(r);
        }
Example #13
0
 /// <summary>
 /// Add Item(Key & Value) to the proper location on B-Tree.
 /// </summary>
 /// <param name="item"></param>
 public void Add(BTreeItemOnDisk item)
 {
     if (RootNode == null)
     {
         throw new InvalidOperationException("Can't Add item to a Close ObjectStore.");
     }
     if (HintSequentialRead)
     {
         HintSequentialRead = false;
     }
     BeginTreeMaintenance();
     RootNode.Add(this, item);
     ProcessDistribution();
     ProcessPromotion();
     EndTreeMaintenance();
     UpdateCount(UpdateCountType.Increment);
     SaveBlocks(MaxBlocks, false);
     RegisterChange(true);
     // Current item pointer points to null after add of an item.
     SetCurrentItemAddress(-1, 0);
 }
        private void InitializeTree(Control control)
        {
            IList itemsToShow = new RootNode {
                control
            };

            foreach (var o in PropertyObjects)
            {
                itemsToShow.Add(o);
            }

            treeView1.ImageList = new ImageList {
                ColorDepth = ColorDepth.Depth32Bit
            };
            treeView1.ImageList.Images.Add("Control", Resources.Control);
            treeView1.ImageList.Images.Add("Data", Resources.Data);


            AddAllNodes(treeView1.Nodes, itemsToShow);

            treeView1.NodeMouseClick += delegate { propertyGrid1.SelectedObject = treeView1.SelectedNode.Tag; };
        }
        internal override bool ParseNodeBodyElement(string id, VRMLParser parser)
        {
            int line = parser.Line;

            if (id == "center")
            {
                Center = parser.ParseSFVec3fStringValue();
            }
            else if (id == "child1Url")
            {
                Child1URL.AddRange(parser.ParseSFStringOrMFStringValue());
            }
            else if (id == "child2Url")
            {
                Child2URL.AddRange(parser.ParseSFStringOrMFStringValue());
            }
            else if (id == "child3Url")
            {
                Child3URL.AddRange(parser.ParseSFStringOrMFStringValue());
            }
            else if (id == "child4Url")
            {
                Child4URL.AddRange(parser.ParseSFStringOrMFStringValue());
            }
            else if (id == "geoOrigin")
            {
                X3DNode node = parser.ParseSFNodeValue();
                if (node != null)
                {
                    GeoOrigin = node as IX3DGeoOriginNode;
                    if (GeoOrigin == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                }
            }
            else if (id == "geoSystem")
            {
                if (wasGeoSystem)
                {
                    GeoSystem.AddRange(parser.ParseSFStringOrMFStringValue());
                }
                else
                {
                    GeoSystem = parser.ParseSFStringOrMFStringValue();
                }
                wasGeoSystem = true;
            }
            else if (id == "range")
            {
                Range = parser.ParseDoubleValue();
            }
            else if (id == "rootUrl")
            {
                RootURL.AddRange(parser.ParseSFStringOrMFStringValue());
            }
            else if (id == "rootNode")
            {
                List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue();
                foreach (X3DNode node in nodes)
                {
                    X3DChildNode rn = node as X3DChildNode;
                    if (rn == null)
                    {
                        parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line);
                    }
                    else
                    {
                        RootNode.Add(rn);
                    }
                }
            }
            else if (id == "bboxCenter")
            {
                BBoxCenter = parser.ParseSFVec3fValue();
            }
            else if (id == "bboxSize")
            {
                BBoxSize = parser.ParseSFVec3fValue();
            }
            else
            {
                return(false);
            }
            return(true);
        }
        private void InitializeTree(Control control)
        {
            IList itemsToShow = new RootNode {control};
            foreach (var o in PropertyObjects)
            {
                itemsToShow.Add(o);
            }

            treeView1.ImageList = new ImageList { ColorDepth = ColorDepth.Depth32Bit };
            treeView1.ImageList.Images.Add("Control", Resources.Control);
            treeView1.ImageList.Images.Add("Data", Resources.Data);
            
            
            AddAllNodes(treeView1.Nodes, itemsToShow);

            treeView1.NodeMouseClick += delegate { propertyGrid1.SelectedObject = treeView1.SelectedNode.Tag; };
        }
Example #17
0
 /// <summary>
 /// Add a node to the tree
 /// </summary>
 public void Add(Node node, bool addLeft)
 {
     RootNode.Add(node, addLeft);
 }
Example #18
0
 /// <summary>
 /// adds a node to the tree
 /// </summary>
 public bool Add(Node node)
 {
     return(RootNode.Add(node));
 }
Example #19
0
        public void ResetLevel()
        {
            Score            = 0;
            SecondsRemaining = 120;
            CoinsCollected   = 0;
            BananasCollected = 0;

            TimeAlongPath            = 0;
            PlayerCharacter.Position = LocationAlongPath(TimeAlongPath);
            PlayerCharacter.Rotation = GetPlayerDirectionFromCurrentPosition();
            HitByLavaReset           = false;

            // Remove dynamic objects from the level.
            SCNTransaction.Begin();

            if (Bananas != null)
            {
                foreach (SCNNode b in Coconuts)
                {
                    b.RemoveFromParentNode();
                }
            }

            if (Bananas != null)
            {
                foreach (SCNNode b in Bananas)
                {
                    b.RemoveFromParentNode();
                }
            }

            if (LargeBananas != null)
            {
                foreach (SCNNode largeBanana in LargeBananas)
                {
                    largeBanana.RemoveFromParentNode();
                }
            }

            SCNTransaction.Commit();

            // Add dynamic objects to the level, like bananas and large bananas
            Bananas  = new List <SCNNode> ();
            Coconuts = new List <Coconut> ();

            for (int i = 0; i < 10; i++)
            {
                SCNNode banana = CreateBanana();
                RootNode.Add(banana);
                SCNVector3 location = LocationAlongPath((i + 1) / 20.0f - 0.01f);
                location.Y     += 50;
                banana.Position = location;
                Bananas.Add(banana);
            }

            LargeBananas = new List <SCNNode> ();

            for (int i = 0; i < 6; i++)
            {
                SCNNode largeBanana = CreateLargeBanana();
                RootNode.AddChildNode(largeBanana);
                SCNVector3 location = LocationAlongPath(MathUtils.RandomPercent());
                location.Y          += 50;
                largeBanana.Position = location;
                LargeBananas.Add(largeBanana);
            }

            GameSimulation.Sim.PlayMusic("music.caf");
            GameSimulation.Sim.PlayMusic("night.caf");
        }