public static Parent GetParent(int id = 0)
        {
            var parent = new Parent()
            {
                Id   = id + 2,
                Name = "Parent0"
            };

            var child1 = new Child()
            {
                Id   = id + 0,
                Name = $"Child{id + 0}"
            };

            var child2 = new Child()
            {
                Id   = id + 1,
                Name = $"Child{id + 1}"
            };

            parent.AddChild(child1);
            parent.AddChild(child2);

            return(parent);
        }
        public void should_write_a_poco()
        {
            var parentFormat = new DocumentFormat("parent");

            var o = new Parent();

            o.AddChild("one");
            o.AddChild("于百");

            var id = _fs.Save(parentFormat, o);

            Assert.AreEqual(new BlobId(parentFormat, 1), id);

            var descriptor = _fs.GetDescriptor(id);

            Assert.AreEqual(
                new FileNameWithExtension("Parent.json"),
                descriptor.FileNameWithExtension
                );

            using (var stream = descriptor.OpenRead())
                using (var reader = new StreamReader(stream))
                {
                    var asString = reader.ReadToEnd();
                    Assert.AreEqual("{\"Format\":null,\"Childs\":[{\"Value\":\"one\"},{\"Value\":\"于百\"}]}", asString);

                    stream.Seek(0, SeekOrigin.Begin);
                    Assert.AreEqual(0xEF, stream.ReadByte(), "Missing UTF-8 BOM");
                    Assert.AreEqual(0xBB, stream.ReadByte(), "Missing UTF-8 BOM");
                    Assert.AreEqual(0xBF, stream.ReadByte(), "Missing UTF-8 BOM");
                }
        }
    static void Main(string[] args)
    {
        Parent parent = new Parent();

        parent.AddChild();
        Parent childParent = parent.Children[0].Parent;

        parent.AddChild();
    }
Beispiel #4
0
        // <summary>
        //     NOTE: The association set mapping view model doesn't keep a reference to the mapping model item. Instead, it
        //     keeps it to the AssociationSet and then it can find the AssociationSetMapping as an anti-dep.  We don't need to clear
        //     or set the ModelItem property.
        // </summary>
        internal override void CreateModelItem(CommandProcessorContext cpc, EditingContext context, EFElement underlyingModelItem)
        {
            Debug.Assert(context != null, "The context argument cannot be null");
            Debug.Assert(AssociationSet.AssociationSetMapping == null, "Don't call this method if we already have a mapping");
            Debug.Assert(underlyingModelItem != null, "The underlyingModelItem cannot be null");
            var storeEntityType = underlyingModelItem as EntityType;

            Debug.Assert(
                storeEntityType != null,
                "underlyingModelItem must be of type EntityType, actual type = " + underlyingModelItem.GetType().FullName);
            Debug.Assert(!storeEntityType.EntityModel.IsCSDL, "The storageEntityType must not be a CSDL EntityType");

            Context = context;

            // create a context if we weren't passed one
            if (cpc == null)
            {
                cpc = new CommandProcessorContext(
                    Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_CreateAssociationSetMapping);
            }

            // create the item
            var cmd1 = new CreateAssociationSetMappingCommand(MappingAssociation.Association, storeEntityType);

            // now try and do some match ups by name
            var cmd2 = new DelegateCommand(
                () =>
            {
                Parent.AddChild(this);

                foreach (var child in Children)
                {
                    var end = child as MappingAssociationSetEnd;
                    if (end != null)
                    {
                        foreach (var child2 in end.Children)
                        {
                            var mesp = child2 as MappingEndScalarProperty;
                            if (mesp != null)
                            {
                                var tableColumn =
                                    MappingAssociationSet.StorageEntityType.GetFirstNamedChildByLocalName(mesp.Property, true) as
                                    Property;
                                if (tableColumn != null)
                                {
                                    mesp.CreateModelItem(cpc, _context, tableColumn);
                                }
                            }
                        }
                    }
                }
            });

            // now make the change
            var cp = new CommandProcessor(cpc);

            cp.EnqueueCommand(cmd1);
            cp.EnqueueCommand(cmd2);
            cp.Invoke();
        }
Beispiel #5
0
        private void ShowPopupOrList()
        {
            int iMin = (_items.Length > 5) ? _lineHeight * 5 : _lineHeight * _items.Length;
            int h    = Parent.Height - Y - Height;

            if (_forcePopup || h < iMin)
            {
                new Thread(Modal).Start();
            }
            else
            {
                if (h > Core.ScreenHeight / 2)
                {
                    h = Core.ScreenHeight / 2;
                }
                if (h > (_items.Length * _lineHeight) + 3)
                {
                    h = (_items.Length * _lineHeight) + 3;
                }

                var lstDynamic = new Listbox(Name + "_lst", _font, X, Y + Height - 1, Width - 31, h, _items)
                {
                    ZebraStripe      = _bZebra,
                    ZebraStripeColor = _zebra,
                    SelectedIndex    = _selIndex
                };
                lstDynamic.DoubleTap += (sender2, e2) => CleanUp(lstDynamic);
                lstDynamic.LostFocus += sender3 => CleanUp(lstDynamic, false);
                Parent.AddChild(lstDynamic);
                Parent.ActiveChild = lstDynamic;
            }
        }
Beispiel #6
0
        private bool Validate()
        {
            try
            {
                System.Net.IPAddress.Parse(Result);
            }
            catch
            {
                Disable();

                if (myMsg != null)
                {
                    Parent.RemoveChild(myMsg);
                }

                myMsg = new UIMessageBox("Not a valid IP Address", "Error", true)
                {
                    Size = new Vector2(192, 48)
                };
                Parent.AddChild(myMsg);
                myMsg.Centre();

                myMsg.Closed += delegate(object sender, EventArgs e2)
                {
                    myMsg = null;
                    Enable();
                };
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        public virtual void SetParent(Node node)
        {
            if (IsRoot && node != null)
            {
                throw new Exception("Root cannot have a parent");
            }
            if (IsRoot)
            {
                return;
            }
            if (node == null)
            {
                throw new NullReferenceException("Parent node cannot be null!");
            }

            if (Parent != null) //Unhook before we do anything
            {
                Parent.RemoveChild(this);
            }

            Parent = node;

            //Add as a child to the parent
            Parent.AddChild(this);
        }
        private void Astroidgeneration(float deltatime)
        {
            //check how long it has been since last astroid created
            if (_stopwatch.ElapsedMilliseconds > 5000 / Game.difficulty)
            {
                //generate all the values for new astroid
                float XPos = _random.Next(0, Game.windowsizeX);
                float YPos = _random.Next(0, Game.windowsizeY);
                float XVel = _random.Next(-260, 260);
                float YVel = _random.Next(-260, 260);

                //randomly generate new astroid with random position and velocity
                Astroid astroid = new Astroid(XPos, YPos, XVel, YVel);

                //checks if astroid will spawn on player
                if (astroid.Hitbox.DetectCollision(Player.Instance.hitbox))
                {
                    return;
                }
                //add astroid to root
                Parent.AddChild(astroid);
                //add to the astroid list
                Game.AstroidList.Add(astroid);
                //restart astroid timer
                _stopwatch.Restart();
            }
        }
Beispiel #9
0
        // Gets off the tank and pilot moves on its own
        public void ExitTank(float deltaTime)
        {
            if (Input.IsKeyPressed(88) && isEntered)
            {
                RemoveChild(bodyTank);
                Parent.AddChild(bodyTank);

                bodyTank.X = XAbsolute;
                bodyTank.Y = YAbsolute;

                AddChild(_texture);
                AddChild(_hitbox);

                // Grabs Tank's Rotation
                bodyTank.Rotate(GetRotation());
                // Grabs Pilots Rotation
                Rotate(-GetRotation());

                Vector3 tankDirection = bodyTank.GetDirectionAbsolute() * 250f;
                bodyTank.XVelocity = -tankDirection.x;
                bodyTank.YVelocity = tankDirection.y;

                bodyTank.XVelocity     = 0;
                bodyTank.YVelocity     = 0;
                bodyTank.YAcceleration = 0;

                isEntered = false;
            }
        }
Beispiel #10
0
        private void Initialise()
        {
            children          = new List <Control>();
            childrenReadOnly  = new ReadOnlyCollection <Control>(children);
            focusedBy         = new List <ActorFocus>();
            focusedByReadOnly = new ReadOnlyCollection <ActorFocus>(focusedBy);
            Gestures          = new GestureGroup(UserInterface);
            isVisible         = true;
            LikesHavingFocus  = true;
            FocusPriority     = 100;

            if (Parent != null)
            {
                Parent.strataOffsetCount++;
                Strata = new ControlStrata()
                {
                    Layer = Layer.Parent, Offset = Parent.Strata.Offset + Parent.strataOffsetCount
                };

                Parent.AddChild(this);
            }
            else
            {
                Strata = new ControlStrata()
                {
                    Layer = Layer.Medium, Offset = 0
                };
            }
        }
Beispiel #11
0
        public override void Initialize()
        {
            base.Initialize();

            txLockedGame       = AssetLoader.LoadTexture("lockedgame.png");
            txIncompatibleGame = AssetLoader.LoadTexture("incompatible.png");
            txPasswordedGame   = AssetLoader.LoadTexture("passwordedgame.png");

            panelGameInformation      = new GameInformationPanel(WindowManager);
            panelGameInformation.Name = "panelGameInformation";
            panelGameInformation.BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbypanelbg.png");
            panelGameInformation.DrawMode          = ControlDrawMode.UNIQUE_RENDER_TARGET;
            panelGameInformation.Initialize();
            panelGameInformation.ClearInfo();
            panelGameInformation.Disable();
            panelGameInformation.InputEnabled = false;
            panelGameInformation.Alpha        = 0f;
            Parent.AddChild(panelGameInformation); // make this a child of our parent so it's not drawn on our rendertarget

            HoveredIndexChanged += GameListBox_HoveredIndexChanged;

            hoverOnGameColor = AssetLoader.GetColorFromString(
                ClientConfiguration.Instance.HoverOnGameColor);

            loadedGameTextWidth = (int)Renderer.GetTextDimensions(LOADED_GAME_TEXT, FontIndex).X;
        }
Beispiel #12
0
        //Starts the game
        private void StartGame()
        {
            //the interface
            Interface _interface = new Interface();

            //Adds the interface
            Parent.AddChild(_interface);

            BossFightController level = new BossFightController(Parent, _startingStage);

            Parent.AddChild(level);

            //player items
            Player _player = new Player(_interface, Parent, _skins[_selectedSkinNum], _weenieMode);

            //Adds the players sprite and adds the player to the scene
            Parent.AddChild(_player);

            //Places the player
            _player.X = 390f;
            _player.Y = 500f;

            level.StartUp();

            Collectable collect = new Collectable(100, 400, "shootSpeed", "GFX/Powerup.png");

            Parent.AddChild(collect);

            //The menu deletes itself after starting the game to not hog space.
            Parent.RemoveChild(this);
        }
Beispiel #13
0
        private void CreateFlameSprite(Vector3 pos)
        {
            var tf = Matrix.CreateTranslation(pos - (Parent as GameComponent).Position);

            SoundManager.PlaySound(ContentPaths.Audio.fire, pos, true, 1.0f);
            var sprite = Parent.AddChild(new AnimatedSprite(Manager, "Flame", tf)
            {
                OrientationType  = AnimatedSprite.OrientMode.Spherical,
                LightsWithVoxels = false
            }) as AnimatedSprite;
            var frames = new List <Point>()
            {
                new Point(0, 0), new Point(1, 0), new Point(2, 0), new Point(3, 0)
            };

            frames.Shuffle();
            var animation = Library.CreateAnimation(new SpriteSheet(ContentPaths.Particles.more_flames, 32),
                                                    frames, "Flames");

            animation.FrameHZ = MathFunctions.Rand(8.0f, 20.0f);
            animation.Loops   = true;
            sprite.AddAnimation(animation);
            sprite.SetCurrentAnimation("Flames", true);
            sprite.SetFlag(Flag.ShouldSerialize, false);
            sprite.AnimPlayer.Play(animation);
            FlameSprites.Add(sprite);
        }
Beispiel #14
0
    public override AbilityExecution CreateExecution()
    {
        var abilityExecution = Parent.AddChild <SkillExecution_1006>(this);

        abilityExecution.AddComponent <UpdateComponent>();
        return(abilityExecution);
    }
Beispiel #15
0
        public void EndMapping()
        {
            UserNick = UserNick.ToUserDisplayName((UserClass)UserClass);

            if (!IsRead)
            {
                Flags |= NodeFlags.Highlight;
            }

            DisplaySubject = Subject;

            if (IsChild)
            {
                if (!Parent.AddChild(this))
                {
                    // Если дочерняя ветка не найдена, а это происходит если ветка
                    // "оборвана", добавляем ее в корень темы.
                    ParentID = Parent.ID;

                    var ok = Parent.AddChild(this);

                    Trace.Assert(ok, "Сбой при добавлении подветки.");
                }

                _reNum = Parent._reNum + 1;

                if (IsMarked)
                {
                    IsMarked = false;
                    SetMarked(true);
                }

                if (Moderatorials > 0)
                {
                    var cur = Parent;
                    while (cur.Parent != null)
                    {
                        cur.RepliesModeratorials += Moderatorials;
                        cur = cur.Parent;
                    }
                }

                DisplaySubject = _reSubj.FormatStr(UserNick,
                                                   !IsAutoReSubj(Subject, Parent.Subject)
                                                                                                   ? Subject
                                                                                                   : "Re[{0}]".FormatStr(_reNum));
            }

            if (IsUnread)
            {
                Flags = Flags & ~NodeFlags.Highlight;
                SetUnread(true);

                if (!IsChild && RepliesUnread > 0)
                {
                    RepliesUnread--;
                }
            }
        }
Beispiel #16
0
 public Control(IComposition parent)
 {
     this.Parent = parent;
     if (null != parent)
     {
         Parent.AddChild(this);
     }
 }
Beispiel #17
0
        void RecreateCurrentWidget(object state)
        {
            // you can call this like this
            //             AfterUiEvents.AddAction(new AfterUIAction(RecreateCurrentWidget));

            Parent.AddChild(new EditConnectionWidget((ConnectionWindow)Parent, Parent, ActivePrinter));
            Parent.RemoveChild(this);
        }
Beispiel #18
0
        public Schedulable <T> ContinueWithCoroutine(IScheduler scheduler, Func <IEnumerator> starter)
        {
            var func        = CoroutineFunctor.Create(() => default(T), _ => starter());
            var schedulable = new Schedulable <T>(scheduler, func);

            Parent.AddChild(schedulable);
            return(schedulable);
        }
Beispiel #19
0
        public CancellationScope Push()
        {
            Parent = Current;
            Parent.AddChild(this);

            CallContext.LogicalSetData("CancellationScope", this);

            return(Parent);
        }
Beispiel #20
0
        protected sealed override void OnAddChild(VisualNode widget, Element nativeControl)
        {
            if (nativeControl is Page page)
            {
                ContainerPage = page;
            }

            Parent.AddChild(this, nativeControl);
        }
 /// <summary>
 /// Initializes the instance with its default attribute values.
 /// </summary>
 protected BaseInstanceState(NodeState parent, NodeClass nodeClass, QualifiedName browseName) : base(nodeClass, browseName)
 {
     if (parent == null)
     {
         return;
     }
     Parent = (BaseInstanceState)parent;
     Parent.AddChild(this);
 }
Beispiel #22
0
        public override async Task <int> OnHandleAsync(ISampleUnitOfWork uow, AddSomethingCommand command)
        {
            var newRecord = new Parent(command.SomeNewData);

            newRecord.AddChild(newRecord.Description);
            var inserted = await uow.Parents.InsertAsync(newRecord);

            return(inserted.Id);
        }
Beispiel #23
0
 protected override void OnParentAdd()
 {
     if (_UseParentCoordinates)
     {
         for (int i = 0; i < Children.Count; i++)
         {
             Parent.AddChild(Children[i]);
         }
     }
 }
Beispiel #24
0
 public SyntaxNode(SyntaxNode parent, int index, object value, SyntaxKind kind)
 {
     this.instanceId = Guid.NewGuid();
     this.Parent     = parent;
     this.Index      = index;
     this.Value      = value;
     Kind            = kind;
     this.Children   = new List <SyntaxNode>();
     Parent?.AddChild(this);
 }
Beispiel #25
0
 public Node(String name, T parent)
 {
     Parent   = parent;
     Name     = name;
     Children = new Dictionary <String, T>();
     if (Parent != null)
     {
         Parent.AddChild(this as T);
     }
 }
Beispiel #26
0
        protected override void OnInitialized()
        {
            if (Parent == null)
            {
                throw new ApplicationException($"Required cascading value of type \"{nameof(LxSidebar)}\" wasn't supplied.");
            }

            Parent.AddChild(this);
            NavManager.LocationChanged += OnLocationChanged;
        }
Beispiel #27
0
        internal override void CreateModelItem(CommandProcessorContext cpc, EditingContext context, EFElement underlyingModelItem)
        {
            Debug.Assert(context != null, "context must not be null");
            Debug.Assert(Condition == null, "Don't call this method if we already have a ModelItem");
            Debug.Assert(MappingStorageEntityType.StorageEntityType != null, "The parent item isn't set up correctly");
            Debug.Assert(underlyingModelItem != null, "underlyingModelItem must not be null");

            var tableColumn = underlyingModelItem as Property;

            Debug.Assert(
                tableColumn != null, "underlyingModelItem must be of type Property, actual type = " + underlyingModelItem.GetType().FullName);

            // store this off in case we have recover the condition later (if it moves to another ETM on us)
            _modelItemColumnName = tableColumn.LocalName.Value;

            Context = context;

            // local shortcuts
            EntityType entityType = MappingConceptualEntityType.ConceptualEntityType;

            // create a context if we weren't passed one
            if (cpc == null)
            {
                cpc = new CommandProcessorContext(
                    Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_CreateCondition);
            }

            // use empty string as a default condition value
            var cmd = new CreateFragmentConditionCommand(entityType, tableColumn, null, String.Empty);

            // set up our post event to fix up the view model
            cmd.PostInvokeEvent += (o, eventsArgs) =>
            {
                var cond = cmd.CreatedCondition;
                Debug.Assert(cond != null, "cmd failed to create Condition");

                // fix up our view model
                ModelItem = cond;
                Parent.AddChild(this);
            };

            try
            {
                // now make the change
                var cp = new CommandProcessor(cpc, cmd);
                cp.Invoke();
            }
            catch
            {
                ModelItem = null;
                Parent.RemoveChild(this);

                throw;
            }
        }
Beispiel #28
0
        /// <summary>
        ///     Creates a new instance of the <see cref="Folder" /> class and adds itself to the child collection of the provided
        ///     <paramref name="parent" />
        /// </summary>
        /// <param name="parent">The parent of the folder</param>
        /// <param name="name">The name of the folder</param>
        public Folder(ProfileElement parent, string name) : base(parent.Profile)
        {
            FolderEntity = new FolderEntity();
            EntityId     = Guid.NewGuid();

            Parent  = parent ?? throw new ArgumentNullException(nameof(parent));
            Profile = Parent.Profile;
            Name    = name;

            Parent.AddChild(this);
        }
Beispiel #29
0
        /// <summary>
        /// Add new entity node as sibling adjacent to this node
        /// </summary>
        /// <param name="item">Entity to add</param>
        /// <param name="adjacency">Specifies which side to place the node</param>
        /// <returns></returns>
        public virtual TNode AddAtAdjacentPosition(TItem item, Adjacency adjacency)
        {
            if (IsRoot)
            {
                throw new InvalidOperationException("Cannot insert at root level");
            }

            var insertIndex = OrderIndex + (adjacency == Adjacency.Before ? 0 : 1);

            return(Parent.AddChild(item, insertIndex));
        }
Beispiel #30
0
        void AddChild(DocumentDesign design)
        {
            Parent?.AddChild(design);

            if (decendentsAndSelf.ContainsKey(design.Discriminator))
            {
                throw new InvalidOperationException($"Discriminator '{design.Discriminator}' is already in use.");
            }

            decendentsAndSelf.Add(design.Discriminator, design);
        }
        public void should_write_a_poco()
        {
            var parentFormat = new DocumentFormat("parent");

            var o = new Parent();
            o.AddChild("one");
            o.AddChild("于百");

            var id = _fs.Save(parentFormat, o);
            Assert.AreEqual(new BlobId(parentFormat, 1), id);

            var descriptor = _fs.GetDescriptor(id);

            Assert.AreEqual(
                new FileNameWithExtension("Parent.json"), 
                descriptor.FileNameWithExtension
            );

            using(var stream = descriptor.OpenRead())
            using (var reader = new StreamReader(stream))
            {
                var asString = reader.ReadToEnd();
                Assert.AreEqual("{\"Format\":null,\"Childs\":[{\"Value\":\"one\"},{\"Value\":\"于百\"}]}", asString);

                stream.Seek(0, SeekOrigin.Begin);
                Assert.AreEqual(0xEF, stream.ReadByte(), "Missing UTF-8 BOM");
                Assert.AreEqual(0xBB, stream.ReadByte(), "Missing UTF-8 BOM");
                Assert.AreEqual(0xBF, stream.ReadByte(), "Missing UTF-8 BOM");
            }
        }