예제 #1
0
        private void AliasChanged(object sender, FileSystemEventArgs e)
        {
            var currentAlias = SelectedRuntime;

            _aliases.Clear();
            _aliases.AddRange(Runt.Kvm.ListAlias().Select(a => a.Alias));
            SelectedRuntime = currentAlias;
        }
        public async void Handle(DataMessage dataMessage)
        {
            switch (dataMessage.Message)
            {
            case DataMessages.USER:
                switch (_userService.User.UserType)
                {
                case UserType.PERSON:
                    // COMMENT: Profile and Logout buttons are defined in the View. They are 'static' elements visible in all cases.
                    MenuItems.AddRange(new BindableCollection <CustomMenuItem>
                    {
                        new CustomMenuItem {
                            Name = "My vehicles", OnClick = GoToMyVehicles
                        },
                        new CustomMenuItem {
                            Name = "Market", OnClick = GoToMarket
                        },
                    });
                    PersonUserModel personUser = await _personUserService.Get(_userService.User.Username);

                    _personUserService.PersonUser      = personUser;
                    _personUserService.PersonUser.User = _userService.User;
                    if (personUser.PersonType == PersonType.POLICE)
                    {
                        MenuItems.Insert(2, new CustomMenuItem {
                            Name = "Report accident", OnClick = GoToReportAccident
                        });
                    }
                    break;

                case UserType.SERVICE:
                    MenuItems.AddRange(new BindableCollection <CustomMenuItem>
                    {
                        new CustomMenuItem {
                            Name = "Add service", OnClick = GoToAddService
                        },
                        new CustomMenuItem {
                            Name = "My services", OnClick = GoToMyServices
                        },
                    });
                    ServiceUserModel serviceUser = await _serviceUserService.Get(_userService.User.Username);

                    _serviceUserService.ServiceUser      = serviceUser;
                    _serviceUserService.ServiceUser.User = _userService.User;
                    break;

                default:
                    break;
                }
                // COMMENT: to avoid unsafe async reach to context from both this and MyVehiclesViewModel
                _eventAggregator.PublishOnUIThread(new DataMessage(DataMessages.HEADER_LOADED));
                break;

            default:
                break;
            }
        }
예제 #3
0
        private async Task LoadData()
        {
            var data = await GlobalData.GetAsync();

            heroes.Add(new Hero(null));
            heroes.AddRange(data.Heroes);
        }
예제 #4
0
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            Styles = new BindableCollection<BaseContent>();
            Styles.AddRange(Service.PoITypes.Where(k => k.Style != null).ToList());
        }
예제 #5
0
        private void OnSelectedPixelChanged(object sender, PixelChangedEventArgs e)
        {
            FrameNumber   = _selectionService.SelectedFrame.Number;
            PixelLocation = e.SelectedPixel;

            HasSelectedPixel = true;
            _pixelEvents.Clear();

            var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher);
            var replayer           = new Replayer(
                _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model,
                swapChainPresenter,
                _selectionService.SelectedFrame.ActiveRenderTargetViewIdentifier,
                _selectionService.SelectedFrame.ActiveRenderTargetArraySlice,
                e.SelectedPixel.X, e.SelectedPixel.Y);

            Task.Factory.StartNew(() =>
            {
                replayer.Replay();

                var events = replayer.Logger.GetPixelHistoryEvents(_selectionService.SelectedFrame.Number);
                _pixelEvents.AddRange(events.Select(x => new PixelHistoryEventViewModel(x)));

                FinalFrameBufferColor = ((ColorResultViewModel)_pixelEvents.Last(x => x.Result is ColorResultViewModel).Result).Result;
            });
        }
        private void InitializeData()
        {
            var data = GlobalData.Get();

            heroes.Clear();
            heroes.AddRange(data.Heroes);
        }
예제 #7
0
        public HomeViewModel()
        {
            Projects             = new BindableCollection <Project>();
            Languages            = new BindableCollection <string>();
            ArchiveItems         = new BindableCollection <ArchiveItem>();
            SelectedArchiveItems = new BindableCollection <ArchiveItem>();

            var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ArchiveViewer\\";

            _projectPath = folderPath + _projectPath;

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            if (File.Exists(_projectPath))
            {
                string projects = string.Join("", File.ReadAllLines(_projectPath));
                Projects.AddRange(JsonConvert.DeserializeObject <Project[]>(projects));
            }

            _archiveParser   = new ArchiveParser();
            _csvImportExport = new CsvImportExport();

            _archiveItemsFiltered = new CollectionViewSource
            {
                Source = ArchiveItems
            };
            _archiveItemsFiltered.Filter += ArchiveItemsFilteredOnFilter;
            _translator = new GoogleTranslator();
            _translator.Init();
        }
        /// <summary>
        /// Activates this view model. This method should get called, when the ui framework
        /// begins to display this view model.
        /// </summary>
        public async Task Activate()
        {
            _logMessages.Clear();

            try
            {
                await _provideAlarms.SubscribeForAlarmChanges(_moduleNames, UpdateAlarms);

                await _provideAlarms.RequestAlarms(_moduleNames);

                var logFilters = new List <string>();

                foreach (var moduleName in _moduleNames)
                {
                    logFilters.AddRange(_provideLogFilters.GetLogFiltersForModule(moduleName));
                }

                IEnumerable <string> messages = await _provideLogMessages.GetMessages(logFilters);

                _logMessages.AddRange(messages);
            }
            catch (Exception exception)
            {
                _logger.Warn("Activating the AlarmSummaryViewModel of the platform module(s) did throw an exception.", exception);
            }
        }
예제 #9
0
        private void RefreshMessages()
        {
            var messageInfos = _queueService.GetMessageInfos(_messageQueue);

            Messages.Clear();
            Messages.AddRange(messageInfos.Select(info => new MessageGridRowViewModel(info)));
        }
예제 #10
0
        public void Findtranslate()
        {
            string           notice           = "Вы собираетесь найти перевод  в  БД   слова :\n " + InputText + "\n словарь : " + Languages[indexLanguage];
            MessageViewModel messageViewModel = new MessageViewModel(notice);

            _windowManager.ShowDialog(messageViewModel);

            if (true == messageViewModel.Result)
            {
                try
                {
                    Words.Clear();
                    Information = "На сервер отправлен запрос на перевода слова : " + InputText;
                    var wordsTranslate = proxy.FindTranslate(indexLanguage, InputText);

                    if (wordsTranslate != null)
                    {
                        Information = "Из базы данных получен  перевода слова : " + InputText;
                        translatedwords.AddRange(wordsTranslate);
                    }
                    else
                    {
                        Information = "В базе данных нет перевода слова : " + InputText;
                    }
                }
                catch (CommunicationException ex)
                {
                    Information     = "Возникли проблемы с отправкой пакета, попробуйте соединиться с сервером и отправить новый запрос!\n" + ex.Message;
                    BeConnectServer = true;
                }
            }
        }
예제 #11
0
        public AppearanceViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog,
                                   BindableCollection <string> fontSizesCollection,
                                   BindableCollection <Color> accentColorsCollection,
                                   BindableCollection <ThemeItemViewModel> themesCollection)
            : base(log, scheduler, standardDialog)
        {
            this.SetupHeader(scheduler, "Appearance");

            FontSizes = fontSizesCollection;
            FontSizes.AddRange(new[] { FONT_SMALL, FONT_LARGE });

            SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FONT_LARGE : FONT_SMALL;

            AccentColors = accentColorsCollection;
            foreach (var accentColor in _accentColors)
            {
                AccentColors.Add(accentColor);
            }

            // add the default themes
            Themes = themesCollection;
            Themes.AddRange(new[]
            {
                new ThemeItemViewModel {
                    Name = "Dark", Source = AppearanceManager.DarkThemeSource
                },
                new ThemeItemViewModel {
                    Name = "Light", Source = AppearanceManager.LightThemeSource
                }
            });

            SyncThemeAndColor();

            AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
        }
        public void Populate()
        {
            isCreating = false;

            inventoryItemList.Clear();
            inventoryItemList.AddRange(Context.Items.ToList());

            Items.Clear();
            Items.AddRange(Context.SourcingTransactions.Include(i => i.SourcingTransactionItems)
                           .OrderByDescending(i => i.DateTime)
                           .ToList());

            if (Items.Count == 0)
            {
                New();
            }
            else
            {
                ActivateItem(Items.First());
            }

            isCreating = false;

            NotifyAll();
        }
예제 #13
0
        public void when_RefreshAsync_is_called_and_IsNotifying_is_false_then_Reset_event_fired()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var result = false;

            var bindableCollection = new BindableCollection <int>(testSchedulerProvider);

            var items = Enumerable.Range(0, 1).ToList();

            bindableCollection.AddRange(items);

            bindableCollection.CollectionChanged += (sender, args) =>
            {
                if (args.Action == NotifyCollectionChangedAction.Reset)
                {
                    result = true;
                }
            };

            bindableCollection.IsNotifying = false;

            bindableCollection.RefreshAsync();

            Assert.That(result, Is.False);
        }
예제 #14
0
 private void InitializeVariables(IEnumerable <TextFilesEventsListener> filesEventsListeners)
 {
     foreach (var textFilesEventsListener in filesEventsListeners)
     {
         variables.AddRange(textFilesEventsListener.Variables);
     }
 }
예제 #15
0
        public AppearanceViewModel(ILog log, IDispatcherSchedulerProvider scheduler, IStandardDialog standardDialog,
                                   BindableCollection<string> fontSizesCollection,
                                   BindableCollection<Color> accentColorsCollection,
                                   BindableCollection<ThemeItemViewModel> themesCollection)
            : base(log, scheduler, standardDialog)
        {
            this.SetupHeader(scheduler, "Appearance");

            FontSizes = fontSizesCollection;
            FontSizes.AddRange(new[] {FONT_SMALL, FONT_LARGE});

            SelectedFontSize = AppearanceManager.Current.FontSize == FontSize.Large ? FONT_LARGE : FONT_SMALL;

            AccentColors = accentColorsCollection;
            foreach (var accentColor in _accentColors)
            {
                AccentColors.Add(accentColor);
            }

            // add the default themes
            Themes = themesCollection;
            Themes.AddRange(new[]
            {
                new ThemeItemViewModel {Name = "Dark", Source = AppearanceManager.DarkThemeSource},
                new ThemeItemViewModel {Name = "Light", Source = AppearanceManager.LightThemeSource}
            });

            SyncThemeAndColor();

            AppearanceManager.Current.PropertyChanged += OnAppearanceManagerPropertyChanged;
        }
예제 #16
0
        //Seat flow
        public BindableCollection <SeatModel> GetAllSeatsByAreaId(int areaId)
        {
            var seatClient = GetSeatServiceceClient(UserInfo.Username, UserInfo.Token);

            var seats = seatClient.GetAll();
            var list  = new List <SeatModel>();

            foreach (var item in seats)
            {
                list.Add(new SeatModel
                {
                    Id     = item.Id,
                    AreaId = item.AreaId,
                    Row    = item.Row,
                    Number = item.Number
                });
            }

            var seatsByAreaId = list.FindAll(x => x.AreaId == areaId).ToList();
            var col           = new BindableCollection <SeatModel>();

            col.AddRange(seatsByAreaId);

            return(col);
        }
예제 #17
0
        private async void UpdateSubscribers()
        {
            var items = await _detailsController.Get();

            Subscribers = new BindableCollection <Person>();
            Subscribers.AddRange(items);
        }
예제 #18
0
        public BindableCollection <LayoutModel> GetAllLayoutsByVenueId(int venueId)
        {
            var layoutClient = GetLayoutServiceClient(UserInfo.Username, UserInfo.Token);

            var layouts = layoutClient.GetAll();
            var list    = new List <LayoutModel>();

            foreach (var item in layouts)
            {
                list.Add(new LayoutModel
                {
                    Id          = item.Id,
                    VenueId     = item.VenueId,
                    Name        = item.Name,
                    Description = item.Description,
                });
            }

            var layoutsByVenueId = list.FindAll(x => x.VenueId == venueId).OrderBy(x => x.Name).ToList();
            BindableCollection <LayoutModel> col = new BindableCollection <LayoutModel>();

            col.AddRange(layoutsByVenueId);

            return(col);
        }
예제 #19
0
        //Area flow
        public BindableCollection <AreaModel> GetAllAreasByLayoutId(int layoutId)
        {
            var areaClient = GetAreaServiceClient(UserInfo.Username, UserInfo.Token);

            var areas = areaClient.GetAll();
            var list  = new List <AreaModel>();

            foreach (var item in areas)
            {
                list.Add(new AreaModel
                {
                    Id          = item.Id,
                    LayoutId    = item.LayoutId,
                    Description = item.Description,
                    CoordX      = item.CoordX,
                    CoordY      = item.CoordY
                });
            }

            var areasByLayoutId = list.FindAll(x => x.LayoutId == layoutId).ToList();
            var col             = new BindableCollection <AreaModel>();

            col.AddRange(areasByLayoutId);

            return(col);
        }
예제 #20
0
        protected override async void OnActivate()
        {
            base.OnActivate();
            var response = await IoC.Get <IDataService>().GetRaceAsync(SelectedRace.Id);

            _teams.AddRange(response.Teams);
        }
 public LaunchAccountViewModel()
 {
     Accounts = new BindableCollection <Account>();
     Launchs  = new BindableCollection <LaunchAccount>();
     Launchs.AddRange(DataContext.GetAllLauchs());
     Accounts.AddRange(DataContext.GetAllAccounts());
 }
예제 #22
0
 private void HandleReset()
 {
     _copy.ForEach(a => HandleElement(NotifyCollectionChangedAction.Remove, a));
     _collection.ForEach(a => HandleElement(NotifyCollectionChangedAction.Add, a));
     _copy.Clear();
     _copy.AddRange(_collection);
 }
예제 #23
0
        private void Initialise()
        {
            RunnerSpecs.Clear();
            var specs = _runnerSpecRepo.Specs;

            RunnerSpecs.AddRange(specs.Select(x => new RunnerSpecViewModel(x)));
        }
예제 #24
0
        private void UpdateReferences()
        {
            var referencesIds = Regex.Matches(jsonData, @"""(\w+/\w+)""");

            references.Clear();
            references.AddRange(referencesIds.Cast <Match>().Select(x => x.Groups[1].Value).Distinct());
        }
예제 #25
0
        /// <summary>
        /// The get hits.
        /// </summary>
        /// <param name="move">
        /// The move.
        /// </param>
        /// <returns>
        /// The <see cref="BindableCollection"/>.
        /// </returns>
        private static BindableCollection <HitViewModel> GetHits(Move move)
        {
            BindableCollection <HitViewModel> tmpHitList = new BindableCollection <HitViewModel>();

            List <HitViewModel.CancelAbilityEnum> cancelList = new List <HitViewModel.CancelAbilityEnum>();

            if (move.Script.Name != "NONE")
            {
                // These aren't finished. More cancels exists. I'll add them as I go.
                //    foreach (CancelCommand cancel in move.Script.CommandLists[(int)CommandListType.CANCELS])
                //    {
                //        if (cancel.CancelList != null)
                //        {
                //            // This is just for debugging...
                //            notes += cancel.CancelList + " ";
                //            if (cancel.CancelList.ToString().Contains("SUPER MOVE"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Special);
                //            }

                //            if (cancel.CancelList.ToString().Contains("SUPER COMBO"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Super);
                //            }

                //            if (cancel.CancelList.ToString().Contains("SC"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Super);
                //            }

                //            if (cancel.CancelList.ToString().Contains("UC"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Ultra);
                //            }

                //            if (cancel.CancelList.ToString().Contains("SAVING"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Dash);
                //            }

                //            if (cancel.CancelList.ToString().Contains("CANCEL_"))
                //            {
                //                cancelList.Add(HitViewModel.CancelAbilityEnum.Chain);
                //            }
                //        }
                //    }

                //    tmpCancel = cancelList.ToArray();

                Script target = move.Script;
                ObservableCollection <HitboxCommand> hitboxes = target.CommandLists[7];

                tmpHitList.AddRange(ProcessMoveHits(move));

                // Info loaded here is mostly wrong or missing. Notes are currently used for debugging/getting info.
            }

            return(tmpHitList);
        }
예제 #26
0
 private async void LoadPageContent()
 {
     UserFundraisingPages = new BindableCollection<FundraisingPage>();
     UserDonations = new BindableCollection<Donation>();
     UserFundraisingPages.AddRange(await _accountRepository.GetFundraisingPagesForUser(UserHelperIsolatedStorage.User.Email));
     UserDonations.AddRange(await _accountRepository.GetDonationsForUser());
     AccountInformation = UserHelperIsolatedStorage.User;
 }
예제 #27
0
        public AddLedViewModel(bool addBefore, DeviceLayoutViewModel deviceLayoutViewModel)
        {
            _addBefore             = addBefore;
            _deviceLayoutViewModel = deviceLayoutViewModel;

            AvailableLedIds = new BindableCollection <string>();
            AvailableLedIds.AddRange(deviceLayoutViewModel.Model.GetAvailableLedIds());
        }
 private void OnSelectedFrameChanged(object sender, TracefileFrameChangedEventArgs e)
 {
     _events.Clear();
     if (e.TracefileFrameViewModel != null)
     {
         _events.AddRange(e.TracefileFrameViewModel.Events);
     }
 }
예제 #29
0
        public void Handle(Message <IEnumerable <Book> > message)
        {
            _recentBooks.AddRange(message.Value);
            _allBooks.AddRange(message.Value);

            NotifyOfPropertyChange(nameof(RecentBooks));
            NotifyOfPropertyChange(nameof(AllBooks));
        }
        public ChangelogPageViewModel()
        {
            ReleaseNotes = new BindableCollection<Release>();

            if (Execute.InDesignMode) {
                ReleaseNotes.AddRange(FakeData.ReleaseNotes);
            }
        }
예제 #31
0
        public LogSyntaxProvider(ILogSyntax[] defaultSyntaxImplementations, ILogVisualizer logVisualizer)
        {
            _logVisualizer = logVisualizer;
            _syntaxCollection.AddRange(defaultSyntaxImplementations);

            SyntaxCollection = _syntaxCollection;
            _syntaxCollection.CollectionChanged += SyntaxCollectionOnCollectionChanged;
        }
예제 #32
0
        /// <summary>
        /// Converts an IEnumerable<typeparamref name="T"/> To a BindableCollection<typeparamref name="T"/>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="enumerable"></param>
        /// <returns>BindableCollection<typeparamref name="T"/></returns>
        public static BindableCollection <T> ToBindableCollection <T>(this IEnumerable <T> enumerable)
        {
            var col = new BindableCollection <T>();

            col.AddRange(enumerable);

            return(col);
        }
예제 #33
0
        public void LoadJson(string data)
        {
            List <QueryEvent> qe = JsonConvert.DeserializeObject <List <QueryEvent> >(data);

            _queryEvents.Clear();
            _queryEvents.AddRange(qe);
            NotifyOfPropertyChange(() => QueryEvents);
        }
예제 #34
0
        /// <summary>
        /// Money Converter Page Initializer
        /// </summary>
        /// <param name="selected"></param>
        public MoneyConverterPageViewModel(Country selected, List <Rate> rates)
        {
            _rates        = new BindableCollection <Rate>();
            this._country = selected;

            _rates.AddRange(rates);

            PageActive = true;
        }
예제 #35
0
        public MenuViewModel(IEventAggregator eventAggregator)
        {
            EventAggregator = eventAggregator;

            SalesItems = new BindableCollection<IMenuItem>()
            {
                new MenuItemViewModel<SummaryViewModel>("Balance Sheet"),
                new MenuItemViewModel<TodaysCustomerTransactionsViewModel>("Todays Transactions", o => o.StartDate = DateTime.Today),
            };

            AdministrationItems = new BindableCollection<IMenuItem>()
            {
                new MenuItemViewModel<ProductsViewModel>("Products"),
                new MenuItemViewModel<CustomersViewModel>("Customers"),
                new MenuItemViewModel<DiscountsViewModel>("Discounts")
            };

            Items = new BindableCollection<IMenuItem>();
            Items.AddRange(SalesItems);
            Items.AddRange(AdministrationItems);
        }
        /// <summary>
        /// button evet click handler, handles Diagnozy synchronization
        /// </summary>
        public void SynchronizeDiagnozy()
        {
            ambulanceDiagonzies = new BindableCollection<Cis_Diagnoza>();
            AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>();
            EntityQuery<Cis_Diagnoza> query = ambulance.GetCis_DiagnozaQuery();
            EntityQuery<Diagnozy> query2 = _laboratoryDomainContext.GetAllDiagnoziesQuery();

            List<IResult> results = new List<IResult>();
            results.Add(Show.Busy());
            LoadData<Cis_Diagnoza> loadResult = new LoadData<Cis_Diagnoza>(ambulance,query,LoadBehavior.RefreshCurrent,(sender) =>
            {
                ambulanceDiagonzies.Clear();
                ambulanceDiagonzies.AddRange(((LoadOperation<Cis_Diagnoza>)sender).Entities);
            }
            );

            LoadData<Diagnozy> loadResult2 = new LoadData<Diagnozy>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) =>
            {
                laboratoryDiagnozy.Clear();
                laboratoryDiagnozy.AddRange(((LoadOperation<Diagnozy>)sender).Entities);
                bool found = false;

                foreach (var item in ambulanceDiagonzies)
                {
                    for (int i = 0; i < laboratoryDiagnozy.Count; i++)
                    {
                        found = false;
                        if (item.Nazov == laboratoryDiagnozy[i].nazov && item.Poznamka == laboratoryDiagnozy[i].popis)
                        {
                            laboratoryDiagnozy.RemoveAt(i);
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        Diagnozy novaDiagnoza = new Diagnozy();
                        novaDiagnoza.nazov = item.Nazov;
                        novaDiagnoza.popis = item.Poznamka;
                        _laboratoryDomainContext.Diagnozies.Add(novaDiagnoza);
                    }
                }
                _laboratoryDomainContext.SubmitChanges();
                Coroutine.BeginExecuteFor(Show.NotBusy(), this);

            }
            );
            results.Add(loadResult);
            results.Add(loadResult2);

            Coroutine.BeginExecuteFor(results, this);
        }
예제 #37
0
        public void does_not_fire_a_collectionchanged_event_for_each_item_in_addrange()
        {
            var collection = new BindableCollection<string>();
            var eventsFired = 0;
            collection.CollectionChanged += (source, args) => { eventsFired++; };

            collection.AddRange(new[]
            {
                "abc", "def"
            });

            Assert.That(eventsFired, Is.EqualTo(1), "The CollectionChanged event should only have fired once.");
        }
예제 #38
0
        public FlyoutSettingsViewModel(MainManager mainManager, ILogger logger, DebugViewModel debugViewModel)
        {
            _logger = logger;
            _debugViewModel = debugViewModel;

            MainManager = mainManager;
            Header = "Settings";
            Position = Position.Right;
            GeneralSettings = SettingsProvider.Load<GeneralSettings>();

            LogLevels = new BindableCollection<string>();
            LogLevels.AddRange(LogLevel.AllLoggingLevels.Select(l => l.Name));

            PropertyChanged += KeyboardUpdater;
            mainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;
            mainManager.EffectManager.OnEffectChangedEvent += EffectManagerOnOnEffectChangedEvent;
        }
예제 #39
0
        public void AddRangeUsesDispatcherToAddElements()
        {
            var itemsToAdd = new[] { new Element(), new Element() };
            var existingItems = new[] { new Element() };
            var collection = new BindableCollection<Element>(existingItems);

            var dispatcher = new TestDispatcher();
            Execute.Dispatcher = dispatcher;

            collection.AddRange(itemsToAdd);

            Assert.That(collection, Is.EquivalentTo(existingItems));
            Assert.NotNull(dispatcher.SendAction);

            dispatcher.SendAction();

            Assert.AreEqual(existingItems.Concat(itemsToAdd), collection);
        }
예제 #40
0
        public void when_AddRange_is_called_and_IsNotifying_is_false_then_Reset_event_fired()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var result = false;

            var bindableCollection = new BindableCollection<int>(testSchedulerProvider);

            bindableCollection.CollectionChanged += (sender, args) =>
                                                    {
                                                        if (args.Action == NotifyCollectionChangedAction.Reset)
                                                        {
                                                            result = true;
                                                        }
                                                    };

            bindableCollection.IsNotifying = false;

            bindableCollection.AddRange(Enumerable.Range(0, 1));

            Assert.That(result, Is.False);
        }
예제 #41
0
        public void AddRangeFiresPropertyChangedAfterAddingItems()
        {
            var collection = new BindableCollection<Element>(new[] { new Element(), new Element() });

            var changedProperties = new List<string>();
            ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) =>
            {
                Assert.AreEqual(4, collection.Count);
                changedProperties.Add(e.PropertyName);
            };
 
            collection.AddRange(new[] { new Element(), new Element() });

            Assert.That(changedProperties, Is.EquivalentTo(new[] { "Count", "Item[]" }));
        }
예제 #42
0
        public void AddRangeFiresCollectionChangedAfterAddingItems()
        {
            var collection = new BindableCollection<Element>(new[] { new Element(), new Element() });

            var changedEvents = new List<NotifyCollectionChangedEventArgs>();
            collection.CollectionChanged += (o, e) =>
            {
                Assert.AreEqual(4, collection.Count);
                changedEvents.Add(e);
            };

            var elementsToAdd = new[] { new Element(), new Element() };
            collection.AddRange(elementsToAdd);

            Assert.AreEqual(1, changedEvents.Count);
            var changedEvent = changedEvents[0];
            Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
        }
        private void SetupControls()
        {
            var dataModelProps = _layerEditorViewModel.DataModelProps;
            Name = _property + ":";

            // Populate target combobox
            Targets = new BindableCollection<GeneralHelpers.PropertyCollection>
            {
                new GeneralHelpers.PropertyCollection {Display = "None"}
            };
            Targets.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Populate sources combobox
            Sources = new BindableCollection<GeneralHelpers.PropertyCollection>();
            Sources.AddRange(dataModelProps.Where(p => (p.Type == "Int32") || (p.Type == "Single")));

            // Preselect according to the model
            SelectedTarget = dataModelProps.FirstOrDefault(p => p.Path == Proposed.GameProperty);
            SelectedSource = dataModelProps.FirstOrDefault(p => p.Path == Proposed.PercentageProperty);
            LayerPropertyType = Proposed.LayerPropertyType;

            // Populate the extra options combobox
            switch (_property)
            {
                case "Width":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.LeftToRight,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.RightToLeft
                    };
                    break;
                case "Height":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Downwards,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Upwards
                    };
                    break;
                case "Opacity":
                    LayerPropertyOptions = new BindableCollection<LayerPropertyOptions>
                    {
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Increase,
                        Artemis.Profiles.Layers.Models.LayerPropertyOptions.Decrease
                    };
                    break;
            }

            UserSourceIsVisible = LayerPropertyType == LayerPropertyType.PercentageOf;
            SourcesIsVisible = LayerPropertyType == LayerPropertyType.PercentageOfProperty;

            // Set up a default for SelectedTarget if it was null
            if (SelectedTarget.Display == null)
                SelectedTarget = Targets.FirstOrDefault();
            // Set up a default for the extra option if it fell outside the range
            if (!LayerPropertyOptions.Contains(Proposed.LayerPropertyOptions))
                Proposed.LayerPropertyOptions = LayerPropertyOptions.FirstOrDefault();
        }
        private void GetVysledky()
        {
            EntityQuery<Vysetrenie_Vysetrovane_latky> query = _laboratoryDomainContext.GetVysetrenie_Vysetrovane_latkyQuery(Vysetrenie.id_vysetrenie);
            query = query.OrderBy(x => x.id_vysetrovana_latka);

            List<IResult> results = new List<IResult>();
            results.Add(Show.Busy());
            LoadData<Vysetrenie_Vysetrovane_latky> loadResult = new LoadData<Vysetrenie_Vysetrovane_latky>(_laboratoryDomainContext, query, LoadBehavior.RefreshCurrent, (sender) =>
            {
                BindableCollection<Vysetrenie_Vysetrovane_latky> vysledkyVys = new BindableCollection<Vysetrenie_Vysetrovane_latky>();
                vysledkyVys.AddRange(((LoadOperation<Vysetrenie_Vysetrovane_latky>)sender).Entities);

                _laboratoryDomainContext.Vzorkies.Clear();
                _laboratoryDomainContext.Load(_laboratoryDomainContext.GetVzorkaQuery(Vysetrenie.id_vzorka)).Completed += (sender2, e2) =>
                {
                    Vzorky vzorka = null;
                    foreach (var item in _laboratoryDomainContext.Vzorkies)
                    {
                        vzorka = item;
                    }


                    int idDiagnozy = -1;
                    try
                    {
                        idDiagnozy = (int)vzorka.id_diagnoza;
                    }
                    catch (Exception)
                    {
                    }

                    if (idDiagnozy == -1)
                    {
                        GetHodnotyLatky(vysledkyVys, vzorka, null);
                    }
                    else
                    {
                        _laboratoryDomainContext.Diagnozies.Clear();
                        _laboratoryDomainContext.Load(_laboratoryDomainContext.GetDiagnozaQuery(idDiagnozy)).Completed += (sender3, e3) =>
                       {
                           Diagnozy diag = null;
                           foreach (var item in _laboratoryDomainContext.Diagnozies)
                           {
                               diag = item;
                           }

                           GetHodnotyLatky(vysledkyVys, vzorka, diag);
                       };
                    }


                };
            });
            results.Add(loadResult);
            Coroutine.BeginExecuteFor(results, this);
        }
예제 #45
0
 void LoadGroups()
 {
     var data = GroupRepository.GetGroups();
     _groups = new BindableCollection<GroupViewModel>();
     _groups.AddRange(data.Select(x => new GroupViewModel(x)));
 }
예제 #46
0
        public void when_RemoveRange_is_called_then_Reset_event_fired()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var result = false;

            var bindableCollection = new BindableCollection<int>(testSchedulerProvider);

            var items = Enumerable.Range(0, 1).ToList();

            bindableCollection.AddRange(items);

            bindableCollection.CollectionChanged += (sender, args) =>
                                                    {
                                                        if (args.Action == NotifyCollectionChangedAction.Reset)
                                                        {
                                                            result = true;
                                                        }
                                                    };

            bindableCollection.RemoveRange(items);

            Assert.That(result, Is.True);
        }
예제 #47
0
        public void when_items_are_added_those_items_are_pumped_onto_AddedItemsCollectionChanged()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var results = new List<Guid>();

            var bindableCollection = new BindableCollection<Guid>(testSchedulerProvider);
            bindableCollection.AddedItemsCollectionChanged
                              .Subscribe(x => results.AddRange(x));

            var items = Enumerable.Range(0, 10)
                                  .Select(_ => Guid.NewGuid())
                                  .ToList();

            bindableCollection.AddRange(items);

            var intersectionCount = results.Intersect(items).Count();

            Assert.That(intersectionCount, Is.EqualTo(items.Count));
        }
        /// <summary>
        /// button evet click handler, handles Lieky synchronization
        /// </summary>
        public void SynchronizeLieky()
        {
            
            ambulanceLieky = new BindableCollection<Cis_Lieky>();
            AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>();
            EntityQuery<Cis_Lieky> query = ambulance.GetCis_LiekyQuery();
            EntityQuery<Lieky> query2 = _laboratoryDomainContext.GetAllLiekiesQuery();

            List<IResult> results = new List<IResult>();
            results.Add(Show.Busy());
            LoadData<Cis_Lieky> loadResult = new LoadData<Cis_Lieky>(ambulance, query, LoadBehavior.RefreshCurrent, (sender) =>
            {
                ambulanceLieky.Clear();
                ambulanceLieky.AddRange(((LoadOperation<Cis_Lieky>)sender).Entities);
            }
            );

            LoadData<Lieky> loadResult2 = new LoadData<Lieky>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) =>
            {
                laboratoryLieky.Clear();
                laboratoryLieky.AddRange(((LoadOperation<Lieky>)sender).Entities);
                bool found = false;

                foreach (var item in ambulanceLieky)
                {
                    for (int i = 0; i < laboratoryLieky.Count; i++)
                    {
                        found = false;
                        if (item.Nazov == laboratoryLieky[i].nazov && item.Kod == laboratoryLieky[i].kod)
                        {
                            laboratoryLieky.RemoveAt(i);
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        Lieky novyLiek = new Lieky();
                        novyLiek.nazov = item.Nazov;
                        novyLiek.kod = item.Kod;
                        _laboratoryDomainContext.Liekies.Add(novyLiek);
                    }
                }
                _laboratoryDomainContext.SubmitChanges();
                Coroutine.BeginExecuteFor(Show.NotBusy(), this);

            }
            );
            results.Add(loadResult);
            results.Add(loadResult2);

            Coroutine.BeginExecuteFor(results, this);
        }
        /// <summary>
        /// button evet click handler, handles Poistovne synchronization
        /// </summary>
        public void SynchronizePoistovne()
        {
            
            ambulancePoistovne = new BindableCollection<Cis_Poistovne>();
            AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>();
            EntityQuery<Cis_Poistovne> query = ambulance.GetCis_PoistovneQuery();
            EntityQuery<Poistovne> query2 = _laboratoryDomainContext.GetAllPoistovneQuery();

            List<IResult> results = new List<IResult>();
            results.Add(Show.Busy());
            LoadData<Cis_Poistovne> loadResult = new LoadData<Cis_Poistovne>(ambulance, query, LoadBehavior.RefreshCurrent, (sender) =>
            {
                ambulancePoistovne.Clear();
                ambulancePoistovne.AddRange(((LoadOperation<Cis_Poistovne>)sender).Entities);
            }
            );

            LoadData<Poistovne> loadResult2 = new LoadData<Poistovne>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) =>
            {
                laboratoryPoistovne.Clear();
                laboratoryPoistovne.AddRange(((LoadOperation<Poistovne>)sender).Entities);
                bool found = false;

                foreach (var item in ambulancePoistovne)
                {
                    for (int i = 0; i < laboratoryPoistovne.Count; i++)
                    {
                        found = false;
                        if (item.Nazov == laboratoryPoistovne[i].nazov)
                        {
                            laboratoryPoistovne.RemoveAt(i);
                            found = true;
                            break;
                        }
                    }

                    if (found == false)
                    {
                        Poistovne novaPoistovna = new Poistovne();
                        novaPoistovna.nazov = item.Nazov;
                        _laboratoryDomainContext.Poistovnes.Add(novaPoistovna);
                    }
                }
                _laboratoryDomainContext.SubmitChanges();
                Coroutine.BeginExecuteFor(Show.NotBusy(), this);

            }
            );
            results.Add(loadResult);
            results.Add(loadResult2);

            Coroutine.BeginExecuteFor(results, this);
        }
예제 #50
0
파일: AppLib.cs 프로젝트: jserna-arl/LIMSv2
 public static ObservableCollection<IModule> LoadModules(IEnumerable<Lazy<IModule, IModuleMetadata>> modules)
 {
     BindableCollection<IModule> existingModules = new BindableCollection<IModule>();
     BindableCollection<IModule> authorizedModules = new BindableCollection<IModule>();
     try {
         existingModules.AddRange(from m in modules orderby m.Metadata.Order select m.Value);
         foreach (IModule module in existingModules) {
             if (module.Module.ToString() == ModuleNames.Dashboard.ToString() && module.Module.ToString() != "Inventory") {
                 authorizedModules.Add(module);
             }else {
                 if (!module.IsButtonModule && module.Module.ToString() != "Inventory")
                 {
                     authorizedModules.Add(module);
                 }else {
                     if (IsAuthorized(module.Module.ToString()) && module.Module.ToString() != "Inventory")
                     {
                         authorizedModules.Add(module);
                     }
                 }
             }
         }
         return authorizedModules;
     }catch {
         throw;
     }finally {
         existingModules = null;
         authorizedModules = null;
     }
 }
예제 #51
0
 //this returns seasons populated down to the category level.
 public async Task<BindableCollection<Season>> GetSortedSeasons()
 {
     TeamResponse response = await ServiceAccessor.GetTeams();
     if (response.status == SERVICE_RESPONSE.SUCCESS)
     {
         BindableCollection<Team> teams = response.teams;
         BindableCollection<Season> seasons = new BindableCollection<Season>();
         foreach (Team team in teams)
         {
             BindableCollection<Season> teamSeason = await GetPopulatedSeasons(team);
             if (teamSeason != null)
             {
                 seasons.AddRange(teamSeason);
             }
         }
         return new BindableCollection<Season>(seasons.OrderByDescending(s => s.year));
     }
     return null;
 }
예제 #52
0
        public void AddRangeFiresCollectionChangingBeforeAddingItems()
        {
            var collection = new BindableCollection<Element>();

            var changedEvents = new List<NotifyCollectionChangedEventArgs>();
            collection.CollectionChanging += (o, e) =>
            {
                changedEvents.Add(e);
                Assert.AreEqual(0, collection.Count);
            };

            collection.AddRange(new[] { new Element() });

            Assert.AreEqual(1, changedEvents.Count);
            var changedEvent = changedEvents[0];
            Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
        }