Exemplo n.º 1
0
        /// <summary>
        /// Handles OnSyncPairAddedToRepository Event
        /// </summary>
        /// <param name="sender">Sending Object</param>
        /// <param name="e">Event Arguments</param>
        void OnSyncPairAddedToRepository(object sender, SyncPairAddedEventArgs e)
        {
            // Create new sync pair view model with supplied args.
            var viewModel = new SyncPairViewModel(e.NewSyncPair, _syncPairRepository, _wsCommands);

            // Add view model to observable collection.
            AllSyncPairs.Add(viewModel);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles OnSyncPairRemovedToRepository Event
 /// </summary>
 /// <param name="sender">Sending Object</param>
 /// <param name="e">Event Arguments</param>
 void OnSyncPairRemovedFromRepository(object sender, SyncPairRemovedEventArgs e)
 {
     // Find sync pair view model by matching description.
     foreach (var syncPairViewModel in AllSyncPairs)
     {
         if (syncPairViewModel.Description == e.OldSyncPair.Description)
         {
             // If it is the same view model, remove it from observable collection.
             if (AllSyncPairs.Contains(syncPairViewModel))
             {
                 AllSyncPairs.Remove(syncPairViewModel);
                 break;
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            // Destroy any sync pair view models.
            foreach (SyncPairViewModel custVM in AllSyncPairs)
            {
                custVM.Dispose();
            }

            // Remove sync pairs.
            AllSyncPairs.Clear();

            // Raise event to notify that collection has changed.
            AllSyncPairs.CollectionChanged -= OnCollectionChanged;

            // Detach event.
            _syncPairRepository.SyncPairAdded -= OnSyncPairAddedToRepository;
        }