- Timestamp:
- 04/16/10 01:49:10 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r3341 r3362 71 71 protected override void OnInitialized(EventArgs e) { 72 72 base.OnInitialized(e); 73 SetEnabledStateOfControls(); 73 74 Enabled = false; 74 75 infoLabel.Text = "Loading ..."; … … 77 78 ThreadPool.QueueUserWorkItem(new WaitCallback(LoadItems)); 78 79 } 80 protected override void OnReadOnlyChanged() { 81 base.OnReadOnlyChanged(); 82 SetEnabledStateOfControls(); 83 } 79 84 protected override void OnClosing(FormClosingEventArgs e) { 80 85 base.OnClosing(e); … … 83 88 this.Hide(); 84 89 } 90 } 91 92 private void SetEnabledStateOfControls() { 93 addButton.Enabled = !ReadOnly; 94 removeButton.Enabled = !ReadOnly && listView.SelectedItems.Count > 0; 95 saveButton.Enabled = !ReadOnly; 85 96 } 86 97 … … 207 218 #region ListView Events 208 219 private void listView_SelectedIndexChanged(object sender, EventArgs e) { 209 removeButton.Enabled = listView.SelectedItems.Count > 0;220 removeButton.Enabled = !ReadOnly && listView.SelectedItems.Count > 0; 210 221 } 211 222 private void listView_KeyDown(object sender, KeyEventArgs e) { 212 223 if (e.KeyCode == Keys.Delete) { 213 if ( listView.SelectedItems.Count > 0) {224 if (!ReadOnly && (listView.SelectedItems.Count > 0)) { 214 225 foreach (ListViewItem item in listView.SelectedItems) 215 226 RemoveItem((T)item.Tag); … … 220 231 if (listView.SelectedItems.Count == 1) { 221 232 T item = (T)listView.SelectedItems[0].Tag; 222 IView view = MainFormManager.CreateDefaultView(item );233 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 223 234 if (view != null) view.Show(); 224 235 } … … 230 241 data.SetData("Type", item.GetType()); 231 242 data.SetData("Value", item); 232 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 233 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 234 RemoveItem(item); 243 if (ReadOnly) { 244 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 245 } else { 246 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 247 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 248 RemoveItem(item); 249 } 235 250 } 236 251 private void listView_DragEnterOver(object sender, DragEventArgs e) { … … 238 253 Type type = e.Data.GetData("Type") as Type; 239 254 T item = e.Data.GetData("Value") as T; 240 if ( (type != null) && (item != null)) {255 if (!ReadOnly && (type != null) && (item != null)) { 241 256 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 242 257 else if (((e.KeyState & 4) == 4) && !itemListViewItemTable.ContainsKey(item)) e.Effect = DragDropEffects.Move; // SHIFT key -
trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs
r3289 r3362 77 77 if (Content == null) { 78 78 logView.Content = null; 79 executionTimeTextBox.Text = "-"; 80 } else { 81 logView.Content = Content.Log; 82 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 83 } 84 SetEnabledStateOfControls(); 85 } 86 87 protected override void OnReadOnlyChanged() { 88 base.OnReadOnlyChanged(); 89 SetEnabledStateOfControls(); 90 } 91 92 private void SetEnabledStateOfControls() { 93 if (Content == null) { 79 94 logView.Enabled = false; 80 executionTimeTextBox.Text = "-";81 95 executionTimeTextBox.Enabled = false; 82 96 } else { 83 logView. Content = Content.Log;97 logView.ReadOnly = ReadOnly; 84 98 logView.Enabled = true; 85 executionTimeTextBox.Text = Content.ExecutionTime.ToString();86 99 executionTimeTextBox.Enabled = true; 87 100 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs
r3351 r3362 138 138 this.itemsListView.View = System.Windows.Forms.View.Details; 139 139 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 140 this.itemsListView.SizeChanged += new System.EventHandler(this.itemsListView_SizeChanged);141 140 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 142 141 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r3341 r3362 88 88 Caption = "Item Array"; 89 89 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 90 itemsListView.Enabled = false;91 detailsGroupBox.Enabled = false;92 90 viewHost.Content = null; 93 moveUpButton.Enabled = false;94 moveDownButton.Enabled = false;95 96 91 if (Content != null) { 97 92 Caption += " (" + Content.GetType().Name + ")"; 98 itemsListView.Enabled = true;99 93 foreach (T item in Content) 100 94 AddListViewItem(CreateListViewItem(item)); 95 } 96 SetEnabledStateOfControls(); 97 } 98 99 protected override void OnReadOnlyChanged() { 100 base.OnReadOnlyChanged(); 101 SetEnabledStateOfControls(); 102 } 103 104 private void SetEnabledStateOfControls() { 105 if (Content == null) { 106 addButton.Enabled = false; 107 moveUpButton.Enabled = false; 108 moveDownButton.Enabled = false; 109 removeButton.Enabled = false; 110 itemsListView.Enabled = false; 111 detailsGroupBox.Enabled = false; 112 } else { 113 addButton.Enabled = itemsListView.SelectedItems.Count > 0 && 114 !Content.IsReadOnly && !ReadOnly; 115 moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 && 116 itemsListView.SelectedIndices[0] != 0 && 117 !Content.IsReadOnly && !ReadOnly; 118 moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 && 119 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 && 120 !Content.IsReadOnly && !ReadOnly; 121 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && 122 !Content.IsReadOnly && !ReadOnly; 123 itemsListView.Enabled = true; 124 detailsGroupBox.Enabled = true; 125 viewHost.ReadOnly = ReadOnly; 101 126 } 102 127 } … … 126 151 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 127 152 } 153 AdjustListViewColumnSizes(); 128 154 } 129 155 protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) { … … 133 159 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 134 160 } 161 AdjustListViewColumnSizes(); 135 162 } 136 163 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { … … 157 184 } 158 185 186 #region ListView Events 159 187 protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) { 160 addButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly ;188 addButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly && !ReadOnly; 161 189 moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 && 162 190 itemsListView.SelectedIndices[0] != 0 && 163 !Content.IsReadOnly ;191 !Content.IsReadOnly && !ReadOnly; 164 192 moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 && 165 193 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 && 166 !Content.IsReadOnly ;167 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly ;194 !Content.IsReadOnly && !ReadOnly; 195 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly && !ReadOnly; 168 196 169 197 if (itemsListView.SelectedItems.Count == 1) { … … 178 206 } 179 207 180 #region ListView Events181 protected virtual void itemsListView_SizeChanged(object sender, EventArgs e) {182 if (itemsListView.Columns.Count > 0)183 itemsListView.Columns[0].Width = Math.Max(0, itemsListView.Width - 25);184 }185 186 208 protected virtual void itemsListView_KeyDown(object sender, KeyEventArgs e) { 187 209 if (e.KeyCode == Keys.Delete) { 188 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly ) {210 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) { 189 211 foreach (ListViewItem item in itemsListView.SelectedItems) 190 212 Content[item.Index] = null; … … 197 219 T item = itemsListView.SelectedItems[0].Tag as T; 198 220 if (item != null) { 199 IView view = MainFormManager.CreateDefaultView(item );221 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 200 222 if (view != null) view.Show(); 201 223 } … … 210 232 data.SetData("Type", item.GetType()); 211 233 data.SetData("Value", item); 212 if (Content.IsReadOnly ) {234 if (Content.IsReadOnly || ReadOnly) { 213 235 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 214 236 } else { … … 222 244 e.Effect = DragDropEffects.None; 223 245 Type type = e.Data.GetData("Type") as Type; 224 if ( (!Content.IsReadOnly)&& (type != null) && (typeof(T).IsAssignableFrom(type))) {246 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 225 247 Point p = itemsListView.PointToClient(new Point(e.X, e.Y)); 226 248 ListViewItem listViewItem = itemsListView.GetItemAt(p.X, p.Y); … … 354 376 UpdateListViewItemText(listViewItem); 355 377 } 378 AdjustListViewColumnSizes(); 379 } 380 } 381 #endregion 382 383 #region Helpers 384 protected virtual void AdjustListViewColumnSizes() { 385 if (itemsListView.Items.Count > 0) { 386 for (int i = 0; i < itemsListView.Columns.Count; i++) 387 itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 356 388 } 357 389 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs
r3351 r3362 115 115 this.itemsListView.View = System.Windows.Forms.View.Details; 116 116 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 117 this.itemsListView.SizeChanged += new System.EventHandler(this.itemsListView_SizeChanged);118 117 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 119 118 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3350 r3362 46 46 Caption = "Item Collection"; 47 47 } 48 49 48 public ItemCollectionView(IObservableCollection<T> content) 50 49 : this() { … … 76 75 SortItemsListView(SortOrder.Ascending); 77 76 } 78 SetEnable StateOfControls();77 SetEnabledStateOfControls(); 79 78 } 80 79 81 80 protected override void OnReadOnlyChanged() { 82 81 base.OnReadOnlyChanged(); 83 SetEnableStateOfControls(); 84 } 85 private void SetEnableStateOfControls() { 82 SetEnabledStateOfControls(); 83 } 84 85 private void SetEnabledStateOfControls() { 86 86 if (Content == null) { 87 addButton.Enabled = false; 88 sortAscendingButton.Enabled = false; 89 sortDescendingButton.Enabled = false; 90 removeButton.Enabled = false; 87 91 itemsListView.Enabled = false; 88 92 detailsGroupBox.Enabled = false; 89 sortAscendingButton.Enabled = itemsListView.Items.Count > 0;90 sortDescendingButton.Enabled = itemsListView.Items.Count > 0;91 viewHost.Enabled = false;92 addButton.Enabled = false;93 removeButton.Enabled = false;94 93 } else { 94 addButton.Enabled = !Content.IsReadOnly && !ReadOnly; 95 sortAscendingButton.Enabled = itemsListView.Items.Count > 1; 96 sortDescendingButton.Enabled = itemsListView.Items.Count > 1; 97 removeButton.Enabled = !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0; 95 98 itemsListView.Enabled = true; 96 99 detailsGroupBox.Enabled = true; 97 sortAscendingButton.Enabled = true;98 sortDescendingButton.Enabled = true;99 viewHost.Enabled = true;100 100 viewHost.ReadOnly = ReadOnly; 101 addButton.Enabled = !ReadOnly;102 removeButton.Enabled = !ReadOnly;103 101 } 104 102 } … … 125 123 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 126 124 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 127 sortAscendingButton.Enabled = itemsListView.Items.Count > 0; 128 sortDescendingButton.Enabled = itemsListView.Items.Count > 0; 125 AdjustListViewColumnSizes(); 126 sortAscendingButton.Enabled = itemsListView.Items.Count > 1; 127 sortDescendingButton.Enabled = itemsListView.Items.Count > 1; 129 128 } 130 129 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { … … 135 134 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 136 135 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 137 sortAscendingButton.Enabled = itemsListView.Items.Count > 0;138 sortDescendingButton.Enabled = itemsListView.Items.Count > 0;136 sortAscendingButton.Enabled = itemsListView.Items.Count > 1; 137 sortDescendingButton.Enabled = itemsListView.Items.Count > 1; 139 138 } 140 139 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { … … 157 156 #region ListView Events 158 157 protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) { 159 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly;158 removeButton.Enabled = !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0; 160 159 if (itemsListView.SelectedItems.Count == 1) { 161 160 T item = (T)itemsListView.SelectedItems[0].Tag; … … 168 167 } 169 168 } 170 protected virtual void itemsListView_SizeChanged(object sender, EventArgs e) {171 if (itemsListView.Columns.Count > 0)172 itemsListView.Columns[0].Width = Math.Max(0, itemsListView.Width - 25);173 }174 169 protected virtual void itemsListView_KeyDown(object sender, KeyEventArgs e) { 175 170 if (e.KeyCode == Keys.Delete) { 176 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly ) {171 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) { 177 172 foreach (ListViewItem item in itemsListView.SelectedItems) 178 173 Content.Remove((T)item.Tag); … … 183 178 if (itemsListView.SelectedItems.Count == 1) { 184 179 T item = (T)itemsListView.SelectedItems[0].Tag; 185 IView view = MainFormManager.CreateDefaultView(item );180 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 186 181 if (view != null) view.Show(); 187 182 } … … 193 188 data.SetData("Type", item.GetType()); 194 189 data.SetData("Value", item); 195 if (Content.IsReadOnly ) {190 if (Content.IsReadOnly || ReadOnly) { 196 191 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 197 192 } else { … … 204 199 e.Effect = DragDropEffects.None; 205 200 Type type = e.Data.GetData("Type") as Type; 206 if ( (!Content.IsReadOnly)&& (type != null) && (typeof(T).IsAssignableFrom(type))) {201 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 207 202 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 208 203 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 295 290 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 296 291 UpdateListViewItemText(listViewItem); 292 AdjustListViewColumnSizes(); 297 293 } 298 294 } … … 305 301 itemsListView.Sorting = SortOrder.None; 306 302 } 303 protected virtual void AdjustListViewColumnSizes() { 304 if (itemsListView.Items.Count > 0) { 305 for (int i = 0; i < itemsListView.Columns.Count; i++) 306 itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 307 } 308 } 307 309 #endregion 308 310 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs
r3351 r3362 149 149 this.itemsListView.View = System.Windows.Forms.View.Details; 150 150 this.itemsListView.SelectedIndexChanged += new System.EventHandler(this.itemsListView_SelectedIndexChanged); 151 this.itemsListView.SizeChanged += new System.EventHandler(this.itemsListView_SizeChanged);152 151 this.itemsListView.DoubleClick += new System.EventHandler(this.itemsListView_DoubleClick); 153 152 this.itemsListView.DragDrop += new System.Windows.Forms.DragEventHandler(this.itemsListView_DragDrop); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r3341 r3362 92 92 Caption = "Item List"; 93 93 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 94 itemsListView.Enabled = false;95 detailsGroupBox.Enabled = false;96 94 viewHost.Content = null; 97 addButton.Enabled = false;98 moveUpButton.Enabled = false;99 moveDownButton.Enabled = false;100 removeButton.Enabled = false;101 102 95 if (Content != null) { 103 96 Caption += " (" + Content.GetType().Name + ")"; 104 itemsListView.Enabled = true;105 addButton.Enabled = !Content.IsReadOnly;106 97 foreach (T item in Content) 107 98 AddListViewItem(CreateListViewItem(item)); 99 } 100 SetEnabledStateOfControls(); 101 } 102 103 protected override void OnReadOnlyChanged() { 104 base.OnReadOnlyChanged(); 105 SetEnabledStateOfControls(); 106 } 107 108 private void SetEnabledStateOfControls() { 109 if (Content == null) { 110 addButton.Enabled = false; 111 moveUpButton.Enabled = false; 112 moveDownButton.Enabled = false; 113 removeButton.Enabled = false; 114 itemsListView.Enabled = false; 115 detailsGroupBox.Enabled = false; 116 } else { 117 addButton.Enabled = !Content.IsReadOnly && !ReadOnly; 118 moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 && 119 itemsListView.SelectedIndices[0] != 0 && 120 !Content.IsReadOnly && !ReadOnly; 121 moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 && 122 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 && 123 !Content.IsReadOnly && !ReadOnly; 124 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && 125 !Content.IsReadOnly && !ReadOnly; 126 itemsListView.Enabled = true; 127 detailsGroupBox.Enabled = true; 128 viewHost.ReadOnly = ReadOnly; 108 129 } 109 130 } … … 131 152 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 132 153 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 154 AdjustListViewColumnSizes(); 133 155 } 134 156 protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) { … … 136 158 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 137 159 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 160 AdjustListViewColumnSizes(); 138 161 } 139 162 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { … … 156 179 } 157 180 181 #region ListView Events 158 182 protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) { 159 183 moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 && 160 184 itemsListView.SelectedIndices[0] != 0 && 161 !Content.IsReadOnly ;185 !Content.IsReadOnly && !ReadOnly; 162 186 moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 && 163 187 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 && 164 !Content.IsReadOnly ;188 !Content.IsReadOnly && !ReadOnly; 165 189 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && 166 !Content.IsReadOnly ;190 !Content.IsReadOnly && !ReadOnly; 167 191 168 192 if (itemsListView.SelectedItems.Count == 1) { … … 177 201 } 178 202 179 #region ListView Events180 protected virtual void itemsListView_SizeChanged(object sender, EventArgs e) {181 if (itemsListView.Columns.Count > 0)182 itemsListView.Columns[0].Width = Math.Max(0, itemsListView.Width - 25);183 }184 185 203 protected virtual void itemsListView_KeyDown(object sender, KeyEventArgs e) { 186 204 if (e.KeyCode == Keys.Delete) { 187 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly ) {205 if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) { 188 206 foreach (ListViewItem item in itemsListView.SelectedItems) 189 207 Content.RemoveAt(item.Index); … … 195 213 if (itemsListView.SelectedItems.Count == 1) { 196 214 T item = (T)itemsListView.SelectedItems[0].Tag; 197 IView view = MainFormManager.CreateDefaultView(item );215 IView view = MainFormManager.CreateDefaultView(item, ReadOnly); 198 216 if (view != null) view.Show(); 199 217 } … … 206 224 data.SetData("Type", item.GetType()); 207 225 data.SetData("Value", item); 208 if (Content.IsReadOnly ) {226 if (Content.IsReadOnly || ReadOnly) { 209 227 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 210 228 } else { … … 217 235 e.Effect = DragDropEffects.None; 218 236 Type type = e.Data.GetData("Type") as Type; 219 if ( (!Content.IsReadOnly)&& (type != null) && (typeof(T).IsAssignableFrom(type))) {237 if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(T).IsAssignableFrom(type))) { 220 238 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 221 239 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key … … 360 378 UpdateListViewItemText(listViewItem); 361 379 } 380 AdjustListViewColumnSizes(); 381 } 382 } 383 #endregion 384 385 #region Helpers 386 protected virtual void AdjustListViewColumnSizes() { 387 if (itemsListView.Items.Count > 0) { 388 for (int i = 0; i < itemsListView.Columns.Count; i++) 389 itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 362 390 } 363 391 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemView.cs
r3235 r3362 29 29 /// Base class for all visual representations. 30 30 /// </summary> 31 [View("Item View")]32 [Content(typeof(Item), false)]33 [Content(typeof(IItem), false)]34 31 public partial class ItemView : AsynchronousContentView { 35 32 public new IItem Content { -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r3327 r3362 81 81 return new ListViewItem[] { listViewItemDictionary[item] }; 82 82 } 83 83 84 84 #region ListView Events 85 85 protected override void itemsListView_DragEnterOver(object sender, DragEventArgs e) { … … 102 102 UpdateListViewItemText(listViewItem); 103 103 } 104 AdjustListViewColumnSizes(); 104 105 } 105 106 } -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs
r3350 r3362 74 74 toolTip.SetToolTip(descriptionTextBox, Content.Description); 75 75 } 76 SetEnable StateOfControls();76 SetEnabledStateOfControls(); 77 77 } 78 78 79 79 protected override void OnReadOnlyChanged() { 80 80 base.OnReadOnlyChanged(); 81 SetEnable StateOfControls();81 SetEnabledStateOfControls(); 82 82 } 83 private void SetEnable StateOfControls() {83 private void SetEnabledStateOfControls() { 84 84 if (Content == null) { 85 85 nameTextBox.Enabled = false; … … 137 137 138 138 protected void descriptionTextBox_DoubleClick(object sender, EventArgs e) { 139 using (TextDialog dialog = new TextDialog("Description of " + Content.Name, Content.Description, !Content.CanChangeDescription)) {139 using (TextDialog dialog = new TextDialog("Description of " + Content.Name, Content.Description, ReadOnly || !Content.CanChangeDescription)) { 140 140 if (dialog.ShowDialog(this) == DialogResult.OK) 141 141 Content.Description = dialog.Content; -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorGraphView.cs
r3361 r3362 87 87 Caption = "Operator Graph"; 88 88 operatorsView.Content = null; 89 operatorsView.Enabled = false;90 89 operatorTreeView.Content = null; 91 operatorTreeView.Enabled = false;92 93 90 if (Content != null) { 94 91 Caption = Content.ItemName + " (" + Content.GetType().Name + ")"; 95 92 operatorsView.Content = Content.Operators; 96 operatorsView.Enabled = true;97 93 MarkInitialOperator(); 98 94 operatorTreeView.Content = Content.InitialOperator; 99 operatorTreeView.Enabled = true;100 95 } 96 SetEnabledStateOfControls(); 101 97 } 98 99 protected override void OnReadOnlyChanged() { 100 base.OnReadOnlyChanged(); 101 SetEnabledStateOfControls(); 102 } 103 104 private void SetEnabledStateOfControls() { 105 operatorsView.Enabled = Content != null; 106 operatorTreeView.Enabled = Content != null; 107 operatorsView.ReadOnly = ReadOnly; 108 operatorTreeView.ReadOnly = ReadOnly; 109 operatorsContextMenuStrip.Enabled = Content != null && !ReadOnly; 110 } 111 102 112 103 113 protected virtual void MarkInitialOperator() { -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r3341 r3362 90 90 if (graphTreeView.Nodes.Count > 0) 91 91 RemoveTreeNode(graphTreeView.Nodes[0]); 92 graphTreeView.Enabled = false;93 92 Caption = "Operator"; 94 93 if (Content != null) { … … 97 96 FillTreeNode(root, Content); 98 97 graphTreeView.Nodes.Add(root); 99 graphTreeView.Enabled = true; 100 } 98 } 99 SetEnabledStateOfControls(); 100 } 101 102 protected override void OnReadOnlyChanged() { 103 base.OnReadOnlyChanged(); 104 SetEnabledStateOfControls(); 105 } 106 107 private void SetEnabledStateOfControls() { 108 graphTreeView.Enabled = Content != null; 101 109 } 102 110 … … 334 342 } 335 343 private void graphTreeView_KeyDown(object sender, KeyEventArgs e) { 336 if ( (e.KeyCode == Keys.Delete) && (graphTreeView.SelectedNode != null)) {344 if (!ReadOnly && (e.KeyCode == Keys.Delete) && (graphTreeView.SelectedNode != null)) { 337 345 IValueParameter<IOperator> opParam = GetOperatorParameterTag(graphTreeView.SelectedNode); 338 346 if (opParam != null) opParam.Value = null; … … 349 357 IOperator op = GetOperatorTag(graphTreeView.SelectedNode); 350 358 if (op != null) { 351 IView view = MainFormManager.CreateDefaultView(op );359 IView view = MainFormManager.CreateDefaultView(op, ReadOnly); 352 360 if (view != null) { 353 361 viewToolStripMenuItem.Enabled = true; … … 368 376 data.SetData("Type", op.GetType()); 369 377 data.SetData("Value", op); 370 if ( opParam == null) {378 if (ReadOnly || (opParam == null)) { 371 379 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 372 380 } else { … … 379 387 e.Effect = DragDropEffects.None; 380 388 Type type = e.Data.GetData("Type") as Type; 381 if ( (type != null) && (typeof(IOperator).IsAssignableFrom(type))) {389 if (!ReadOnly && (type != null) && (typeof(IOperator).IsAssignableFrom(type))) { 382 390 TreeNode node = graphTreeView.GetNodeAt(graphTreeView.PointToClient(new Point(e.X, e.Y))); 383 391 if ((node != null) && !node.IsExpanded) node.Expand(); -
trunk/sources/HeuristicLab.Core.Views/3.3/ParameterizedNamedItemView.cs
r2917 r3362 52 52 protected override void OnContentChanged() { 53 53 base.OnContentChanged(); 54 if (Content == null) { 55 parameterCollectionView.Content = null; 56 } else { 57 parameterCollectionView.Content = Content.Parameters; 58 } 54 parameterCollectionView.Content = Content == null ? null : Content.Parameters; 55 SetEnabledStateOfControls(); 56 } 57 58 protected override void OnReadOnlyChanged() { 59 base.OnReadOnlyChanged(); 60 SetEnabledStateOfControls(); 61 } 62 63 private void SetEnabledStateOfControls() { 64 parameterCollectionView.Enabled = Content != null; 65 parameterCollectionView.ReadOnly = ReadOnly; 59 66 } 60 67 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs
r2917 r3362 79 79 } 80 80 variableCollectionView.Content = null; 81 variableCollectionView.Enabled = false; 82 if (Content == null) { 83 Caption = "Scope"; 84 scopesTreeView.Enabled = false; 85 } else { 81 Caption = "Scope"; 82 if (Content != null) { 86 83 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 87 scopesTreeView.Enabled = true;88 84 scopesTreeView.Nodes.Add(CreateTreeNode(Content)); 89 85 } 86 SetEnabledStateOfControls(); 87 } 88 89 protected override void OnReadOnlyChanged() { 90 base.OnReadOnlyChanged(); 91 SetEnabledStateOfControls(); 92 } 93 94 private void SetEnabledStateOfControls() { 95 scopesTreeView.Enabled = Content != null; 96 variableCollectionView.Enabled = Content != null; 97 variableCollectionView.ReadOnly = ReadOnly; 90 98 } 91 99 … … 161 169 if (scope != null) { 162 170 DataObject data = new DataObject(); 163 data.SetData(" Scope", scope);164 data.SetData(" DragSource", scopesTreeView);165 DoDragDrop(data, DragDropEffects.Copy );171 data.SetData("Type", scope.GetType()); 172 data.SetData("Value", scope); 173 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 166 174 } 167 175 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.cs
r2989 r3362 83 83 Caption = "Variable"; 84 84 viewHost.Content = null; 85 valuePanel.Enabled = false;86 85 } else { 87 86 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 88 valuePanel.Enabled = true;89 87 viewHost.ViewType = null; 90 88 viewHost.Content = Content.Value; 91 89 } 90 SetEnabledStateOfControls(); 91 } 92 93 protected override void OnReadOnlyChanged() { 94 base.OnReadOnlyChanged(); 95 SetEnabledStateOfControls(); 96 } 97 98 private void SetEnabledStateOfControls() { 99 valuePanel.Enabled = Content != null; 100 viewHost.ReadOnly = ReadOnly; 92 101 } 93 102 … … 104 113 e.Effect = DragDropEffects.None; 105 114 Type type = e.Data.GetData("Type") as Type; 106 if ( (type != null) && (typeof(IItem).IsAssignableFrom(type))) {115 if (!ReadOnly && (type != null) && (typeof(IItem).IsAssignableFrom(type))) { 107 116 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 108 117 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs
r2949 r3362 85 85 Caption = "Variable"; 86 86 dataTypeTextBox.Text = "-"; 87 dataTypeTextBox.Enabled = false;88 setValueButton.Enabled = false;89 clearValueButton.Enabled = false;90 valueGroupBox.Enabled = false;91 87 viewHost.Content = null; 92 88 } else { 93 89 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 94 90 dataTypeTextBox.Text = Content.Value == null ? "-" : Content.Value.GetType().GetPrettyName(); 95 dataTypeTextBox.Enabled = Content.Value != null;96 setValueButton.Enabled = true;97 clearValueButton.Enabled = Content.Value != null;98 valueGroupBox.Enabled = true;99 91 viewHost.ViewType = null; 100 92 viewHost.Content = Content.Value; 101 93 } 94 SetEnabledStateOfControls(); 95 } 96 97 protected override void OnReadOnlyChanged() { 98 base.OnReadOnlyChanged(); 99 SetEnabledStateOfControls(); 100 } 101 102 private void SetEnabledStateOfControls() { 103 dataTypeTextBox.Enabled = Content != null && Content.Value != null; 104 setValueButton.Enabled = Content != null && !ReadOnly; 105 clearValueButton.Enabled = Content != null && Content.Value != null && !ReadOnly; 106 valueGroupBox.Enabled = Content != null; 107 viewHost.ReadOnly = ReadOnly; 102 108 } 103 109 … … 130 136 e.Effect = DragDropEffects.None; 131 137 Type type = e.Data.GetData("Type") as Type; 132 if ( (type != null) && (typeof(IItem).IsAssignableFrom(type))) {138 if (!ReadOnly && (type != null) && (typeof(IItem).IsAssignableFrom(type))) { 133 139 if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy; // CTRL key 134 140 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key -
trunk/sources/HeuristicLab.Data.Views/3.3/BoolValueView.cs
r3350 r3362 62 62 valueCheckBox.Checked = Content.Value; 63 63 } 64 SetEnable StateOfControls();64 SetEnabledStateOfControls(); 65 65 } 66 66 67 67 protected override void OnReadOnlyChanged() { 68 68 base.OnReadOnlyChanged(); 69 SetEnable StateOfControls();69 SetEnabledStateOfControls(); 70 70 } 71 private void SetEnable StateOfControls() {71 private void SetEnabledStateOfControls() { 72 72 if (Content == null) valueCheckBox.Enabled = false; 73 73 else valueCheckBox.Enabled = !ReadOnly; -
trunk/sources/HeuristicLab.Data.Views/3.3/ComparisonView.cs
r3350 r3362 63 63 valueComboBox.SelectedItem = Content.Value; 64 64 } 65 SetEnable StateOfControls();65 SetEnabledStateOfControls(); 66 66 } 67 67 protected override void OnReadOnlyChanged() { 68 68 base.OnReadOnlyChanged(); 69 SetEnable StateOfControls();69 SetEnabledStateOfControls(); 70 70 } 71 private void SetEnable StateOfControls() {71 private void SetEnabledStateOfControls() { 72 72 if (Content == null) valueComboBox.Enabled = false; 73 73 else valueComboBox.Enabled = !ReadOnly; -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleArrayView.cs
r3350 r3362 71 71 UpdateData(); 72 72 } 73 SetEnable StateOfControls();73 SetEnabledStateOfControls(); 74 74 } 75 75 protected override void OnReadOnlyChanged() { 76 76 base.OnReadOnlyChanged(); 77 SetEnable StateOfControls();77 SetEnabledStateOfControls(); 78 78 } 79 private void SetEnable StateOfControls() {79 private void SetEnabledStateOfControls() { 80 80 if (Content == null) { 81 81 lengthTextBox.Enabled = false; -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r3350 r3362 90 90 UpdateData(); 91 91 } 92 SetEnable StateOfControls();92 SetEnabledStateOfControls(); 93 93 } 94 94 protected override void OnReadOnlyChanged() { 95 95 base.OnReadOnlyChanged(); 96 SetEnable StateOfControls();97 } 98 private void SetEnable StateOfControls() {96 SetEnabledStateOfControls(); 97 } 98 private void SetEnabledStateOfControls() { 99 99 if (Content == null) { 100 100 rowsTextBox.Enabled = false; -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
r3350 r3362 65 65 valueTextBox.Text = Content.GetValue(); 66 66 } 67 SetEnable StateOfControls();67 SetEnabledStateOfControls(); 68 68 } 69 69 protected override void OnReadOnlyChanged() { 70 70 base.OnReadOnlyChanged(); 71 SetEnable StateOfControls();71 SetEnabledStateOfControls(); 72 72 } 73 private void SetEnable StateOfControls() {73 private void SetEnabledStateOfControls() { 74 74 if (Content == null) valueTextBox.Enabled = false; 75 75 else { -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/GraphVisualizationInfoView.cs
r3355 r3362 76 76 protected override void OnReadOnlyChanged() { 77 77 base.OnReadOnlyChanged(); 78 this.SetEnable StateOfControls();79 } 80 81 private void SetEnable StateOfControls() {78 this.SetEnabledStateOfControls(); 79 } 80 81 private void SetEnabledStateOfControls() { 82 82 DeleteTool deleteTool = (DeleteTool) this.Controller.Tools.Where( t => t.Name == ControllerBase.DeleteToolName).FirstOrDefault(); 83 83 HeuristicLab.Netron.Controller controller = this.Controller as HeuristicLab.Netron.Controller; … … 110 110 this.UpdateLayoutRoot(); 111 111 } 112 this.SetEnable StateOfControls();112 this.SetEnabledStateOfControls(); 113 113 } 114 114 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs
r3361 r3362 73 73 this.graphVisualizationInfoView.RelayoutGraph(); 74 74 75 this.SetEnable StateOfControls();75 this.SetEnabledStateOfControls(); 76 76 } 77 77 78 78 protected override void OnReadOnlyChanged() { 79 79 base.OnReadOnlyChanged(); 80 this.SetEnable StateOfControls();81 } 82 83 private void SetEnable StateOfControls() {80 this.SetEnabledStateOfControls(); 81 } 82 83 private void SetEnabledStateOfControls() { 84 84 if (Content == null) { 85 85 selectButton.Enabled = false; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultView.cs
r3350 r3362 97 97 viewHost.Content = Content.Value; 98 98 } 99 SetEnable StateOfControls();99 SetEnabledStateOfControls(); 100 100 } 101 101 protected override void OnReadOnlyChanged() { 102 102 base.OnReadOnlyChanged(); 103 SetEnable StateOfControls();103 SetEnabledStateOfControls(); 104 104 } 105 private void SetEnable StateOfControls() {105 private void SetEnabledStateOfControls() { 106 106 if (Content == null) { 107 107 dataTypeTextBox.Enabled = false; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3350 r3362 81 81 AddListViewItem(CreateListViewItem(item)); 82 82 } 83 SetEnable StateOfControls();83 SetEnabledStateOfControls(); 84 84 } 85 85 86 86 protected override void OnReadOnlyChanged() { 87 87 base.OnReadOnlyChanged(); 88 SetEnable StateOfControls();89 } 90 private void SetEnable StateOfControls() {88 SetEnabledStateOfControls(); 89 } 90 private void SetEnabledStateOfControls() { 91 91 if (Content == null) { 92 92 itemsListView.Enabled = false; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3350 r3362 75 75 else 76 76 Caption = Content.Name + " (" + Content.GetType().Name + ")"; 77 SetEnable StateOfControls();77 SetEnabledStateOfControls(); 78 78 } 79 79 protected override void OnReadOnlyChanged() { 80 80 base.OnReadOnlyChanged(); 81 SetEnable StateOfControls();81 SetEnabledStateOfControls(); 82 82 } 83 private void SetEnable StateOfControls() {83 private void SetEnabledStateOfControls() { 84 84 if (Content == null) { 85 85 parametersResultsGroupBox.Enabled = false;
Note: See TracChangeset
for help on using the changeset viewer.