protected override void OnModelPropertyChanged(string propertyName) { if (propertyName == "Model") { OnConfigChanged(this, EventArgs.Empty); } else if (propertyName == "Presentation") { if (myPresentation == Model.Presentation) { return; } myPresentation = Model.Presentation; myPresentation.GetModule <INodeMaskModule>().AutoHideAllNodesForShowMasks = true; if (myPresentation.Graph.Nodes.Count() > DotToolLayoutEngine.FastRenderingNodeCountLimit) { new ChangeClusterFolding(myPresentation) .FoldUnfoldAllClusters(); } var graphLayoutModule = myPresentation.GetModule <IGraphLayoutModule>(); graphLayoutModule.Algorithm = LayoutAlgorithm; PropertyBinding.Bind(() => LayoutAlgorithm, () => graphLayoutModule.Algorithm); RaisePropertyChanged(nameof(IsEnabled)); } }
public void PropertyOwnersMarkedForGC_BindingReleased() { WeakReference <ViewModel1> wr1 = null; WeakReference <ViewModel2> wr2 = null; new Action(() => { var vm1 = new ViewModel1(); var vm2 = new ViewModel2(); wr1 = new WeakReference <ViewModel1>(vm1); wr2 = new WeakReference <ViewModel2>(vm2); PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay); })(); EnforceGC(); { ViewModel1 vm1; Assert.That(wr1.TryGetTarget(out vm1), Is.False); ViewModel2 vm2; Assert.That(wr2.TryGetTarget(out vm2), Is.False); } }
protected override void OnModelPropertyChanged(string propertyName) { if (propertyName == "Model") { OnConfigChanged(this, EventArgs.Empty); } else if (propertyName == "Presentation") { if (myPresentation == Model.Presentation) { return; } myPresentation = Model.Presentation; if (myPresentation.Graph.Nodes.Count() > DotToolLayoutEngine.FastRenderingNodeCountLimit) { myPresentation.ToogleFoldingOfVisibleClusters(); } var graphLayoutModule = myPresentation.GetModule <IGraphLayoutModule>(); graphLayoutModule.Algorithm = LayoutAlgorithm; PropertyBinding.Bind(() => LayoutAlgorithm, () => graphLayoutModule.Algorithm); RaisePropertyChanged(nameof(IsEnabled)); } }
public void Bind(object Object, string Property) { UnBind(); _value.Bind(Object, Property); // so the value isn't updated at this time we unsubscribe from the event temporarily CheckedChanged -= Check2Change; Checked = _value.Value; CheckedChanged += Check2Change; }
public void OneWayToSourceBinding_ChangesOnTargetNotSyncedtoSource() { var vm1 = new ViewModel1(); var vm2 = new ViewModel2(); PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.OneWayToSource); vm1.PrimaryValue = 42; Assert.That(vm2.SecondaryValue, Is.Not.EqualTo(42)); }
public void TwoWayBinding_ChangesOnEitherEndSyncedToTheOtherOne() { var vm1 = new ViewModel1(); var vm2 = new ViewModel2(); PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay); vm1.PrimaryValue = 42; Assert.That(vm2.SecondaryValue, Is.EqualTo(42)); vm2.SecondaryValue = 24; Assert.That(vm1.PrimaryValue, Is.EqualTo(24)); }
public void PropertyOwnersStillAlive_BindingsSurvivesGC() { var vm1 = new ViewModel1(); var vm2 = new ViewModel2(); PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue, BindingMode.TwoWay); EnforceGC(); { // lets see whether binding still works vm1.PrimaryValue = 42; Assert.That(vm2.SecondaryValue, Is.EqualTo(42)); } }
public void Unbind_RemovesBindingAgain() { var vm1 = new ViewModel1(); var vm2 = new ViewModel2(); var id = PropertyBinding.Bind(() => vm1.PrimaryValue, () => vm2.SecondaryValue); vm2.SecondaryValue = 42; Assert.That(vm1.PrimaryValue, Is.EqualTo(42)); PropertyBinding.Unbind(id); vm2.SecondaryValue = 2525; Assert.That(vm1.PrimaryValue, Is.EqualTo(42)); }
public void Bind(object Object, string PropertyName) { _value.Bind(Object, PropertyName); BackColor = _value.Value; ForeColor = ContrastColor(BackColor); }