protected override bool CreateChildren(bool diffOldChildren)
        {
            try {
                if (mergedPd.PropertyType.IsValueType || (Flags & GridEntry.FLAG_IMMUTABLE) != 0)
                {
                    return(base.CreateChildren(diffOldChildren));
                }

                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties(mergedPd.GetValues(objs), this, this.PropertySort, this.CurrentTab);

                Debug.Assert(mergedProps != null, "MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = this.Children.Count > 0;
                if (!fExpandable)
                {
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                return(fExpandable);
            }
            catch (Exception) {
                return(false);
            }
        }
        private static void checkChildCollectionData()
        {
            Console.WriteLine("Child Collection Format");
            ChildCollection test = new ChildCollection();

            test.id            = 1;
            test.name          = "test";
            test.decimal_value = 5.3M;

            test.collections = new List <ChildCollection>()
            {
                test.Clone() as ChildCollection
            };

            var creator = new Creator <ChildCollection>();

            var kvps = new List <KeyValuePair <string, object> >();

            creator.addKVP(kvps, test);

            foreach (var kvp in kvps)
            {
                Console.WriteLine($"{kvp.Key}  - {kvp.Value}");
            }
        }
Example #3
0
        protected override bool CreateChildren(bool diffOldChildren)
        {
            try {
                object[] rgobjs = (object[])objValue;


                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = PropertyMerger.GetMergedProperties(rgobjs, this, this.PropertySort, CurrentTab);

                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose && mergedProps == null, "PropertyGridView: MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = this.Children.Count > 0;
                if (!fExpandable)
                {
                    //Debug.WriteLine("Object " + rgobjs[0].GetType().FullName + " is not expandable because it has no children");
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                CategorizePropEntries();
                return(fExpandable);
            }
            catch {
                return(false);
            }
        }
Example #4
0
 public void UpdateChildPositions(double diffX, double diffY)
 {
     if (IsChild)
     {
         _posX += diffX;
         _posY += diffY;
         OnPropertyChanged("PosX");
         OnPropertyChanged("PosY");
     }
     if (ChildCollection != null && ChildCollection.Any())
     {
         foreach (var child in ChildCollection)
         {
             if (child is Bone)
             {
                 (child as Bone).UpdateChildPositions(diffX, diffY);
             }
             else if (child is Texture2D)
             {
                 var tex = child as Texture2D;
                 tex.PosX += diffX;
                 tex.PosY += diffY;
             }
         }
     }
 }
Example #5
0
        private void DataWrite(uint oldValue, uint newValue)
        {
            //moved from WriteByte
            byteTransferFinished.Value = false;
            Update();
            switch (state)
            {
            case State.AwaitingAddress:
                startBit.Value          = false;
                willReadOnSelectedSlave = (newValue & 1) == 1; //LSB is 1 for read and 0 for write
                var address = (int)(newValue >> 1);
                if (ChildCollection.ContainsKey(address))
                {
                    selectedSlave = ChildCollection[address];
                    addressSentOrMatched.Value = true;                    //Note: ADDR is not set after a NACK reception - from documentation

                    transmitterReceiver.Value = !willReadOnSelectedSlave; //true when transmitting

                    if (willReadOnSelectedSlave)
                    {
                        dataToReceive      = new Queue <byte>(selectedSlave.Read());
                        dataRegister.Value = 0u;
                        if (dataToReceive.Any())
                        {
                            dataRegister.Value         = dataToReceive.Dequeue();
                            dataRegisterNotEmpty.Value = true;
                        }
                        state = State.HasDataToRead;
                    }
                    else
                    {
                        state          = State.AwaitingData;
                        dataToTransfer = new List <byte>();
                    }
                }
                else
                {
                    state = State.Idle;
                    acknowledgeFailed.Value = true;
                }
                machine.ExecuteIn(Update);
                break;

            case State.AwaitingData:
                dataToTransfer.Add((byte)newValue);
                dataRegisterEmpty.Value = true;
                machine.ExecuteIn(() =>
                {
                    byteTransferFinished.Value = true;
                    state = State.AwaitingRestartOrStop;
                    Update();
                });
                Update();
                break;

            default:
                this.Log(LogLevel.Warning, "Writing {0} to DataRegister in unsupported state {1}.", newValue, state);
                break;
            }
        }
Example #6
0
        private void UpdateRotation(double diffRotation)
        {
            var centerPoint = new Point(CenterPointX, CenterPointY);
            var endpoint    = RotatePoint(new Point(EndPointX, EndPointY), centerPoint, diffRotation);

            EndPointX        = endpoint.X;
            EndPointY        = endpoint.Y;
            _lsidePoint      = RotatePoint(_lsidePoint, centerPoint, diffRotation);
            _rsidePoint      = RotatePoint(_rsidePoint, centerPoint, diffRotation);
            BoneShape.Points = new PointCollection {
                centerPoint, _lsidePoint, endpoint, _rsidePoint
            };

            if (ChildCollection != null && ChildCollection.Any())
            {
                centerPoint = new Point(PosX + CenterPointX, PosY + CenterPointY);
                foreach (var child in ChildCollection)
                {
                    if (child is Bone)
                    {
                        (child as Bone).UpdateChildRotation(centerPoint, diffRotation);
                    }
                    else if (child is Texture2D)
                    {
                        var tex    = child as Texture2D;
                        var newPos = RotatePoint(new Point(tex.PosX + tex.CenterPointX, tex.PosY + tex.CenterPointY), centerPoint, diffRotation);
                        tex.PosX      = newPos.X - tex.CenterPointX;
                        tex.PosY      = newPos.Y - tex.CenterPointY;
                        tex.Rotation += diffRotation;
                    }
                }
            }
        }
        /// <summary>
        /// Render a box
        /// </summary>
        /// <param name="box">box to render</param>
        public void RenderControl(UXBox box)
        {
            UXTable t = new UXTable();
            UXCell  c = new UXCell();

            foreach (IUXObject ux in box.Children)
            {
                c.Add(ux);
            }
            Marshalling.MarshallingHash hash = Marshalling.MarshallingHash.CreateMarshalling("content", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "ColumnCount", 1 },
                    { "LineCount", 1 },
                    { "children",
                      ChildCollection.CreateChildCollection("row", () =>
                        {
                            return new List <IUXObject>()
                            {
                                Creation.CreateRow(1, null, c)
                            };
                        }) }
                });
            });
            t.Bind(hash);
            RenderControl(t);
        }
        protected override bool CreateChildren(bool diffOldChildren)
        {
            try
            {
                if (mergedPd.PropertyType.IsValueType || (Flags & GridEntry.FLAG_IMMUTABLE) != 0)
                {
                    return(base.CreateChildren(diffOldChildren));
                }

                ChildCollection.Clear();

                MultiPropertyDescriptorGridEntry[] mergedProps = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties(mergedPd.GetValues(objs), this, PropertySort, CurrentTab);

                Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose && mergedProps is null, "PropertyGridView: MergedProps returned null!");

                if (mergedProps != null)
                {
                    ChildCollection.AddRange(mergedProps);
                }
                bool fExpandable = Children.Count > 0;
                if (!fExpandable)
                {
                    SetFlag(GridEntry.FL_EXPANDABLE_FAILED, true);
                }
                return(fExpandable);
            }
            catch
            {
                return(false);
            }
        }
Example #9
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);
 }
Example #10
0
        public Container(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            childs             = new ChildCollection(this);
            childs.ChildAdded += new GuiComponentEventHandler <GuiChildComponentEventArgs>(childs_ChildAdded);

            focusable = false;
        }
Example #11
0
        public virtual void Dispose()
        {
            foreach (var child in ChildCollection.Values.OfType <IDisposable>())
            {
                child.Dispose();
            }

            ChildCollection.Clear();
        }
Example #12
0
        private void UpdateManyToManyRelation(ChildCollection collection, object oldState, object newState)
        {
            //if no table name is set this is considered a read only collection
            if (collection.TableName == null)
            {
                return;
            }
            var newStateType = newState.GetType();
            var newStateProp = newStateType.GetProperty(collection.PropertyName);

            //only update collections that are present on newState object
            if (newStateProp == null)
            {
                return;
            }

            var newCollection = newStateProp.GetValue(newState, null) as IEnumerable <object>;

            //only update collections that are present on newState object
            if (newCollection == null)
            {
                return;
            }
            if (oldState != null)
            {
                //compare with old state for deletes and inserts
                var oldStateType  = oldState.GetType();
                var oldStateProp  = oldStateType.GetProperty(collection.PropertyName);
                var oldCollection = oldStateProp.GetValue(oldState, null) as IEnumerable <object>;
                if (oldCollection != null)
                {
                    //process deletes
                    foreach (var d in oldCollection.Where(x => !newCollection.Contains(x)))
                    {
                        //delete d from database
                        DeleteManyToManyRelation(collection, newState, d, oldState.GetType().Name);
                    }
                    //process inserts
                    foreach (var i in newCollection.Where(x => !oldCollection.Contains(x)))
                    {
                        //insert i
                        InsertManyToManyRelation(collection, newState, i, oldState.GetType().Name);
                    }
                }
                else
                {
                    //inserts all items
                    foreach (var i in newCollection)
                    {
                        //insert i
                        InsertManyToManyRelation(collection, newState, i, oldState.GetType().Name);
                    }
                }
            }
        }
Example #13
0
 private void SelectDevice(Device device)
 {
     lock (selectedDeviceLock)
     {
         if (!ChildCollection.TryGetValue((int)device, out selectedDevice))
         {
             this.Log(LogLevel.Debug, "Selected non existing device");
             selectedDevice = null;
         }
     }
 }
Example #14
0
        public void Unregister(ICFU cfu)
        {
            var toRemove = ChildCollection.Where(x => x.Value.Equals(cfu)).Select(x => x.Key).ToList(); //ToList required, as we remove from the source

            foreach (var key in toRemove)
            {
                ChildCollection.Remove(key);
            }

            machine.UnregisterAsAChildOf(this, cfu);
        }
Example #15
0
 private void HandleBumper()
 {
     if ((hostMode.Value || startOfFramePacketsGenerationEnable.Value) && ChildCollection.Any())
     {
         bumper.Start();
     }
     else
     {
         bumper.Stop();
     }
 }
Example #16
0
 public Steps()
 {
     this.steps             = new ChildCollection <Step>();
     this.steps.ChildAdded += (s, e) =>
     {
         if (e.Item != null)
         {
             e.Item.ParentId = null;
         }
     };
 }
Example #17
0
 internal WZObject(string name, WZObject parent, WZFile container, bool children, WZObjectType type)
 {
     Name   = string.Intern(name);
     Parent = parent;
     File   = container;
     _canContainChildren = children;
     if (_canContainChildren)
     {
         _backing = new ChildCollection();
     }
     Type = type;
 }
Example #18
0
        /// <summary>
        /// Release the child form index when it is unloaded
        /// </summary>
        /// <param name="e">OnClosed event args</param>
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            // Remove from the collection only if the calling form is a MDI child form
            if (this.IsMdiContainer == false && this.MdiParent != null)
            {
                ChildCollection.Remove(this.Name.ToString());
                childNames.Remove(this.CurrentFormName);
                this.IntimateParent(false);
            }
        }
Example #19
0
        private void MapChildCollection(ChildCollection r, object item)
        {
            if (item == null || string.IsNullOrEmpty(r.GetCommandName))
            {
                return;
            }

            var start = DateTime.Now;

            SqlCommand cmd;

            if (r.GetCommandType == CommandType.StoredProcedure)
            {
                cmd             = Dao.GetSqlCommand(r.GetCommandName);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue(typeof(T).Name + "Id", TableMap.GetKeyValues(item).First());
            }
            else
            {
                //assume table or view
                var viewName    = r.GetCommandName;
                var masterField = r.MasterFieldName ?? $"{typeof(T).Name}Id";
                var condition   = $"[{masterField}]=@p1";
                var query       = $"select * from {viewName} where {condition}";
                cmd = Dao.GetSqlCommand(query);
                cmd.Parameters.AddWithValue("p1", TableMap.GetKeyValues(item).First());
            }

            using (var reader = CommandRunner.Run(cmd, x => x.ExecuteReader()))
            {
                //get generic mapper for child property
                var childType        = new[] { r.ChildType };
                var getMapper        = _catalog.GetType().GetMethod("GetPropertyMapper");
                var getGenericMapper = getMapper.MakeGenericMethod(childType);
                var mapper           = getGenericMapper.Invoke(_catalog, null);

                var mapMethod = mapper.GetType().GetMethod("MapAll", new[] { typeof(IDataReader) });
                var args      = new object[] { reader };
                var list      = mapMethod.Invoke(mapper, args);

                var prop = typeof(T).GetProperty(r.PropertyName);
                prop.SetValue(item, list, null);

                reader.Close();
            }

            var end = DateTime.Now;

#if DEBUG
            Console.WriteLine(@"Execute query {0:#,##0}mS", end.Subtract(start).TotalMilliseconds);
#endif
        }
Example #20
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);
            }
        }
Example #21
0
        public virtual void Unregister(T peripheral)
        {
            var toRemove = ChildCollection.Where(x => x.Value.Equals(peripheral)).Select(x => x.Key).ToList();

            if (toRemove.Count == 0)
            {
                throw new RegistrationException("The specified peripheral was never registered.");
            }
            foreach (var key in toRemove)
            {
                ChildCollection.Remove(key);
            }
        }
Example #22
0
        private bool TryResolveSelectedSlave(out II2CPeripheral selectedSlave)
        {
            var slaveAddress = (byte)(transmitBuffer.Value >> 1);

            if (!ChildCollection.TryGetValue(slaveAddress, out selectedSlave))
            {
                this.Log(LogLevel.Warning, "Addressing unregistered slave: 0x{0:X}", slaveAddress);
                receivedAckFromSlaveNegated.Value = true;
                return(true);
            }

            receivedAckFromSlaveNegated.Value = false;
            return(false);
        }
Example #23
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);
        }
      }
    }
Example #24
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);
                        }
                    }
                }
            }
        }
Example #25
0
 private void DeleteManyToManyRelation(ChildCollection collection, object newState, object linkedObject,
                                       string typeName)
 {
     using (var cmd = GetSqlCommand())
     {
         var masterField = collection.MasterFieldName ?? $"{typeName}Id";
         var childField  = collection.ChildFieldName ?? $"{linkedObject.GetType().Name}Id";
         cmd.CommandText = $"delete {collection.TableName} where [{masterField}] = @p1 and [{childField}] = @p2";
         var id1Property = newState.GetType().GetProperty(collection.MasterPropertyName ?? "Id");
         var id2Property = linkedObject.GetType().GetProperty(collection.ChildPropertyName ?? "Id");
         cmd.Parameters.AddWithValue("p1", id1Property.GetValue(newState, null));
         cmd.Parameters.AddWithValue("p2", id2Property.GetValue(linkedObject, null));
         CommandRunner.Run(cmd, x => x.ExecuteNonQuery());
     }
 }
Example #26
0
        public ScrollBar(Microsoft.Xna.Framework.Game game, ScrollbarType type)
            : base(game)
        {
            this.type = type;

            childs    = new ChildCollection(this);
            renderer  = new BasicScrollbarRenderer(game, this);
            focusable = false;
            value     = 0;

            thumb = new ScrollThumb(game, type);
            childs.AddChild(thumb);

            thumb.SetParent(this);
        }
Example #27
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;
        }
Example #28
0
        public SceneNode(SceneManager manager, string name)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            Manager = manager;
            Name    = name;

            Children = new ChildCollection(this);
            Objects  = new ObjectCollection(this);
        }
        private void HandleWriteToSlaveCommand()
        {
            if (generateStartCondition.Value)
            {
                generateStartCondition.Value = false;
                if (transactionInProgress)
                {
                    // repeated start - finish previous transaction first
                    SendDataToSlave();
                }
                else
                {
                    transactionInProgress = true;
                }

                var slaveAddress    = (byte)(transmitBuffer.Value >> 1);
                var isReadOperation = BitHelper.IsBitSet(transmitBuffer.Value, 0);
                if (!ChildCollection.TryGetValue(slaveAddress, out selectedSlave))
                {
                    this.Log(LogLevel.Warning, "Addressing unregistered slave: 0x{0:X}", slaveAddress);
                    receivedAckFromSlaveNegated.Value = true;
                }
                else
                {
                    if (isReadOperation)
                    {
                        foreach (var b in selectedSlave.Read())
                        {
                            dataFromSlave.Enqueue(b);
                        }
                    }
                    receivedAckFromSlaveNegated.Value = false;
                }
            }
            else
            {
                if (!transactionInProgress)
                {
                    this.Log(LogLevel.Warning, "Writing to slave without generating START signal");
                    return;
                }
                dataToSlave.Enqueue((byte)transmitBuffer.Value);
            }
            interruptFlag.Value = true;
        }
Example #30
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);
          }
        }
      }
    }
Example #31
0
 public virtual void ImportChildren(ChildCollection children)
 {
     foreach (var child in children.ToList()) Import(child);
 }
Example #32
0
 public virtual bool ParseChildren(ChildCollection c)
 {
     Contract.Assume(c.Parser == this);
     c.Clear();
     var res = true;
     var cl = CurrentToken.Class;
     while (cl != TokenClass.EndOfDocument &&
         (cl == TokenClass.Literal || cl == TokenClass.Identifier || cl == TokenClass.Equals || cl == TokenClass.CDataStart || cl == TokenClass.String || cl == TokenClass.TagStart ||
             cl == TokenClass.ServerTagStart || cl == TokenClass.DoctypeStart || cl == TokenClass.XmlDocTagStart)) {
         switch (cl) {
         case TokenClass.Identifier:
         case TokenClass.Literal:
         case TokenClass.Equals:
         case TokenClass.CDataStart:
         case TokenClass.String:
             var literal = c.New<Literal>();
             if (!ParseLiteral(literal, true)) res = false;
             break;
         case TokenClass.TagStart:
             var p = PeekToken();
             if (p.Class == TokenClass.Identifier && p.Value.ToLower() == "script") {
                 var script = c.New<Script>();
                 if (!ParseScript(script)) res = false;
             } else if (p.Class == TokenClass.Identifier && p.Value.ToLower() == "style") {
                 var style = c.New<Style>();
                 if (!ParseStyle(style)) res = false;
             } else {
                 var elem = c.New<Element>();
                 if (!ParseElement(elem)) res = false;
             }
             break;
         case TokenClass.ServerTagStart:
             if (CurrentToken.ServerTagClass == ServerTagClass.PersistentObject) {
                 var t = c.New<PersistentObject>();
                 if (!ParsePersistentObject(t)) res = false;
             } else {
                 var serverTag = c.New<ServerTag>();
                 if (!ParseServerTag(serverTag)) res = false;
             }
             break;
         case TokenClass.DoctypeStart:
             var doctype = c.New<Doctype>();
             if (!ParseDoctype(doctype)) res = false;
             break;
         case TokenClass.XmlDocTagStart:
             var xmldoc = c.New<XmlDocHeader>();
             if (!ParseXmlDocHeader(xmldoc)) res = false;
             break;
         }
         cl = CurrentToken.Class;
     }
     return res;
 }
Example #33
0
 public virtual void WriteChildren(ChildCollection children)
 {
     foreach (var child in children) Write(child);
 }