コード例 #1
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (ui == null)
                {
                    ui = new System.Windows.Forms.TGIBlockListEditorForm.MainForm();
                    //ui.Icon = ((System.Drawing.Icon)(new ComponentResourceManager(typeof(MainForm)).GetObject("$this.Icon")));
                    ui.Icon = Settings.Default.FormIcon;
                }

                TGIBlockListCTD          ctd  = value as TGIBlockListCTD;
                DependentList <TGIBlock> list = ctd.owner[ctd.field].Value as DependentList <TGIBlock>;

                ui.Items = list;
                DialogResult dr = edSvc.ShowDialog(ui);

                if (dr != DialogResult.OK)
                {
                    return(value);
                }

                list.Clear();
                list.AddRange(ui.Items);

                return(value);
            }
コード例 #2
0
 public TGIBlockListIndexCTD(AApiVersionedFields owner, string field, DependentList <TGIBlock> tgiBlocks, object component)
 {
     this.owner     = owner;
     this.field     = field;
     this.tgiBlocks = tgiBlocks;
     this.component = component;
 }
コード例 #3
0
 public Entry(EventHandler handler, AgeGenderFlags ageGender, float amount, int index,
              DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(handler)
 {
     this.ParentTGIBlocks = ParentTGIBlocks;
     this.ageGender       = new AgeGenderFlags(handler, ageGender);
     this.amount          = amount;
     this.index           = index;
 }
コード例 #4
0
ファイル: FaceClothingResource.cs プロジェクト: yakoder/s3pi
 public CASEntry(int APIversion, EventHandler handler, FacialRegionFlags facialRegion, EntryList geomEntries, EntryList boneEntries,
                 DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(APIversion, handler)
 {
     this._ParentTGIBlocks = ParentTGIBlocks;
     this.facialRegion     = facialRegion;
     this.geomEntries      = new EntryList(handler, geomEntries, _ParentTGIBlocks);
     this.boneEntries      = new EntryList(handler, boneEntries, _ParentTGIBlocks);
 }
コード例 #5
0
ファイル: FaceClothingResource.cs プロジェクト: yakoder/s3pi
 public CASEntryList(EventHandler handler, IEnumerable <CASEntry> le, DependentList <TGIBlock> ParentTGIBlocks = null)
     : this(null, ParentTGIBlocks)
 {
     elementHandler = handler; foreach (var t in le)
     {
         this.Add((CASEntry)t.Clone(null));
     }
     this.handler = handler;
 }
コード例 #6
0
        public void SetField(AApiVersionedFields owner, string field, DependentList <TGIBlock> tgiBlocks)
        {
            this.owner     = owner;
            this.field     = field;
            this.tgiBlocks = tgiBlocks;

            tgiBlockCombo1.TGIBlocks     = this.tgiBlocks;
            tgiBlockCombo1.SelectedIndex = Convert.ToInt32(this.owner[this.field].Value);
        }
コード例 #7
0
 public ShaderDataList(EventHandler handler, Stream s, long start, Nullable <int> expectedDataLen, DependentList <TGIBlock> ParentTGIBlocks = null, string RCOLTag = "MATD")
     : base(null)
 {
     elementHandler        = handler;
     this._ParentTGIBlocks = ParentTGIBlocks;
     this._RCOLTag         = RCOLTag;
     Parse(s, start, expectedDataLen);
     this.handler = handler;
 }
コード例 #8
0
ファイル: TGIBlockSelection.cs プロジェクト: dd-dk/sims3tools
        public void SetField(AApiVersionedFields owner, string field, DependentList<TGIBlock> tgiBlocks)
        {
            this.owner = owner;
            this.field = field;
            this.tgiBlocks = tgiBlocks;

            tgiBlockCombo1.TGIBlocks = this.tgiBlocks;
            tgiBlockCombo1.SelectedIndex = Convert.ToInt32(this.owner[this.field].Value);
        }
コード例 #9
0
 public void Initialize()
 {
     _model = new ContactList();
     _model.AddContact(new Contact() { FirstName = "Charles", LastName = "Babbage" });
     _model.AddContact(new Contact() { FirstName = "Alan", LastName = "Turing" });
     _contactViewModels = new DependentList<ContactViewModel>(() =>
         from c in _model.Contacts
         select new ContactViewModel(c)
     );
 }
コード例 #10
0
        public TracksViewModel(Attendee attendee, ImageCache imageCache, SearchModel searchModel)
        {
            _attendee = attendee;
            _imageCache = imageCache;
            _searchModel = searchModel;

            _tracks = new DependentList<Track>(() =>
                from track in _attendee.Conference.Tracks
                orderby track.Name
                select track);
        }
コード例 #11
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
            {
                TGIBlockListCTD          ctd  = value as TGIBlockListCTD;
                DependentList <TGIBlock> list = ctd.owner[ctd.field].Value as DependentList <TGIBlock>;

                if (typeof(string).Equals(destinationType))
                {
                    return(list == null ? "(null)" : "(TGI Blocks: 0x" + list.Count.ToString("X") + ")");
                }
                return(base.ConvertTo(context, culture, value, destinationType));
            }
コード例 #12
0
ファイル: TracksViewModel.cs プロジェクト: mobidian/MyCon
        public TracksViewModel(Attendee attendee, ImageCache imageCache, SearchModel searchModel)
        {
            _attendee    = attendee;
            _imageCache  = imageCache;
            _searchModel = searchModel;

            _tracks = new DependentList <Track>(() =>
                                                from track in _attendee.Conference.Tracks
                                                orderby track.Name
                                                select track);
        }
コード例 #13
0
ファイル: BookViewModel.cs プロジェクト: michaellperry/Ledger
        public BookViewModel(Book book, NewEntryModel newEntry)
        {
            _book = book;
            _newEntry = newEntry;

            _otherAccountOptions = new DependentList<AccountHeaderViewModel>(() =>
                from account in _book.Account.Company.Accounts
                orderby account.Name.Value
                select new AccountHeaderViewModel(account)
            );
        }
コード例 #14
0
ファイル: SpeakerDayViewModel.cs プロジェクト: mobidian/MyCon
        public SpeakerDayViewModel(Attendee attendee, Speaker speaker, Day day, ImageCache imageCache)
        {
            _attendee   = attendee;
            _speaker    = speaker;
            _day        = day;
            _imageCache = imageCache;

            _matchingSessionPlaces = new DependentList <SessionPlace>(() =>
                                                                      from sessionPlace in _speaker.AvailableSessions
                                                                      where sessionPlace.Place.PlaceTime.Day == _day
                                                                      select sessionPlace);
        }
コード例 #15
0
ファイル: ShaderData.cs プロジェクト: yakoder/s3pi
 public ElementTextureRef(int APIversion, EventHandler handler, DependentList <TGIBlock> ParentTGIBlocks = null, string RCOLTag = "MATD")
     : this(APIversion, handler, (FieldType)0, ParentTGIBlocks, RCOLTag)
 {
     if (_RCOLTag == "GEOM")
     {
         index = 0;
     }
     else
     {
         data = new GenericRCOLResource.ChunkReference(0, handler);
     }
 }
コード例 #16
0
 public ShaderDataList(EventHandler handler, IEnumerable <ShaderData> ilt, DependentList <TGIBlock> ParentTGIBlocks = null, string RCOLTag = "MATD")
     : base(handler)
 {
     elementHandler        = handler;
     this._ParentTGIBlocks = ParentTGIBlocks;
     this._RCOLTag         = RCOLTag;
     foreach (ShaderData t in ilt)
     {
         this.Add(t);
     }
     this.handler = handler;
 }
コード例 #17
0
 public ElementTextureRef(EventHandler handler, ElementTextureRef basis,
                          DependentList <TGIBlock> ParentTGIBlocks = null, string RCOLTag = null)
     : this(handler, basis.field, ParentTGIBlocks ?? basis._ParentTGIBlocks, RCOLTag ?? basis._RCOLTag)
 {
     if (_RCOLTag == "GEOM")
     {
         index = basis.index;
     }
     else
     {
         data = new GenericRCOLResource.GenericRCOLResource.ChunkReference(handler, basis.data);
     }
 }
コード例 #18
0
        public static ShaderData CreateEntry(EventHandler handler, Stream s, long start,
                                             DependentList <TGIBlock> _ParentTGIBlocks = null, string _RCOLTag = "MATD")
        {
            BinaryReader r      = new BinaryReader(s);
            FieldType    field  = (FieldType)r.ReadUInt32();
            DataType     sdType = (DataType)r.ReadUInt32();
            int          count  = r.ReadInt32();
            uint         offset = r.ReadUInt32();
            long         pos    = s.Position;

            s.Position = start + offset;
            try
            {
                #region Determine entry type
                switch (sdType)
                {
                case DataType.dtFloat:
                    switch (count)
                    {
                    case 1: return(new ElementFloat(handler, field, s));

                    case 2: return(new ElementFloat2(handler, field, s));

                    case 3: return(new ElementFloat3(handler, field, s));

                    case 4: return(new ElementFloat4(handler, field, s));
                    }
                    throw new InvalidDataException(String.Format("Invalid count #{0}' for DataType 0x{1:X8} at 0x{2:X8}", count, sdType, s.Position));

                case DataType.dtInt:
                    switch (count)
                    {
                    case 1: return(new ElementInt(handler, field, s));
                    }
                    throw new InvalidDataException(String.Format("Invalid count #{0}' for DataType 0x{1:X8} at 0x{2:X8}", count, sdType, s.Position));

                case DataType.dtTexture:
                    switch (count)
                    {
                    case 4: return(new ElementTextureRef(handler, field, s, _ParentTGIBlocks, _RCOLTag));

                    case 5: return(new ElementTextureKey(handler, field, s));
                    }
                    throw new InvalidDataException(String.Format("Invalid count #{0}' for DataType 0x{1:X8} at 0x{2:X8}", count, sdType, s.Position));
                }
                throw new InvalidDataException(String.Format("Unknown DataType 0x{0:X8} at 0x{1:X8}", sdType, s.Position));
                #endregion
            }
            finally { s.Position = pos; }
        }
コード例 #19
0
        public SearchDayViewModel(Attendee attendee, Day day, ImageCache imageCache, SearchModel searchModel)
        {
            _attendee    = attendee;
            _day         = day;
            _imageCache  = imageCache;
            _searchModel = searchModel;

            _matchingSessionPlaces = new DependentList <SessionPlace>(() =>
                                                                      _searchModel.SearchTerm == null || _searchModel.SearchTerm.Length < 3 ?
                                                                      Enumerable.Empty <SessionPlace>() :
                                                                      from time in _day.Times
                                                                      from sessionPlace in time.AvailableSessions
                                                                      where sessionPlace.Session.Matches(_searchModel.SearchTerm.ToLower())
                                                                      select sessionPlace);
        }
コード例 #20
0
        public SearchDayViewModel(Attendee attendee, Day day, ImageCache imageCache, SearchModel searchModel)
        {
            _attendee = attendee;
            _day = day;
            _imageCache = imageCache;
            _searchModel = searchModel;

            _matchingSessionPlaces = new DependentList<SessionPlace>(() =>
                _searchModel.SearchTerm == null || _searchModel.SearchTerm.Length < 3 ?
                    Enumerable.Empty<SessionPlace>() :
                    from time in _day.Times
                    from sessionPlace in time.AvailableSessions
                    where sessionPlace.Session.Matches(_searchModel.SearchTerm.ToLower())
                    select sessionPlace);
        }
コード例 #21
0
ファイル: VPXY.cs プロジェクト: Onebeld/Regul
            public static Entry CreateEntry(EventHandler handler, Stream s, DependentList <TGIBlock> ParentTGIBlocks)
            {
                BinaryReader r         = new BinaryReader(s);
                byte         entryType = r.ReadByte();

                if (entryType == 0x00)
                {
                    return(new Entry00(handler, 0, r.ReadByte(), s, ParentTGIBlocks));
                }
                if (entryType == 0x01)
                {
                    return(new Entry01(handler, 1, r.ReadInt32(), ParentTGIBlocks));
                }
                throw new InvalidDataException(String.Format("Unknown EntryType 0x{0:X2} at 0x{1:X8}", entryType, s.Position));
            }
コード例 #22
0
 public void Initialize()
 {
     _model = new ContactList();
     _model.AddContact(new Contact()
     {
         FirstName = "Charles", LastName = "Babbage"
     });
     _model.AddContact(new Contact()
     {
         FirstName = "Alan", LastName = "Turing"
     });
     _contactViewModels = new DependentList <ContactViewModel>(() =>
                                                               from c in _model.Contacts
                                                               select new ContactViewModel(c)
                                                               );
 }
コード例 #23
0
        public void TestDependentList()
        {
            var obj = new DependentList();
            var dependentCounter     = 0;
            var sourcesCounter       = 0;
            var dependentExpectation = 0;
            var sourcesExpectation   = 0;

            ObservableUtility.FromProperty(() => obj.DependentCount).Subscribe(_ => dependentCounter++);
            ObservableUtility.FromProperty(() => obj.Sources).Subscribe(_ => sourcesCounter++);

            Assert.AreEqual(++sourcesExpectation, sourcesCounter);
            Assert.AreEqual(++dependentExpectation, dependentCounter);
            Assert.AreEqual(0, obj.DependentCount);
            Assert.AreEqual(0, obj.SourcesCount);
            obj.Sources = new ObservableCollection <Source>();
            Assert.AreEqual(++sourcesExpectation, sourcesCounter);
            Assert.AreEqual(++dependentExpectation, dependentCounter);

            Assert.AreEqual(0, obj.DependentCount);
            Assert.AreEqual(0, obj.SourcesCount);
            obj.Sources.Add(new Source());
            Assert.AreEqual(1, obj.DependentCount);
            Assert.AreEqual(1, obj.SourcesCount);
            Assert.AreEqual(++sourcesExpectation, sourcesCounter);
            Assert.AreEqual(++dependentExpectation, dependentCounter);

            obj.Dependent.Add(new Source());
            Assert.AreEqual(++dependentExpectation, dependentCounter);

            Assert.AreEqual(2, obj.DependentCount);
            Assert.AreEqual(2, obj.SourcesCount);
            var newList = new ObservableCollection <Source>();

            obj.Sources = newList;
            Assert.AreEqual(0, obj.DependentCount);
            Assert.AreEqual(0, obj.SourcesCount);
            Assert.AreEqual(++dependentExpectation, dependentCounter);

            obj.Sources.Add(new Source());
            Assert.AreEqual(++dependentExpectation, dependentCounter);

            Assert.AreEqual(1, obj.DependentCount);
            Assert.AreEqual(1, obj.SourcesCount);
            obj.Sources.RemoveAt(0);
            Assert.AreEqual(++dependentExpectation, dependentCounter);
        }
コード例 #24
0
ファイル: MainForm.cs プロジェクト: mrhodes/Sims4Tools
        /// <summary>
        /// Displays a modal form allowing a list of TGIBlocks to be edited (created, updated, deleted).
        /// </summary>
        /// <param name="owner">Any object that implements System.Windows.Forms.IWin32Window
        /// and represents the top-level window that will own this form.</param>
        /// <param name="ltgi">an AResource.DependentList&lt;AResource.TGIBlock&gt; object.</param>
        /// <returns>the DialogResult</returns>
        public static DialogResult Show(IWin32Window owner, DependentList <TGIBlock> ltgi)
        {
            TGIBlockListEditorForm.MainForm theForm = new System.Windows.Forms.TGIBlockListEditorForm.MainForm();
            theForm.Items = ltgi;
            if (owner as Form != null)
            {
                theForm.Icon = (owner as Form).Icon;
            }
            DialogResult dr = theForm.ShowDialog();

            if (dr != DialogResult.OK)
            {
                return(dr);
            }
            ltgi.Clear();
            ltgi.AddRange(theForm.Items);
            return(dr);
        }
コード例 #25
0
        public void DependentListMultiThreadingTrap()
        {
            var list           = new DependentList();
            var counter        = 0;
            var victimWaiter   = new Waiter();
            var attackerWaiter = new Waiter();

            var observableExpression = new DebugReactiveExpression <int>(() => list.DependentCount, "DependentCountObserver");

            observableExpression.Evaluate();

            var victim = new Thread(() =>
            {
                observableExpression.Skip(1).Subscribe(s =>
                {
                    s();
                    counter++;
                    attackerWaiter.Release();
                    victimWaiter.Wait();
                });

                list.Sources.Add(new Source());
                Assert.AreEqual(1, counter);
            });

            var attackerList = new DependentList();

            var attacker = new Thread(() =>
            {
                attackerWaiter.Wait();
                attackerList.Sources.Add(new Source());
                victimWaiter.Release();
            });

            Assert.AreEqual(0, attackerList.DependentCount);

            victim.Start();
            attacker.Start();

            victim.Join();
            attacker.Join();

            Assert.AreEqual(1, counter);
        }
コード例 #26
0
        public void Undo_UpdateDepthFudge(float fFudge, bool bNewFudge = false)
        {
#if UNITY_EDITOR
            DependentList.ForEach(r =>
            {
                var Iso2D = r.GetComponent <Iso2DObject>();
                if (Iso2D != null)
                {
                    if (bNewFudge)
                    {
                        Iso2D.Undo_NewDepthFudge(fFudge);
                    }
                    else
                    {
                        Iso2D.Undo_AddDepthFudge(fFudge);
                    }
                }
            });
#endif
        }
コード例 #27
0
ファイル: RowVM.cs プロジェクト: sizzles/ecsharp
        //DisplaySettingsVM _settings;

        public RowVM(RowModel model, ProjectVM tree, RowVM parent) : base(model)
        {
            Tree   = tree;
            Parent = parent;
            //_settings = settings;
            //settings.PropertyChanged += new PropertyChangedEventHandler(Settings_PropertyChanged);

            _children = new DependentList <RowVM>(() => Tree.Filter.ApplyTo(model.Children).Select(m => new RowVM(m, Tree, this)));
            _children.DependentSentry.Invalidated += () => Tree.FireChildrenInvalidated(this);
            _depChangeDetector = Dependent.New("RowVM._depChangeDetector", () => {
                // Watch for changes in any of the model's properties,
                // to trigger a screen refresh when using TreeViewAdv
                var a = Model.Type;
                var b = Model.Name;
                var c = Model.Status;
                var d = Model.Priority;
                var e = Model.RunTime;
                var f = Model.Summary;
            });
            _depChangeDetector.Invalidated += () => Tree.FireRowInvalidated(this);
        }
コード例 #28
0
 public TypedValuePropertyDescriptor(AApiVersionedFields owner, string field, Attribute[] attrs)
     : base(field, attrs)
 {
     try
     {
         this.owner = owner;
         if (typeof(ArrayOwner).Equals(owner.GetType()))
         {
             fieldType = ((ArrayOwner)owner).ElementType;
         }
         else if (typeof(AsKVP).Equals(owner.GetType()))
         {
             fieldType = ((AsKVP)owner).GetType(Name);
         }
         else
         {
             string name = GetFieldName(field);
             fieldType = GetFieldType(owner, field);
             priority  = ElementPriorityAttribute.GetPriority(owner.GetType(), name);
             tgiBlocks = owner.GetTGIBlocks(name);
         }
     }
     catch (Exception ex) { throw ex; }
 }
コード例 #29
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public CDTAssetResourceName(int APIversion, EventHandler handler, string key, byte controlCode, int data, DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(APIversion, handler, key, controlCode, data, ParentTGIBlocks)
 {
 }
コード例 #30
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public CDTAssetResourceName(int APIversion, EventHandler handler, DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(APIversion, handler, "CDTAssetResourceName-Key", (byte)0x02, (Int32)0, ParentTGIBlocks)
 {
 }
コード例 #31
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 internal ComponentDataList(EventHandler handler, Stream s, DependentList <TGIBlock> ParentTGIBlocks = null)
     : this(null, ParentTGIBlocks)
 {
     elementHandler = handler; Parse(s); this.handler = handler;
 }
コード例 #32
0
ファイル: TGIBlockCombo.cs プロジェクト: falerin/Sims4Tools
 public TGIBlockCombo(DependentList<TGIBlock> tgiBlocks, int index, bool showEdit) : this() { TGIBlocks = tgiBlocks; SelectedIndex = index; ShowEdit = showEdit; }
コード例 #33
0
ファイル: TGIBlockCombo.cs プロジェクト: falerin/Sims4Tools
 public TGIBlockCombo(DependentList<TGIBlock> tgiBlocks, int index) : this(tgiBlocks, index, true) { }
コード例 #34
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public CDTResourceKey(int APIversion, EventHandler handler, string key, byte controlCode, int data, DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(APIversion, handler, key, controlCode)
 {
     this.ParentTGIBlocks = ParentTGIBlocks; this.data = data;
 }
コード例 #35
0
ファイル: MainForm.cs プロジェクト: falerin/Sims4Tools
 /// <summary>
 /// Displays a modal form allowing a list of TGIBlocks to be edited (created, updated, deleted).
 /// </summary>
 /// <param name="ltgi">an AResource.DependentList&lt;AResource.TGIBlock&gt; object.</param>
 /// <returns>the DialogResult</returns>
 public static DialogResult Show(DependentList<TGIBlock> ltgi)
 {
     return Show(OwningForm, ltgi);
 }
コード例 #36
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public CDTAssetResourceName(int APIversion, EventHandler handler, CDTAssetResourceName basis, DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(APIversion, handler, basis, ParentTGIBlocks ?? basis.ParentTGIBlocks)
 {
 }
コード例 #37
0
ファイル: MainForm.cs プロジェクト: falerin/Sims4Tools
 /// <summary>
 /// Displays a modal form allowing a list of TGIBlocks to be edited (created, updated, deleted).
 /// </summary>
 /// <param name="owner">Any object that implements System.Windows.Forms.IWin32Window
 /// and represents the top-level window that will own this form.</param>
 /// <param name="ltgi">an AResource.DependentList&lt;AResource.TGIBlock&gt; object.</param>
 /// <returns>the DialogResult</returns>
 public static DialogResult Show(IWin32Window owner, DependentList<TGIBlock> ltgi)
 {
     TGIBlockListEditorForm.MainForm theForm = new System.Windows.Forms.TGIBlockListEditorForm.MainForm();
     theForm.Items = ltgi;
     if (owner as Form != null) theForm.Icon = (owner as Form).Icon;
     DialogResult dr = theForm.ShowDialog();
     if (dr != DialogResult.OK) return dr;
     ltgi.Clear();
     ltgi.AddRange(theForm.Items);
     return dr;
 }
コード例 #38
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public ComponentDataList(EventHandler handler, DependentList <TGIBlock> ParentTGIBlocks = null)
     : base(handler, Byte.MaxValue)
 {
     _ParentTGIBlocks = ParentTGIBlocks;
 }
コード例 #39
0
        internal static void UpdateSourceDependentLists(DependencyObject d, DependencyProperty dp, DependencySource[] sources, Expression expr, bool add) 
        {
            // Sources already validated to be on the same thread as Dependent (d)

            if (sources != null) 
            {
                // don't hold a reference on the dependent if the expression is doing 
                // the invalidations.  This helps avoid memory leaks (bug 871139) 
                if (expr.ForwardsInvalidations)
                { 
                    d = null;
                    dp = null;
                }
 
                for (int i = 0; i < sources.Length; i++)
                { 
                    DependencySource source = sources[i]; 

                    // A Sealed DependencyObject does not have a Dependents list 
                    // so don't bother updating it (or attempt to add one).

                    Debug.Assert((!source.DependencyObject.IsSealed) ||
                            (DependentListMapField.GetValue(source.DependencyObject) == default(object))); 

                    if (!source.DependencyObject.IsSealed) 
                    { 
                        // Retrieve the DependentListMap for this source
                        // The list of dependents to invalidate is stored using a special negative key 

                        FrugalMap dependentListMap;
                        object value = DependentListMapField.GetValue(source.DependencyObject);
                        if (value != null) 
                        {
                            dependentListMap = (FrugalMap)value; 
                        } 
                        else
                        { 
                            dependentListMap = new FrugalMap();
                        }

                        // Get list of DependentList off of ID map of Source 
                        object dependentListObj = dependentListMap[source.DependencyProperty.GlobalIndex];
                        Debug.Assert(dependentListObj != null, "dependentList should either be unset or non-null"); 
 
                        // Add/Remove new Dependent (this) to Source's list
                        if (add) 
                        {
                            DependentList dependentList;
                            if (dependentListObj == DependencyProperty.UnsetValue)
                            { 
                                dependentListMap[source.DependencyProperty.GlobalIndex] = dependentList = new DependentList();
                            } 
                            else 
                            {
                                dependentList = (DependentList)dependentListObj; 
                            }

                            dependentList.Add(d, dp, expr);
                        } 
                        else
                        { 
                            if (dependentListObj != DependencyProperty.UnsetValue) 
                            {
                                DependentList dependentList = (DependentList)dependentListObj; 

                                dependentList.Remove(d, dp, expr);

                                if (dependentList.IsEmpty) 
                                {
                                    // No more dependencies for this property; reclaim the space if we can. 
                                    dependentListMap[source.DependencyProperty.GlobalIndex] = DependencyProperty.UnsetValue; 
                                }
                            } 
                        }

                        // Set the updated struct back into the source's _localStore.
                        DependentListMapField.SetValue(source.DependencyObject, dependentListMap); 
                    }
                } 
            } 
        }
コード例 #40
0
ファイル: ObjKeyResource.cs プロジェクト: yalaier/Sims4Tools
 public ComponentDataList(EventHandler handler, IEnumerable <ComponentDataType> lcdt, DependentList <TGIBlock> ParentTGIBlocks = null)
     : this(null, ParentTGIBlocks)
 {
     elementHandler = handler; foreach (var t in lcdt)
     {
         this.Add((ComponentDataType)t.Clone(null));
     }
     this.handler = handler;
 }
コード例 #41
0
ファイル: TGIBlockCombo.cs プロジェクト: falerin/Sims4Tools
 public TGIBlockCombo(DependentList<TGIBlock> tgiBlocks) : this(tgiBlocks, -1, true) { }