public MenuItemVm(IButtonItemModel model, IShellContainerVm shellContainerVm)
     : base(shellContainerVm)
 {
     MenuItemBackgroundColor        = new SolidColorBrush(model.Color.ToRgbColor());
     MenuItemBackgroundOverColor    = new SolidColorBrush(model.Color.ToRgbLightColor(20));
     MenuItemBackgroundPressedColor = new SolidColorBrush(model.Color.ToRgbLightColor(-20));
     MenuItemLogo   = new BitmapImage(new Uri(URI_RESOURCE + model.Image));
     Title          = model.Title;
     ExecuteCommand = ReactiveCommand.Create(Observable.Return(true));
     _parameters    = model.Parameters;
     ExecuteCommand.Subscribe(_ => ShellContainerVm.ChangeCurrentView(model.Code.ToEnum(), true, false, _parameters));
 }
Exemple #2
0
        private void InitializeCommands()
        {
            var canSignIn = this.WhenAny(vm => vm.UserName, s => !String.IsNullOrWhiteSpace(s.Value));

            canSignIn.Subscribe(x => IsSignInVisible = x ? Visibility.Visible : Visibility.Hidden);

            SignInCommand = ReactiveCommand.CreateAsyncTask(canSignIn, async x =>
            {
                IsOnSignIn  = Visibility.Collapsed;
                IsOnWaiting = Visibility.Visible;
                var pass    = (PasswordBox)x;
                using (var loginSvc = new LoginSvcClient())
                {
                    try
                    {
                        var response =
                            await
                            loginSvc.LoginAsync(new LoginModel
                        {
                            Password = Cypher.Encrypt(pass.Password),
                            Username = Cypher.Encrypt(UserName)
                        });
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        return(new ResponseMessage {
                            IsSuccess = false, Message = ResNetwork.ERROR_NETWORK_DOWN + ex.Message
                        });
                    }
                    finally
                    {
                        pass.Password = String.Empty;
                        IsOnSignIn    = Visibility.Visible;
                        IsOnWaiting   = Visibility.Collapsed;
                        MessageBus.Current.SendMessage(String.Empty, SharedMessageConstants.LOGIN_FOCUS_USERNAME);
                    }
                }
            });


            SignInCommand.Subscribe(x =>
            {
                if (x.IsSuccess)
                {
                    var bForceToInit = CurrentUserSettings.UserInfo.Username == null ||
                                       CurrentUserSettings.UserInfo.Username != UserName;

                    CurrentUserSettings.UserInfo.Username = x.UserDetail.UserName;
                    CurrentUserSettings.UserInfo.FullName = x.UserDetail.FullName;
                    CurrentUserSettings.UserInfo.Role     = x.UserDetail.Role;
                    ShellContainerVm.ChangeCurrentView(StatusScreen.ShMenu, true, bForceToInit);  //Only when comes from login, it should be reinit
                    OnUserChanged(CurrentUserSettings.UserInfo);
                }
                else
                {
                    MessageBus.Current.SendMessage(new MessageBoxSettings
                    {
                        Message = x.Message,
                        Title   = "Error al ingresar",
                    }, SharedMessageConstants.MSG_SHOW_ERRQST);
                    //Message = x.Message;
                }
            });
        }
 public BackPreviousVm()
 {
     BackCommand = ReactiveCommand.Create(Observable.Return(true));
     BackCommand.Subscribe(_ => ShellContainerVm.ChangeCurrentView(StatusScreen.ShMenu, true));
 }
 protected override void OnShellContainerVmChange(IShellContainerVm value)
 {
     base.OnShellContainerVmChange(value);
     ShellContainerVm.AddOrUpdateFlyouts(_upsertAddress);
 }
 protected override void OnShellContainerVmChange(IShellContainerVm value)
 {
     base.OnShellContainerVmChange(value);
     ShellContainerVm.AddOrUpdateFlyouts(LastOrderFo);
 }
 private void OnEndOrder()
 {
     ShellContainerVm.ChangeCurrentView(StatusScreen.ShMenu, true);
 }