#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using HeuristicLab.Clients.Access;
using HeuristicLab.Common.Resources;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
using System.Collections;
using HeuristicLab.Common;
namespace HeuristicLab.Clients.Hive.Administrator.Views {
[View("ProjectView")]
[Content(typeof(Project), IsDefaultView = false)]
public partial class ProjectResourcesView : ItemView {
private const int slaveImageIndex = 0;
private const int slaveGroupImageIndex = 1;
public const string UNGROUPED_GROUP_NAME = "UNGROUPED";
public const string UNGROUPED_GROUP_DESCRIPTION = "Contains slaves that are not assigned to any group.";
public const string IMMUTABLE_TAG = " [assigned, immutable]";
public const string INCLUDED_TAG = " [included]";
public const string ADDED_ASSIGNMENT_TAG = " [added assignment]";
public const string REMOVED_ASSIGNMENT_TAG = " [removed assignment]";
public const string ADDED_INCLUDE_TAG = " [added include]";
public const string REMOVED_INCLUDE_TAG = " [removed include]";
private readonly HashSet assignedResources = new HashSet();
private readonly HashSet newAssignedResources = new HashSet();
private readonly HashSet includedResources = new HashSet();
private readonly HashSet newIncludedResources = new HashSet();
private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1
private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48
private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd
private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291
private readonly Color selectedBackColor = Color.DodgerBlue;
private readonly Color selectedForeColor = Color.White;
private readonly Color grayTextColor = SystemColors.GrayText;
private HashSet projectExclusiveResources = new HashSet();
private TreeNode ungroupedGroupNode;
public new Project Content {
get { return (Project)base.Content; }
set { base.Content = value; }
}
public ProjectResourcesView() {
InitializeComponent();
treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed;
}
#region Overrides
protected override void OnClosing(FormClosingEventArgs e) {
HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed;
HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing;
base.OnClosing(e);
}
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null) {
assignedResources.Clear();
newAssignedResources.Clear();
includedResources.Clear();
treeView.Nodes.Clear();
detailsViewHost.Content = null;
} else {
UpdateAssignedResources();
UpdateIncludedResources();
detailsViewHost.Content = BuildResourceTree();
}
SetEnabledStateOfControls();
}
protected override void SetEnabledStateOfControls() {
base.SetEnabledStateOfControls();
bool enabled = Content != null && !Locked && !ReadOnly;
inheritButton.Enabled = enabled;
saveButton.Enabled = enabled;
treeView.Enabled = enabled;
if (detailsViewHost != null) {
detailsViewHost.Locked = true;
}
}
#endregion
#region Event Handlers
private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) {
if (InvokeRequired) Invoke((Action