Exemplo n.º 1
0
 public static void Replace <T>(this IObservableCollection <T> collection, IEnumerable <T> items)
 {
     collection.IsNotifying = false;
     collection.Clear();
     collection.AddRange(items);
     collection.IsNotifying = true;
     collection.Refresh();
 }
        public void ResetFiresClearsAndAdds()
        {
            var people = _generator.Take(10);

            _collection.AddRange(people);
            Assert.AreEqual(1, _results.Messages.Count, "Should be 1 updates");

            _collection.Reset();
            Assert.AreEqual(10, _results.Data.Count, "Should be 10 items in the cache");
            Assert.AreEqual(2, _results.Messages.Count, "Should be 2 updates");

            var update11 = _results.Messages[1];

            Assert.AreEqual(10, update11.Removes, "Should be 10 removes");
            Assert.AreEqual(10, update11.Adds, "Should be 10 adds");
            Assert.AreEqual(10, _results.Data.Count, "Should be 10 items in the cache");
        }
        /// <summary>
        /// Função chamada quando a tela é exibida
        /// </summary>
        protected override void OnActivate()
        {
            _manipulacoes.Clear();

            // Recupera uma referência do banco
            using (var db = new DataBase.ManipulaImagemContext())
            {
                // Carrega as manipulações cadastradas
                _manipulacoes.AddRange(
                    db.Manipulacoes.ToArray().Select(m =>
                {
                    var i         = IoC.Get <ManipulacaoItemViewModel>();
                    i.Manipulacao = m;
                    i.Excluido   += (s, e) => _manipulacoes.Remove(i);
                    return(i);
                }));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for the dependencies
        /// </summary>
        public FinderViewModel()
        {
            // Limit to 100 items
            ActiveDirectoryGlobals.SizeLimit = 100;
            ActiveDirectoryGlobals.PageSize  = 0;
            var query      = Query.AND.WhereIsUser().WhereEqualTo(UserProperties.Username, Environment.UserName);
            var userResult = query.Execute <IUser>().FirstOrDefault();

            if (userResult == null)
            {
                return;
            }
            query = Query.AND.WhereIsUser().WhereEqualTo(UserProperties.Department, userResult.Department);
            var departmentResult = query.Execute <IUser>();

            // Just something to generate some output
            Users.AddRange(departmentResult);
        }
Exemplo n.º 5
0
        private static void ReorderRecentFiles(IObservableCollection <RecentFileInfo> target)
        {
            if (target == null)
            {
                return;
            }

            var orderedItem = new List <RecentFileInfo>();

            orderedItem.AddRange(target.Where(p => p.FixedAt.HasValue).OrderByDescending(p => p.FixedAt));
            orderedItem.AddRange(target.Where(p => !p.FixedAt.HasValue).OrderByDescending(p => p.LastOpenedAt));

            target.IsNotifying = false;

            target.Clear();

            target.IsNotifying = true;

            target.AddRange(orderedItem);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Download all transactions for specific account of the specific user.
        /// </summary>
        /// <returns>Operation result.</returns>
        public IEnumerable <IResult> DownloadAllTransactions()
        {
            yield return(Show.Busy(new BusyScreen {
                Message = "Loading..."
            }));

            var request = new GetAllTransactionsResult(userId, CurrentAccount.Id);

            yield return(request);

            TransactionRecords.Clear();
            TransactionRecords.AddRange(request.TransactionRecords);

            if (Reloaded != null)
            {
                Reloaded(this, EventArgs.Empty);
            }

            yield return(Show.NotBusy());
        }
Exemplo n.º 7
0
        public void LoadEnumerable <T, TCollectionType>(
            Func <TService, IEnumerable <T> > func,
            IObservableCollection <TCollectionType> collection)
        {
            using (var service = proxyCreator())
            {
                var data = func(service);

                if (data == null)
                {
                    return;
                }

                var dataConverted =
                    typeof(T) != typeof(TCollectionType) ?
                    data.Select(item => Mapper.Map <TCollectionType>(item)) :
                    data.Select(item => (TCollectionType)(object)item);

                collection.AddRange(dataConverted);
            }
        }
Exemplo n.º 8
0
 public void Input(IEnumerable <T> data)
 {
     Reset();
     Datas.AddRange(data);
 }