Changeset 15777 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
- Timestamp:
- 02/14/18 11:19:55 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15767 r15777 43 43 private readonly Color changedColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 44 44 private readonly Color selectedColor = Color.FromArgb(255, 240, 194, 59); // #f0c23b 45 45 46 private Project selectedProject = null; 47 public Project SelectedProject { 48 get { return selectedProject; } 49 set { if (selectedProject != value) ChangeSelectedProject(value); } 50 } 46 51 47 52 private readonly object locker = new object(); … … 93 98 projectResourcesView.Content = null; 94 99 } else { 95 var top = BuildProjectTree(Content); 96 projectView.Content = top; 97 projectPermissionsView.Content = top; 98 projectResourcesView.Content = top; 99 100 if(top != null && top.Id == Guid.Empty) { 101 projectPermissionsView.Locked = true; 102 projectResourcesView.Locked = true; 103 } 100 BuildProjectTree(Content); 104 101 } 105 102 } … … 107 104 protected override void SetEnabledStateOfControls() { 108 105 base.SetEnabledStateOfControls(); 109 bool enabled = Content != null && ! ReadOnly;106 bool enabled = Content != null && !Locked && !ReadOnly; 110 107 refreshButton.Enabled = enabled; 111 108 addButton.Enabled = enabled; … … 213 210 }; 214 211 215 selectedProject = project;212 SelectedProject = project; 216 213 Content.Add(project); 217 214 } … … 278 275 } 279 276 280 private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 281 ChangeSelectedProjectNode(e.Node); 282 283 //if (projectView.Content != null) 284 // projectView.Content.PropertyChanged -= ProjectViewContent_PropertyChanged; 285 286 projectView.Content = selectedProject; 287 projectPermissionsView.Content = selectedProject; 288 projectResourcesView.Content = selectedProject; 289 290 //if (selectedProject != null) 291 // selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged; 277 private void projectsTreeView_MouseDown(object sender, MouseEventArgs e) { 278 var node = projectsTreeView.GetNodeAt(e.Location); 279 if(node != null) ChangeSelectedProjectNode(node); 280 } 281 282 private void projectsTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 283 e.Cancel = true; 292 284 } 293 285 … … 306 298 var targetNode = treeView.GetNodeAt(targetPoint); 307 299 308 if (sourceNode == targetNode) return;309 300 var targetProject = (targetNode != null) ? (Project)targetNode.Tag : null; 310 301 311 if (targetProject != null && targetProject.Id == Guid.Empty) {302 if (!HiveAdminClient.Instance.CheckParentChange(sourceProject, targetProject)) { 312 303 MessageBox.Show( 313 "You cannot drag projects to a not yet storedproject.",304 "You cannot drag projects to this project.", 314 305 "HeuristicLab Hive Administrator", 315 306 MessageBoxButtons.OK, 316 307 MessageBoxIcon.Information); 317 308 return; 318 }319 if(!HiveAdminClient.Instance.CheckParentChange(sourceProject, targetProject)) {320 MessageBox.Show(321 "You cannot drag to this project.",322 "HeuristicLab Hive Administrator",323 MessageBoxButtons.OK,324 MessageBoxIcon.Information);325 return;326 309 } 327 310 … … 340 323 } 341 324 342 selectedProject = sourceProject;325 SelectedProject = sourceProject; 343 326 OnContentChanged(); 344 327 } … … 364 347 || sourceProject == null 365 348 || sourceNode == targetNode 366 || (targetProject != null && targetProject.Id == Guid.Empty)367 || (targetProject != null && targetProject.Id == sourceProject.ParentProjectId)368 349 || !HiveAdminClient.Instance.CheckParentChange(sourceProject, targetProject)) { 369 350 e.Effect = DragDropEffects.None; … … 398 379 } 399 380 381 private void ChangeSelectedProject(Project project) { 382 projectView.Content = project; 383 projectPermissionsView.Content = project; 384 projectResourcesView.Content = project; 385 386 bool locked = project == null || (project != null && project.Id == Guid.Empty); 387 addButton.Enabled = !locked; 388 projectPermissionsView.Locked = locked; 389 projectResourcesView.Locked = locked; 390 selectedProject = project; 391 } 392 400 393 private void ChangeSelectedProjectNode(TreeNode projectNode) { 401 selectedProject = (Project)projectNode.Tag; 394 if (projectNode == null) return; 395 SelectedProject = (Project)projectNode.Tag; 402 396 ResetTreeNodes(projectsTreeView.Nodes, selectedColor, Color.Transparent, true); 403 397 projectNode.BackColor = selectedColor; … … 405 399 } 406 400 407 private ProjectBuildProjectTree(IEnumerable<Project> projects) {401 private void BuildProjectTree(IEnumerable<Project> projects) { 408 402 projectsTreeView.Nodes.Clear(); 409 if (!projects.Any()) return null;403 if (!projects.Any()) return; 410 404 411 405 var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null)); … … 417 411 418 412 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); 419 if (selectedProject != null) selectedProject = projects.Where(x => x.Id == selectedProject.Id).FirstOrDefault();413 if (selectedProject != null) SelectedProject = projects.Where(x => x.Id == selectedProject.Id).FirstOrDefault(); 420 414 bool nodeSelected = false; 421 415 … … 433 427 } 434 428 if (selectedProject == null) { 435 selectedProject = newProject;429 SelectedProject = newProject; 436 430 } 437 431 if (newProject.Id == selectedProject.Id && !nodeSelected) { … … 471 465 472 466 projectsTreeView.ExpandAll(); 473 474 return selectedProject;475 467 } 476 468 … … 485 477 486 478 private void RemoveProject(Project project) { 487 if (project == null || project.Id == Guid.Empty) return;479 if (project == null) return; 488 480 489 481 try { 490 HiveAdminClient.Delete(project);482 if(project.Id != Guid.Empty) HiveAdminClient.Delete(project); 491 483 Content.Remove(selectedProject); 492 484 } catch (AnonymousUserException) { … … 497 489 private bool IsAuthorized(Project project) { 498 490 return project != null && UserInformation.Instance.UserExists; 499 //&& (project.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());500 491 } 501 492
Note: See TracChangeset
for help on using the changeset viewer.