// TODO //public VirtualDesktopConfiguration(IVirtualDesktop targetDesktop, IConfigurationFactory factory) //{ // BindToTarget(targetDesktop, factory); // // should take values from desktop // UpdateFromTarget(); //} public void BindToTarget(IVirtualDesktop value, IConfigurationFactory factory) { _propertyChangedBinding?.Unbind(); TargetDesktop = value; _configurationFactory = factory; if (value == null) { _backgroundPathSetter = path => ThrowWhenUnbound(nameof(BackgroundPath)); _fitSetter = fit => ThrowWhenUnbound(nameof(Fit)); return; } _backgroundPathSetter = SetBackgroundPath; _fitSetter = SetFit; _propertyChangedBinding = factory.Bind(UpdateFromTarget, value); var updateTargetBackground = true; // TODO this should have tests for it causing a return if (!_backgroundPath.HasValue) { _backgroundPath = value.Background.Path; updateTargetBackground = false; } // TODO be sure to fully test that this returns if (_fit.Equals(default(Fit))) { _fit = value.Background.Fit; updateTargetBackground = false; } if (!updateTargetBackground) { return; } value.Background = factory.BackgroundFrom(_backgroundPath, _fit); }