Changeset 17843 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration
- Timestamp:
- 02/23/21 16:36:44 (4 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/IArrayJsonItemVM.cs
r17446 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 2 public interface IArrayJsonItemVM : IJsonItemVM { 9 3 bool Resizable { get; set; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/IJsonItemVM.cs
r17473 r17843 1 1 using System; 2 using System.Collections.Generic;3 2 using System.ComponentModel; 4 using System.Linq;5 using System.Text;6 using System.Threading.Tasks;7 3 using System.Windows.Forms; 8 4 9 5 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 public interface IJsonItemVM : INotifyPropertyChanged , IDisposable6 public interface IJsonItemVM : INotifyPropertyChanged 11 7 { 12 8 event Action ItemChanged; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/ILookupJsonItemVM.cs
r17471 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 public interface ILookupJsonItemVM : IJsonItemVM { 9 string ActualName { get; set; } 10 } 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 2 public interface ILookupJsonItemVM : IJsonItemVM { } 11 3 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/IMatrixJsonItemVM.cs
r17471 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 1 using System.Collections.Generic; 6 2 7 3 namespace HeuristicLab.JsonInterface.OptimizerIntegration { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Interfaces/IValueLookupJsonItemVM.cs
r17471 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 8 2 public interface IValueLookupJsonItemVM : ILookupJsonItemVM { 9 3 IJsonItem JsonItemReference { get; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ArrayValueVM.cs
r17828 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.ComponentModel;4 using System.Linq;5 using System.Text;6 using System.Threading.Tasks;7 2 using System.Windows.Forms; 8 3 … … 17 12 public ArrayValueVM() { } 18 13 19 public abstract T[] Value { get; set; }20 14 public bool Resizable { 21 15 get => Item.Resizable; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ConcreteRestrictedJsonItemVM.cs
r17828 r17843 1 using System; 2 using System.Collections.Generic; 1 using System.Collections.Generic; 3 2 using System.Linq; 4 using System.Text;5 using System.Threading.Tasks;6 3 using System.Windows.Forms; 7 4 … … 17 14 public override UserControl Control { 18 15 get { 19 var control = new ConcreteItemsRestrictor(); 20 control.Init(Item.ConcreteRestrictedItems); 16 var control = ConcreteItemsRestrictor.Create(Item.ConcreteRestrictedItems); 21 17 control.OnChecked += AddComboOption; 22 18 control.OnUnchecked += RemoveComboOption; 23 19 return control; 24 }25 }26 27 public V Value {28 get => Item.Value;29 set {30 Item.Value = value;31 OnPropertyChange(this, nameof(Value));32 20 } 33 21 } … … 40 28 41 29 if (!RangeContainsValue()) { 42 Value = GetDefaultValue();30 Item.Value = GetDefaultValue(); 43 31 44 32 //if no elements exists -> deselect item 45 33 if (Range.Count() == 0) 46 34 base.Selected = false; 47 48 OnPropertyChange(this, nameof(Value));49 35 } 50 36 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/DoubleVMs.cs
r17828 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 7 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 2 public class DoubleRangeVM : RangeVM<double, DoubleRangeJsonItem> { 10 3 protected override double MinTypeValue => double.MinValue; … … 15 8 protected override double MinTypeValue => double.MinValue; 16 9 protected override double MaxTypeValue => double.MaxValue; 17 public override double[] Value {18 get => Item.Value;19 set {20 Item.Value = value;21 OnPropertyChange(this, nameof(Value));22 }23 }24 10 } 25 11 26 12 public class DoubleMatrixValueVM : MatrixValueVM<double, DoubleMatrixJsonItem> { 27 public override double[][] Value {28 get => Item.Value;29 set {30 Item.Value = value;31 OnPropertyChange(this, nameof(Value));32 }33 }34 13 protected override double MinTypeValue => double.MinValue; 35 14 protected override double MaxTypeValue => double.MaxValue; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/IntVMs.cs
r17828 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 7 8 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 1 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 2 public class IntArrayValueVM : ArrayValueVM<int, IntArrayJsonItem> { 10 3 protected override int MinTypeValue => int.MinValue; 11 4 protected override int MaxTypeValue => int.MaxValue; 12 13 public override int[] Value {14 get => Item.Value;15 set {16 Item.Value = value;17 OnPropertyChange(this, nameof(Value));18 }19 }20 5 } 21 6 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/JsonItemVMBase.cs
r17828 r17843 1 1 using System; 2 using System.Collections.Generic;3 2 using System.ComponentModel; 4 3 using System.Drawing; 5 using System.Linq;6 using System.Text;7 using System.Threading.Tasks;8 4 using System.Windows.Forms; 9 5 … … 21 17 get => item; 22 18 set { 23 item?.LoosenPath();24 19 item = value; 25 item.FixatePath();26 20 ItemChanged?.Invoke(); 27 21 } … … 65 59 public event Action SelectedChanged; 66 60 67 68 61 protected void OnPropertyChange(object sender, string propertyName) { 69 62 // Make a temporary copy of the event to avoid possibility of … … 75 68 tmp?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 76 69 } 77 78 #region IDisposable Support79 private bool disposedValue = false; // To detect redundant calls80 81 protected virtual void Dispose(bool disposing) {82 if (!disposedValue) {83 if (disposing) {84 item.LoosenPath();85 item = null;86 }87 disposedValue = true;88 }89 }90 91 // This code added to correctly implement the disposable pattern.92 public void Dispose() {93 // Do not change this code. Put cleanup code in Dispose(bool disposing) above.94 Dispose(true);95 }96 #endregion97 70 } 98 71 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/LookupJsonItemVM.cs
r17828 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Forms; 1 using System.Windows.Forms; 7 2 8 3 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 9 4 public class LookupJsonItemVM : JsonItemVMBase<LookupJsonItem>, ILookupJsonItemVM { 10 5 public override UserControl Control => null; 11 public string ActualName {12 get => Item.ActualName;13 set {14 Item.ActualName = value;15 OnPropertyChange(this, nameof(ActualName));16 }17 }18 6 } 19 7 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/MatrixValueVM.cs
r17828 r17843 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.ComponentModel;4 using System.Linq;5 using System.Text;6 using System.Threading.Tasks;7 3 using System.Windows.Forms; 8 4 … … 16 12 public override UserControl Control => CompoundControl.Create(base.Control, MatrixJsonItemControl.Create(this)); 17 13 18 public abstract T[][] Value { get; set; }19 14 public bool RowsResizable { 20 15 get => Item.RowsResizable; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangeVM.cs
r17519 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.ComponentModel;4 using System.Linq;5 using System.Text;6 using System.Threading.Tasks;7 using System.Windows.Forms;8 9 2 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 10 11 3 public abstract class RangeVM<T, JsonItemType> : RangedValueBaseVM<T, JsonItemType> 12 4 where T : IComparable 13 5 where JsonItemType : class, IRangedJsonItem<T> 14 { 15 16 public T MinValue { 17 get => Item.MinValue; 18 set { 19 Item.MinValue = value; 20 OnPropertyChange(this, nameof(MinValue)); 21 } 22 } 23 24 public T MaxValue { 25 get => Item.MaxValue; 26 set { 27 Item.MaxValue = value; 28 OnPropertyChange(this, nameof(MaxValue)); 29 } 30 } 31 } 6 { } 32 7 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/RangedValueBaseVM.cs
r17828 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using System.Windows.Forms; 7 3 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ResultItemVM.cs
r17834 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using System.Windows.Forms; 7 3 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/SingleValueVM.cs
r17828 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.ComponentModel;4 using System.Linq;5 using System.Text;6 using System.Threading.Tasks;7 2 using System.Windows.Forms; 8 3 … … 10 5 11 6 public class BoolValueVM : JsonItemVMBase<BoolJsonItem> { 12 13 public bool Value {14 get => Item.Value;15 set {16 Item.Value = value;17 OnPropertyChange(this, nameof(Value));18 }19 }20 21 7 public override UserControl Control => null; 22 8 } … … 25 11 where T : IComparable 26 12 where JsonItemType : class, IIntervalRestrictedJsonItem<T>, IValueJsonItem<T> 27 { 28 29 public T Value { 30 get => Item.Value; 31 set { 32 Item.Value = value; 33 OnPropertyChange(this, nameof(Value)); 34 } 35 } 36 } 13 { } 37 14 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/StringValueVM.cs
r17828 r17843 2 2 3 3 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 4 5 4 public class StringValueVM : ConcreteRestrictedJsonItemVM<StringJsonItem, string, string> { 6 5 protected override string GetDefaultValue() => Range.FirstOrDefault(); 7 8 protected override bool RangeContainsValue() => Range.Contains(Value); 6 protected override bool RangeContainsValue() => Range.Contains(Item.Value); 9 7 } 10 8 11 9 public class StringArrayVM : ConcreteRestrictedJsonItemVM<StringArrayJsonItem, string, string[]> { 12 10 protected override string[] GetDefaultValue() => Range.ToArray(); 13 14 protected override bool RangeContainsValue() => Value.All(x => Range.Any(y => x == y)); 11 protected override bool RangeContainsValue() => Item.Value.All(x => Range.Any(y => x == y)); 15 12 } 16 13 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/ViewModels/ValueLookupJsonItemVM.cs
r17477 r17843 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 using System.Threading.Tasks;6 2 using System.Windows.Forms; 7 3 … … 9 5 public class ValueLookupJsonItemVM : LookupJsonItemVM, IValueLookupJsonItemVM { 10 6 public override Type TargetedJsonItemType => typeof(ValueLookupJsonItem); 11 public override UserControl Control => new ValueLookupJsonItemControl(this);7 public override UserControl Control => ValueLookupJsonItemControl.Create(this); 12 8 public IJsonItem JsonItemReference => ((IValueLookupJsonItem)Item).ActualValue; 13 9 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ArrayJsonItemControl.cs
r17829 r17843 4 4 public partial class ArrayJsonItemControl : UserControl { 5 5 6 p ublicArrayJsonItemControl() {6 private ArrayJsonItemControl() { 7 7 InitializeComponent(); 8 8 } 9 9 10 public static ArrayJsonItemControl Create(IJsonItemVM vm) { 11 var control = new ArrayJsonItemControl(); 12 control.checkBoxResizable.DataBindings.Add("Checked", vm, nameof(IArrayJsonItemVM.Resizable)); 13 return control; 10 protected ArrayJsonItemControl(IJsonItemVM vm) { 11 InitializeComponent(); 12 checkBoxResizable.DataBindings.Add("Checked", vm, nameof(IArrayJsonItemVM.Resizable)); 14 13 } 14 15 public static ArrayJsonItemControl Create(IJsonItemVM vm) => new ArrayJsonItemControl(vm); 15 16 } 16 17 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/CompoundControl.cs
r17829 r17843 32 32 } 33 33 } 34 public CompoundControl() { 34 35 protected CompoundControl() { 35 36 InitializeComponent(); 36 37 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ConcreteItemsRestrictor.cs
r17829 r17843 15 15 public event Action<object> OnUnchecked; 16 16 17 p ublicConcreteItemsRestrictor() {17 protected ConcreteItemsRestrictor() { 18 18 InitializeComponent(); 19 19 } 20 20 21 public void Init<T>(IEnumerable<T> objs) { 22 if(objs != null) { 23 foreach(var obj in objs) { 21 public static ConcreteItemsRestrictor Create<T>(IEnumerable<T> objs) { 22 ConcreteItemsRestrictor ctrl = new ConcreteItemsRestrictor(); 23 ctrl.Init<T>(objs); 24 return ctrl; 25 } 26 27 protected void Init<T>(IEnumerable<T> objs) { 28 if(objs != null) 29 foreach(var obj in objs) 24 30 SetupOption(obj); 25 }26 }27 31 } 28 32 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17828 r17843 116 116 VMs.Add(vm); 117 117 Node2VM.Add(node, vm); 118 UserControl control = new JsonItemBaseControl(vm, vm.Control);118 UserControl control = JsonItemBaseControl.Create(vm, vm.Control); 119 119 Node2Control.Add(node, control); 120 120 return vm; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/JsonItemBaseControl.cs
r17829 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Drawing; 5 using System.Data; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 1 using System.ComponentModel; 9 2 using System.Windows.Forms; 10 3 … … 16 9 InitializeComponent(); 17 10 } 18 19 p ublic JsonItemBaseControl(IJsonItemVM vm) {11 12 protected JsonItemBaseControl(IJsonItemVM vm, UserControl control) { 20 13 InitializeComponent(); 21 14 VM = vm; 22 Init(); 23 } 24 25 public JsonItemBaseControl(IJsonItemVM vm, UserControl control) { 26 InitializeComponent(); 27 VM = vm; 28 if(control != null) { 15 if (control != null) { 29 16 control.Margin = new Padding() { All = 0 }; 30 17 tableLayoutPanel1.Controls.Add(control, 0, 1); 31 18 control.Dock = DockStyle.Fill; 32 19 } 33 Init();34 }35 36 private void Init() {37 20 textBoxName.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Name)); 38 21 textBoxDescription.DataBindings.Add("Text", VM, nameof(IJsonItemVM.Description)); … … 47 30 } 48 31 } 32 33 public static JsonItemBaseControl Create(IJsonItemVM vm, UserControl control) => new JsonItemBaseControl(vm, control); 49 34 } 50 35 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/MatrixJsonItemControl.cs
r17829 r17843 3 3 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 4 4 public partial class MatrixJsonItemControl : UserControl { 5 p ublicMatrixJsonItemControl() {5 private MatrixJsonItemControl() { 6 6 InitializeComponent(); 7 7 } 8 8 9 public static MatrixJsonItemControl Create(IJsonItemVM vm) { 10 var control = new MatrixJsonItemControl(); 11 control.checkBoxRowsResizable.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.RowsResizable)); 12 control.checkBoxColumnsResizable .DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable)); 13 return control; 9 protected MatrixJsonItemControl(IJsonItemVM vm) { 10 InitializeComponent(); 11 checkBoxRowsResizable.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.RowsResizable)); 12 checkBoxColumnsResizable.DataBindings.Add("Checked", vm, nameof(IMatrixJsonItemVM.ColumnsResizable)); 14 13 } 14 15 public static MatrixJsonItemControl Create(IJsonItemVM vm) => new MatrixJsonItemControl(vm); 15 16 } 16 17 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/NumericRangeControl.cs
r17829 r17843 16 16 public CheckBox EnableMinRange { get; set; } 17 17 public CheckBox EnableMaxRange { get; set; } 18 public NumericRangeControl() { 18 19 private NumericRangeControl() { 19 20 InitializeComponent(); 21 Init(); 22 } 23 24 protected NumericRangeControl(IJsonItemVM vm) { 25 InitializeComponent(); 26 Init(); 27 TBMinRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange)); 28 TBMaxRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange)); 29 EnableMinRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange), 30 false, DataSourceUpdateMode.OnPropertyChanged); 31 EnableMaxRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange), 32 false, DataSourceUpdateMode.OnPropertyChanged); 33 } 34 35 36 private void Init() { 20 37 TBMinRange = textBoxFrom; 21 38 TBMaxRange = textBoxTo; … … 52 69 } 53 70 54 public static UserControl Create(IJsonItemVM vm) { 55 NumericRangeControl numericRangeControl = new NumericRangeControl(); 56 numericRangeControl.TBMinRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MinRange)); 57 numericRangeControl.TBMaxRange.DataBindings.Add("Text", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.MaxRange)); 58 numericRangeControl.EnableMinRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMinRange), 59 false, DataSourceUpdateMode.OnPropertyChanged); 60 numericRangeControl.EnableMaxRange.DataBindings.Add("Checked", vm, nameof(RangedValueBaseVM<int, IntJsonItem>.EnableMaxRange), 61 false, DataSourceUpdateMode.OnPropertyChanged); 62 return numericRangeControl; 63 } 71 public static UserControl Create(IJsonItemVM vm) => new NumericRangeControl(vm); 64 72 } 65 73 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ResultJsonItemControl.cs
r17834 r17843 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 1 using System.Linq; 9 2 using System.Windows.Forms; 10 3 11 4 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 12 5 public partial class ResultJsonItemControl : UserControl { 13 p ublicResultJsonItemControl() {6 private ResultJsonItemControl() { 14 7 InitializeComponent(); 15 8 } 16 9 17 p ublic static ResultJsonItemControl Create(ResultItemVM vm) {18 var control = new ResultJsonItemControl();10 protected ResultJsonItemControl(ResultItemVM vm) { 11 InitializeComponent(); 19 12 var formatters = ResultFormatter.ForType(vm.Item.ValueType).ToList(); 20 co ntrol.comboBoxFormatter.DataSource = formatters;21 co ntrol.comboBoxFormatter.DisplayMember = "Name";22 13 comboBoxFormatter.DataSource = formatters; 14 comboBoxFormatter.DisplayMember = "Name"; 15 23 16 // set action to override the ResultFormatterType property for changing the selected value 24 control.comboBoxFormatter.SelectedValueChanged += (s, e) => vm.ResultFormatterType = control.comboBoxFormatter.SelectedValue.GetType().FullName; 25 control.comboBoxFormatter.SelectedItem = formatters.Last(); 17 comboBoxFormatter.SelectedValueChanged += (s, e) => vm.ResultFormatterType = comboBoxFormatter.SelectedValue.GetType().FullName; 18 comboBoxFormatter.SelectedItem = formatters.Last(); 19 } 26 20 27 return control; 28 } 21 public static ResultJsonItemControl Create(ResultItemVM vm) => new ResultJsonItemControl(vm); 29 22 } 30 23 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ValueLookupJsonItemControl.cs
r17828 r17843 12 12 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 13 13 public partial class ValueLookupJsonItemControl : UserControl { 14 private static IDictionary<Type, Type> JI2VM { get; set; }15 14 16 public ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) { 15 private static IDictionary<Type, Type> ji2vm = null; 16 private static IDictionary<Type, Type> JI2VM { 17 get { 18 if (ji2vm == null) { 19 ji2vm = new Dictionary<Type, Type>(); 20 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 21 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 22 ji2vm.Add(vm.TargetedJsonItemType, vmType); 23 } 24 } 25 return ji2vm; 26 } 27 } 28 29 private ValueLookupJsonItemControl() { 17 30 InitializeComponent(); 18 InitCache(); 31 } 32 33 protected ValueLookupJsonItemControl(IValueLookupJsonItemVM vm) { 34 InitializeComponent(); 19 35 if (vm.JsonItemReference != null && JI2VM.TryGetValue(vm.JsonItemReference.GetType(), out Type vmType)) { 20 36 IJsonItemVM tmp = (IJsonItemVM)Activator.CreateInstance(vmType); … … 29 45 } 30 46 31 private void InitCache() { 32 if(JI2VM == null) { 33 JI2VM = new Dictionary<Type, Type>(); 34 foreach (var vmType in ApplicationManager.Manager.GetTypes(typeof(IJsonItemVM))) { 35 IJsonItemVM vm = (IJsonItemVM)Activator.CreateInstance(vmType); 36 JI2VM.Add(vm.TargetedJsonItemType, vmType); 37 } 38 } 39 } 47 public static ValueLookupJsonItemControl Create(IValueLookupJsonItemVM vm) => new ValueLookupJsonItemControl(vm); 40 48 } 41 49 }
Note: See TracChangeset
for help on using the changeset viewer.