Changeset 16173 for addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs
- Timestamp:
- 09/21/18 16:00:50 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs
r12930 r16173 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Windows.Forms; 26 using HeuristicLab.Clients.Hive; 27 using HeuristicLab.Clients.Hive.JobManager.Views; 23 28 using HeuristicLab.Core.Views; 24 29 using HeuristicLab.MainForm; … … 28 33 [Content(typeof(HiveEngine), IsDefaultView = true)] 29 34 public sealed partial class HiveEngineView : ItemView { 35 private readonly HiveResourceSelectorDialog hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Guid.Empty, Guid.Empty); 36 30 37 public new HiveEngine Content { 31 38 get { return (HiveEngine)base.Content; } … … 70 77 base.OnContentChanged(); 71 78 if (Content == null) { 72 resourceIdsTextBox.Text = string.Empty;73 priority TextBox.Text = string.Empty;79 projectNameTextBox.Text = string.Empty; 80 priorityComboBox.SelectedIndex = 1; 74 81 executionTimeOnHiveTextBox.Text = string.Empty; 75 82 hiveExperimentListView.Content = null; 76 83 logView.Content = null; 77 84 } else { 78 resourceIdsTextBox.Text = Content.ResourceNames; 79 priorityTextBox.Text = Content.Priority.ToString(); 85 if (Content.ProjectId != null && Content.ProjectId != Guid.Empty) { 86 var project = HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(Content.ProjectId)); 87 if (project != null) projectNameTextBox.Text = project.Name; 88 } else { 89 projectNameTextBox.Text = string.Empty; 90 } 91 92 if (Content.Priority >= 0 && Content.Priority < priorityComboBox.Items.Count) { 93 priorityComboBox.SelectedIndex = Content.Priority; 94 } else { 95 priorityComboBox.SelectedIndex = 1; 96 } 97 80 98 executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); 81 99 hiveExperimentListView.Content = Content.Jobs; … … 86 104 protected override void SetEnabledStateOfControls() { 87 105 base.SetEnabledStateOfControls(); 88 // Enable or disable controls based on whether the content is null or the view is set readonly 89 if (Content != null) { 90 resourceIdsTextBox.ReadOnly = this.ReadOnly; 91 priorityTextBox.ReadOnly = this.ReadOnly; 92 } else { 93 resourceIdsTextBox.ReadOnly = false; 94 priorityTextBox.ReadOnly = false; 106 107 searchButton.Enabled = Content != null && !ReadOnly && !Locked; 108 projectNameTextBox.Enabled = Content != null && !ReadOnly && !Locked; 109 priorityComboBox.Enabled = Content != null && !ReadOnly && !Locked; 110 } 111 112 private void searchButton_Click(object sender, EventArgs e) { 113 hiveResourceSelectorDialog.SelectedProjectId = Content != null ? Content.ProjectId : Guid.Empty; 114 hiveResourceSelectorDialog.SelectedResourceIds = Content != null ? Content.ResourceIds : new List<Guid>(); 115 116 var result = hiveResourceSelectorDialog.ShowDialog(this); 117 if (result == DialogResult.OK) { 118 var selectedProject = hiveResourceSelectorDialog.SelectedProject; 119 if (selectedProject != null) { 120 projectNameTextBox.Text = selectedProject.Name; 121 Content.ProjectId = selectedProject.Id; 122 Content.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); 123 } else { 124 projectNameTextBox.Text = string.Empty; 125 Content.ProjectId = Guid.Empty; 126 Content.ResourceIds = new List<Guid>(); 127 } 95 128 } 96 129 } 97 130 98 #region Event Handlers (child controls) 99 private void resourceIdsTextBox_Validated(object sender, EventArgs e) { 100 Content.ResourceNames = resourceIdsTextBox.Text; 131 private void priorityComboBox_SelectedIndexChanged(object sender, EventArgs e) { 132 if (Content != null && Content.Priority != priorityComboBox.SelectedIndex) { 133 Content.Priority = priorityComboBox.SelectedIndex; 134 } 101 135 } 102 103 private void priorityTextBox_Validated(object sender, EventArgs e) {104 Content.Priority = int.Parse(priorityTextBox.Text);105 }106 #endregion107 136 } 108 137 }
Note: See TracChangeset
for help on using the changeset viewer.