public void TestMethod6() { string file = File.ReadAllText(@"TestFiles\Test1.html"); const string KEY = "button"; const string NAME = "Dish"; const string SECOND_NAME = "CompleteDish"; const string CLASS_NAME = "DishCreator"; ComponentsContainer basicComponentsContainer = ComponentsContainer.Instance; ComponentsFactory factory = new ComponentsFactory(basicComponentsContainer, basicComponentsContainer, basicComponentsContainer, basicComponentsContainer); Mock <IComponentAddin> addin = new Mock <IComponentAddin>(); addin.Setup(add => add.AddinKey).Returns(KEY); addin.Setup(add => add.GenerateHelpers(CLASS_NAME, NAME, It.IsAny <IPropertyGenerator>())).Returns(new[] { $"{CLASS_NAME} With{NAME}(string {NAME.ToLower()}){{}}" }); addin.Setup(add => add.GenerateHelpers(CLASS_NAME, SECOND_NAME, It.IsAny <IPropertyGenerator>())).Returns(new[] { $"{CLASS_NAME} {SECOND_NAME}(){{}}" }); addin.Setup(add => add.Type).Returns(Consts.WEB_ELEMENT_CLASS_NAME); basicComponentsContainer.AddAddin(addin.Object); var files = factory.CreateCsOutput(file); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE)); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE)); foreach (ComponentGeneratorOutput innerFile in files) { File.WriteAllText(innerFile.CsFilePath, innerFile.Body); } }
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(); }
private void RefreshRemoveStoryConfirmationDialogVisibility() { ComponentsContainer.Get <Dispatcher>().Invoke( delegate { UserStoryRemovingConfirmationDialog.Visibility = _viewModel.ShowRemoveStoryConfirmationDialog ? Visibility.Visible : Visibility.Hidden; }); }
// 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 OnProjectSelected(object sender, Project project) { if (project != null) { CurrentProject = project; CurrentViewModel = _viewModelsContainer.Resolve <ProductBacklogViewModel>(); ComponentsContainer.Get <IRegistryService>().SetCurrentProjectId(project.Id); } }
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 CreateComponents() { BaseFormBuilder <MultipleGraphsCanvas> builder = new BaseFormBuilder <MultipleGraphsCanvas>( meanMovement.Sensors, flowLayoutPanel, comboBox, pb => new MultipleGraphsCanvas(pb)); int width = flowLayoutPanel.Width - 20; //TODO add custom externComponents = builder.GetInicializedComponents(width); externComponents.ComboBox.SelectedIndex = 0; }
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(); } } }
public void Clear() { this.Price = 0; foreach (ComponentType componentType in Enum.GetValues(typeof(ComponentType))) { if (components.ContainsKey(componentType)) { components[componentType] = new ComponentsContainer(componentType, typeService); } else { components.Add(componentType, new ComponentsContainer(componentType, typeService)); } } }
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 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 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 CreateComponents() { flowLayoutPanel.Controls.Clear(); cbListOfGraphs.Items.Clear(); var builder = new BaseFormBuilder <MovementCreationCanvas>( sensors.Sensors, flowLayoutPanel, cbListOfGraphs, pb => new MovementCreationCanvas(pb)); decimal requstedWidth = graphWidh.Value; int width = (int)(requstedWidth * flowLayoutPanel.Width - 10); width = Math.Max(100, width); // min width is 100; externComponents = builder.GetInicializedComponents(width); externComponents.ComboBox.SelectedIndex = 0; }
public void GenerateProject(string webAppBaseDirectory, string projectName, string solutionName = null, string distDirectory = null) { BuiltInComponentsInserter.InsertBuiltInComponents(); distDirectory = distDirectory ?? Environment.CurrentDirectory + "\\test"; CreateSolution(projectName); ComponentsContainer container = ComponentsContainer.Instance; ComponentsFactory componentsFactory = new ComponentsFactory(container, container, container, container); WebFolderToCsFilesConverter converter = new WebFolderToCsFilesConverter(componentsFactory, new HtmlFinder()); List <ComponentGeneratorOutput> results = converter.GenerateClasses(webAppBaseDirectory); AddBaseClassesToResults(results); CreateFiles(distDirectory, results); string packageConfigName = CreatePackagesConfig(distDirectory); ProjectBuilder builder = new ProjectBuilder(); builder.BuildProject(projectName, results, distDirectory, packageConfigName); }
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); }
public void TestMethod7() { string file = File.ReadAllText(@"TestFiles\Test1.html"); const string KEY = "label"; Mock <IComponentAddin> addin = new Mock <IComponentAddin>(); addin.Setup(add => add.AddinKey).Returns(KEY); addin.Setup(add => add.Type).Returns("string"); ComponentsContainer basicComponentsContainer = ComponentsContainer.Instance; basicComponentsContainer.AddAddin(new LabelAddin()); basicComponentsContainer.AddAddin(new InputAddin()); ComponentsFactory factory = new ComponentsFactory(basicComponentsContainer, basicComponentsContainer, basicComponentsContainer, basicComponentsContainer); var files = factory.CreateCsOutput(file); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE)); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE)); foreach (var innerFile in files) { File.WriteAllText(innerFile.CsFilePath, innerFile.Body); } }
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 { } }); }
public void TestMethod1() { const string KEY = "ccc"; const string NAME = "bbb"; const string CLASS_NAME = "DishCreator"; const string SELECTOR = "auto-page-" + CLASS_NAME; ComponentsContainer basicComponentsContainer = ComponentsContainer.Instance; PageGenerator generator = new PageGenerator(new BasicClassBuilder(), new DriverFindElementPropertyGenerator("Driver"), basicComponentsContainer, Consts.PAGES_NAMESPACE); Mock <IComponentAddin> addin = new Mock <IComponentAddin>(); addin.Setup(add => add.AddinKey).Returns(KEY); addin.Setup(add => add.GenerateHelpers(CLASS_NAME, NAME, generator.PropertyGenerator)).Returns(new[] { "void Main(){}", "public void Main2(){}" }); addin.Setup(add => add.Type).Returns("string"); basicComponentsContainer.AddAddin(addin.Object); var classStr = generator.GenerateComponentClass(SELECTOR, new[] { new ElementSelectorData { FullSelector = "aaa", Name = NAME, Type = KEY, AutomationAttributes = new string[0] } }); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.PAGES_NAMESPACE)); Directory.CreateDirectory(NamespaceFileConverter.ConvertNamespaceToFilePath(Consts.COMPONENTS_NAMESPACE)); File.WriteAllText(classStr.CsFilePath, classStr.Body); }
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); }