public async Task InvokeTestFromOtherThread() { var collection = new ExtendedObservableCollection <string>(); var firstTask = Task.Run(() => { for (var i = 0; i <= 99999; i++) { collection.Add("test1"); } }); var secondTask = Task.Run(() => { for (var i = 0; i <= 99999; i++) { collection.Add("test2"); } }); await Task.WhenAll(firstTask, secondTask); Assert.Equal(200000, collection.Count); Assert.Equal(100000, collection.Count(x => x == "test1")); Assert.Equal(100000, collection.Count(x => x == "test2")); }
public void Test_AddRange_Ok() { int eventCount = 0; IEnumerable <int> initialNumbers = Enumerable.Range(1, 4); IEnumerable <int> newNumbers = Enumerable.Range(16, 32); ExtendedObservableCollection <int> observableCollection = new ExtendedObservableCollection <int>(initialNumbers); observableCollection.CollectionChanged += (sender, args) => eventCount++; observableCollection.AddRange(newNumbers); Assert.Equal(initialNumbers.Count() + newNumbers.Count(), observableCollection.Count); foreach (int number in initialNumbers) { Assert.Contains(observableCollection, numberItem => numberItem == number); } foreach (int number in newNumbers) { Assert.Contains(observableCollection, numberItem => numberItem == number); } Assert.Equal(1, eventCount); }
public GroupingsPageViewModel() { _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _folderService = ServiceContainer.Resolve <IFolderService>("folderService"); _collectionService = ServiceContainer.Resolve <ICollectionService>("collectionService"); _syncService = ServiceContainer.Resolve <ISyncService>("syncService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _vaultTimeoutService = ServiceContainer.Resolve <IVaultTimeoutService>("vaultTimeoutService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _passwordRepromptService = ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"); Loading = true; PageTitle = AppResources.MyVault; GroupedItems = new ExtendedObservableCollection <GroupingsPageListGroup>(); RefreshCommand = new Command(async() => { Refreshing = true; await LoadAsync(); }); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); }
public string SerializeBase64(ExtendedObservableCollection <string> o) { MemoryStream ws = new MemoryStream(); try { // Serialize to a base 64 string byte[] bytes; long length = 0; BinaryFormatter sf = new BinaryFormatter(); sf.Serialize(ws, o); length = ws.Length; bytes = ws.GetBuffer(); string encodedData = bytes.Length + ":" + Convert.ToBase64String(bytes, 0, bytes.Length, Base64FormattingOptions.None); ws.Flush(); ws.Close(); return(encodedData); } catch (Exception e) { ClientLogger.Instance.WriteEntry("Unexpected exception occured: " + e, MISD.Core.LogType.Exception); return(null); } finally { ws.Flush(); ws.Close(); ws.Dispose(); } }
public void Add_TwoItems_ItemsAreAddedAndCollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int>(); collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.Add(123); collection.Add(456); Assert.Equal(2, collection.Count); Assert.Equal(123, collection[0]); Assert.Equal(456, collection[1]); Assert.Equal(2, collectionChangedEventArgsList.Count); Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[0].Action); Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[1].Action); Assert.NotNull(collectionChangedEventArgsList[0].NewItems); Assert.Single(collectionChangedEventArgsList[0].NewItems); Assert.NotNull(collectionChangedEventArgsList[1].NewItems); Assert.Single(collectionChangedEventArgsList[1].NewItems); Assert.Equal(123, collectionChangedEventArgsList[0].NewItems[0]); Assert.Equal(456, collectionChangedEventArgsList[1].NewItems[0]); }
public void Item_SetNewItem_ItemIsUpdatedAndCollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int> { 135, 123, 456, 789 }; collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection[0] = 987; Assert.Equal(new[] { 987, 123, 456, 789 }, collection); Assert.Single(collectionChangedEventArgsList); Assert.Equal(NotifyCollectionChangedAction.Replace, collectionChangedEventArgsList[0].Action); Assert.NotNull(collectionChangedEventArgsList[0].OldItems); Assert.Single(collectionChangedEventArgsList[0].OldItems); Assert.Equal(135, collectionChangedEventArgsList[0].OldItems[0]); Assert.NotNull(collectionChangedEventArgsList[0].NewItems); Assert.Single(collectionChangedEventArgsList[0].NewItems); Assert.Equal(987, collectionChangedEventArgsList[0].NewItems[0]); }
private async Task GetNotifications() { try { var notificationModels = await _notificationService.GetAllAsync(ApiPriority.UserInitiated); var notifications = new List <INotification>(); if (notificationModels?.Notifications != null) { foreach (var notificationModel in notificationModels.Notifications) { // Get user notifications.Add(ToModel(notificationModel, notificationModels.RelatedItems)); } } Items = new ExtendedObservableCollection <INotification>(notifications.Where(n => n != null).OrderByDescending(n => n.CreationDateTime)); SendUpdateUnread(); } catch (Exception ex) { ExceptionService.HandleException(ex); } }
public void Move_OneItem_ItemIsMovedToNewIndex() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int> { 123, 456, 789 }; collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.Move(1, 2); Assert.Equal(new[] { 123, 789, 456 }, collection); Assert.Single(collectionChangedEventArgsList); Assert.Equal(NotifyCollectionChangedAction.Move, collectionChangedEventArgsList[0].Action); Assert.NotNull(collectionChangedEventArgsList[0].NewItems); Assert.Single(collectionChangedEventArgsList[0].NewItems); Assert.Equal(456, collectionChangedEventArgsList[0].NewItems[0]); Assert.NotNull(collectionChangedEventArgsList[0].OldItems); Assert.Single(collectionChangedEventArgsList[0].OldItems); Assert.Equal(456, collectionChangedEventArgsList[0].OldItems[0]); Assert.Equal(1, collectionChangedEventArgsList[0].OldStartingIndex); Assert.Equal(2, collectionChangedEventArgsList[0].NewStartingIndex); }
public void RemoveAt_TwoItems_ItemsAreRemovedAndCollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int> { 135, 123, 456, 789 }; collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.RemoveAt(3); collection.RemoveAt(1); Assert.Equal(2, collection.Count); Assert.Equal(135, collection[0]); Assert.Equal(456, collection[1]); Assert.Equal(2, collectionChangedEventArgsList.Count); Assert.Equal(NotifyCollectionChangedAction.Remove, collectionChangedEventArgsList[0].Action); Assert.NotNull(collectionChangedEventArgsList[0].OldItems); Assert.Single(collectionChangedEventArgsList[0].OldItems); Assert.Equal(789, collectionChangedEventArgsList[0].OldItems[0]); Assert.Equal(NotifyCollectionChangedAction.Remove, collectionChangedEventArgsList[1].Action); Assert.NotNull(collectionChangedEventArgsList[1].OldItems); Assert.Single(collectionChangedEventArgsList[1].OldItems); Assert.Equal(123, collectionChangedEventArgsList[1].OldItems[0]); }
private void LoadReferences() { References = new ExtendedObservableCollection <ReferenceModel>(); NuGetReferences = new ExtendedObservableCollection <ReferenceModel>(); List <string> packageDirs = new List <string>(); packageDirs.Add("/packages/"); packageDirs.Add("\\packages\\"); if (SolutionFile.Exists) { string nuGetRepositoryPath = GetNuGetRepositoryPath(SolutionFile.Directory); if (!string.IsNullOrEmpty(nuGetRepositoryPath)) { packageDirs.Add(nuGetRepositoryPath); } } foreach (var vsReference in _vsProject.References.OfType <Reference>()) { var reference = new ReferenceModel(vsReference); References.Add(reference); string vsReferencePath = vsReference.Path.ToLower(); foreach (string packageDir in packageDirs) { if (vsReferencePath.Contains(packageDir)) { NuGetReferences.Add(reference); break; } } } }
public void Synchronization_TwoItemsAddedWithNoneSyncMethod_ItemsAreAddedAndCollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int>(SynchronizationContext.Current, SynchronizationMethod.None, () => new LockSlimLockingMechanism()); collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.Add(123); collection.Add(456); Assert.Equal(2, collection.Count); Assert.Equal(123, collection[0]); Assert.Equal(456, collection[1]); Assert.Equal(2, collectionChangedEventArgsList.Count); Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[0].Action); Assert.Equal(NotifyCollectionChangedAction.Add, collectionChangedEventArgsList[1].Action); Assert.NotNull(collectionChangedEventArgsList[0].NewItems); Assert.Single(collectionChangedEventArgsList[0].NewItems); Assert.NotNull(collectionChangedEventArgsList[1].NewItems); Assert.Single(collectionChangedEventArgsList[1].NewItems); Assert.Equal(123, collectionChangedEventArgsList[0].NewItems[0]); Assert.Equal(456, collectionChangedEventArgsList[1].NewItems[0]); }
public FoldersPageViewModel() { _folderService = ServiceContainer.Resolve <IFolderService>("folderService"); PageTitle = AppResources.Folders; Folders = new ExtendedObservableCollection <FolderView>(); }
public void EndUpdate_NestedUpdates_CollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int>(); collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.BeginUpdate(); collection.Add(1234); collection.BeginUpdate(); collection.Add(5678); collection.EndUpdate(); Assert.Empty(collectionChangedEventArgsList); collection.EndUpdate(); Assert.Equal(2, collection.Count); Assert.Single(collectionChangedEventArgsList); Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action); }
public PropertyNodeViewModel(DacMemberCategoryNodeViewModel dacMemberCategoryVM, DacPropertyInfo propertyInfo, bool isExpanded = false) : base(dacMemberCategoryVM, dacMemberCategoryVM, propertyInfo, isExpanded) { var extraInfos = GetExtraInfos(); ExtraInfos = new ExtendedObservableCollection <ExtraInfoViewModel>(extraInfos); }
private void currentLayout_PropertyChanged(KeyValuePair <string, string> property) { // alert event handlers if (this.PropertyChanged != null) { this.PropertyChanged(property); } if (ConfigClass.IsOperator) { SendLayoutChanges(new LayoutChangeCommand(property)); } if (property.Key.Equals(PropertyValues.PLUGIN_PRIORITY.ToString())) { StackTrace stackTrace = new StackTrace(); if (!stackTrace.ToString().Contains("PluginPriority_CollectionChanged")) { ExtendedObservableCollection <string> o = new ExtendedObservableCollection <string>(); foreach (string s in property.Value.Split(';')) { o.Add(s); } this.PluginPriority = o; } //else { Console.WriteLine("Skipped to set the Collection new"); } stackTrace = null; } }
public void IndexOf_FindItemInItems_CorrectIndexFound(int item, int index, params int[] items) { var collection = new ExtendedObservableCollection <int>(items); var foundIndex = collection.IndexOf(item); Assert.Equal(index, foundIndex); }
public PromptDialogViewModel() { PromptDialogModel = new PromptDialogModel(); OkButtonCommand = new RelayCommand(param => InvokeRequestClose(new RequestCloseEventArgs(true)), param => CanExecute()); NetlistBrowseButtonCommand = new RelayCommand(param => OpenFileCommand()); TargetBrowseButtonCommand = new RelayCommand(param => SaveAsCommand()); _loadedNetlists = new ExtendedObservableCollection <string>(); }
public static ExtendedObservableCollection <T> BeginAddRange <T>(this ExtendedObservableCollection <T> collection, IEnumerable <T> range) { foreach (var x in range) { collection.BeginAddOnUI(x); } return(collection); }
public OrganizationalUnit(int id, string name, string fqdn, int?parentID, ExtendedObservableCollection <TileableElement> elements, DateTime?lastUpdate) : base(id, name, fqdn) { Initialize(); this.ParentID = parentID; this.Elements = elements; this.LastUpdate = lastUpdate; LayoutManager.Instance.SetOUState(ID, false); }
public MainDialogModel() { Projects = new ExtendedObservableCollection<ProjectModel>(); Transformations = new ExtendedObservableCollection<FromNuGetToProjectTransformation>(); RemoveProjects = true; SaveProjects = true; }
public AddCcuViewModel(IWindowManager windowManager) { OkCommand = new SimpleRelayCommand(() => windowManager.CloseDialog(this, true), () => !string.IsNullOrWhiteSpace(Address)); CancelCommand = new SimpleRelayCommand(() => windowManager.CloseDialog(this, false)); MruAddresses = new ExtendedObservableCollection <string>(); }
public MainDialogModel() { Projects = new ExtendedObservableCollection <ProjectModel>(); Transformations = new ExtendedObservableCollection <FromNuGetToProjectTransformation>(); RemoveProjects = true; SaveProjects = true; }
public NetworkAdapterTileCustomUI() { NumberOfAdapters = " - "; NamePerAdapter = new ExtendedObservableCollection <IndicatorValue>(); IPPerAdapter = new ExtendedObservableCollection <IndicatorValue>(); MACPerAdapter = new ExtendedObservableCollection <IndicatorValue>(); UpPerAdapter = new List <KeyValuePair <string, int> >(); DownPerAdapter = new List <KeyValuePair <string, int> >(); }
public void Ctor_WithItems_ItemsAreSet() { var input = new[] { 1, 3, 5, 7, 9 }; var collection = new ExtendedObservableCollection <int>(input); Assert.Equal(input.Length, collection.Count); input.ForEach((item, index) => Assert.Equal(item, collection[index])); }
/** * This is the constructor for the WallHandler. * It creates the internal corner list and registers a callback to it. * It creates the internal wall list and registers a callback to it. */ private WallHandler() { this._corners = new ExtendedObservableCollection<Corner>(); this._corners.CollectionChanged += EventCornerCollectionChanged; this._cornerIdDict = new Dictionary<uint, Corner>(); this._walls = new ExtendedObservableCollection<Wall>(); this._walls.CollectionChanged += EventWallCollectionChanged; }
public CollectionsPageViewModel() { _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _collectionService = ServiceContainer.Resolve <ICollectionService>("collectionService"); Collections = new ExtendedObservableCollection <CollectionViewModel>(); PageTitle = AppResources.Collections; }
public AutofillCiphersPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); GroupedItems = new ExtendedObservableCollection <GroupingsPageListGroup>(); CipherOptionsCommand = new Command <CipherView>(CipherOptionsAsync); }
public PasswordHistoryPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _cipherService = ServiceContainer.Resolve <ICipherService>("cipherService"); PageTitle = AppResources.PasswordHistory; History = new ExtendedObservableCollection <PasswordHistoryView>(); CopyCommand = new Command <PasswordHistoryView>(CopyAsync); }
public override async void OnNavigatingTo(INavigationParameters parameters) { if (parameters.GetNavigationMode() == NavigationMode.New) { var dbChats = await _database.Chats.GetAll(); AreChatsEmpty = dbChats.Count == 0; var chatEntries = new List <ChatEntry>(); foreach (var dbChat in dbChats) { var chatEntry = dbChat.ToChatEntry(); if (chatEntry.LastMessage != null) { if (chatEntry.Type == ChatType.Normal) { chatEntry.LastMessage.Decrypt(_walletManager.Wallet, chatEntry.ChatPartner.PublicKey); } else if (chatEntry.Type == ChatType.Group) { var privKey = chatEntry.GroupInfo.IsPublic ? chatEntry.GroupInfo.PrivateKey : _walletManager.Wallet.Decrypt(chatEntry.GroupInfo.PrivateKey, chatEntry.GroupInfo.PublicKey); chatEntry.LastMessage.Decrypt(privKey, chatEntry.LastMessage.Sender.PublicKey); } } var dbLastReadMessageID = await _database.LastReadMessageIDs.GetByChatID(chatEntry.ID); chatEntry.UpdateUnreadMessageCount(dbLastReadMessageID != null ? dbLastReadMessageID.LastReadID : 0); chatEntries.Add(chatEntry); } ChatEntries = new ExtendedObservableCollection <ChatEntry>(chatEntries); ChatEntries.Sort(false); // BETA await TryJoinPublicBetaGroup(); } else if (parameters.GetNavigationMode() == NavigationMode.Back) // Navigated back to this page { try { foreach (var chatEntry in ChatEntries.ToList()) { var dbLastReadMessageID = await _database.LastReadMessageIDs.GetByChatID(chatEntry.ID); chatEntry.UpdateUnreadMessageCount(dbLastReadMessageID != null ? dbLastReadMessageID.LastReadID : 0); } } catch (Exception ex) { Debug.WriteLine(ex); } } CheckFreeUsage(); }
public GlobalDataObject() { _itemsCollection = new ExtendedObservableCollection <BookDataGridItem>(); _bookAuthorCollection = new ExtendedObservableCollection <BookAuthor>(); _bookCategoryCollection = new ExtendedObservableCollection <BookCategory>(); _bookGenreCollection = new ExtendedObservableCollection <BookGenre>(); _bookPlacementCollection = new ExtendedObservableCollection <BookPlacement>(); _bookPublisherCollection = new ExtendedObservableCollection <BookPublisher>(); _bookTypeCollection = new ExtendedObservableCollection <BookType>(); }
public Payload(PayloadDirection direction, PayloadStream streamKind, DateTime transmissionDate, uint bodyTypeHash, byte[] body) { _payloadPackets = new ExtendedObservableCollection <PacketBase>(); Direction = direction; StreamKind = streamKind; TransmissionDate = transmissionDate; BodyTypeHash = bodyTypeHash; Body = body; }
public GeneratorHistoryPageViewModel() { _platformUtilsService = ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"); _passwordGenerationService = ServiceContainer.Resolve <IPasswordGenerationService>( "passwordGenerationService"); PageTitle = AppResources.PasswordHistory; History = new ExtendedObservableCollection <GeneratedPasswordHistory>(); CopyCommand = new Command <GeneratedPasswordHistory>(CopyAsync); }
/// <summary> /// Initializes an instance of <see cref="TransactionFilterViewModel"/>. /// </summary> /// <param name="isUserAdmin"></param> /// <param name="userRepository"></param> /// <param name="messagingService"></param> public TransactionFilterViewModel(bool isUserAdmin, IUserRepository userRepository, IMessagingService messagingService) { if (userRepository == null) throw new ArgumentNullException("userRepository"); if (messagingService == null) throw new ArgumentNullException("messagingService"); _userRepository = userRepository; _messagingService = messagingService; IsUserAdmin = isUserAdmin; ResetDates(); ApplyFilterCommand = new RelayCommand(ApplyFilter, CanApplyFilter); AllUsers = new ExtendedObservableCollection<string>(false); }
/// <summary> /// Initializes an instance of <see cref="ManageViewModel"/>. /// </summary> /// <param name="registeredName"></param> /// <param name="userRepository"></param> /// <param name="messagingService"></param> /// <param name="canUserNavigate"></param> public ManageViewModel(string registeredName, IUserRepository userRepository, IMessagingService messagingService,bool canUserNavigate) : base(registeredName,canUserNavigate) { if (userRepository == null) throw new ArgumentNullException("userRepository"); if (messagingService == null) throw new ArgumentNullException("messagingService"); _userRepository = userRepository; _messagingService = messagingService; DisplayName = UIText.MANAGE_VIEW_HEADER; CanGoBack = true; Users = new ExtendedObservableCollection<UserViewModel>(); //Intialize commands RefreshUserListCommand = new RelayCommand(RefreshUserList); SaveUsersCommand = new RelayCommand(SaveUser, CanSaveUser); AddNewUserCommand = new RelayCommand(() => SelectedUser = new UserViewModel(_userRepository.GetNewUser(),_messagingService)); }
private void LoadReferences() { References = new ExtendedObservableCollection<ReferenceModel>(); NuGetReferences = new ExtendedObservableCollection<ReferenceModel>(); foreach (var vsReference in _vsProject.References.OfType<Reference>()) { var reference = new ReferenceModel(vsReference); References.Add(reference); if (vsReference.Path.Contains("/packages/") || vsReference.Path.Contains("\\packages\\")) NuGetReferences.Add(reference); } }
/** * This is the constructor for the FloorHandler. * It creates the internal floor list and registers a callback to it. */ private RoomHandler() { this._rooms = new ExtendedObservableCollection<Room>(); this._rooms.CollectionChanged += EventRoomCollectionChanged; }
private void ResetCustomerGroups() { CustomerGroups = new ExtendedObservableCollection<CustomerGroup>(CustomerGroupManager.Instance.GetAll().Where(c => c.SalesArea.IDDivision == LoggedUser.Division.ID && c.IncludeInSystem && (Animation.ObservableAnimationCustomerGroups.Select(acg => acg.IDCustomerGroup).Contains(c.ID) == false)).OrderBy(c => c.SalesArea.Name).ThenBy(c => c.Name)); }
private void RecalculateProcurementPlan() { var grouped = Animation.AnimationCustomerGroups.Where(acg => acg.IDRetailerType != Guid.Empty).GroupBy(acg => acg.IDRetailerType).Select( g => new ProcurementPlanAnimation { RetailerType = RetailerTypeManager.Instance.GetAll(true).Where(rt => rt.ID == g.Key).First ().Name, OnCounterDate = g.Min(acg => acg.OnCounterDate), ComponentDeadline = g.Min(acg => acg.PLVComponentDate), DeliveryDeadline = g.Min(acg => acg.PLVDeliveryDate), StockDeadline = g.Min(acg => acg.StockDate), AllocationQuantity = 1234 }); ProcurementPlan = new ExtendedObservableCollection<ProcurementPlanAnimation>(grouped); }
/// <summary> /// Gets the graph data. /// </summary> /// <param name="list"></param> /// <returns></returns> private ExtendedObservableCollection<GraphItemViewModel> GetGraphData(IList<Transaction> list) { ExtendedObservableCollection<GraphItemViewModel> graphItems = null; if (list != null && list.Any()) { graphItems = new ExtendedObservableCollection<GraphItemViewModel>(); var totalNeed = list.Where(t => t.PurposeType == TransactionPurposeType.Need).Sum(t => t.Amount); var totalWant = list.Where(t => t.PurposeType == TransactionPurposeType.Want).Sum(t => t.Amount); graphItems.Add(new GraphItemViewModel() { Description = "Need", Value = totalNeed }); graphItems.Add(new GraphItemViewModel() { Description = "Want", Value = totalWant }); } return graphItems; }
/// <summary> /// Initialize the variables and wire up events. /// </summary> protected override void OnInitialize() { FilterViewModel = new TransactionFilterViewModel(IsUserAdmin, _userRepository, _messagingService) { Header = UIText.FILTER_HEADER_TEXT, Position = VisibilityPosition.Right, Theme = FlyoutTheme.AccentedTheme }; //FilterViewModel.Initialize(); _messagingService.RegisterFlyout(FilterViewModel); Transactions = new ExtendedObservableCollection<TransactionViewModel>(); //register to the task completed events of the repository. _transactionRepository.GetTransactionsCompleted += TransactionRepositoryGetTransactionsCompleted; _transactionRepository.SaveTransactionCompleted += TransactionRepositorySaveTransactionCompleted; _transactionRepository.DeleteTransactionsCompleted += TransactionRepositoryDeleteTransactionsCompleted; //Register to the Filter view models applied filter event FilterViewModel.FilterApplied += FilterViewModelFilterApplied; }
void ObservableAnimationCustomerGroups_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { customerGroup = null; }
void CustomerGroupsAllocation_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { CustomerGroupAllocation acg = e.NewItems[0] as CustomerGroupAllocation; acg.PropertyChanged +=new PropertyChangedEventHandler(acg_PropertyChanged); // acg.AnimationProductDetail = productDetail; acg.IDAnimationProductDetail = productDetail.ID; } else if (e.Action == NotifyCollectionChangedAction.Remove) { CustomerGroupAllocation acg = e.OldItems[0] as CustomerGroupAllocation; if (acg.CustomerGroup != null) { customerGroup = null; acg.CustomerGroup.CustomerGroupAllocations.Remove(acg); } productDetail.CustomerGroupAllocations.Remove(acg); } }
void acg_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "ID") { customerGroup = null; } }
void AnimationAllocations_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "SelectedAllocationCustomerGroup") { if (SelectedAllocationCustomerGroup != null) { CustomersAllocation = new ObservableCollection<CustomerAllocation>(SelectedAllocationCustomerGroup.CustomerAllocations); } else { CustomersAllocation = new ObservableCollection<CustomerAllocation>(); } customers = null; } }
// ---------------- методы ---------------- /// <summary> /// ОБновление фильрованного списка /// </summary> /// <param name="query">Query.</param> public void UpdateFilteredStations(string query){ if (query == null) return; var filterList = Stations.Where (x => x.ToString ().IndexOf (query, StringComparison.OrdinalIgnoreCase) >= 0).ToList (); FilteredStations = new ExtendedObservableCollection<SectionStation> (filterList); }