Changeset 17694
- Timestamp:
- 07/23/20 14:18:19 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ReferenceParameter.cs
r17594 r17694 110 110 } 111 111 112 // TODO: Remove 113 //protected void ChangeReference(IValueParameter newReference, bool retainData) { 114 // IItem oldValue = Value; 115 // var oldRef = ReferencedParameter; 116 // oldRef.ToStringChanged -= (o, e) => OnToStringChanged(); 117 // oldRef.ItemImageChanged -= (o, e) => OnItemImageChanged(); 118 // if (valueChanged != null) oldRef.ValueChanged -= OnReferencedParameterValueChanged; 119 // newReference.ToStringChanged += (o, e) => OnToStringChanged(); 120 // newReference.ItemImageChanged += (o, e) => OnItemImageChanged(); 121 // if (valueChanged != null) newReference.ValueChanged += OnReferencedParameterValueChanged; 122 // ReferencedParameter = newReference; 123 // oldRef.Value = (IItem)oldValue.Clone(); // This is problematic, e.g. FixedValueParameter !!! But necessary, otherwise the value holds reference to the old parameter 124 // if (retainData) Value = oldValue; 125 //} 126 112 127 113 128 #region event handlers … … 128 143 private void OnReferencedParameterValueChanged(object sender, EventArgs args) { 129 144 valueChanged?.Invoke(this, args); // note "this", not "sender" as sender would be the referenced parameter 145 OnItemImageChanged(); 146 OnToStringChanged(); 130 147 } 131 148 … … 166 183 return new ReferenceParameter<T>(this, cloner); 167 184 } 185 186 // TODO: Remove 187 //public void ChangeReference(IValueParameter<T> newParameter, bool retainData) { 188 // base.ChangeReference(newParameter, retainData); 189 //} 168 190 } 169 191 … … 193 215 return new ReferenceParameter<T, U>(this, cloner); 194 216 } 217 218 // TODO: Remove 219 //public void ChangeReference(IValueParameter<U> newParameter, bool retainData) { 220 // base.ChangeReference(newParameter, retainData); 221 //} 195 222 } 196 223 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
r17680 r17694 21 21 22 22 using System; 23 using System.ComponentModel;24 23 using System.Drawing; 25 24 using System.Linq; … … 187 186 protected override void OnEncodingChanged() { 188 187 base.OnEncodingChanged(); 188 var jobData = (ItemList<Job>)JobData.Clone(); 189 var jobs = Jobs; 190 var resources = Resources; 189 191 Parameters.Remove(JobDataParameter); 190 192 Parameters.Add(JobDataParameter = new ReferenceParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", Encoding.JobDataParameter)); … … 193 195 Parameters.Remove(ResourcesParameter); 194 196 Parameters.Add(ResourcesParameter = new ReferenceParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", Encoding.ResourcesParameter)); 197 JobData = jobData; 198 Jobs = jobs; 199 Resources = resources; 200 201 RegisterEventHandlers(); 195 202 } 196 203 197 204 198 205 private void RegisterEventHandlers() { 199 JobDataParameter.ValueChanged += JobDataParameterOnValueChanged; 200 JobData.PropertyChanged += JobDataOnPropertyChanged; 201 } 202 203 private void JobDataParameterOnValueChanged(object sender, EventArgs e) { 204 JobData.PropertyChanged += JobDataOnPropertyChanged; 206 ItemListParameterChangeHandler<Job>.Create(JobDataParameter, JobDataOnChanged); 207 } 208 209 private void JobDataOnChanged() { 205 210 Jobs = JobData.Count; 206 } 207 208 private void JobDataOnPropertyChanged(object sender, PropertyChangedEventArgs e) { 209 if (e.PropertyName == nameof(JobData.Count)) { 210 Jobs = JobData.Count; 211 } 212 } 211 Resources = JobData.SelectMany(x => x.Tasks).Select(x => x.ResourceNr).Distinct().Count(); 212 } 213 213 214 214 215 #region Problem Instance Handling
Note: See TracChangeset
for help on using the changeset viewer.