A command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is 'true'. RaiseCanExecuteChanged needs to be called whenever CanExecute is expected to return a different value.
Inheritance: ICommand
Exemplo n.º 1
0
 public ViewModelBase()
 {
     GoToSettingsCommand = new RelayCommand(() =>
     {
     #if WINDOWS_PHONE_APP
         App.CurrentFrame.Navigate((typeof (SettingsPage)));
     #endif
     });
     RefreshCommand = new RelayCommand(App.UpdateSnapchatData);
     LogoutCommand = new RelayCommand(async () => await App.LogoutAsync());
 }
Exemplo n.º 2
0
		public FriendsViewModel(CollectionViewSource friends, CollectionViewSource pending,
			CollectionViewSource blocked)
		{
			ChangeDisplayNameCommand = new RelayCommand<Friend>(ChangeDisplayName);
			BlockFriendCommand = new RelayCommand<Friend>(BlockFriend);
			UnBlockFriendCommand = new RelayCommand<Friend>(UnblockFriend);
			RemoveFriendCommand = new RelayCommand<Friend>(RemoveFriend);
			GetFriendsCommand = new RelayCommand(GetFriends);
			GoToFriendCommand = new RelayCommand<Friend>(GoToFriend);

			// Set up Collection View Sources
			FriendsViewSource = friends;
			PendingFriendsViewSource = pending;
			BlockedFriendsViewSource = blocked;
		}
Exemplo n.º 3
0
		public StartViewModel()
		{
			IsStartPageVisible = true;

			#region Commands

			OpenSignInPageCommand = new RelayCommand(
				() =>
				{
					IsSignInPageVisible = true;
					IsStartPageVisible = false;
					IsCaptchaPageVisible = false;
				},
				() => IsStartPageVisible);

			OpenRegisterPageCommand = new RelayCommand(
				() =>
				{
					IsRegisterPageVisible = true;
					IsStartPageVisible = false;
					IsCaptchaPageVisible = false;
				},
				() => IsStartPageVisible);

			OpenCaptchaPageCommand = new RelayCommand(
				() =>
				{
					IsCaptchaPageVisible = true;
					IsRegisterPageVisible = false;
					IsStartPageVisible = false;
				},
				() => IsStartPageVisible);

			GoBackToStartCommand = new RelayCommand(() =>
			{
				IsSignInPageVisible = false;
				IsRegisterPageVisible = false;
				IsStartPageVisible = true;
			});

			SignInCommand = new RelayCommand<Page>(SignIn);
			RegisterPhase1Command = new RelayCommand<Page>(RegisterPhase1);
			RegisterPhase2Command = new RelayCommand<Page>(RegisterPhase2);

			#endregion
		}
Exemplo n.º 4
0
        public MainViewModel()
        {
            if (App.SnapChatManager.Account == null) return;

            RecentSnaps = new ObservableCollection<Snap>();

            #region Commands

            SignOutCommand = new RelayCommand(async () =>
            {
                await App.LogoutAsync();
            });

            ViewSnapsCommand = new RelayCommand(() => App.CurrentFrame.Navigate(typeof (SnapsPage)));

            #endregion

            RecentSnaps = new ObservableCollection<Snap>(App.SnapChatManager.Account.Snaps.Take(MaximumRecentSnaps));
            GetFriends();

            App.SnapChatManager.PropertyChanged += delegate
            {
                if (App.SnapChatManager.Account != null)
                {
                    RecentSnaps = new ObservableCollection<Snap>(App.SnapChatManager.Account.Snaps.Take(MaximumRecentSnaps));
                    GetFriends();
                }
            };
            App.SnapChatManager.Account.PropertyChanged += delegate
            {
                RecentSnaps = new ObservableCollection<Snap>(App.SnapChatManager.Account.Snaps.Take(MaximumRecentSnaps));
                GetFriends();
            };

            App.SnapChatManager.Account.Snaps.CollectionChanged += delegate
            {
                RecentSnaps = new ObservableCollection<Snap>(App.SnapChatManager.Account.Snaps.Take(MaximumRecentSnaps));
            };
        }
Exemplo n.º 5
0
        public SnapsViewModel()
        {
            #region Create Spoofed Test Snaps

            SpoofedSnaps = new ObservableCollection<Snap>
            {
                // Sent
                new Snap // Delivered
                {
                    SenderName = "wumbotestalex",
                    RecipientName = "Snaisy",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Delivered,
                    MediaType = MediaType.Image
                },
                new Snap // Opened
                {
                    SenderName = "wumbotestalex",
                    RecipientName = "Snaisy",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Opened,
                    MediaType = MediaType.Image
                },
                new Snap // Screenshot
                {
                    SenderName = "wumbotestalex",
                    RecipientName = "Snaisy",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Screenshotted,
                    MediaType = MediaType.Image
                },

                // Recieved
                new Snap // Delivered
                {
                    SenderName = "Snaisy",
                    RecipientName = "wumbotestalex",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Delivered,
                    MediaType = MediaType.Image
                },
                new Snap // Opened
                {
                    SenderName = "Snaisy",
                    RecipientName = "wumbotestalex",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Opened,
                    MediaType = MediaType.Image
                },
                new Snap // Screenshotted
                {
                    SenderName = "Snaisy",
                    RecipientName = "wumbotestalex",
                    Timestamp = DateTime.UtcNow,
                    Status = SnapStatus.Screenshotted,
                    MediaType = MediaType.Image
                }
            };

            #endregion

            TryDownloadMediaCommand = new RelayCommand<Snap>(async snap =>
            {
                await snap.DownloadSnapBlobAsync(App.SnapChatManager);
                App.SnapChatManager.SaveAccountData();
            });
        }