private void ShowDialogEventHandler(object sender, ViewModelBase viewModel) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { if (_dialogs != null) { foreach (BaseMetroDialog dialog in _dialogs) { if (dialog.DataContext == null) { continue; } if (dialog.DataContext.GetType() == viewModel.GetType()) { dialog.Visibility = Visibility.Visible; DialogsMask.Visibility = Visibility.Visible; } else { dialog.Visibility = Visibility.Hidden; } } } }); }
private void RemoveSelectedStory() { if (SelectedStory == null) { return; } _menuBasedShellViewModel.IsLoadingData = true; new Task(() => { try { _storiesDataModel.Remove(SelectedStory.Story); ComponentsContainer.Get <Dispatcher>().Invoke( delegate { AllUserStories.Remove(SelectedStory); }); HideDialog?.Invoke(this, null); } catch (Exception ex) { ShowMessage($"User story doesn't removed: technical issues encountered."); _logger.Fatal(ex); } _menuBasedShellViewModel.IsLoadingData = false; }).Start(); }
// Can't use boolToVisibility converter in XAML of this view // because for unknown reasons changing of one property value changes both dialogs. // TODO: fix this crutch. private void RefreshShowErrorMessageDialogVisibility() { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { ErrorMessageDialog.Visibility = _viewModel.ShowErrorMessageDialog ? Visibility.Visible : Visibility.Hidden; }); }
private void RefreshCreateNewProjectDialogVisibility() { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { NewProjectDialog.Visibility = _viewModel.ShowCreateNewProjectDialog ? Visibility.Visible : Visibility.Hidden; }); }
private void SubscribeToDataModelEvents() { _teamsDataModel.NewTeamCreated += NewTeamCreatedEventHandler; _teamsDataModel.UserJoinedTeam += UserJoinedTeamEventHandler; _teamsDataModel.UserLeavedTeam += UserLeavedTeamEventHandler; ComponentsContainer.Get <IProjectsDataModel>().NewProjectCreated += NewProjectCreatedEventHandler; }
private void RefreshRemoveStoryConfirmationDialogVisibility() { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { UserStoryRemovingConfirmationDialog.Visibility = _viewModel.ShowRemoveStoryConfirmationDialog ? Visibility.Visible : Visibility.Hidden; }); }
private void OnTeamSelected(object sender, Team team) { if (team != null) { _mainShellViewModel.CurrentTeam = team; CurrentViewModel = _viewModelsContainer.Resolve <ProjectsViewModel>(); ComponentsContainer.Get <IRegistryService>().SetCurrentTeamId(team.Id); } }
private void OnProjectSelected(object sender, Project project) { if (project != null) { CurrentProject = project; CurrentViewModel = _viewModelsContainer.Resolve <ProductBacklogViewModel>(); ComponentsContainer.Get <IRegistryService>().SetCurrentProjectId(project.Id); } }
public string GetExecutorName() { string name = string.Empty; if (ExecutorId != default(uint)) { User executor = ComponentsContainer.Get <IUsersDataModel>().GetUser(ExecutorId); name = $"{executor.FirstName} {executor.LastName}"; } return(name); }
private void InitializeFields() { Project currentProject = _menuBasedShellViewModel.CurrentProject; if (currentProject == null) { MessageBoxViewModel = new MessageBoxViewModel(); MessageBoxViewModel.Text = "Select project!"; MessageBoxViewModel.Confirmed += delegate { _menuBasedShellViewModel.SetCurrentViewModel(typeof(Projects.ProjectsViewModel)); }; SetDialog?.Invoke(this, MessageBoxViewModel); return; } Data.Entities.Sprint currentSprint = _sprintsDataModel.GetSprintByProjectId(_menuBasedShellViewModel.CurrentProject.Id); if (currentSprint == null) { SprintDialogViewModel = new SprintDialogViewModel(); SprintDialogViewModel.ConfirmSelected += delegate { CreateSprintFromDialog(); // Here sets value of '_currentSprint'. HideDialog?.Invoke(this, null); }; SprintDialogViewModel.CancelSelected += delegate { /*HideDialog?.Invoke(this, null);*/ }; SetDialog?.Invoke(this, SprintDialogViewModel); } else { if (_currentSprint != null) { if (!_currentSprint.Equals(currentSprint)) { _currentSprint = currentSprint; Backlog currentSprintBacklog = ComponentsContainer.Get <IBacklogsDataModel>().GetBacklogById(currentSprint.BacklogId); List <StoryItem> items = ConvertToStoryItems(currentSprintBacklog.Stories); AllUserStories = new ObservableCollection <StoryItem>(items); InitializeSprintDependentFields(); } } else { _currentSprint = currentSprint; Backlog currentSprintBacklog = ComponentsContainer.Get <IBacklogsDataModel>().GetBacklogById(currentSprint.BacklogId); List <StoryItem> items = ConvertToStoryItems(currentSprintBacklog.Stories); AllUserStories = new ObservableCollection <StoryItem>(items); InitializeSprintDependentFields(); } } }
private void AddProjectsItems(IList <Project> projects) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { try { foreach (Project project in projects) { Control projectControl = CreateProjectControl(project); currentUserProjectsContainer.Children.Add(projectControl); } } catch { } }); }
private void OnStoryItemUpdated(object sender, StoryItem item) { if (item != null) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { OnPropertyChanged("WaitingForExecutorStories"); OnPropertyChanged("InProgressStories"); OnPropertyChanged("CompletedStories"); //AllUserStories.Remove(item); // It will throw exception in view. //AllUserStories.Add(item); }); } }
private void AddTeamsItems(IList <Team> teams) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { try { foreach (Team team in teams) { Control teamControl = CreateTeamControl(team); currentUserTeamsContainer.Children.Add(teamControl); } } catch { } }); }
private void SetUserAsExecutor(StoryItem obj) { if (SelectedStory == null) { return; } _menuBasedShellViewModel.IsLoadingData = true; new Task(() => { try { Story story = SelectedStory.Story; SelectedStory.ExecutorId = _menuBasedShellViewModel.CurrentUser.Id; SetStatus(ref story, StoryStatus.InProgress); _logger.Debug($"Started editing story with id '{SelectedStory.Id}'."); _storiesDataModel.Update(story); SelectedStory.Story = story; ComponentsContainer.Get <Dispatcher>().Invoke( delegate { OnPropertyChanged("WaitingForExecutorStories"); OnPropertyChanged("InProgressStories"); OnPropertyChanged("CompletedStories"); //AllUserStories.Remove(SelectedStory); // It will throw exception in view. //AllUserStories.Add(SelectedStory); }); } catch (Exception ex) { ShowMessage($"User story doesn't edited: technical issues encountered."); _logger.Fatal(ex); } _menuBasedShellViewModel.IsLoadingData = false; HideDialog?.Invoke(this, null); }).Start(); }
private bool InitializeCurrentTeam() { bool initialized = false; uint currentTeamId = _registryService.GetCurrentTeamId(); if (currentTeamId != 0) { Team team = ComponentsContainer.Get <ITeamsDataModel>().GetTeamById(currentTeamId); if (team != null) { _mainShellViewModel.CurrentTeam = team; initialized = true; } } return(initialized); }
private void HideDialogEventHandler(object sender, EventArgs e) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { if (_dialogs != null) { foreach (BaseMetroDialog dialog in _dialogs) { if (dialog.Visibility == Visibility.Visible) { dialog.Visibility = Visibility.Hidden; } } } DialogsMask.Visibility = Visibility.Hidden; }); }
private bool InitializeCurrentProject() { bool initialized = false; uint currentProjectId = _registryService.GetCurrentProjectId(); if (currentProjectId != 0) { Project project = ComponentsContainer.Get <IProjectsDataModel>().GetProjectById(currentProjectId); if (project != null) { _mainShellViewModel.CurrentProject = project; initialized = true; } } return(initialized); }
public Sprint CreateNewSprint(string mainGoal, DateTime startDate, DateTime finishDate, uint projectId) { Sprint sprint = null; try { using (MySqlConnection connection = OpenNewConnection()) { uint backlogId = ComponentsContainer.Get <IBacklogsDataModel>().CreateBacklog().Id; MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = $"INSERT INTO `{_SPRINT_TABLE_NAME}` " + "(MainGoal, StartDate, FinishDate, ProjectId, BacklogId) " + "VALUES (@MainGoal, @StartDate, @FinishDate, @ProjectId, @BacklogId)"; command.Parameters.Add(new MySqlParameter("@MainGoal", mainGoal)); command.Parameters.Add(new MySqlParameter("@StartDate", startDate)); command.Parameters.Add(new MySqlParameter("@FinishDate", finishDate)); command.Parameters.Add(new MySqlParameter("@ProjectId", projectId)); command.Parameters.Add(new MySqlParameter("@BacklogId", backlogId)); command.ExecuteNonQuery(); uint id = Convert.ToUInt32(command.LastInsertedId); sprint = new Sprint(id, mainGoal, startDate, finishDate, projectId, backlogId, false); NewSprintCreated?.Invoke(this, sprint); } } catch (Exception ex) { _logger.Fatal("Sprint creation exception."); _logger.Fatal(ex); throw; } return(sprint); }
internal LogoutViewModel(MenuBasedShellViewModel menuBasedShellViewModel) { _menuBasedShellViewModel = menuBasedShellViewModel; SetDialog += delegate(object sender, ViewModelBase dialogViewModel) { CurrentDialogViewModel = dialogViewModel; ShowDialog = true; }; HideDialog += delegate { ShowDialog = false; }; ConfirmationDialogViewModel = new ConfirmationDialogViewModel(); ConfirmationDialogViewModel.Text = "Do you really want to log out?"; ConfirmationDialogViewModel.ConfirmSelected += delegate { try { _menuBasedShellViewModel.Logout(); } catch { if (ViewContext != null) { ComponentsContainer.Get <IDialogCoordinator>().ShowMessageAsync( ViewContext, "Log out error", "Please, run applications with administrator rights and try to log out again."); } } }; ConfirmationDialogViewModel.CancelSelected += delegate { _menuBasedShellViewModel.SetCurrentViewModel(typeof(AllUserTasksViewModel)); }; SetDialog?.Invoke(this, ConfirmationDialogViewModel); }
private void RemoveProjectsItems(IList <Project> projects) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { try { List <UIElement> controlsForRemoving = new List <UIElement>(); foreach (Project project in projects) { foreach (UIElement uiElement in currentUserProjectsContainer.Children) { if (uiElement is Tile) { Tile tile = uiElement as Tile; if (tile.Tag is Project) { Project tempProject = tile.Tag as Project; if (project.Equals(tempProject)) { controlsForRemoving.Add(uiElement); } } } } } foreach (UIElement element in controlsForRemoving) { currentUserProjectsContainer.Children.Remove(element); } } catch { } }); }
private void RemoveTeamsItems(IList <Team> teams) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { try { List <UIElement> controlsForRemoving = new List <UIElement>(); foreach (Team team in teams) { foreach (UIElement uiElement in currentUserTeamsContainer.Children) { if (uiElement is Tile) { Tile tile = uiElement as Tile; if (tile.Tag is Team) { Team tmpTeam = tile.Tag as Team; if (team.Id == tmpTeam.Id) { controlsForRemoving.Add(uiElement); } } } } } foreach (UIElement element in controlsForRemoving) { currentUserTeamsContainer.Children.Remove(element); } } catch { } }); }
private void EditSelectedStory() { if (StoryDialogViewModel == null) { return; } if (!StoryDialogViewModel.CanExecuteConfirmCommand(null)) { return; } if (SelectedStory == null) { return; } _menuBasedShellViewModel.IsLoadingData = true; new Task(() => { try { StoryItem newStoryItem = SelectedStory.Clone() as StoryItem; newStoryItem.Name = StoryDialogViewModel.Name; newStoryItem.Importance = StoryDialogViewModel.Importance; newStoryItem.InitialEstimate = StoryDialogViewModel.InitialEstimate; newStoryItem.Status = StoryDialogViewModel.Status; newStoryItem.HowToDemo = StoryDialogViewModel.HowToDemo; newStoryItem.Notes = StoryDialogViewModel.Notes; string previousStatus = SelectedStory.Status; string newStatus = newStoryItem.Status; if (previousStatus != newStatus) // status was changed { if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) // it was "WaitingForExecutor" status { newStoryItem.ExecutorId = _menuBasedShellViewModel.CurrentUser.Id; } else if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.InProgress)) // it was "InProgress" status { if (newStoryItem.ExecutorId != _menuBasedShellViewModel.CurrentUser.Id) { StoryDialogViewModel.ErrorMessage = "You can't change the task executing by another user."; StoryDialogViewModel.ShowErrorMessage = true; _menuBasedShellViewModel.IsLoadingData = false; return; } else { newStoryItem.ExecutorId = (newStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) ? 0 : _menuBasedShellViewModel.CurrentUser.Id; } } else if (previousStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.Completed)) // it was "Completed" status { if (newStoryItem.ExecutorId != _menuBasedShellViewModel.CurrentUser.Id) { StoryDialogViewModel.ErrorMessage = "You can't change the task executed by another user."; StoryDialogViewModel.ShowErrorMessage = true; _menuBasedShellViewModel.IsLoadingData = false; return; } else { newStoryItem.ExecutorId = (newStatus == _storyStatusesDataModel.GetStatusText(StoryStatus.WaitingForExecutor)) ? 0 : _menuBasedShellViewModel.CurrentUser.Id; } } } if (SelectedStory.Equals(newStoryItem)) { StoryDialogViewModel.ErrorMessage = "Story data is not changed"; StoryDialogViewModel.ShowErrorMessage = true; _menuBasedShellViewModel.IsLoadingData = false; return; } List <StoryItem> storyItemsWithTheSameName = AllUserStories.Where(si => si.Name == newStoryItem.Name).ToList(); if (storyItemsWithTheSameName.Count > 0) { if (storyItemsWithTheSameName.First().Id != newStoryItem.Id) { StoryDialogViewModel.ErrorMessage = $"Story with name '{newStoryItem.Name}' already exists."; StoryDialogViewModel.ShowErrorMessage = true; _menuBasedShellViewModel.IsLoadingData = false; return; } } _logger.Debug($"Started editing story with id '{SelectedStory.Id}'."); _storiesDataModel.Update(newStoryItem.Story); StoryItem item = AllUserStories.FirstOrDefault(s => s.Id == newStoryItem.Id); if (item != null) { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { AllUserStories.Remove(item); newStoryItem.StoryUpdated += OnStoryItemUpdated; AllUserStories.Add(newStoryItem); }); } HideDialog?.Invoke(this, null); } catch (Exception ex) { ShowMessage($"User story doesn't edited: technical issues encountered."); _logger.Fatal(ex); } _menuBasedShellViewModel.IsLoadingData = false; }).Start(); }
private static void SetStatus(ref Story story, StoryStatus storyStatus) { story.Status = ComponentsContainer.Get <IStoryStatusesDataModel>().GetStatusText(storyStatus); }