Exemplo n.º 1
0
            public CarDisplayNameBind(TextBlock text, AcItemWrapper wrapper)
            {
                _text    = text;
                _wrapper = wrapper;

                WeakEventManager <AcItemWrapper, WrappedValueChangedEventArgs> .AddHandler(wrapper, nameof(AcItemWrapper.ValueChanged), Wrapper_ValueChanged);

                if (wrapper.IsLoaded)
                {
                    WeakEventManager <INotifyPropertyChanged, PropertyChangedEventArgs> .AddHandler(wrapper.Value, nameof(INotifyPropertyChanged.PropertyChanged),
                                                                                                    Value_PropertyChanged);
                }

                _text.Text = wrapper.Value.DisplayName;
            }
Exemplo n.º 2
0
        public async Task Test()
        {
            var b = new AcWrapperObservableCollection();
            var e = new AcEnabledOnlyCollection <AcFakeObject>(b);

            // First run
            b.Add(new AcItemWrapper(new AcFakeObject("a", true)));
            await Task.Delay(1);

            b.Add(new AcItemWrapper(new AcFakeObject("b", true)));
            b.Add(new AcItemWrapper(new AcFakeObject("c", false)));
            Assert.AreEqual("a,b", e.Select(x => x.Id).JoinToString(','));

            // Loading
            var w = new AcItemWrapper(new FakeLoader(), new AcPlaceholderNew("a", true));

            b.Add(w);
            Assert.AreEqual("a,b", e.Select(x => x.Id).JoinToString(','));
            w.Value = new AcFakeObject("L", true);
            Assert.AreEqual("a,b,L", e.Select(x => x.Id).JoinToString(','));

            // Removal
            b.RemoveAt(1);
            b.RemoveAt(2);
            await Task.Delay(1);

            b.Add(new AcItemWrapper(new AcFakeObject("q", true)));
            Assert.AreEqual("a,q", e.Select(x => x.Id).JoinToString(','));

            // Replacement
            b.Replace(b.First(x => x.Id == "a"), new AcItemWrapper(new AcFakeObject("a", false)));
            b.Replace(b.First(x => x.Id == "c"), new AcItemWrapper(new AcFakeObject("c", true)));
            Assert.AreEqual("c,q", e.Select(x => x.Id).JoinToString(','));

            // Insert
            b.Insert(0, new AcItemWrapper(new AcFakeObject("m", true)));
            Assert.AreEqual("m,c,q", e.Select(x => x.Id).JoinToString(','));
        }
        private void RefreshFilter(AcItemWrapper obj)
        {
            if (!Loaded)
            {
                return;
            }

            if (CurrentItem == obj)
            {
                _testMeLater = CurrentItem;
                return;
            }

            _testMeLater = null;

            var contains = _mainList.OfType <AcItemWrapper>().Contains(obj);
            var newValue = FilterTest(obj);

            if (contains != newValue)
            {
                _list.RefreshFilter(obj);
            }
        }
Exemplo n.º 4
0
 protected override bool Test(AcItemWrapper source)
 {
     return(source.IsLoaded && source.Value.Enabled);
 }
Exemplo n.º 5
0
 protected override T Wrap(AcItemWrapper source)
 {
     return((T)source.Value);
 }
 int IComparer.Compare(object x, object y)
 {
     return(AcItemWrapper.CompareHelper(x, y));
 }
Exemplo n.º 7
0
 public CarEntry([NotNull] AcItemWrapper carObjectWrapper) : this(carObjectWrapper.Id, carObjectWrapper)
 {
 }
Exemplo n.º 8
0
 private CarEntry(string carId, AcItemWrapper carObjectWrapper)
 {
     Id = carId;
     CarObjectWrapper = carObjectWrapper;
     CarExists        = carObjectWrapper != null;
 }