Beispiel #1
0
 public virtual void Register(T peripheral, NumberRegistrationPoint <int> registrationPoint)
 {
     if (ChildCollection.ContainsKey(registrationPoint.Address))
     {
         throw new RegistrationException("The specified registration point is already in use.");
     }
     ChildCollection.Add(registrationPoint.Address, peripheral);
 }
Beispiel #2
0
        /// <summary>
        /// The child form will be captured when it gets loaded
        /// </summary>
        /// <param name="e">OnLoad event args</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            ////Add to the collection only if the calling form is a MDI child form

            if (this.IsMdiContainer == false && this.MdiParent != null)
            {
                ChildCollection.Add(this.formID.ToString());
                ChildNames.Add(this.CurrentFormName);
                this.IntimateParent(true);
            }
        }
Beispiel #3
0
        public void Drop(IDropInfo dropInfo)
        {
            var tex     = dropInfo.Data as Texture2D;
            var bone    = dropInfo.Data as Bone;
            var texArr  = dropInfo.Data as List <Texture2D>;
            var boneArr = dropInfo.Data as List <Bone>;

            if (tex != null && !ChildCollection.Contains(tex))
            {
                MainViewModel.ViewportCollection.Remove(tex);
                if (!ChildCollection.Contains(tex))
                {
                    ChildCollection.Add(tex);
                }
            }
            else if (texArr != null)
            {
                foreach (var t in texArr)
                {
                    MainViewModel.ViewportCollection.Remove(t);
                    if (!ChildCollection.Contains(t))
                    {
                        ChildCollection.Add(t);
                    }
                }
            }
            else if (bone != null && !ChildCollection.Contains(bone) && bone != this)
            {
                MainViewModel.ViewportCollection.Remove(bone);
                if (!ChildCollection.Contains(bone))
                {
                    ChildCollection.Add(bone);
                }
            }

            else if (boneArr != null)
            {
                foreach (var b in boneArr)
                {
                    if (b != null && !ChildCollection.Contains(b) && b != this)
                    {
                        MainViewModel.ViewportCollection.Remove(b);
                        if (!ChildCollection.Contains(b))
                        {
                            ChildCollection.Add(b);
                        }
                    }
                }
            }
        }
Beispiel #4
0
    public void CopyFrom (TComponentModelItem alias)
    {
      if (alias.NotNull ()) {
        base.CopyFrom (alias);

        Category = alias.Category;

        ChildCollection.Clear ();

        foreach (var item in alias.ChildCollection) {
          ChildCollection.Add (item);
        }
      }
    }
Beispiel #5
0
        public void Register(ICFU cfu, NumberRegistrationPoint <int> registrationPoint)
        {
            var isRegistered = ChildCollection.Where(x => x.Value.Equals(cfu)).Select(x => x.Key).ToList();

            if (isRegistered.Count != 0)
            {
                throw new RegistrationException("Can't register the same CFU twice.");
            }
            else if (ChildCollection.ContainsKey(registrationPoint.Address))
            {
                throw new RegistrationException("The specified registration point is already in use.");
            }

            ChildCollection.Add(registrationPoint.Address, cfu);
            machine.RegisterAsAChildOf(this, cfu, registrationPoint);
            cfu.ConnectedCpu = this;
        }
Beispiel #6
0
    public void RequestNode (TEntityAction action)
    {
      if (action.NotNull ()) {
        foreach (var node in action.CollectionAction.ExtensionNodeCollection) {
          NodeModelCollection.Add (node);

          if (action.CollectionAction.ModelCollection.ContainsKey (node.ChildId)) {
            var childNodeModel = action.CollectionAction.ModelCollection [node.ChildId]; // node model
            var childNodeComponentModel = Create (childNodeModel); // child node 

            var childNodeComponentModelItem = Create (childNodeComponentModel);
            childNodeComponentModelItem.Select (Server.Models.Infrastructure.TCategoryType.FromValue (node.ChildCategory));

            ChildCollection.Add (childNodeComponentModelItem);
          }
        }
      }
    }
Beispiel #7
0
    public void RequestRelation (TEntityAction action)
    {
      if (action.NotNull ()) {
        if (action.ComponentOperation.ParentIdCollection.ContainsKey (Id)) {
          var relationCollection = action.ComponentOperation.ParentIdCollection [Id]; // relation

          //  child relation 
          foreach (var relation in relationCollection) {
            if (action.CollectionAction.EntityCollection.ContainsKey (relation.ChildId)) {
              var childAction = action.CollectionAction.EntityCollection [relation.ChildId]; // child action

              // child model
              var childModelItem = Create (childAction);
              childModelItem.GeometryModel.PositionCol = relation.PositionColumn;
              childModelItem.GeometryModel.PositionRow = relation.PositionRow;
              childModelItem.GeometryModel.PositionIndex = relation.PositionIndex;
              childModelItem.Select (Server.Models.Infrastructure.TCategoryType.FromValue (relation.ChildCategory));

              ChildCollection.Add (childModelItem); // add to child collection 
            }
          }
        }
      }
    }
Beispiel #8
0
 internal void Add(WZObject o)
 {
     _backing.Add(o);
 }
Beispiel #9
0
 protected Child(ChildCollection <TParent, TChild> childCollection)
 {
     this.childCollection = childCollection;
     childCollection.Add((TChild)this);
 }
Beispiel #10
0
 public void AddChild(StructurInfo child)
 {
     ChildCollection.Add(child);
 }
Beispiel #11
0
        public void _0001_Test()
        {
            //https://msdn.microsoft.com/en-us/library/system.data.datatable.childrelations(v=vs.110).aspx
            ParentCollection parents = new ParentCollection();

            parents.Add(new ParentItem(1, "Parent-1"));
            parents.Add(new ParentItem(2, "Parent-2"));
            parents.Add(new ParentItem(3, "Parent-3"));
            parents.Add(new ParentItem(4, "Parent-4"));

            ChildCollection childs = new ChildCollection();

            childs.Add(new ChildItem(1, "Child-1", 1));
            childs.Add(new ChildItem(2, "Child-2", 1));
            childs.Add(new ChildItem(3, "Child-3", 3));
            childs.Add(new ChildItem(4, "Child-4", 4));
            childs.Add(new ChildItem(5, "Child-5", 3));
            childs.Add(new ChildItem(6, "Child-6", 4));


            /*Data SET*/
            DataSet dataSet = new DataSet("DemoDataSet");

            /*Parent*/
            /*ParentId-PK,ParentName*/
            DataTable parentsDt = ToDataTable(parents, "Parents");

            parentsDt.PrimaryKey = new DataColumn[] { parentsDt.Columns["ParentId"] };
            dataSet.Tables.Add(parentsDt);

            /*Childs*/
            /*ChildId-PK, ChildName, ParentId*/
            DataTable childsDt = ToDataTable(childs, "Childs");

            childsDt.PrimaryKey = new DataColumn[] { parentsDt.Columns["ChildId"] };
            DataColumn parentsNameColumn = new DataColumn("ParentName", typeof(string));

            childsDt.Columns.Add(parentsNameColumn);
            dataSet.Tables.Add(childsDt);

            /*SzÜlők gyerekei reláció*/
            /*A szülő táblán végig lépkedve megtudható a szülők gyerekei*/
            /*A szülő táblázat lesz amiben megjelnnek az eredmények!*/
            DataRelation parentChildRelation = dataSet.Relations.Add("ParentChilds",
                                                                     dataSet.Tables["Parents"].Columns["ParentId"],
                                                                     dataSet.Tables["Childs"].Columns["ParentId"], false);

            foreach (DataRow parent in parentsDt.Rows)
            {
                /*Itt használja a relációt*/
                DataRow[] children = parent.GetChildRows(parentChildRelation); //A Child táblával dolgozik
                Console.WriteLine("\n{0}, has {1} children", parent["ParentName"].ToString(), children.Count <DataRow>());
                foreach (DataRow child in children)
                {
                    Console.WriteLine("\t{0}", child["ChildName"].ToString());
                }
            }


            Form2 f2 = new Form2();

            f2.dataGridView1.DataSource = dataSet;
            f2.dataGridView1.DataMember = "Parents";

            /*A szülők gyerekei*/
            /*Egy szülőnek több gyereke is lehet, ezért az eredmény táblázat a gyerek számával nő, a szülők ismétlődnek*/
            /*Ez a JOIN*/
            var results = from table1 in parentsDt.AsEnumerable()
                          join table2 in childsDt.AsEnumerable() on table1["ParentId"] equals table2["ParentId"]
                          select new
            {
                ParentId   = table1["ParentId"],
                ParentName = table1["ParentName"],
                ChildName  = table2["ChildName"],
            };

            var list = results.ToList();

            f2.dataGridView2.DataSource = list;


            Application.Run(f2);
        }