public void CollectionShouldBeUpdated(int section, params int[] newItems)
            {
                Setup();

                var items = new MvxObservableCollection <MvxObservableCollection <int> >
                {
                    new MvxObservableCollection <int>
                    {
                        1, 2
                    },
                    new MvxObservableCollection <int>
                    {
                        3, 4, 5, 6
                    }
                };

                var sut = new FlatObservableCollection <int>(items);

                items[section].ReplaceWith(newItems);

                var flatItems = GetFlatItems(items).ToArray();
                var flatCount = flatItems.Length;

                Assert.AreEqual(flatCount, sut.Count);
                Assert.AreEqual(flatItems, sut);
            }
Example #2
0
        private async Task <bool> LoadGrades()
        {
            log.Debug("PrepayViewModel: Loading grades.");
            var pump = fcsService.FCSConfig.Pumps
                       .Where(_pump => _pump.PumpID == PumpId.ToString())
                       .Single();

            SupportedGrades = new MvxObservableCollection <Grade>();

            foreach (var pumpGrade in pump.Grades)
            {
                try
                {
                    var grade = fcsService.FCSConfig.FuelPrice.Grades
                                .Where(_grade => _grade.Type == pumpGrade.Type)
                                .Single();
                    SupportedGrades.Add(grade);
                }
                catch { }
            }

            if (SupportedGrades.Count <= 0)
            {
                return(false);
            }
            else
            {
                SelectedGrade = SupportedGrades[0];
                return(true);
            }
        }
Example #3
0
        public MainViewModel(IBlockchainService blockchainService)
        {
            _blockChainService = blockchainService;
            List <Block> blockBufor = _blockChainService.GetBlock();

            Blocks = new MvxObservableCollection <Block>(blockBufor);
        }
Example #4
0
        public ForwardViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            Items = new MvxObservableCollection <Chat>();

            SendCommand = new RelayCommand(SendExecute, () => SelectedItem != null);
        }
Example #5
0
        public StatisticCashFlowViewModel(IMvxMessenger messenger, CashFlowDataProvider cashFlowDataProvider)
            : base(messenger)
        {
            this.cashFlowDataProvider = cashFlowDataProvider;

            StatisticItems = new MvxObservableCollection <StatisticItem>();
        }
Example #6
0
 public TodoListViewModel(ITodoService service)
 {
     _service           = service;
     _deleteItemCommand = new MvxAsyncCommand <TodoItemViewModel>(DeleteItemAsync);
     Items      = new MvxObservableCollection <TodoItemViewModel>();
     AddCommand = new MvxAsyncCommand(AddItemAsync);
 }
        public override async Task Initialize()
        {
            ChatMessages       = new MvxObservableCollection <ChatMessage>();
            OpenMessageCommand = new MvxAsyncCommand <ChatMessage>(async(e) => {
                if (e.Files?.Count > 0)
                {
                    await OpenMessage(e);
                }
            });

            BeginTime = EndTime = DateTime.Now;
            if (timer == null)
            {
                timer          = new Timer(App.Context.PullMessageTime * 1000);
                timer.Elapsed += async(sender, e) =>
                {
                    if (LoadNewMessageTask == null || LoadNewMessageTask.IsCompleted)
                    {
                        await LoadNewMessage.ExecuteAsync();
                    }
                };
            }

            timer.Start();
            await LoadChatMessages();

            await base.Initialize();
        }
        public SettingsQuickReactionViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            Items = new MvxObservableCollection <SettingsReactionOption>();

            SendCommand = new RelayCommand(SendExecute);
        }
Example #9
0
        public override async Task Initialize()
        {
            Files = new MvxObservableCollection <File>();
            await LoadDocuments();

            await base.Initialize();
        }
Example #10
0
 public HomeViewModel(IApiService apiService, IMvxNavigationService navigationService, /*IDialogService dialogService*/ IUserDialogs dialogService)
 {
     this.apiService        = apiService;
     this.navigationService = navigationService;
     this.dialogService     = dialogService;
     itemsPosts             = new MvxObservableCollection <Post>();
 }
Example #11
0
        public TagViewModel(IRepository Repository, IMvxNavigationService Navigation)
        {
            Tags = new MvxObservableCollection <TagPresentation>();

            repository = Repository;
            navigation = Navigation;
        }
Example #12
0
 public MessagesViewModel(IMessageService messageService, IChatService chatService, IMvxMessenger messenger)
 {
     _messageService = messageService;
     _chatService    = chatService;
     _chatMessageSubscriptionToken = messenger.Subscribe <ChatMessage>(OnNewMessage);
     MessageItemViewModels         = new MvxObservableCollection <MessageItemViewModel>();
 }
Example #13
0
 public MenuViewModel(IMvxNavigationService navigationService, IMvxMessenger messenger)
 {
     _navigationService = navigationService;
     _token             = messenger.Subscribe <UpdateLanguageMessage>(OnUpdateLanguageMessage);
     MenuItemList       = new MvxObservableCollection <CommonMenuItem>()
     {
         new CommonMenuItem {
             Icon = "\uf015", Code = "Home", Name = AppResources.Menu_Home
         },
         new CommonMenuItem {
             Icon = "\uf201", Code = "Chart", Name = AppResources.Menu_Chart
         },
         //new CommonMenuItem{Icon = "\uf03a", Name = "Edit"},
         new CommonMenuItem {
             Icon = "\uf013", Code = "Settings", Name = AppResources.Menu_Settings
         },
         //new CommonMenuItem{Icon = "\uf1e0", Name = "Share" },
         //new CommonMenuItem{Icon = "\uf118", Name = "Like Me!" },
         //new CommonMenuItem{Icon = "\uf0e0", Name = "Feedback" },
         //new CommonMenuItem{Icon = "\uf4c4", Name = "Help" },
         new CommonMenuItem {
             Icon = "\uf129", Code = "About", Name = AppResources.Menu_About
         },
     };
 }
            public void CollectionShouldBeUpdated(int section, int oldIndex, int newIndex)
            {
                Setup();

                var items = new MvxObservableCollection <MvxObservableCollection <int> >
                {
                    new MvxObservableCollection <int>
                    {
                        1, 2
                    },
                    new MvxObservableCollection <int>
                    {
                        3, 4, 5, 6
                    }
                };

                var flatOldItems = GetFlatItems(items).ToArray();
                var flatOldCount = flatOldItems.Length;

                var sut = new FlatObservableCollection <int>(items);

                items[section].Move(oldIndex, newIndex);

                var flatNewItems = GetFlatItems(items).ToArray();
                var flatNewCount = flatNewItems.Length;

                Assert.AreEqual(flatOldCount, sut.Count);
                Assert.AreEqual(flatNewCount, sut.Count);
                Assert.AreEqual(flatNewItems, sut);
            }
Example #15
0
        public void ValidateStartingIndexOnAddRangeTest()
        {
            var collection = new MvxObservableCollection <string>();
            var newItems   = new[] { "Bar", "Baz", "Herp", "Derp" };

            NotifyCollectionChangedEventHandler handler = (s, a) =>
            {
                Assert.Equal(0, a.NewStartingIndex);
                Assert.Equal(newItems.Length, a.NewItems.Count);
                Assert.Null(a.OldItems);
            };

            collection.CollectionChanged += handler;

            collection.AddRange(newItems);
            var newStartIndex = collection.Count;

            collection.CollectionChanged -= handler;

            handler = (s, a) => {
                Assert.Equal(newStartIndex, a.NewStartingIndex);
                Assert.Equal(newItems.Length, a.NewItems.Count);
            };

            collection.CollectionChanged += handler;

            collection.AddRange(newItems);
        }
Example #16
0
        public override void Prepare(ExcersizeLogWrapper parameter)
        {
            excersizeLogWrapper = parameter;
            if (parameter.LoggedExcersizeTemp.ExcersizeID == null)
            {
                CurrentLoggedExcersize = new LoggedExcersize();
            }

            CurrentLoggedExcersize = parameter.LoggedExcersizeTemp;

            CurrentLoggedExcersize.ExcersizeID   = parameter.ExcersizeTemplate.ID;
            CurrentLoggedExcersize.ExcersizeName = parameter.ExcersizeTemplate.Name;

            if (parameter.LogComplete)
            {
                CurrentLoggedExcersize.Sets = parameter.LoggedExcersizeTemp.Sets;
                LoggingSets = new MvxObservableCollection <LoggingSet>(parameter.LoggedExcersizeTemp.Sets);
            }
            else
            {
                CurrentLoggedExcersize.Sets = new List <LoggingSet>();

                CurrentTemplate = parameter.ExcersizeTemplate;

                int setsToLog = int.Parse(parameter.ExcersizeTemplate.Sets);
                LoggingSets = new MvxObservableCollection <LoggingSet>();

                for (int i = 0; i < setsToLog; i++)
                {
                    LoggingSet toAdd = new LoggingSet();
                    LoggingSets.Add(toAdd);
                }
            }
        }
Example #17
0
 /// <summary>
 ///     Initializes a new instance of the
 ///     <see cref="T:MoneyFox.Business.ViewModels.Statistic.StatisticCategorySummaryViewModel" /> class.
 /// </summary>
 /// <param name="categorySummaryDataDataProvider">Category summary data data provider.</param>
 /// <param name="messenger">Messenger.</param>
 /// <param name="settingsManager">Instance of a ISettingsManager</param>
 public StatisticCategorySummaryViewModel(CategorySummaryDataProvider categorySummaryDataDataProvider,
                                          IMvxMessenger messenger,
                                          ISettingsManager settingsManager) : base(messenger, settingsManager)
 {
     this.categorySummaryDataDataProvider = categorySummaryDataDataProvider;
     CategorySummary = new MvxObservableCollection <StatisticItem>();
 }
 public AdminPostCommentsViewModel(IMvxNavigationService navigationService,
                                   IPostCommentService commentForPostService)
 {
     _navigationService     = navigationService;
     _commentForPostService = commentForPostService;
     PostCommentViewModels  = new MvxObservableCollection <PostCommentViewModel>();
 }
Example #19
0
 public AdminUsersViewModel(IMvxNavigationService navigationService, IUserService userService)
 {
     _navigationService      = navigationService;
     _userService            = userService;
     AdminUserItemViewModels = new MvxObservableCollection <AdminUserItemViewModel>();
     this.SubscribeSearchText(nameof(SearchText), SearchCommand, () => !IsRefreshing && !IsLoading);
 }
Example #20
0
 public VMDetailPokemon(IMvxNavigationService navigationService, IPokemonService pokemonService, IRestClient restClient)
 {
     _navigationService = navigationService;
     _pokemonService    = pokemonService;
     _restClient        = restClient;
     PokemonsTypes      = new MvxObservableCollection <PokemonGeneration>();
 }
Example #21
0
        public ChatsViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator, INotificationsService notificationsService, ChatList chatList)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            _notificationsService = notificationsService;

            Items = new ItemsCollection(protoService, aggregator, this, chatList);

            ChatPinCommand     = new RelayCommand <Chat>(ChatPinExecute);
            ChatArchiveCommand = new RelayCommand <Chat>(ChatArchiveExecute);
            ChatMarkCommand    = new RelayCommand <Chat>(ChatMarkExecute);
            ChatNotifyCommand  = new RelayCommand <Chat>(ChatNotifyExecute);
            ChatDeleteCommand  = new RelayCommand <Chat>(ChatDeleteExecute);
            ChatClearCommand   = new RelayCommand <Chat>(ChatClearExecute);
            ChatSelectCommand  = new RelayCommand <Chat>(ChatSelectExecute);

            ChatsMarkCommand    = new RelayCommand(ChatsMarkExecute);
            ChatsNotifyCommand  = new RelayCommand(ChatsNotifyExecute);
            ChatsArchiveCommand = new RelayCommand(ChatsArchiveExecute);
            ChatsDeleteCommand  = new RelayCommand(ChatsDeleteExecute);
            ChatsClearCommand   = new RelayCommand(ChatsClearExecute);

            FolderAddCommand    = new RelayCommand <(int, Chat)>(FolderAddExecute);
            FolderRemoveCommand = new RelayCommand <(int, Chat)>(FolderRemoveExecute);
            FolderCreateCommand = new RelayCommand <Chat>(FolderCreateExecute);

            ClearRecentChatsCommand = new RelayCommand(ClearRecentChatsExecute);

            TopChatDeleteCommand = new RelayCommand <Chat>(TopChatDeleteExecute);

#if MOCKUP
            Items.AddRange(protoService.GetChats(null));
#endif

            SelectedItems = new MvxObservableCollection <Chat>();
        }
        public SettingsNetworkViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            Items = new MvxObservableCollection <KeyedList <TdNetworkType, NetworkStatisticsEntry> >();

            ResetCommand = new RelayCommand(ResetExecute);
        }
Example #23
0
        public DialogGalleryViewModel(IProtoService protoService, IEventAggregator aggregator, long chatId, Message selected)
            : base(protoService, aggregator)
        {
            _group  = new MvxObservableCollection <GalleryItem>();
            _chatId = chatId;

            //if (selected.Media is TLMessageMediaPhoto photoMedia || selected.IsVideo())
            //{
            //    Items = new MvxObservableCollection<GalleryItem> { new GalleryLegacyMessageItem(selected) };
            //    SelectedItem = Items[0];
            //    FirstItem = Items[0];
            //}
            //else
            //{
            //    Items = new MvxObservableCollection<GalleryItem>();
            //}

            //Initialize(selected.Id);

            Items = new MvxObservableCollection <GalleryItem> {
                new GalleryMessageItem(protoService, selected)
            };
            SelectedItem = Items[0];
            FirstItem    = Items[0];

            Initialize(selected.Id);
        }
Example #24
0
        public PlaybackViewModel(IProtoService protoService, ICacheService cacheService, IEventAggregator aggregator, IPlaybackService playbackService)
            : base(protoService, cacheService, aggregator)
        {
            _playbackService = playbackService;

            Items = new MvxObservableCollection <Message>();
        }
        public SettingsLanguageViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            Items = new MvxObservableCollection <LanguagePackInfo>();

            ChangeCommand = new RelayCommand <LanguagePackInfo>(ChangeExecute);
        }
        public async Task <MvxObservableCollection <ICatalogItemVM> > LoadProductsInCategory(string categoryId,
                                                                                             int offset                   = 0,
                                                                                             int count                    = 10,
                                                                                             string searchText            = null,
                                                                                             List <ApplyedFilter> filters = null,
                                                                                             SortType sort                = null)
        {
            MvxObservableCollection <ICatalogItemVM> dataSource = null;

            try
            {
                var products = await ProductService.LoadProductsInCategory(
                    categoryId,
                    offset,
                    count,
                    searchText,
                    filters,
                    sort
                    );

                dataSource = new MvxObservableCollection <ICatalogItemVM>(products.Select(SetupItem));
            }
            catch (ConnectionException ex)
            {
                OnConnectionException(ex);
            }
            catch (Exception ex)
            {
                OnException(ex);
            }

            return(dataSource);
        }
Example #27
0
        private async void SearchExecute(string query)
        {
            Query = query;

            var response = await ProtoService.SearchAsync(_dialog.Peer, _query, _from?.ToInputUser(), null, 0, 0, 0, 0, 100);

            if (response.IsSucceeded && response.Result is ITLMessages result)
            {
                if (response.Result is TLMessagesMessagesSlice slice)
                {
                    TotalItems = slice.Count;
                }
                else if (response.Result is TLMessagesChannelMessages channelMessages)
                {
                    TotalItems = channelMessages.Count;
                }
                else
                {
                    TotalItems = result.Messages.Count;
                }

                Items        = new MvxObservableCollection <TLMessageBase>(result.Messages);
                SelectedItem = Items.FirstOrDefault();

                if (_selectedItem != null)
                {
                    await Dialog.LoadMessageSliceAsync(null, _selectedItem.Id);
                }
            }
            else
            {
                // TODO
            }
        }
Example #28
0
        public void AddRangeSuppressesChangesTest()
        {
            var collection  = new MvxObservableCollection <string>();
            var invokeCount = 0;

            collection.CollectionChanged += (s, e) =>
            {
                invokeCount++;
            };

            collection.Add("Foo");

            Assert.Equal(1, invokeCount);
            Assert.Contains("Foo", collection);

            var newItems = new[] { "Bar", "Baz", "Herp", "Derp" };

            collection.AddRange(newItems);

            Assert.Equal(2, invokeCount);

            foreach (var item in newItems)
            {
                Assert.Contains(item, collection);
            }
        }
        public InviteViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator, IContactsService contactsService)
            : base(protoService, cacheService, settingsService, aggregator)
        {
            _contactsService = contactsService;

            Items = new MvxObservableCollection <object>();
        }
            public void ResetEventShouldBeRaised(int section, params int[] newItems)
            {
                Setup();

                var events = new List <NotifyCollectionChangedEventArgs>();

                var items = new MvxObservableCollection <MvxObservableCollection <int> >
                {
                    new MvxObservableCollection <int>
                    {
                        1, 2
                    },
                    new MvxObservableCollection <int>
                    {
                        3, 4, 5, 6
                    }
                };

                var sut = new FlatObservableCollection <int>(items);

                sut.CollectionChanged += (_, args) => events.Add(args);

                items[section].ReplaceWith(newItems);

                Assert.AreEqual(1, events.Count);
                Assert.AreEqual(NotifyCollectionChangedAction.Reset, events[0].Action);
            }