Changeset 11474 for trunk/sources/HeuristicLab.Scripting.Views
- Timestamp:
- 10/16/14 18:34:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs
r11472 r11474 202 202 break; 203 203 case Keys.F2: 204 var focusedItem = variableListView.FocusedItem; 205 if (variableListView.LabelEdit && focusedItem.Selected) 206 focusedItem.BeginEdit(); 204 if (variableListView.SelectedItems.Count != 1) return; 205 var selectedItem = variableListView.SelectedItems[0]; 206 if (variableListView.LabelEdit) 207 selectedItem.BeginEdit(); 207 208 break; 208 209 case Keys.A: … … 249 250 if (e.Effect == DragDropEffects.Copy) { 250 251 object item = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 251 var cloner = new Cloner();252 252 var dc = item as IDeepCloneable; 253 if (dc != null) item = cloner.Clone(dc); 254 var namedItem = item as INamedItem; 255 bool nameValid = namedItem != null && !string.IsNullOrEmpty(namedItem.Name); 256 string name = nameValid ? GenerateNewVariableName(namedItem.Name, false) : GenerateNewVariableName(); 253 if (dc != null) item = dc.Clone(); 254 255 string name; 256 bool editLabel; 257 if (sender == variableListView) { 258 name = GenerateNewVariableName(variableListView.FocusedItem.Text, false); 259 editLabel = true; 260 } else { 261 var namedItem = item as INamedItem; 262 editLabel = namedItem == null || string.IsNullOrEmpty(namedItem.Name); 263 name = editLabel ? GenerateNewVariableName() : GenerateNewVariableName(namedItem.Name, false); 264 } 265 257 266 Content.Add(name, item); 258 267 var listViewItem = variableListView.FindItemWithText(name); 259 if (!nameValid) listViewItem.BeginEdit(); 268 variableListView.SelectedItems.Clear(); 269 if (editLabel) listViewItem.BeginEdit(); 260 270 } 261 271 } … … 280 290 protected virtual void addButton_Click(object sender, EventArgs e) { 281 291 object newVar = CreateItem(); 282 if (newVar != null) { 283 string name = GenerateNewVariableName(); 284 Content.Add(name, newVar); 285 var item = variableListView.FindItemWithText(name); 286 item.BeginEdit(); 287 } 292 if (newVar == null) return; 293 294 var namedItem = newVar as INamedItem; 295 bool editLabel = namedItem == null || string.IsNullOrEmpty(namedItem.Name); 296 string name = editLabel ? GenerateNewVariableName() : GenerateNewVariableName(namedItem.Name, false); 297 Content.Add(name, newVar); 298 299 var item = variableListView.FindItemWithText(name); 300 item.BeginEdit(); 288 301 } 289 302 protected virtual void sortAscendingButton_Click(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.