public DynamicCommandViewModel(RegisteredDynamicCommand registeredDynamicCommand,
                                       IEnumerable <ClientViewModel> executingClients)
        {
            DynamicCommand       = registeredDynamicCommand;
            DynamicCommandStatus = registeredDynamicCommand.Status;
            TransmissionType     = GetTransmissionName(registeredDynamicCommand.TransmissionEvent);
            ExecutionEvent       = GetExecutionName(registeredDynamicCommand.ExecutionEvent);

            if (registeredDynamicCommand.DynamicCommandEvents != null)
            {
                foreach (var dynamicCommandEvent in registeredDynamicCommand.DynamicCommandEvents)
                {
                    switch (dynamicCommandEvent.Status)
                    {
                    case ActivityType.Sent:
                        _sent++;
                        break;

                    case ActivityType.Succeeded:
                        _succeeded++;
                        break;

                    case ActivityType.Failed:
                        _failed++;
                        break;
                    }
                }
            }

            DynamicCommandEvents =
                new FastObservableCollection <DynamicCommandEvent>(registeredDynamicCommand.DynamicCommandEvents ??
                                                                   new List <DynamicCommandEvent>());

            ExecutingClients = new FastObservableCollection <ClientViewModel>(executingClients ?? new ClientViewModel[0]);
        }
Beispiel #2
0
 public DateTimePickerViewModel()
 {
     AvailableFormats    = new FastObservableCollection <CultureFormat>();
     DateTimeValue       = DateTime.Now;
     DateTimeValueString = string.Empty;
     SetNull             = new Command(OnSetNullExecute);
 }
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="loadSubEntryFunc"></param>
        public BreadcrumbTreeItemHelperViewModel(Func <bool, object, Task <IEnumerable <VM> > > loadSubEntryFunc)
            : this()
        {
            _loadSubEntryFunc = loadSubEntryFunc;

            _All = new FastObservableCollection <VM>();
        }
Beispiel #4
0
        public EntriesHelper(Func <bool, object, Task <IEnumerable <VM> > > loadSubEntryFunc)
        {
            _loadSubEntryFunc = loadSubEntryFunc;

            All = new FastObservableCollection <VM>();
            All.Add(default(VM));
        }
Beispiel #5
0
        public static double[] GetUpperBounds(FastObservableCollection <Input_ParamDefBase> inInputParams)
        {
            List <double> toRet = new List <double>();

            foreach (Input_ParamDefBase inputDef in inInputParams)
            {
                switch (inputDef)
                {
                case Double_Input_ParamDef dblParam:
                    toRet.Add(dblParam.SearchRange.Range.Max);
                    break;

                case Point_Input_ParamDef pntParam:
                    toRet.Add(pntParam.SearchRange.RangeX.Max);
                    toRet.Add(pntParam.SearchRange.RangeY.Max);
                    toRet.Add(pntParam.SearchRange.RangeZ.Max);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(toRet.ToArray());
        }
Beispiel #6
0
        private void updateEntries(params VM[] viewModels)
        {
            FastObservableCollection <VM> all = All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();

            var removeItems = all.Where(vm => !viewModels.Contains(vm)).ToList();
            var addItems    = viewModels.Where(vm => !all.Contains(vm)).ToList();

            if (addItems.Count == 0 && removeItems.Count == 0)
            {
                return; //nothing to do here
            }
            foreach (var vm in removeItems)
            {
                all.Remove(vm);
            }

            foreach (var vm in addItems)
            {
                all.Add(vm);
            }

            _subItemList = all.ToArray().ToList();
            all.NotifyChanges();

            EntriesChanged?.Invoke(this, EventArgs.Empty);
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class.
        /// </summary>
        public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository,
                                  IMessageService messageService)
            : base(messageMediator)
        {
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => employeeRepository);
            Argument.IsNotNull(() => messageService);

            _uiVisualizerService = uiVisualizerService;
            _employeeRepository  = employeeRepository;
            _messageService      = messageService;

            AddEmployee    = new Command(OnAddEmployeeExecute);
            EditEmployee   = new Command(OnEditEmployeeExecute, OnEditEmployeeCanExecute);
            DeleteEmployee = new Command(OnDeleteEmployeeExecute, OnDeleteEmployeeCanExecute);

            Employees = new FastObservableCollection <IEmployee>();
            if (!ObjectHelper.IsNull(SelectedDepartment))
            {
                Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name));
            }

            if (Employees.Count > 0)
            {
                SelectedEmployee = Employees[0];
            }

            Mediator.Register <string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees");
        }
Beispiel #8
0
        private void updateEntries(params VM[] viewModels)
        {
            FastObservableCollection <VM> all = All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();

            var removeItems = all.Where(vm => !viewModels.Contains(vm)).ToList();
            var addItems    = viewModels.Where(vm => !all.Contains(vm)).ToList();

            foreach (var vm in removeItems)
            {
                all.Remove(vm);
            }

            foreach (var vm in addItems)
            {
                all.Add(vm);
            }

            _subItemList = all.ToArray().ToList();
            all.NotifyChanges();

            if (EntriesChanged != null)
            {
                EntriesChanged(this, EventArgs.Empty);
            }
        }
 private void ReplaceRange(FastObservableCollection <NavigationNode> selectedItems, List <NavigationNode> navigationNodes)
 {
     using (selectedItems.SuspendChangeNotifications())
     {
         ((ICollection <NavigationNode>)SelectedItems).ReplaceRange(navigationNodes);
     }
 }
        public ClientMenuViewModel(User user, Reservation reservation, FastObservableCollection <OrderedDish> orderedDishes = null)
        {
            _user          = user;
            _reservation   = reservation;
            _rootViewModel = ViewModelManager.GetFirstOrDefaultInstance <MainWindowViewModel>();
            OrderedDishes.AutomaticallyDispatchChangeNotifications = true;
            // передаем в конструктор ссылку на собираемую коллекцию заказанных блюд
            _sumCalculator = new OrderedSumCalculator(OrderedDishes);

            AddCommand = new Command(OnAddCommandExecute);
            SelectionChangedCommand = new Command(OnSelectionChangedCommandExecute);
            DeleteCommand           = new Command(OnDeleteCommandExecute, OnDeleteCommandCanExecute);
            BackCommand             = new Command(OnBackCommandExecute);
            NextCommand             = new Command(OnNextCommandExecute, OnNextCommandCanExecute);

            RefreshDishesCollection();

            if (orderedDishes != null)
            {
                OrderedDishes = orderedDishes;
                TotalSum      = _sumCalculator.GetCurrentOrderedSum();
            }
            else
            {
                OrderedDishes.Clear();
            }
        }
        public LogViewerViewModel(ITypeFactory typeFactory, IDispatcherService dispatcherService, LogViewerLogListener logViewerLogListener)
        {
            Argument.IsNotNull(() => typeFactory);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => logViewerLogListener);

            _typeFactory = typeFactory;
            _dispatcherService = dispatcherService;
            _logViewerLogListener = logViewerLogListener;

            LogListenerType = typeof(LogViewerLogListener);
            ShowDebug = true;
            ShowInfo = true;
            ShowWarning = true;
            ShowError = true;

            var typeNames = new FastObservableCollection<string>
            {
                defaultComboBoxItem
            };

            TypeNames = typeNames;

            ResetEntriesCount();
        }
Beispiel #12
0
            public void HandlesChangesOfSuspendedFastObservableCollectionCorrectly()
            {
                var collection = new FastObservableCollection <TestModel>
                {
                    AutomaticallyDispatchChangeNotifications = false
                };

                for (var i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                var newModel = new TestModel();

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                    collection.Add(newModel);
                }

                newModel.FirstName = "Geert";

                Assert.IsTrue(collectionItemPropertyChanged, "Collection item property should have changed");
            }
Beispiel #13
0
            public void HandlesClearOfSuspendedFastObservableCollectionCorrectly()
            {
                var collection = new FastObservableCollection <TestModel>
                {
                    AutomaticallyDispatchChangeNotifications = false
                };

                TestModel model = null;

                for (var i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                model = collection[0];

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                }

                model.FirstName = "Geert";

                Assert.IsFalse(collectionItemPropertyChanged);
            }
Beispiel #14
0
            public void CallingResetWhileAddingItemsInAddingMode()
            {
                var counter   = 0;
                var eventArgs = (NotifyCollectionChangedEventArgs)null;

                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) =>
                {
                    counter++;
                    eventArgs = e;
                };

                var token = fastCollection.SuspendChangeNotifications(SuspensionMode.Adding);

                fastCollection.Add(1);
                fastCollection.Add(2);

                fastCollection.Reset();
                Assert.AreEqual(0, counter);

                fastCollection.Add(3);
                fastCollection.Add(4);
                fastCollection.Add(5);
                token.Dispose();

                Assert.AreEqual(1, counter);
                Assert.AreEqual(NotifyCollectionChangedAction.Add, eventArgs.Action);
                CollectionAssert.AreEqual(eventArgs.NewItems, new[] { 1, 2, 3, 4, 5 });
            }
Beispiel #15
0
        public LogViewerViewModel(ITypeFactory typeFactory, IDispatcherService dispatcherService,
                                  IApplicationLogFilterGroupService applicationLogFilterGroupService, LogViewerLogListener logViewerLogListener)
        {
            Argument.IsNotNull(() => typeFactory);
            Argument.IsNotNull(() => dispatcherService);
            Argument.IsNotNull(() => applicationLogFilterGroupService);
            Argument.IsNotNull(() => logViewerLogListener);

            _typeFactory       = typeFactory;
            _dispatcherService = dispatcherService;
            _applicationLogFilterGroupService = applicationLogFilterGroupService;
            _logViewerLogListener             = logViewerLogListener;

            _timer = new Timer(OnTimerTick);

            LogListenerType = typeof(LogViewerLogListener);
            ShowDebug       = true;
            ShowInfo        = true;
            ShowWarning     = true;
            ShowError       = true;

            var typeNames = new FastObservableCollection <string>
            {
                _defaultComboBoxItem
            };

            TypeNames = typeNames;

            ResetEntriesCount();
        }
            public void SuspendsValidationWhileAddingAndRemovingItems()
            {
                int counter = 0;

                var fastCollection = new FastObservableCollection<int>();
                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                using (fastCollection.SuspendChangeNotifications())
                {
                    fastCollection.Add(1);
                    fastCollection.Add(2);
                    fastCollection.Add(3);
                    fastCollection.Add(4);
                    fastCollection.Add(5);

                    fastCollection.Remove(5);
                    fastCollection.Remove(4);
                    fastCollection.Remove(3);
                    fastCollection.Remove(2);
                    fastCollection.Remove(1);
                }

                Assert.AreEqual(1, counter);
            }
Beispiel #17
0
            public void ThrowsInvalidOperationExceptionForInvalidSuspensionMode()
            {
                var fastCollection = new FastObservableCollection <int>(new[] { 1, 2, 3, 4, 5 });

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => fastCollection.RemoveItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Adding));
            }
        public FastObservableCollection <Dish> LoadAllDishes()
        {
            FastObservableCollection <Dish> dishes = new FastObservableCollection <Dish>();

            dishes.AddItems(_unitOfWork.Dishes.GetAll());
            return(dishes);
        }
Beispiel #19
0
            public void RaisesSingleEventWhileRemovingRange()
            {
                var counter = 0;

                var fastCollection = new FastObservableCollection <int>(new[] { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 });

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                fastCollection.RemoveItems(new[] { 1, 2, 3, 4, 5 });

                Assert.AreEqual(1, counter);

                fastCollection.RemoveItems(new[] { 1, 2, 3, 4, 5 }, SuspensionMode.Removing);

                Assert.AreEqual(2, counter);

                fastCollection.RemoveItems(new ArrayList(new[] { 1, 2, 3, 4, 5 }));

                Assert.AreEqual(3, counter);

                fastCollection.RemoveItems(new ArrayList(new[] { 1, 2, 3, 4, 5 }), SuspensionMode.Removing);

                Assert.AreEqual(4, counter);
            }
            public void CascadedAddingItemsInAddingModeWithInterceptingDisposing()
            {
                var counter   = 0;
                var eventArgs = (NotifyCollectionChangedEventArgs)null;

                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) =>
                {
                    counter++;
                    eventArgs = e;
                };

                var firstToken  = fastCollection.SuspendChangeNotifications(SuspensionMode.Adding);
                var secondToken = fastCollection.SuspendChangeNotifications(SuspensionMode.Adding);

                fastCollection.Add(1);
                fastCollection.Add(2);

                secondToken.Dispose();
                Assert.AreEqual(0, counter);
                Assert.IsNull(eventArgs);

                fastCollection.Add(3);
                fastCollection.Add(4);
                fastCollection.Add(5);

                firstToken.Dispose();
                Assert.AreEqual(1, counter);
                // ReSharper disable PossibleNullReferenceException
                Assert.AreEqual(NotifyCollectionChangedAction.Add, eventArgs.Action);
                CollectionAssert.AreEqual(eventArgs.NewItems, new[] { 1, 2, 3, 4, 5 });
                // ReSharper restore PossibleNullReferenceException
            }
Beispiel #21
0
        public AgeViewModel(int number, string serializedLandscape)
        {
            Number = number;
            _serializedLandscape = serializedLandscape;

            AliveAgents = new FastObservableCollection<AgentViewModel>();
        }
Beispiel #22
0
            public void SuspendsValidationWhileAddingAndRemovingItems()
            {
                var counter = 0;

                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                using (fastCollection.SuspendChangeNotifications())
                {
                    fastCollection.Add(1);
                    fastCollection.Add(2);
                    fastCollection.Add(3);
                    fastCollection.Add(4);
                    fastCollection.Add(5);

                    fastCollection.Remove(5);
                    fastCollection.Remove(4);
                    fastCollection.Remove(3);
                    fastCollection.Remove(2);
                    fastCollection.Remove(1);
                }

                Assert.AreEqual(0, counter);
            }
            public void HandlesChangesOfSuspendedFastObservableCollectionCorrectly()
            {
                var       collection = new FastObservableCollection <TestModel>();
                TestModel model      = null;

                for (int i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                var newModel = new TestModel();

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                    collection.Add(newModel);
                }

                newModel.FirstName = "Geert";

                Assert.IsTrue(collectionItemPropertyChanged);
            }
        public ClientHallViewModel(User user, Reservation reservation = null, FastObservableCollection <OrderedDish> orderedDishes = null)
        {
            _user          = user;
            _orderedDishes = orderedDishes;
            _reservation   = new Reservation();
            _rootViewModel = ViewModelManager.GetFirstOrDefaultInstance <MainWindowViewModel>();

            _availabilityChecker = new TablesAvailabilityChecker(Tables);

            BackCommand             = new Command(OnBackCommandExecute);
            NextCommand             = new Command(OnNextCommandExecute, OnNextCommandCanExecute);
            TimeValuChangedCommand  = new Command(OnTimeValuChangedCommandExecute);
            DateValueChangedCommand = new Command(OnDateValueChangedCommandExecute);
            TableSelectionChanged   = new Command(OnTableSelectionChangedExecute);

            DateMinMaxHelper helper = new DateMinMaxHelper();

            MinimumDate = helper.Minimum;
            MaximumDate = helper.Maximum;

            RefreshTablesCollection();
            ReservationsListRefresh();

            if (reservation != null)
            {
                SetViewModelProperties(reservation);
            }
        }
 /// <summary>
 /// Class constructor
 /// </summary>
 internal SuggestSourceDirectory()
 {
     _LocationIndicator  = new LocationIndicator();
     _Queue              = new Dictionary <string, CancellationTokenSource>();
     _SlowStuffSemaphore = new SemaphoreSlim(1, 1);
     _ListQueryResult    = new FastObservableCollection <object>();
 }
Beispiel #26
0
        public ManageFontModel()
        {
            Fonts      = new FastObservableCollection <string>();
            FontStyles = new FastObservableCollection <string>();
            FontSizes  = new FastObservableCollection <string>();

            using (var installedFontCollection = new InstalledFontCollection())
            {
                var fonts = installedFontCollection.Families;

                foreach (var font in fonts)
                {
                    Fonts.Add(font.Name);
                }
            }

            using (FontStyles.SuspendChangeNotifications())
            {
                foreach (var propertyInfo in typeof(FontStyles).GetProperties())
                {
                    FontStyles.Add(propertyInfo.Name);
                }
            }

            using (FontSizes.SuspendChangeNotifications())
            {
                for (var i = MinFontSize; i < MaxFontSize; i = i + FontSizeStep)
                {
                    FontSizes.Add($"{i}");
                }
            }
        }
Beispiel #27
0
            public void MultipleActionsWithoutSuspendingNotifications()
            {
                var counter = 0;

                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                fastCollection.Add(0);
                fastCollection.Add(1);

                fastCollection.Remove(0);
                fastCollection.Remove(1);

                fastCollection.AddRange(new[] { 1, 2 });

                fastCollection[0] = 5;

                fastCollection.Move(0, 1);

                fastCollection.Clear();

                Assert.AreEqual(9, counter);
            }
Beispiel #28
0
            public void RemovingItemsInRemovingMode()
            {
                var counter   = 0;
                var eventArgs = (NotifyCollectionChangedEventArgs)null;

                var fastCollection = new FastObservableCollection <int> {
                    1, 2, 3, 4, 5
                };

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) =>
                {
                    counter++;
                    eventArgs = e;
                };

                using (fastCollection.SuspendChangeNotifications(SuspensionMode.Removing))
                {
                    fastCollection.Remove(1);
                    fastCollection.Remove(2);
                    fastCollection.Remove(3);
                    fastCollection.Remove(4);
                    fastCollection.Remove(5);
                }

                Assert.AreEqual(1, counter);
                Assert.AreEqual(NotifyCollectionChangedAction.Remove, eventArgs.Action);
                CollectionAssert.AreEqual(eventArgs.OldItems, new[] { 1, 2, 3, 4, 5 });
            }
        private void Start()
        {
            if (_refreshTimer == null)
            {
                _refreshTimer = new DispatcherTimer {
                    Interval = TimeSpan.FromSeconds(1)
                };
                _refreshTimer.Tick += RefreshTimerOnTick;
            }
            _refreshTimer.Start();
            _cpuUsageMonitor = new CpuUsageMonitor();
            _lastDataUpdate  = DateTime.UtcNow;

            if (Packages == null)
            {
                Packages = new FastObservableCollection <PackageInformation>();
            }
            else
            {
                Packages.Add(new PackageInformation
                {
                    Description = "Activity logging started",
                    Timestamp   = DateTime.Now
                });
            }

            _brakingCollectionManager = new BrakingCollectionManager <PackageInformation>(Packages);

            _connectionManager.PackageReceived += ConnectionManagerOnPackageReceived;
            _connectionManager.PackageSent     += ConnectionManagerOnPackageSent;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class.
        /// </summary>
        public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository,
            IMessageService messageService)
            : base(messageMediator)
        {
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => employeeRepository);
            Argument.IsNotNull(() => messageService);

            _uiVisualizerService = uiVisualizerService;
            _employeeRepository = employeeRepository;
            _messageService = messageService;

            AddEmployee = new Command(OnAddEmployeeExecute);
            EditEmployee = new Command(OnEditEmployeeExecute, OnEditEmployeeCanExecute);
            DeleteEmployee = new Command(OnDeleteEmployeeExecute, OnDeleteEmployeeCanExecute);

            Employees = new FastObservableCollection<IEmployee>();
            if (!ObjectHelper.IsNull(SelectedDepartment))
            {
                Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name));
            }

            if (Employees.Count > 0)
            {
                SelectedEmployee = Employees[0];
            }

            Mediator.Register<string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees");
        }
Beispiel #31
0
        public void CreateOrders(FastObservableCollection <Order> orders)
        {
            orders.Clear();
            var currentOrders = _unitOfWork.Orders.GetAll().Where(_ordersSelector).ToList();

            currentOrders.Sort((o1, o2) => o2.Reservation.Day.CompareTo(o1.Reservation.Day));
            orders.AddItems(currentOrders);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ResultsViewModel"/> class.
        /// </summary>
        /// <param name="logEntries">The log entries.</param>
        public ResultsViewModel(IEnumerable<LogEntry> logEntries)
        {
            Argument.IsNotNull(() => logEntries);

            LogEntries = new FastObservableCollection<LogEntry>(logEntries);

            CopyToClipboard = new Command(OnCopyToClipboardExecute, OnCopyToClipboardCanExecute);
        }
Beispiel #33
0
 public ImageFrame(int width, int height)
 {
     Data = null;
     Width = width;
     Height = height;
     Children = new FastObservableCollection<INode>();
     CenterPointX = CenterPointY = 0;
 }
            public void ReturnsFalseWhenNoPendingNotificationsAreListed()
            {
                var fastCollection = new FastObservableCollection<int>();

                fastCollection.Add(1);

                Assert.IsFalse(fastCollection.IsDirty);
            }
Beispiel #35
0
            public void ThrowsArgumentNullExceptionForNullCollection()
            {
                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null));
                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.AddItems(null, SuspensionMode.Adding));
            }
Beispiel #36
0
            public void ReturnsFalseWhenNoPendingNotificationsAreListed()
            {
                var fastCollection = new FastObservableCollection <int>();

                fastCollection.Add(1);

                Assert.IsFalse(fastCollection.IsDirty);
            }
Beispiel #37
0
            private SuspensionContext <T> GetSuspensionContext <T>(FastObservableCollection <T> collection)
            {
                var t = typeof(FastObservableCollection <T>);
                var f = t.GetFieldEx("_suspensionContext", BindingFlags.Instance | BindingFlags.NonPublic);
                var v = f.GetValue(collection) as SuspensionContext <T>;

                return(v);
            }
Beispiel #38
0
 public Folder()
 {
     Folders = new FastObservableCollection<Folder>();
     Images = new FastObservableCollection<ImageData>();
     Children = new FastObservableCollection<INode>();
     Children.CollectionChanged += ChildrenOnCollectionChanged;
     Name = "New Folder";
     Type = "Folder";
 }
Beispiel #39
0
        public FileNode(FileInfo fileInfo)
        {
            Argument.IsNotNull(() => fileInfo);

            FileInfo = fileInfo;
            Name = fileInfo.Name;
            FullName = fileInfo.FullName;

            Records = new FastObservableCollection<LogRecord>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeeViewModel" /> class.
        /// </summary>
        /// <param name="employee">The employee.</param>
        /// <param name="messageMediator">The message mediator.</param>
        /// <param name="departmentRepository">The department repository.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="employee" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="messageMediator" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="departmentRepository" /> is <c>null</c>.</exception>
        public EmployeeViewModel(IEmployee employee, IMessageMediator messageMediator, IDepartmentRepository departmentRepository)
            : base(messageMediator)
        {
            Argument.IsNotNull(() => employee);
            Argument.IsNotNull(() => messageMediator);

            Employee = employee;

            AvailableDepartments = new FastObservableCollection<IDepartment>(departmentRepository.GetAllDepartments());
        }
        public MainWindowViewModel(ITestDataService testDataService)
        {
            Argument.IsNotNull(() => testDataService);

            _testDataService = testDataService;

            RawItems = _testDataService.GenerateTestItems();
            FilteredItems = new FastObservableCollection<TestEntity>();

            FilteredItems.CollectionChanged += (sender, e) => Console.WriteLine("Collection updated");
        }
        public MainViewModel(IDataGenerationService dataGenerationService, ISearchService searchService)
        {
            Argument.IsNotNull(() => dataGenerationService);
            Argument.IsNotNull(() => searchService);

            _dataGenerationService = dataGenerationService;
            _searchService = searchService;

            AllObjects = new FastObservableCollection<object>();
            FilteredObjects = new FastObservableCollection<object>();
        }
        private void OnPackageSourcesChanged()
        {
            EditablePackageSources = new FastObservableCollection<EditablePackageSource>(PackageSources.Select(x =>
                new EditablePackageSource
                {
                    IsEnabled = x.IsEnabled,
                    Name = x.Name,
                    Source = x.Source
                }));

            VerifyAll();
        }
            public void RaisesSingleEventWhileAddingRange()
            {
                int counter = 0;

                var fastCollection = new FastObservableCollection<int>(new [] { 1, 2, 3, 4, 5 });
                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                fastCollection.RemoveItems(new[] { 1, 2, 3, 4, 5 });

                Assert.AreEqual(1, counter);
            }
        /// <summary>
        /// Initializes a new instance of the <see cref="DepartmentsViewModel"/> class. 
        /// </summary>
        public DepartmentsViewModel(IMessageMediator messageMediator, IDepartmentRepository departmentRepository, IUIVisualizerService uiVisualizerService)
            : base(messageMediator)
        {
            _uiVisualizerService = uiVisualizerService;

            Departments = new FastObservableCollection<IDepartment>(departmentRepository.GetAllDepartments());
            if (Departments.Count > 0)
            {
                SelectedDepartment = Departments[0];
            }

            Select = new Command(OnSelectExecute);
        }
        public MainViewModel(ITestDataService testDataService, IFilterService filterService)
        {
            Argument.IsNotNull(() => testDataService);
            Argument.IsNotNull(() => filterService);

            _testDataService = testDataService;
            _filterService = filterService;
            _filterService.SelectedFilterChanged += OnFilterServiceSelectedFilterChanged;
            RawItems = _testDataService.GetTestItems();
            FilteredItems = new FastObservableCollection<TestEntity>();

            FilteredItems.CollectionChanged += (sender, e) => Log.Info("Collection updated");
        }
        public WorkspacesViewModel(IWorkspaceManager workspaceManager, IUIVisualizerService uiVisualizerService)
        {
            Argument.IsNotNull(() => workspaceManager);
            Argument.IsNotNull(() => uiVisualizerService);

            _workspaceManager = workspaceManager;
            _uiVisualizerService = uiVisualizerService;

            AvailableWorkspaces = new FastObservableCollection<IWorkspace>();

            EditWorkspace = new Command<IWorkspace>(OnEditWorkspaceExecute, OnEditWorkspaceCanExecute);
            RemoveWorkspace = new TaskCommand<IWorkspace>(OnRemoveWorkspaceExecuteAsync, OnRemoveWorkspaceCanExecute);
        }
            public void ReturnsTrueWhenPendingNotificationsAreListed()
            {
                var fastCollection = new FastObservableCollection<int>();

                using (fastCollection.SuspendChangeNotifications())
                {
                    fastCollection.Add(1);

                    Assert.IsTrue(fastCollection.IsDirty);
                }

                Assert.IsFalse(fastCollection.IsDirty);
            }
        private void OnPackageSourcesChanged()
        {
            EditablePackageSources = new FastObservableCollection<EditablePackageSource>(PackageSources.Select(x =>
                new EditablePackageSource
                {
                    IsEnabled = x.IsEnabled,
                    Name = x.Name,
                    Source = x.Source
                }));

            if (_ignoreNextPackageUpdate)
            {
                return;
            }

            VerifyAll();
        }
Beispiel #50
0
        public homeViewModel()
        {
            Sets = new FastObservableCollection<SetPresentation>();
            SetsView = CollectionViewSource.GetDefaultView(Sets);

            //Errors = new FastObservableCollection<string>();

            //SettingsService = new KoiSoft.VSMine.Services.Providers.SettingsService();
            //RedmineService = new RestSharpRedmineProvider();

            //if (!String.IsNullOrEmpty(VSMinePackage.Options.RedmineBaseURL))
            //{
            //    RedmineService.Init(VSMinePackage.Options.RedmineBaseURL,
            //                        VSMinePackage.Options.RedmineUsername,
            //                        VSMinePackage.Options.RedminePassword);
            //}
        }
        public SearchViewModel(ISearchService searchService, IUIVisualizerService uiVisualizerService, IViewModelFactory viewModelFactory,
            ISearchHistoryService searchHistoryService)
        {
            Argument.IsNotNull(() => searchService);
            Argument.IsNotNull(() => uiVisualizerService);
            Argument.IsNotNull(() => viewModelFactory);
            Argument.IsNotNull(() => searchHistoryService);

            _searchService = searchService;
            _uiVisualizerService = uiVisualizerService;
            _viewModelFactory = viewModelFactory;
            _searchHistoryService = searchHistoryService;

            _dispatcherTimer = new DispatcherTimer();
            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500);

            FilterHistory = new FastObservableCollection<string>();

            BuildFilter = new Command(OnBuildFilterExecute);
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IReflectionService reflectionService, 
            IXmlSerializer xmlSerializer, IMessageService messageService)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => reflectionService);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;
            
            var filterScheme = filterSchemeEditInfo.FilterScheme;

            _originalFilterScheme = filterScheme;
            _reflectionService = reflectionService;
            _xmlSerializer = xmlSerializer;
            _messageService = messageService;

            DeferValidationUntilFirstSaveCall = true;

            InstanceProperties = _reflectionService.GetInstanceProperties(filterScheme.TargetType).Properties;

            // Serializing gives us a *real* deep clone, there was a bug in Copy()
            //FilterScheme = _originalFilterScheme.Copy();

            using (var memoryStream = new MemoryStream())
            {
                xmlSerializer.Serialize(_originalFilterScheme, memoryStream);
                memoryStream.Position = 0L;
                FilterScheme = (FilterScheme) xmlSerializer.Deserialize(typeof (FilterScheme), memoryStream);
            }

            FilterSchemeTitle = FilterScheme.Title;

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition);
        }
        public KeyboardMappingsCustomizationViewModel(IKeyboardMappingsService keyboardMappingsService, ICommandManager commandManager,
            ILanguageService languageService, IMessageService messageService)
        {
            Argument.IsNotNull(() => keyboardMappingsService);
            Argument.IsNotNull(() => commandManager);
            Argument.IsNotNull(() => languageService);
            Argument.IsNotNull(() => messageService);

            _keyboardMappingsService = keyboardMappingsService;
            _commandManager = commandManager;
            _languageService = languageService;
            _messageService = messageService;

            Commands = new FastObservableCollection<CommandInfo>();
            CommandFilter = string.Empty;
            SelectedCommand = string.Empty;

            Reset = new Command(OnResetExecute);
            Remove = new Command(OnRemoveExecute, OnRemoveCanExecute);
            Assign = new Command(OnAssignExecute, OnAssignCanExecute);
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IXmlSerializer xmlSerializer, 
            IMessageService messageService, IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;

            var filterScheme = filterSchemeEditInfo.FilterScheme;

            _originalFilterScheme = filterScheme;
            _xmlSerializer = xmlSerializer;
            _messageService = messageService;
            _serviceLocator = serviceLocator;

            _reflectionService = _serviceLocator.ResolveType<IReflectionService>(filterScheme.Tag);

            DeferValidationUntilFirstSaveCall = true;

            using (var memoryStream = new MemoryStream())
            {
                xmlSerializer.Serialize(_originalFilterScheme, memoryStream);
                memoryStream.Position = 0L;
                FilterScheme = (FilterScheme)xmlSerializer.Deserialize(typeof(FilterScheme), memoryStream);
                FilterScheme.Tag = filterScheme.Tag;
            }

            FilterSchemeTitle = FilterScheme.Title;

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition, OnDeleteConditionCanExecute);
        }
        public EditFilterViewModel(FilterSchemeEditInfo filterSchemeEditInfo, IXmlSerializer xmlSerializer,
            IMessageService messageService, IServiceLocator serviceLocator, ILanguageService languageService)
        {
            Argument.IsNotNull(() => filterSchemeEditInfo);
            Argument.IsNotNull(() => xmlSerializer);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => serviceLocator);
            Argument.IsNotNull(() => languageService);

            _xmlSerializer = xmlSerializer;
            _messageService = messageService;
            _serviceLocator = serviceLocator;
            _languageService = languageService;

            PreviewItems = new FastObservableCollection<object>();
            RawCollection = filterSchemeEditInfo.RawCollection;
            EnableAutoCompletion = filterSchemeEditInfo.EnableAutoCompletion;
            AllowLivePreview = filterSchemeEditInfo.AllowLivePreview;
            EnableLivePreview = filterSchemeEditInfo.AllowLivePreview;

            var filterScheme = filterSchemeEditInfo.FilterScheme;
            _originalFilterScheme = filterScheme;

            _reflectionService = _serviceLocator.ResolveType<IReflectionService>(filterScheme.Scope);

            DeferValidationUntilFirstSaveCall = true;

            FilterScheme = new FilterScheme
            {
                Scope = _originalFilterScheme.Scope
            };

            AddGroupCommand = new Command<ConditionGroup>(OnAddGroup);
            AddExpressionCommand = new Command<ConditionGroup>(OnAddExpression);
            DeleteConditionItem = new Command<ConditionTreeItem>(OnDeleteCondition, OnDeleteConditionCanExecute);
        }
 public SearchResult()
 {
     PackageList = new FastObservableCollection<IPackageDetails>();
 }
Beispiel #57
0
 public ImageData()
 {
     Name = "New Image";
     Type = "Image";
     Children = new FastObservableCollection<INode>();
 }
 public PackagesBatch()
 {
     PackageList = new FastObservableCollection<IPackageDetails>();
 }
Beispiel #59
0
 public FileBrowserModel()
 {
     RootDirectories = new FastObservableCollection<FolderNode>();
     SelectedItems = new FastObservableCollection<NavigationNode>();
 }
 public void ThrowsArgumentNullExceptionForNullCollection()
 {
     var fastCollection = new FastObservableCollection<int>();
     ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => fastCollection.RemoveItems(null));
 }