public NotificationsViewModel(LoadingViewModel loading, NavigationService navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) { Messenger.Default.Register <ObservableCollection <Notification> >(this, param => Notifications = param); }
/// <summary> /// Login to the Lmax Trader platform. The appropriate handler will be called back /// on success or failure. The loginCallback should be the main entry point into /// your trading application. From that point you should add listeners to the /// session, subscribe to resources that you're interested in, e.g. OrderBooks /// and call Start on the <see cref="ISession"/>. /// </summary> /// <param name="loginRequest"> /// A <see cref="LoginRequest"/> that contains your login credentials. /// </param> /// <param name="loginCallback"> /// A <see cref="OnLogin"/> callback, fired when you are successfully logged in. /// </param> /// <param name="failureCallback"> /// A <see cref="OnFailure"/> callback, fired when there is a login failure. /// </param> public void Login(LoginRequest loginRequest, OnLogin loginCallback, OnFailure failureCallback) { LoginResponseHandler handler = new LoginResponseHandler(); try { string sessionId; Response response = _httpInvoker.Invoke(_baseUri, loginRequest, _xmlParser, handler, out sessionId); if (response.IsOk) { if (handler.IsOk) { loginCallback(new Session(handler.AccountDetails, _baseUri, _httpInvoker, _xmlParser, sessionId, true)); } else { failureCallback(new FailureResponse(false, handler.FailureType, handler.Message, null)); } } else { failureCallback(new FailureResponse(true, "HttpStatus: " + response.Status + ", for: " + _baseUri + loginRequest.Uri)); } } catch (Exception e) { failureCallback(new FailureResponse(e, "URI: " + _baseUri + loginRequest.Uri)); } }
public NetworkController(View controlledView, byte subOperationCode = 0) : base(controlledView, subOperationCode) { // All the handlers! All of them! LoginResponseHandler loginHandler = new LoginResponseHandler(this); // register handler! OperationHandlers.Add((byte)loginHandler.Code, loginHandler); PlayerProfileResponseHandler profileHandler = new PlayerProfileResponseHandler(this); OperationHandlers.Add((byte)profileHandler.Code, profileHandler); SpacebuxResponseHandler spacebuxHandler = new SpacebuxResponseHandler(this); OperationHandlers.Add((byte)spacebuxHandler.Code, spacebuxHandler); KnownStarsResponseHandler knownstarsHandler = new KnownStarsResponseHandler(this); OperationHandlers.Add((byte)knownstarsHandler.Code, knownstarsHandler); DiscoveredStarsResponseHandler discoveredstarsHandler = new DiscoveredStarsResponseHandler(this); OperationHandlers.Add((byte)discoveredstarsHandler.Code, discoveredstarsHandler); PlayerShipsResponseHandler retrieveShipsResponseHandler = new PlayerShipsResponseHandler(this); OperationHandlers.Add((byte)retrieveShipsResponseHandler.Code, retrieveShipsResponseHandler); PlayerPlanetResponseHandler retrievePlanetsResponseHandler = new PlayerPlanetResponseHandler(this); OperationHandlers.Add((byte)retrievePlanetsResponseHandler.Code, retrievePlanetsResponseHandler); CreateShipsResponseHandler createShipsResponseHandler = new CreateShipsResponseHandler(this); OperationHandlers.Add((byte)createShipsResponseHandler.Code, createShipsResponseHandler); SendShipOnMissionResponseHandler sendShipOnMissionsResponseHandler = new SendShipOnMissionResponseHandler(this); OperationHandlers.Add((byte)sendShipOnMissionsResponseHandler.Code, sendShipOnMissionsResponseHandler); ColonizePlanetResponseHandler colonizePlanetResponseHandler = new ColonizePlanetResponseHandler(this); OperationHandlers.Add((byte)colonizePlanetResponseHandler.Code, colonizePlanetResponseHandler); UpdateVisitedTimeResponseHandler updateVisitedTimeResponseHandler = new UpdateVisitedTimeResponseHandler(this); OperationHandlers.Add((byte)updateVisitedTimeResponseHandler.Code, updateVisitedTimeResponseHandler); UpdatePopulationResponseHandler updatePopulationResponseHandler = new UpdatePopulationResponseHandler(this); OperationHandlers.Add((byte)updatePopulationResponseHandler.Code, updatePopulationResponseHandler); MissionCompleteResponseHandler missionCompleteResponseHandler = new MissionCompleteResponseHandler(this); OperationHandlers.Add((byte)missionCompleteResponseHandler.Code, missionCompleteResponseHandler); }
public BoardViewModel(LoadingViewModel loading, NavigationServiceInternal navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) { Messenger.Default.Register <IViewModelsState>(this, param => { if (LastDisabled != null && LastDisabled != param) { LastDisabled.ChangeLastState(); } LastDisabled = param; LastDisabled = param; }); Messenger.Default.Register <ObservableCollection <ColumnViewModel> > (this, param => BoardLists = param); Messenger.Default.Register <MyProject> (this, param => CurrentProject = param); Messenger.Default.Register <string>(this, param => ImageSource = "/Images/expand.png"); Messenger.Default.Register <bool>(this, param => BackgroundColorStart = param); AddAnotherListButton = true; ImageSource = "/Images/expand.png"; BackgroundColor = false; BackgroundColorStart = false; }
public void Login(LoginRequest loginRequest, OnLogin loginCallback, OnFailure failureCallback) { LoginResponseHandler loginResponseHandler = new LoginResponseHandler(); try { string sessionId; Response response = this._httpInvoker.Invoke(this._baseUri, (IRequest)loginRequest, this._xmlParser, (Handler)loginResponseHandler, out sessionId); if (response.IsOk) { if (loginResponseHandler.IsOk) { loginCallback((ISession) new Session(loginResponseHandler.AccountDetails, this._baseUri, this._httpInvoker, this._xmlParser, sessionId, true)); } else { failureCallback(new FailureResponse(false, loginResponseHandler.FailureType, loginResponseHandler.Message, (Exception)null)); } } else { failureCallback(new FailureResponse(true, "HttpStatus: " + (object)response.Status + ", for: " + this._baseUri + loginRequest.Uri)); } } catch (Exception ex) { failureCallback(new FailureResponse(ex, "URI: " + this._baseUri + loginRequest.Uri)); } }
public ProjectConfigurationViewModel(LoadingViewModel loading, NavigationService navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) { Sprints = new ObservableCollection <Sprint>() { new Sprint() { Name = "Some sprint" }, new Sprint() { Name = "Other sprint" } }; SomeUsers = new List <User>() { new User() { Name = "Zahid Abbasli" }, new User() { Name = "Samir Mammadli" }, new User() { Name = "Igor Zabolotin" }, new User() { Name = "Ramil Aliyev" }, new User() { Name = "Zakir Mammadli" }, new User() { Name = "Samir Musayev" }, new User() { Name = "Zaur Huseynov" } }; Backlogs = new ObservableCollection <BackLog>(); Users = new ObservableCollection <User>(); AddAnotherCardIsVisible = true; UserListIsVisible = true; }
public EmailEnterViewModel(LoadingViewModel loading, NavigationService navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) { }
public async Task SendMessageAsync(Message msg) { await _networkCommunication.SendBytesAsync(new[] { (byte)msg.Type }); await _networkCommunication.SendShortAsync((short)msg.Id); switch (msg) { // Error case ErrorResponse errorResponse: var errorResponseHandler = new ErrorResponseHandler(_networkCommunication); await errorResponseHandler.SendMessageAsync(errorResponse); break; // Login case LoginRequest loginRequest: var loginRequestHandler = new LoginRequestHandler(_networkCommunication); await loginRequestHandler.SendMessageAsync(loginRequest); break; case LoginResponse loginResponse: var loginResponseHandler = new LoginResponseHandler(_networkCommunication); await loginResponseHandler.SendMessageAsync(loginResponse); break; // Create User case CreateUserRequest createUserRequest: var createUserRequestHandler = new CreateUserRequestHandler(_networkCommunication); await createUserRequestHandler.SendMessageAsync(createUserRequest); break; case CreateUserResponse createUserResponse: var createUserResponseHandler = new CreateUserResponseHandler(_networkCommunication); await createUserResponseHandler.SendMessageAsync(createUserResponse); break; // Create photo case CreatePhotoRequest createPhotoRequest: var createPhotoRequestHandler = new CreatePhotoRequestHandler( _networkCommunication, _fileCommunication ); await createPhotoRequestHandler.SendMessageAsync(createPhotoRequest); break; case CreatePhotoResponse createPhotoResponse: var createPhotoResponseHandler = new CreatePhotoResponseHandler(); await createPhotoResponseHandler.SendMessageAsync(createPhotoResponse); break; // Photo list case PhotoListRequest photoListRequest: var photoListRequestHandler = new PhotoListRequestHandler(_networkCommunication); await photoListRequestHandler.SendMessageAsync(photoListRequest); break; case PhotoListResponse photoListResponse: var photoListResponseHandler = new PhotoListResponseHandler( _networkCommunication, _fileCommunication ); await photoListResponseHandler.SendMessageAsync(photoListResponse); break; // User list case UserListRequest userListRequest: var userListRequestHandler = new UserListRequestHandler(); await userListRequestHandler.SendMessageAsync(userListRequest); break; case UserListResponse userListResponse: var userListResponseHandler = new UserListResponseHandler( _networkCommunication ); await userListResponseHandler.SendMessageAsync(userListResponse); break; // Comment photo case CommentPhotoRequest commentPhotoRequest: var commentPhotoRequestHandler = new CommentPhotoRequestHandler(_networkCommunication); await commentPhotoRequestHandler.SendMessageAsync(commentPhotoRequest); break; case CommentPhotoResponse commentPhotoResponse: var commentPhotoResponseHandler = new CommentPhotoResponseHandler( _networkCommunication ); await commentPhotoResponseHandler.SendMessageAsync(commentPhotoResponse); break; // Comment List case CommentListRequest commentListRequest: var commentListRequestHandler = new CommentListRequestHandler(_networkCommunication); await commentListRequestHandler.SendMessageAsync(commentListRequest); break; case CommentListResponse commentListResponse: var commentListResponseHandler = new CommentListResponseHandler( _networkCommunication ); await commentListResponseHandler.SendMessageAsync(commentListResponse); break; // Logout case LogoutRequest logoutRequest: var logoutRequestHandler = new LogoutRequestHandler(); await logoutRequestHandler.SendMessageAsync(logoutRequest); break; case LogoutResponse logoutResponse: var logoutResponseHandler = new LogoutResponseHandler(); await logoutResponseHandler.SendMessageAsync(logoutResponse); break; default: // TODO Create a custom exception throw new Exception($"Message not recognized ID={msg.Id}, type={msg.Type}"); } }
public ProjectsListViewModel(LoadingViewModel loadingViewModel, NavigationServiceInternal InternalNavigationService, Repo repository, LoginResponseHandler responseHandler, BoardViewModel boardViewModel, MessageBoxViewModel messageBoxViewModel) : base(loadingViewModel, InternalNavigationService, repository, responseHandler, messageBoxViewModel) { #region MockData var projectsFromDataBase = new ObservableCollection <Project>() { new Project { Name = "Some project", BoardLists = new List <BoardList>() { new BoardList() { Name = "ToDo", Cards = new List <Card>() { new Card() { Name = "Create database" }, new Card() { Name = "adasdasd" }, new Card() { Name = "asdasdasdasdasdasd database" }, new Card() { Name = "Creaasdasdasd asd asd asd asdasdasd asdasdas te database" }, } }, new BoardList() { Name = "Doing", Cards = new List <Card>() { new Card() { Name = "adasdasd" }, new Card() { Name = "asdasd asdasad sdasadasdas dasd aadasdas" }, new Card() { Name = "Creaasdasdasd asd asd asd asda" }, } }, new BoardList() { Name = "Done", Cards = new List <Card>() } }, Notifications = new List <Notification>() { new Notification() { Name = "sgfsd" }, new Notification() { Name = "sdssdfs dfsdfsdf" }, } }, new Project { Name = "Another", BoardLists = new List <BoardList>() { new BoardList() { Name = "ToDo", Cards = new List <Card>() { new Card() { Name = "Creadsadasdasnda sdasd asd asd asd a sdasd asdasdasd ate database" }, new Card() { Name = "adasasd asd asd asdasddasd" }, new Card() { Name = "asdasdasdasdasdasd database" }, } }, new BoardList() { Name = "Doing", Cards = new List <Card>() }, new BoardList() { Name = "Done", Cards = new List <Card>() } }, Notifications = new List <Notification>() { new Notification() { Name = "sgfs ssdd" }, new Notification() { Name = "sdsssd fsdf sdaaaaa aaa" }, new Notification() { Name = "sds sdfs dfsdf sdf" } } }, new Project { Name = "Project", BoardLists = new List <BoardList>() { new BoardList() { Name = "ToDo", Cards = new List <Card>() { new Card() { Name = "Creasasda sdnas d as d asd asate database" }, new Card() { Name = "adaasd as das d assdasd" }, new Card() { Name = "asdasasdasd asd asd as d asd as d asd asd as d asd asd asd as d s s s s s ssssdasdasdasdasd database" }, new Card() { Name = "Creaasdasdasd asd asd asd asdasdasd asdasdas te database" }, new Card() { Name = "Create database" }, new Card() { Name = "adasdasd" }, new Card() { Name = "asdasdasdasdasdasd database" }, new Card() { Name = "Creaasdasdasd asd asd asd asdasdasd asdasdas te database" }, } }, new BoardList() { Name = "Doing", Cards = new List <Card>() }, new BoardList() { Name = "Done", Cards = new List <Card>() } }, Notifications = new List <Notification>() }, new Project() { Name = "sdfsdf", BoardLists = new List <BoardList>(), Notifications = new List <Notification>() }, new Project() { Name = "sdfsdf", BoardLists = new List <BoardList>(), Notifications = new List <Notification>() }, new Project() { Name = "sdfsdf", BoardLists = new List <BoardList>(), Notifications = new List <Notification>() }, new Project() { Name = "sdfsdf", BoardLists = new List <BoardList>(), Notifications = new List <Notification>() } }; #endregion CurrentViewModel = boardViewModel; Projects = new ObservableCollection <MyProject>(); foreach (var item in projectsFromDataBase) { Projects.Add(Converter(item)); } for (int i = 0; i < 1000; i++) { Projects .FirstOrDefault() .Notifications.Add(new Notification() { Name = "sgfsd" }); } SetProject(Projects.FirstOrDefault()); }
public RegistrationConfirmCodeViewModel(LoadingViewModel loading, NavigationService navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) => Messenger.Default.Register <CodeInputForm>(this, param => Form = param);
public ForgotPasswordViewModel(LoadingViewModel loading, NavigationService navigationService, Repo repository, LoginResponseHandler responseHandler, MessageBoxViewModel messageBoxViewModel) : base(loading, navigationService, repository, responseHandler, messageBoxViewModel) { Messenger.Default.Register <ChangePasswordForm>(this, param => Form = param); }