#region License Information
/* HeuristicLab
* Copyright (C) 2002-2019 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.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using HeuristicLab.Clients.Hive.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Clients.Hive.JobManager.Views {
public partial class HiveResourceSelectorDialog : Form {
private readonly object locker = new object();
private bool updatingProjects = false;
public Project SelectedProject {
get { return hiveResourceSelector.SelectedProject; }
}
public IEnumerable SelectedResources {
get { return hiveResourceSelector.AssignedResources; }
}
private Guid jobId;
public Guid JobId {
get { return hiveResourceSelector.JobId; }
set { jobId = value; }
}
// persisted projectId
private Guid? projectId;
public Guid? ProjectId {
get { return hiveResourceSelector.ProjectId; }
set { projectId = value; }
}
// currently selected projectId (initially the persisted projectId)
private Guid? selectedProjectId;
public Guid? SelectedProjectId {
get { return selectedProjectId; }
set { selectedProjectId = value; }
}
// currently selected resourceIds (if null, perform lookup in HiveResourceSelector)
private IEnumerable selectedResourceIds;
public IEnumerable SelectedResourceIds {
get { return selectedResourceIds; }
set { selectedResourceIds = value; }
}
public HiveResourceSelectorDialog(Guid jobId, Guid projectId) {
this.jobId = jobId;
this.projectId = projectId;
this.selectedProjectId = projectId;
InitializeComponent();
}
#region Overrides
protected override void OnLoad(EventArgs e) {
HiveClient.Instance.Refreshing += HiveClient_Instance_Refreshing;
HiveClient.Instance.Refreshed += HiveClient_Instance_Refreshed;
base.OnLoad(e);
}
protected override void OnClosing(CancelEventArgs e) {
HiveClient.Instance.Refreshed -= HiveClient_Instance_Refreshed;
HiveClient.Instance.Refreshing -= HiveClient_Instance_Refreshing;
base.OnClosing(e);
}
#endregion
#region Event Handlers
private void HiveClient_Instance_Refreshing(object sender, EventArgs e) {
if (InvokeRequired) Invoke((Action