Пример #1
0
 private void valueChanged(object sender, EventArgs e)
 {
     if (command != null)
     {
         command.Execute((int)segmentedControl.SelectedSegment);
     }
 }
        public void CanExecuteCommand()
        {
            var i       = 0;
            var command = new MvxCommand(() => { ++i; });

            Assert.NotNull(command);

            command.Execute();

            Assert.Equal(1, i);
        }
Пример #3
0
        public ChangeAlbumViewModel(IMvxNavigationService navigationService, IUserDialogs userDialogs, IValidator validator, ISongService songService, IGenreService genreService, IArtistService artistService, IAlbumService albumService, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _userDialogs = userDialogs;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            _songService   = songService;
            _genreService  = genreService;
            _artistService = artistService;
            _albumService  = albumService;

            ValidateNameCommand = new MvxCommand(() => _validationHelper.Validate(() => Name));

            ValidateGenresCommand = new MvxCommand(() => _validationHelper.Validate(() => Genres));

            ValidateArtistsCommand = new MvxCommand(() => _validationHelper.Validate(() => Artists));

            ValidateSongsCommand = new MvxCommand(() => _validationHelper.Validate(() => Songs));

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });

            ChangeCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(ChangeTask.Value))
                {
                    ChangeTask.Value = NotifyTaskCompletion.Create(AttemptChangeAsync);
                }
            });

            _genresTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Genres.Value?.Remove(_ as TokenViewModel <GenreModel>);
                ValidateGenresCommand.Execute(null);
            }));

            _artistsTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Artists.Value?.Remove(_ as TokenViewModel <ArtistModel>);
                ValidateArtistsCommand.Execute(null);
            }));

            _songsTokenParentObject = new TokenParentHelper(new MvxCommand <TokenViewModel>((_) =>
            {
                Songs.Value?.Remove(_ as TokenViewModel <SongModel>);
                ValidateSongsCommand.Execute(null);
            }));
        }
Пример #4
0
        public override void Prepare()
        {
            Stories = StoryService.GetStories();

            _tags = new List <FontTag>();
            _tags.Add(new FontTag(FontItalic, "i"));
            _tags.Add(new FontTag(FontBold, "b"));
            _tags.Add(new FontTag(FontBold, "a", FontTagAction.Link));

            SelectStoryCommand = new MvxCommand <Story>((story) => {
                UpdateStory(story);
            });

            ChangeStyleCommand = new MvxCommand <int>((styleNumber) => {
                Style1Selected = styleNumber == 0;
                Style2Selected = !Style1Selected;

                AssetProvider.ClearFonts();
                AssetProvider.ClearColors();
                if (Style1Selected)
                {
                    LoadStyle1();
                }
                else
                {
                    LoadStyle2();
                }

                UpdateStyle = true;
                SelectStoryCommand.Execute(this._selectedStory);
            });

            ChangeStyleCommand.Execute(0);
            SelectStoryCommand.Execute(Stories.FirstOrDefault());
            RaisePropertyChanged(() => Stories);

            base.Prepare();
        }
Пример #5
0
        public RegistrationViewModel(IMvxNavigationService navigationService, IAuthService authService, IUserDialogs userDialogs, IValidator validator /*, ILocationService locationService*/, MvvmCross.Plugins.Validation.IMvxToastService toastService, IBottomNavigationViewModelService bottomNavigationViewModelService, ITopNavigationViewModelService topNavigationViewModelService)
        {
            _navigationService                = navigationService;
            _topNavigationViewModelService    = topNavigationViewModelService;
            _bottomNavigationViewModelService = bottomNavigationViewModelService;

            _authService  = authService;
            _userDialogs  = userDialogs;
            _toastService = toastService;

            _validationHelper = new ValidationHelper(validator, this, Errors.Value, (propertyName) => { FocusName.Value = propertyName; });

            //_locationService = locationService;

            ValidateEmailCommand     = new MvxCommand(() => _validationHelper.Validate(() => Email));
            ValidateFirstNameCommand = new MvxCommand(() => _validationHelper.Validate(() => FirstName));
            ValidateLastNameCommand  = new MvxCommand(() => _validationHelper.Validate(() => LastName));
            ValidatePasswordCommand  = new MvxCommand(() => _validationHelper.Validate(() => Password));
            ValidateBirthDateCommand = new MvxCommand(() => _validationHelper.Validate(() => BirthDate));

            RegisterCommand = new MvxCommand(() =>
            {
                if (!IsTaskExecutedValueConverter.Convert(RegisterTask.Value))
                {
                    RegisterTask.Value = NotifyTaskCompletion.Create(AttemptRegisterAsync);
                }
            });

            ChangeBirthDateCommand = new MvxAsyncCommand(async() => {
                var datePromptResult = await _userDialogs.DatePromptAsync(new DatePromptConfig()
                {
                    MinimumDate = new DateTime(1900, 1, 1), MaximumDate = DateTime.Now, SelectedDate = BirthDate.Value ?? new DateTime?(new DateTime(1990, 1, 1)), OkText = "OK", CancelText = "Cancel"
                });
                if (datePromptResult.Ok)
                {
                    BirthDate.Value = new DateTime?(datePromptResult.SelectedDate);
                }
                else
                {
                    BirthDate.Value = null;
                }
                ValidateBirthDateCommand.Execute(null);
            });

            InitValidationCommand = new MvxCommand(() => {
                _validationHelper.ResetValidation();
            });
        }
Пример #6
0
        private void loadFinished(object sender, EventArgs e)
        {
            var   offsetHeight = webView.EvaluateJavascript("document.body.offsetHeight");
            float height       = 0;

            if (float.TryParse(offsetHeight, out height))
            {
                this.webView.Frame = new CoreGraphics.CGRect(0,
                                                             0,
                                                             this.webView.Frame.Width,
                                                             height);

                if (command != null)
                {
                    command.Execute(height);
                }
            }
        }
        public ChannelsViewModel(IChannelManager channelManager)
        {
            RefreshCommand = new MvxCommand(() => {
                channelManager.RequestPrivateChannels();
                channelManager.RequestPublicChannels();
            });
            if (channelManager.PublicChannels.Count == 0)
            {
                RefreshCommand.Execute(null);
            }
            Func <ChannelListItem, ListItem> mapper = item => new ListItem(channelManager, item);

            Tabs = new[] {
                new Tab(Strings.Channels_Public, new MappingObservableList <ChannelListItem, ListItem>(channelManager.PublicChannels, mapper)),
                new Tab(Strings.Channels_Private, new MappingObservableList <ChannelListItem, ListItem>(channelManager.PrivateChannels, mapper))
            };
            SelectedTab        = Tabs[0];
            TabSelectedCommand = new MvxCommand <Tab>(tab => SelectedTab = tab);
            CreateCommand      = new MvxCommand <string>(name => {
                channelManager.CreateChannel(name);
                channelManager.RequestPrivateChannels();
            });
        }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var item = (MenuFeedtemViewModel)ItemsSource.ElementAt(indexPath.Row);

            NavigateOtherViewModel.Execute(item.Id);
        }