- Timestamp:
- 02/26/15 18:10:28 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Scripting.Views/3.3/VariableStoreView.cs
r12012 r12088 160 160 sortAscendingButton.Enabled = variableListView.Items.Count > 1; 161 161 sortDescendingButton.Enabled = variableListView.Items.Count > 1; 162 var item = variable.Value as IItem;163 if (item != null) item.ToStringChanged += item_ToStringChanged;164 162 } 165 163 … … 174 172 sortAscendingButton.Enabled = variableListView.Items.Count > 1; 175 173 sortDescendingButton.Enabled = variableListView.Items.Count > 1; 176 var item = variable.Value as IItem;177 if (item != null) item.ToStringChanged -= item_ToStringChanged;178 174 } 179 175 … … 338 334 #region Content Events 339 335 protected virtual void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, object>> e) { 340 if (InvokeRequired) 341 Invoke(new CollectionItemsChangedEventHandler<KeyValuePair<string, object>>(Content_ItemsAdded), sender, e); 342 else { 343 foreach (var item in e.Items) 344 AddVariable(item); 345 AdjustListViewColumnSizes(); 346 } 336 var variables = e.Items; 337 foreach (var variable in variables) { 338 var item = variable.Value as IItem; 339 if (item != null) item.ToStringChanged += item_ToStringChanged; 340 } 341 InvokeVariableAction(AddVariable, variables); 347 342 } 348 343 349 344 protected virtual void Content_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, object>> e) { 350 if (InvokeRequired) 351 Invoke(new CollectionItemsChangedEventHandler<KeyValuePair<string, object>>(Content_ItemsReplaced), sender, e); 352 else { 353 foreach (var item in e.Items) 354 UpdateVariable(item); 355 AdjustListViewColumnSizes(); 356 } 345 var oldVariables = e.OldItems; 346 foreach (var variable in oldVariables) { 347 var item = variable.Value as IItem; 348 if (item != null) item.ToStringChanged -= item_ToStringChanged; 349 } 350 var newVariables = e.Items; 351 foreach (var variable in newVariables) { 352 var item = variable.Value as IItem; 353 if (item != null) item.ToStringChanged += item_ToStringChanged; 354 } 355 InvokeVariableAction(UpdateVariable, e.Items); 357 356 } 358 357 359 358 protected virtual void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, object>> e) { 360 if (InvokeRequired)361 Invoke(new CollectionItemsChangedEventHandler<KeyValuePair<string, object>>(Content_ItemsRemoved), sender, e);362 else {363 foreach (var item in e.Items)364 RemoveVariable(item);365 AdjustListViewColumnSizes();366 367 } 359 var variables = e.Items; 360 foreach (var variable in variables) { 361 var item = variable.Value as IItem; 362 if (item != null) item.ToStringChanged -= item_ToStringChanged; 363 } 364 InvokeVariableAction(RemoveVariable, variables); 365 } 366 368 367 protected virtual void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, object>> e) { 369 368 if (InvokeRequired) … … 490 489 return serializable; 491 490 } 491 492 private void InvokeVariableAction(Action<KeyValuePair<string, object>> action, IEnumerable<KeyValuePair<string, object>> variables) { 493 if (InvokeRequired) 494 Invoke((Action<Action<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>>)InvokeVariableAction, action, variables); 495 else { 496 foreach (var variable in variables) 497 action(variable); 498 AdjustListViewColumnSizes(); 499 } 500 } 492 501 #endregion 493 502 }
Note: See TracChangeset
for help on using the changeset viewer.