- Timestamp:
- 09/22/10 05:54:13 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/AlgorithmView.cs
r4441 r4466 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.Linq; 23 25 using System.Windows.Forms; 24 26 using HeuristicLab.MainForm; 25 27 using HeuristicLab.MainForm.WindowsForms; 28 using System.IO; 26 29 27 30 namespace HeuristicLab.Clients.OKB { … … 42 45 platformComboBox.DataSource = Administrator.Instance.Platforms.ToList(); 43 46 algorithmClassComboBox.DataSource = Administrator.Instance.AlgorithmClasses.ToList(); 47 dataTypeComboBox.DataSource = Administrator.Instance.DataTypes.ToList(); 44 48 } 45 49 … … 62 66 algorithmClassComboBox.SelectedItem = Administrator.Instance.AlgorithmClasses.FirstOrDefault(a => a.Id == Content.AlgorithmClassId); 63 67 } 68 usersListBox.DataSource = null; 69 fileTextBox.Text = ""; 70 dataTypeComboBox.SelectedIndex = -1; 64 71 } 65 72 … … 68 75 platformComboBox.Enabled = Content != null; 69 76 algorithmClassComboBox.Enabled = Content != null; 77 refreshUsersButton.Enabled = Content != null; 78 storeUsersButton.Enabled = usersListBox.DataSource != null; 79 usersListBox.Enabled = usersListBox.DataSource != null; 80 storeDataButton.Enabled = !string.IsNullOrEmpty(fileTextBox.Text) && dataTypeComboBox.SelectedIndex != -1; 70 81 } 71 82 … … 93 104 } 94 105 } 106 107 private void refreshUsersButton_Click(object sender, System.EventArgs e) { 108 Guid[] ids = Administrator.Instance.GetAlgorithmUsers(Content.Id); 109 if (ids != null) { 110 List<User> users = Administrator.Instance.Users.ToList(); 111 usersListBox.DataSource = users; 112 usersListBox.DisplayMember = "Name"; 113 usersListBox.SelectedItems.Clear(); 114 foreach (Guid id in ids) 115 usersListBox.SelectedItems.Add(users.First(u => u.Id == id)); 116 usersListBox.Enabled = true; 117 storeUsersButton.Enabled = false; 118 } 119 } 120 private void storeUsersButton_Click(object sender, System.EventArgs e) { 121 if (Administrator.Instance.StoreAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToArray())) 122 storeUsersButton.Enabled = false; 123 } 124 private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) { 125 storeUsersButton.Enabled = true; 126 } 127 128 private void storeDataButton_Click(object sender, EventArgs e) { 129 AlgorithmData data = new AlgorithmData(); 130 data.AlgorithmId = Content.Id; 131 data.DataTypeId = ((DataType)dataTypeComboBox.SelectedItem).Id; 132 133 using (FileStream stream = new FileStream(fileTextBox.Text, FileMode.Open, FileAccess.Read)) { 134 byte[] bytes = new byte[stream.Length]; 135 stream.Read(bytes, 0, bytes.Length); 136 stream.Close(); 137 data.Data = bytes; 138 } 139 140 if (Administrator.Instance.StoreAlgorithmData(data)) 141 storeDataButton.Enabled = false; 142 } 143 private void openFileButton_Click(object sender, EventArgs e) { 144 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 145 fileTextBox.Text = openFileDialog.FileName; 146 storeDataButton.Enabled = true; 147 } 148 } 149 private void dataTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { 150 storeDataButton.Enabled = !string.IsNullOrEmpty(fileTextBox.Text); 151 } 95 152 } 96 153 }
Note: See TracChangeset
for help on using the changeset viewer.