コード例 #1
0
        public ViewInvitesViewModel(MainViewModel parent, IMobileServiceTable<Invite> invitesTable, Action dismiss)
        {
            _parent = parent;
            _invitesTable = invitesTable;
            Invites = parent.Invites;

            AcceptCommand = new DelegateCommand<Invite>(async invite =>
            {
                invite.Approved = true;
                await _invitesTable.UpdateAsync(invite);
                Invites.Remove(invite);
                _parent.LoadLists();
                _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0;
                if (Invites.Count == 0 )
                {
                    dismiss();
                }
            });

            RejectCommand = new DelegateCommand<Invite>(async invite =>
            {
                await _invitesTable.UpdateAsync(invite);
                Invites.Remove(invite);
                _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0;
                if (Invites.Count == 0)
                {
                    dismiss();
                }
            });
        }
コード例 #2
0
ファイル: InviteUserViewModel.cs プロジェクト: mbin/Win81App
        public InviteUserViewModel(MainViewModel mainViewModelParent, IMobileServiceTable<Profile> mobileServiceProfileTable)
        {
            profileTable = mobileServiceProfileTable;
            parent = mainViewModelParent;

            SearchCommand = new DelegateCommand(() =>
            {
                currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount();
                }
                else
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount().Where
                        (p => p.Name.IndexOf(SearchText) >= 0);
                }
                RefreshQueryAsync();
            });

            NextCommand = new DelegateCommand(() =>
            {
                currentPage++;
                RefreshQueryAsync();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                currentPage--;
                RefreshQueryAsync();
            }, false);
        }
コード例 #3
0
        public MainPage()
        {
            InitializeComponent();
            synchronizationContext = SynchronizationContext.Current;
            viewModel = new MainViewModel(this, synchronizationContext);
            DataContext = viewModel;
            viewModel.Initialize();

            SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;

            viewModel.PropertyChanged += (sender, e) =>
            {
                if (String.Equals(e.PropertyName, "ViewMode"))
                {
                    SwitchViewMode(viewModel.ViewMode);
                }
            };

            listView.SelectionChanged += (sender, e) =>
            {
                IList<object> selectedItems = (sender as ListView).SelectedItems;
                viewModel.SetSelectedItems(selectedItems.Select(i => (Item)i).ToList());
            };

            InviteUser.PlacementSource = panelUserName;
        }
コード例 #4
0
        public MainPage()
        {
            InitializeComponent();
            _synchronizationContext = SynchronizationContext.Current;
            DataContext = _viewModel = new MainViewModel(this, _synchronizationContext);
            _viewModel.Initialize();

            SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;

            this.SizeChanged += MainPage_SizeChanged;

            _viewModel.PropertyChanged += (sender, e) =>
            {
                if (String.Equals(e.PropertyName, "ViewState"))
                {
                    SwitchViewState(_viewModel.ViewState);
                }
            };

            listView.SelectionChanged += (sender, e) =>
            {
                IList<object> selectedItems = (sender as ListView).SelectedItems;
                _viewModel.SetSelectedItems(selectedItems.Select(i => (Item)i).ToList());
            };
        }
コード例 #5
0
        public InviteUserViewModel(MainViewModel parent, IMobileServiceTable<Profile> profileTable, Action dismiss)
        {
            _profileTable = profileTable;
            _parent = parent;
            _dismiss = dismiss;

            SearchCommand = new DelegateCommand(() =>
            {
                _currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount();
                }
                else
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount().Where(p => p.Name.IndexOf(SearchText) > -1);
                }
                RefreshQuery();
            });

            NextCommand = new DelegateCommand(() =>
            {
                _currentPage++;
                RefreshQuery();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                _currentPage--;
                RefreshQuery();
            }, false);
        }
コード例 #6
0
        public ViewInvitesViewModel(MainViewModel mainViewModelParent, IMobileServiceTable<Invite> mobileServiceInvitesTable)
        {
            flyoutProvider = mainViewModelParent.FlyoutProvider;
            parent = mainViewModelParent;
            invitesTable = mobileServiceInvitesTable;
            Invites = parent.Invites;

            AcceptCommand = new DelegateCommand<Invite>(async invite =>
            {
                invite.IsApproved = true;
                await ProcessInvite(invite);
                parent.LoadListsAsync();
            });

            RejectCommand = new DelegateCommand<Invite>(async invite =>
            {
                await ProcessInvite(invite);
            });
        }