コード例 #1
0
 public GroupingViewModel(IDeviceDataBase deviceDataBase, ILogService logService, IndividualSelectorViewModel individualSelectorViewModel, GroupSelectorViewModel groupSelectorViewModel, GroupsOverviewViewModel groupsOverviewViewModel)
 {
     m_deviceDataBase = deviceDataBase;
     m_logService     = logService;
     m_individualSelectorViewModel = individualSelectorViewModel;
     m_groupSelectorViewModel      = groupSelectorViewModel;
     m_groupsOverviewViewModel     = groupsOverviewViewModel;
 }
コード例 #2
0
 public RegisterViewModel(IDeviceDataBase database, INavigationService navigationService, ILogService logService)
 {
     m_database                 = database;
     m_navigationService        = navigationService;
     m_logService               = logService;
     AddIndividualsGroupCommand = new AsyncCommand(AddIndividualsGroup);
     AddIndividualCommand       = new Command(AddIndividual);
     RemoveIndividualCommand    = new AsyncCommand <Individual>(RemoveIndividual);
 }
コード例 #3
0
        public OverviewViewModel(INavigationService navigationService, IDeviceDataBase database, ILogService logService)
        {
            NavigateToGroupingCommand       = new AsyncCommand <Group>(NavigateToGrouping);
            RegisterIndividualsGroupCommand = new AsyncCommand(navigationService.Push <RegisterViewModel>);
            RefreshCommand = new AsyncCommand(Refresh);
            DeleteCommand  = new AsyncCommand <Group>(Delete);
            EditCommand    = new AsyncCommand <Group>(NavigateToEditGroup);

            m_navigationService = navigationService;
            m_database          = database;
            m_logService        = logService;
        }
コード例 #4
0
        public GroupSelectorViewModel(IDeviceDataBase deviceDataBase, ILogService logService)
        {
            ApproveCommand = new AsyncCommand(async() =>
            {
                m_groupingStateMachine.GoToGroupsOverViewState(GroupedGroups.Where(g => g.Any()).ToList());
                try
                {
                    foreach (var groupedGroup in GroupedGroups)
                    {
                        foreach (var individual in groupedGroup)
                        {
                            var otherIndividualsInGroup = groupedGroup.Where(individualInGroup => individualInGroup.GetIndividual().Id != individual.GetIndividual().Id);
                            foreach (var otherIndividual in otherIndividualsInGroup)
                            {
                                await m_deviceDataBase.Save(new IndividualGroupings()
                                {
                                    IndividualId = individual.GetIndividual().Id, OtherIndividualId = otherIndividual.GetIndividual().Id
                                });
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    m_logService.Log(exception);
                }
            });

            GroupCommand = new Command <int>(numberOfIndividualsInGroup =>
            {
                Group(numberOfIndividualsInGroup);
            });

            ChangeSelectionCommand = new Command(() =>
            {
                m_groupingStateMachine.GoToIndividualSelectorState();
            });

            HighlightCommand = new AsyncCommand <MoveableIndividual>(async individual =>
            {
                try
                {
                    CancelMovementCommand.Execute(null);
                    m_highLightedIndividual = individual;
                    m_highLightedIndividual.IsHighligted = true;
                    var groupsToHighlight = GroupedGroups.Where(groupedIndividuals => !groupedIndividuals.Contains(individual));
                    groupsToHighlight.ForEach(g => g.IsHighlighted = true);

                    await DisplayNumberOfTimesWithOthers(individual);
                }
                catch (System.Exception exception)
                {
                    m_logService.Log(exception);
                }
            });

            CancelMovementCommand = new Command(() =>
            {
                GroupedGroups.ForEach(g => g.IsHighlighted = false);
                if (m_highLightedIndividual != null)
                {
                    m_highLightedIndividual.IsHighligted = false;
                }
                m_highLightedIndividual = null;

                GroupedGroups.ForEach(g => g.ForEach(i => i.NumberOfTimesGroupedWith = 0));
            });

            MoveIndividualCommand = new Command <GroupedIndividuals>(ig =>
            {
                var group = GroupedGroups.First(groupedIndividuals => groupedIndividuals.Contains(m_highLightedIndividual));
                group.Remove(m_highLightedIndividual);
                ig.Add(m_highLightedIndividual);
                CancelMovementCommand.Execute(null);
            });
            m_deviceDataBase = deviceDataBase;
            m_logService     = logService;
        }