Пример #1
0
		public void GetCountWithFilter ()
		{
			object[] list = { 0, 1, 2, 3, 4, 5, 6 };
			var cv = new CollectionView (list);
			cv.Filter = item => (int)item % 2 == 0;
			Assert.AreEqual (4, cv.Count, "A1");
		}
Пример #2
0
        public ChatViewModel(IChatService chatService)
        {
            this.contacts = new ObservableCollection<Contact>();
            this.contactsView = new CollectionView(this.contacts);
            this.sendMessageRequest = new InteractionRequest<SendMessageViewModel>();
            this.showReceivedMessageRequest = new InteractionRequest<ReceivedMessage>();
            this.showDetailsCommand = new DelegateCommand<bool?>(this.ExecuteShowDetails, this.CanExecuteShowDetails);

            this.contactsView.CurrentChanged += this.OnCurrentContactChanged;

            this.chatService = chatService;
            this.chatService.Connected = true;
            this.chatService.ConnectionStatusChanged += (s, e) => this.OnPropertyChanged(() => this.ConnectionStatus);
            this.chatService.MessageReceived += this.OnMessageReceived;

            this.chatService.GetContacts(
                result =>
                {
                    if (result.Error == null)
                    {
                        foreach (var item in result.Result)
                        {
                            this.contacts.Add(item);
                        }
                    }
                });
        }
Пример #3
0
        public ChatViewModel(IChatService chatService)
        {
            _contacts = new ObservableCollection<Contact>();
            _contactsView = new CollectionView(_contacts);
            _sendMessageRequest = new InteractionRequest<SendMessageViewModel>();
            _showReceivedMessageRequest = new InteractionRequest<ReceivedMessage>();
            _showDetailsCommand = new ShowDetailsCommandImplementation(this);

            _contactsView.CurrentChanged += OnCurrentContactChanged;

            _chatService = chatService;
            _chatService.Connected = true;
            _chatService.ConnectionStatusChanged += (s, e) => RaisePropertyChanged(() => CurrentConnectionState);
            _chatService.MessageReceived += OnMessageReceived;

            _chatService.GetContacts(
                result =>
                    {
                        if (result.Error != null) return;
                        foreach (var item in result.Result)
                        {
                            _contacts.Add(item);
                        }
                    });
            RaisePropertyChanged(() => CurrentConnectionState);
        }
Пример #4
0
 public SelectProjectViewModel(IView view)
 {
     this.view = view;
     this.projects = new CollectionView(ProjectService.GetAllProjects());
     this.selectCommand = new DelegateCommand(this.SelectCommandHandler);
     this.cancelCommand = new DelegateCommand(this.CancelCommandHandler);
 }
        public MainWindowViewModel()
        {
            var chartsOfAccounts = GetChartOfAccounts();
            ChartsOfAccountsView = new CollectionView(chartsOfAccounts);

            DeleteAccountCommand = new DelegateCommand(DeleteAccount, CanDeleteAccount);
        }
Пример #6
0
        public InboxViewModel(IEmailService emailService, IRegionManager regionManager)
        {
            synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext();

            _composeMessageCommand = new DelegateCommand<object>(ComposeMessage);
            _replyMessageCommand = new DelegateCommand<object>(ReplyMessage, CanReplyMessage);
            _openMessageCommand = new DelegateCommand<EmailDocument>(OpenMessage);

            messagesCollection = new ObservableCollection<EmailDocument>();
            Messages = new CollectionView(this.messagesCollection);
            Messages.CurrentChanged += (s, e) =>
                _replyMessageCommand.RaiseCanExecuteChanged();

            _emailService = emailService;
            _regionManager = regionManager;

            if (_emailService != null)
            {
                _emailService.BeginGetEmailDocuments(
                    r =>
                        {
                            var messages = _emailService.EndGetEmailDocuments(r);
                            synchronizationContext.Post(
                                s =>
                                    {
                                        foreach (var message in messages)
                                        {
                                            messagesCollection.Add(message);
                                        }
                                    }, null);
                        }, null);
            }
        }
Пример #7
0
 private void searchTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (AnnotationsBox.ItemsSource != null)
     {
         System.Windows.Data.CollectionView view = (System.Windows.Data.CollectionView)System.Windows.Data.CollectionViewSource.GetDefaultView(AnnotationsBox.ItemsSource);
         view.Filter = UserFilter;
         System.Windows.Data.CollectionViewSource.GetDefaultView(AnnotationsBox.ItemsSource).Refresh();
     }
 }
 public EnterTransactionDetailsViewModel()
 {
     IList<TransactionStatus> statusList = new List<TransactionStatus>();
     statusList.Add(new TransactionStatus("LR_AUTO"));
     statusList.Add(new TransactionStatus("LR_PASS"));
     statusList.Add(new TransactionStatus("LR_FAIL"));
     statusList.Add(new TransactionStatus("LR_STOP"));
     transactionStatuses = new CollectionView(statusList);
 }
 public DelayRealizedCollection()
 {
     _collection = new CollectionView(_list);
     _initializer = new Thread(x =>
                                   {
                                       Thread.Sleep(100);
                                       _list[0] = new object();
                                   });
 }
Пример #10
0
        public RealizingWrapper(CollectionView collection, TimeSpan timeout)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            _collection = collection;
            _timeout = timeout;
        }
Пример #11
0
        private static void FilterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ItemsControl control = d as ItemsControl;

            if (control.ItemsSource != null)
            {
                System.Windows.Data.CollectionView view = (System.Windows.Data.CollectionView)CollectionViewSource.GetDefaultView(control.ItemsSource);
                view.Filter = (a) => a.GetType().GetProperties().Where(_ => _.PropertyType == e.NewValue.GetType()).Select(_ => _.GetValue(a)).Any(_ => ((string)_).Contains((string)e.NewValue));
            }
        }
Пример #12
0
 public ViewModel()
 {
     Model = new Model();
     viewModelCurrentCamera = new ViewModelCurrentCamera();
     cameraListView = new CollectionView(Model.CameraList.CameraList);
     CameraListView.CurrentChanged += new EventHandler(setCurrentlyCamera);
     if (ViewModelCurrentCamera != null)
     {
         Model.CameraList.onCameraPropertyChangedEvent += ViewModelCurrentCamera.updateCurrentlyCamera;
     }
 }
Пример #13
0
        public void Sort(object columnHeader, System.Windows.Data.CollectionView list)
        {
            string column = SetAdorner(columnHeader);

            if (string.IsNullOrEmpty(column))
            {
                return;
            }

            list.SortDescriptions.Clear();
            list.SortDescriptions.Add(new SortDescription(column, direction));
        }
Пример #14
0
        public Vm()
        {
            _persons = new List<Person>
            {
                new Person("Johan"),
                new Person("Sean")
            };
            PersonsGenericView = new CollectionView<Person>(this, () => Persons);

            //PropertyChangedEventManager.AddListener(this, PersonsGenericView, "Persons");
            PersonsView = new CollectionView(Persons);
        }
Пример #15
0
        public UndoManagerVm(string name, UndoManager manager)
        {
            Name = name;
            Manager = manager;

            UndoStack = new CollectionView(Manager.History.UndoStack);
            RedoStack = new CollectionView(Manager.History.RedoStack);
            manager.History.PropertyChanged += (sender, args) =>
            {
                UndoStack.Refresh();
                RedoStack.Refresh();
            };
        }
Пример #16
0
        public UndoManagerVm(string name)
        {
            Name = name;
            Manager = UndoRedo.UndoManager.GetByName(name);

            UndoStack = new CollectionView(Manager.History.UndoStack);
            RedoStack = new CollectionView(Manager.History.RedoStack);
            UndoManager undoManager = UndoManager.GetByName(Name);
            undoManager.OnClear += (sender, args) => Update();
            undoManager.OnRedo += (sender, args) => Update();
            undoManager.OnUndo += (sender, args) => Update();
            undoManager.Changed += (sender, args) => Update();
        }
Пример #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AddNewProductViewModel"/> class.
        /// </summary>
        /// <param name="patternManager">The pattern manager.</param>
        /// <param name="userMessageService">The user message service.</param>
        public AddNewProductViewModel(IPatternManager patternManager, IUserMessageService userMessageService)
        {
            Guard.NotNull(() => patternManager, patternManager);
            Guard.NotNull(() => userMessageService, userMessageService);

            this.allToolkits = new ObservableCollection<InstalledToolkitInfo>(patternManager.InstalledToolkits.Select(it => new InstalledToolkitInfo(it)));
            this.toolkitsView = new ListCollectionView(this.allToolkits);
            this.patternManager = patternManager;
            this.userMessageService = userMessageService;
            this.CurrentToolkit = this.allToolkits.FirstOrDefault();
            this.SortingItems = GetSortingItems();
            this.SortingItem = this.SortingItems.FirstOrDefault();
            this.InitializeCommands();
            this.ArrangeToolkits();
        }
Пример #18
0
        void Refresh(object param)
        {
            cards = ((App)App.Current).all_data.get_cards();
            //cv = new System.Windows.Data.CollectionView(cards);
            //cv.GroupDescriptions.Add(new System.Windows.Data.PropertyGroupDescription("Type_card"));
            cv = new ListCollectionView(cards);

            cv.GroupDescriptions.Clear();
            cv.GroupDescriptions.Add(new PropertyGroupDescription("Year"));

            RaisePropertyChanged("cv");

            persons      = ((App)App.Current).all_data.get_person();
            units        = ((App)App.Current).all_data.get_unit();
            _unit_filter = ((App)App.Current).all_data.get_unit();
        }
        public TaskDetailsViewModel(Task task, MainWindowViewModel mainWindow)
        {
            using (ProjectRepository projectRepository = new ProjectRepository())
            {
                _projects = new CollectionView(projectRepository.GetAllProjects());
            }

            using (PriorityRepository priorityRepository = new PriorityRepository())
            {
                _priorities = new CollectionView(priorityRepository.GetAllPriorities());
            }

            _task = task;
            _mainWindow = mainWindow;

            SetTabTitle();
        }
        internal NewProjectViewModel(ICollection<ExecutionEnvironment> availableExecutionEngines, ref ExecutionInstance executionInstance, FMTesterConfiguration configuration, StackPanel controlContainer)
        {
            executionEnvironments = new CollectionView(availableExecutionEngines);
            executionInstance = new ExecutionInstance();

            this.simulationSettingsControl = null;
            this.executionInstance = executionInstance;
            this.appConfiguration = configuration;
            SelectedEnvironment = availableExecutionEngines.First();

            this.controlContainer = controlContainer;
            this.currentView = new NewProjectControl();
            this.currentView.DataContext = this;
            controlContainer.Children.Add(currentView);

            IsDone = false;
        }
Пример #21
0
        public ProjectInformationViewModel(IView view)
            : base(view)
        {
            this.currentProject = UserSession.CurrentProject;
            this.newProjectNumber = string.Empty;
            this.newProjectName = string.Empty;

            this.projectAddress = new MutableAddress
              {
                  Street = this.currentProject.Address.Street,
                  City = this.currentProject.Address.City,
                  State = this.currentProject.Address.State,
                  PostalCode = this.currentProject.Address.PostalCode
              };

            this.projectOwnerHeadquartersAddress = new MutableAddress
              {
                  Street = this.currentProject.Owner.HeadquartersAddress.Street,
                  City = this.currentProject.Owner.HeadquartersAddress.City,
                  State = this.currentProject.Owner.HeadquartersAddress.State,
                  PostalCode =
                  this.currentProject.Owner.HeadquartersAddress.PostalCode
              };

            this.CurrentObjectState =
                (this.currentProject != null ?
                ObjectState.Existing : ObjectState.New);

            this.owners = new CollectionView(CompanyService.GetOwners());

            this.marketSegments =
                new CollectionView(ProjectService.GetMarketSegments());

            this.constructionAdministrators =
                new CollectionView(
                    EmployeeService.GetConstructionAdministrators());

            this.principals = new CollectionView(EmployeeService.GetPrincipals());
            this.saveCommand = new DelegateCommand(this.SaveCommandHandler);
            this.newCommand = new DelegateCommand(this.NewCommandHandler);
        }
Пример #22
0
		public void GetCount ()
		{
			object[] list = { 0, 1, 2, 3, 4, 5, 6 };
			var cv = new CollectionView (list);
			Assert.AreEqual (7, cv.Count, "A1");
		}
Пример #23
0
		public void GetComparer ()
		{
			var cv = new CollectionView (new object[] { });
			Assert.IsNull (cv.Comparer);
		}
Пример #24
0
		public void CanSort ()
		{
			var cv = new CollectionView (new object[] { });
			Assert.IsFalse (cv.CanSort, "A1");
		}
Пример #25
0
		public void CanFilter ()
		{
			var cv = new CollectionView (new object[] { });
			Assert.IsTrue (cv.CanFilter, "A1");
		}
Пример #26
0
		public void IndexOf ()
		{
			object[] list = { 1, 7, 3, 3, 5, 6 };
			var cv = new CollectionView (list);
			Assert.AreEqual (2, cv.IndexOf (3), "A1");
			Assert.AreEqual (-1, cv.IndexOf (99), "A2");
		}
Пример #27
0
		public void GetItemAt ()
		{
			object[] list = { 1, 2, 3, 4, 5, 6 };
			var cv = new CollectionView (list);
			Assert.AreEqual (4, cv.GetItemAt (3), "A1");
			Assert.IsNull (cv.GetItemAt (99), "A2");
		}
Пример #28
0
		public void GetItemAtLessThan0 ()
		{
			var cv = new CollectionView (new object[] { });
			cv.GetItemAt (-1);
		}
Пример #29
0
		public void Contains ()
		{
			object[] list = { 1, 2, 3, 4, 5, 6 };
			var cv = new CollectionView (list);
			cv.Filter = item => (int)item % 2 == 0;
			Assert.IsTrue (cv.Contains (4), "A1");
			Assert.IsFalse (cv.Contains (3), "A2");
			Assert.IsFalse (cv.Contains (98), "A3");
			Assert.IsFalse (cv.Contains (99), "A4");
		}
Пример #30
0
		public void PassesFilterWithFilterSet ()
		{
			object[] list = { 1, 2, 3, 4, 5, 6 };
			var cv = new CollectionView (list);
			cv.Filter = item => (int)item % 2 == 0;
			Assert.IsTrue (cv.PassesFilter (4), "A1");
			Assert.IsFalse (cv.PassesFilter (3), "A2");
			Assert.IsTrue (cv.PassesFilter (98), "A3");
			Assert.IsFalse (cv.PassesFilter (99), "A4");
		}
Пример #31
0
		public void PassesFilter ()
		{
			var cv = new CollectionView (new object[] { });
			Assert.IsTrue (cv.PassesFilter (new object ()), "A1");
		}
Пример #32
0
		public void InsertIntoSortDescriptions ()
		{
			var cv = new CollectionView (new object[] { });
			cv.SortDescriptions.Insert (0, new SortDescription ());
		}
Пример #33
0
		public void EnumerateItems ()
		{
			object[] list = { 0, 99, 22, 7, 11, 4, 3 };
			var cv = new CollectionView (list);
			CollectionAssert.AreEquivalent (list, cv, "A1");
		}
Пример #34
0
		public void EnumerateItemsWithFilter ()
		{
			object[] list = { 0, 1, 2, 3, 4, 5, 6 };
			object[] filteredList = { 0, 2, 4, 6 };
			var cv = new CollectionView (list);
			cv.Filter = item => (int)item % 2 == 0;
			CollectionAssert.AreEquivalent (filteredList, cv, "A1");
		}
 internal CollectionViewRegisteringEventArgs(CollectionView view)
 {
     _view = view;
 }