示例#1
0
        private void ContentsChanged(object sender, ListChangedEventArgs eventArgs)
        {
            int intNewIndex = eventArgs?.NewIndex ?? 0;
            List <ControlWithMetaData> lstToRedraw = null;

            switch (eventArgs.ListChangedType)
            {
            case ListChangedType.ItemChanged:
                break;

            case ListChangedType.Reset:
                foreach (ControlWithMetaData objLoopControl in _contentList)
                {
                    objLoopControl.Cleanup();
                }
                _contentList.Clear();
                foreach (TType objLoopTType in _contents)
                {
                    _contentList.Add(new ControlWithMetaData(objLoopTType, this));
                }
                _indexComparer.Reset(_contents);
                lstToRedraw = _contentList;
                break;

            case ListChangedType.ItemAdded:
                _contentList.Insert(intNewIndex, new ControlWithMetaData(_contents[intNewIndex], this));
                _indexComparer.Reset(_contents);
                lstToRedraw = _contentList.GetRange(intNewIndex, _contentList.Count - intNewIndex);
                break;

            case ListChangedType.ItemDeleted:
                _contentList[intNewIndex].Cleanup();
                _contentList.RemoveAt(intNewIndex);
                _indexComparer.Reset(_contents);
                lstToRedraw = _contentList;
                break;
            //case ListChangedType.ItemMoved:
            //    break;

            //case ListChangedType.PropertyDescriptorAdded:
            //    break;
            //case ListChangedType.PropertyDescriptorDeleted:
            //    break;
            //case ListChangedType.PropertyDescriptorChanged:
            //    break;
            default:
                Utils.BreakIfDebug();
                break;
            }
            if (lstToRedraw != null && lstToRedraw.Count > 0)
            {
                pnlDisplay.SuspendLayout();
                ChildPropertyChanged?.Invoke(this, new PropertyChangedEventArgs(""));
                ClearCache(lstToRedraw);
                LoadScreenContent();
                pnlDisplay.ResumeLayout();
            }
        }
示例#2
0
        private void OnChildPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
        {
            var subscription = NotifySubscribers.FirstOrDefault(pair => pair.Value.Equals(sender));
            var args         = new NotifyRouter.ChildPropertyChangedEventArgs(propertyChangedEventArgs.PropertyName)
            {
                ParentPropertyName = subscription.Key,
                Value = sender.GetType().GetProperty(propertyChangedEventArgs.PropertyName).GetValue(sender)
            };

            ChildPropertyChanged?.Invoke(sender, args);
        }
 private void Item_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     ChildPropertyChanged?.Invoke(this, new ChildPropertyChangedEventArgs(sender, e.PropertyName));
 }