コード例 #1
0
ファイル: LoginPresenter.cs プロジェクト: genesissupsup/ChatR
        public LoginPresenter(ILoginView view, IChatHubProxy proxy, INavigationService navigationService)
        {
            _view = view;
            _proxy = proxy;
            _navigationService = navigationService;
            _view.PropertyChanged += (s, e) => _view.SetLoginEnabled(proxy.IsConnected && !_isLoggingIn && !String.IsNullOrWhiteSpace(_view.UserName));

            _view.Login += _view_Login;


            _proxy.Connected = (detail, details) =>
            {

            };

            Action connect = async () =>
            {
                _isLoggingIn = true;
                try
                {
                    await proxy.Connect();
                }
                finally
                {
                    _isLoggingIn = false;
                }
            };

            connect.Invoke();

        }
コード例 #2
0
ファイル: LoginViewModel.cs プロジェクト: genesissupsup/ChatR
        public LoginViewModel(IChatHubProxy proxy, IRegionManager rm)
        {
            _proxy = proxy;

            Login = new DelegateCommand(async () =>
            {
                IsLoggingIn = true;
                try
                {
                    await proxy.Login(Username);
                }
                finally
                {
                    IsLoggingIn = false;
                }

            }, () => IsConnected && !IsLoggingIn && !String.IsNullOrWhiteSpace(Username));

            proxy.Connected = (detail, details) => rm.RequestNavigate(RegionNames.MainRegion, new Uri("ChatView", UriKind.Relative));


            Reconnect = new DelegateCommand(async () => await Connect(), () => !IsConnected && !IsConnecting);

            Reconnect.Execute();
        }