public NodeDependencyAggregate(IPoint location, IObservableValue <bool> errorState, IObservableValue <string> name, IObjectFactory factory) { Location = location; ErrorState = errorState; Name = name; Factory = factory; }
public void Deconstruct(out IPoint Location, out IObservableValue <bool> ErrorState, out IObservableValue <string> Name, out IObjectFactory Factory) { Location = this.Location; ErrorState = this.ErrorState; Name = this.Name; Factory = this.Factory; }
public LaminarValue(ITypeDefinitionProvider provider, IObservableValue <bool> isUserEditable, IObjectFactory factory) : base() { SetTypeDefinitionProvider(provider); IsUserEditable = isUserEditable; _factory = factory; OnChange += (o, val) => NotifyPropertyChanged(nameof(TrueValue)); }
public BindingExpression(DependencyObject target, DependencyProperty targetProperty, PropertyPath path, object source = null, RelativeSource relativeSource = null, string elementName = null, BindingMode mode = BindingMode.Default, UpdateSourceTrigger updateSourceTrigger = UpdateSourceTrigger.Default, IValueConverter converter = null, object converterParameter = null, object fallbackValue = null, object targetNullValue = null) { this.Target = target; this.TargetProperty = targetProperty; this.Path = path; this.Source = source; this.RelativeSource = relativeSource; this.ElementName = elementName; this.Mode = mode; this.UpdateSourceTrigger = updateSourceTrigger; this.Converter = converter; this.ConverterParameter = converterParameter; this.FallbackValue = fallbackValue; this.TargetNullValue = targetNullValue; Status = BindingStatus.Inactive; disableSourceUpdate = new ReentrancyLock(); disableTargetUpdate = new ReentrancyLock(); targetValue = new ObservableValue(Target.GetValue(TargetProperty)); targetValue.ValueChanged += OnTargetValueChanged; BindingMode resolvedBindingMode = Mode == BindingMode.Default ? GetDefaultBindingMode(Target, TargetProperty) : Mode; isSourceUpdateMode = resolvedBindingMode == BindingMode.TwoWay || resolvedBindingMode == BindingMode.OneWayToSource; isTargetUpdateMode = resolvedBindingMode == BindingMode.TwoWay || resolvedBindingMode == BindingMode.OneWay; sourceObserver = CreateSourceObserver(Target, Source, RelativeSource, ElementName); sourceExpression = new ObservableExpression(sourceObserver, Path ?? PropertyPath.Empty); // try to update the target (or the source on OneWayToSource) if (isTargetUpdateMode) { sourceExpression.ValueChanged += (sender, oldValue, newValue) => UpdateTargetOnSourceChanged(); UpdateTargetOnSourceChanged(); } else if (isSourceUpdateMode) { sourceExpression.ValueChanged += (sender, oldValue, newValue) => { if (Status == BindingStatus.UpdateSourceError && sourceExpression.Value != ObservableValue.UnsetValue && !disableTargetUpdate) { // source was connected UpdateSourceOnTargetChanged(); } }; UpdateSourceOnTargetChanged(); } if (UpdateSourceTrigger == UpdateSourceTrigger.LostFocus && isSourceUpdateMode && Target is UIElement) { ((UIElement)Target).LostFocus += OnLostFocus; } }
public void Deconstruct(out IPoint Location, out IObservableValue <bool> ErrorState, out IEditableNodeLabel Name, out INodeComponentList FieldList, out IObjectFactory Factory) { Location = this.Location; ErrorState = this.ErrorState; Name = this.Name; Factory = this.Factory; FieldList = this.FieldList; }
public NodeDependencyAggregate(IPoint location, IObservableValue <bool> errorState, IEditableNodeLabel name, INodeComponentList fieldList, IObjectFactory factory) { Location = location; ErrorState = errorState; Name = name; Factory = factory; FieldList = fieldList; }
public MainPageViewModel() { _navigationValue = this.CreateProperty <INavigationController>("NavigationController"); this.Subscriptions.Add(_navigationValue.WhereNotNull().Subscribe(navigation => navigation.Navigate <GettingStartedPage>())); this.CreateCommand <NavigationViewSelection>("NavigationCommand", this.Navigate); }
public void unBind() { if (boundTo != null) { boundTo.OnChanged -= BoundTo_OnUpdate; boundTo = null; } }
public VisualNodeComponent(IObservableValue <string> name, IOpacity opacity) : base(opacity) { Name = name; VisualComponentList = new List <IVisualNodeComponent>() { this }; }
public void unbind() { if (bound != null) { bound.OnChange -= ObservedChanged; OnChange -= ThisChanged; bound = null; } }
public ReadOnlyValue(IObservableValue <T> value) { if (value == null) { throw new ArgumentNullException("value"); } this.value = value; }
public NodeLabel(IObservableValue <string> name, IOpacity opacity, IObservableValue <string> labelText) : base(name, opacity) { LabelText = labelText; LabelText.Value = Name.Value; Name.PropertyChanged += (o, e) => { LabelText.Value = Name.Value; }; }
private void CurrencyValueChanged(IObservableValue <int> observable) { if (B.Value != 0) { Image.fillAmount = A.Value / (float)B.Value; } else { Image.fillAmount = 1; } }
public LaminarValue(ITypeDefinitionProvider provider, IObservableValue <bool> isUserEditable, IObservableValue <bool> hasDependency, IObjectFactory factory) : base(hasDependency) { _typeDefinitionProvider = provider; TypeDefinition = _typeDefinitionProvider.DefaultDefinition; IsUserEditable = isUserEditable; _factory = factory; hasDependency.OnChange += (b) => { IsUserEditable.Value = !b; }; OnChange += (val) => NotifyPropertyChanged(nameof(TrueValue)); }
/// <summary> /// Constructor /// </summary> public ControlSaveAsCommand(IImageManager imageManager, IObservableValue <SingleTest> selectedTest, HomeViewModel homeView) { DisplayInfo = new DisplayInfo { Description = Resources.SaveAsNewResources, Image16 = imageManager.GetImage16Path("Save") }; Command = new RelayCommand(_ => DoControlSaveAs(homeView), _ => (selectedTest.Value != null)); }
/// <summary> /// Constructor /// </summary> public SaveAsNewResourcesCommand(IImageManager imageManager, IObservableValue <SingleTest> selectedTest, HomeViewModel homeView, ICommandViewModel showTestPropertiesCommand, XMLRepository xmlRepository) { DisplayInfo = new DisplayInfo { Description = Resources.SaveAsNewResources, Image16 = imageManager.GetImage16Path("Save") }; Command = new RelayCommand(_ => DoSaveAsNewResources(showTestPropertiesCommand, xmlRepository, homeView), _ => (selectedTest.Value != null)); }
public VisualNodeComponent(IObservableValue <string> name, IFlow flowInput, IFlow flowOutput, IOpacity opacity) : base(opacity) { Name = name; FlowInput = flowInput; FlowOutput = flowOutput; FlowInput.ParentComponent = this; FlowOutput.ParentComponent = this; VisualComponentList = new List <IVisualNodeComponent>() { this }; }
public static IDisposable PublishTo <T>(this IObservable <T> source, IObservableValue <T> value) { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (value is null) { throw new ArgumentNullException(nameof(value)); } return(source.Subscribe(x => value.Value = x)); }
public NodeField(Instance instance, IObservableValue <string> name, IFlow flowInput, IFlow flowOutput, IOpacity opacity, ILaminarValueStore valueStore, IUserInterfaceManager userInterfaces) : base(name, flowInput, flowOutput, opacity) { _valueStore = valueStore; UserInterfaces = userInterfaces; UserInterfaces.Displays = instance.RegisteredDisplays; UserInterfaces.Editors = instance.RegisteredEditors; _factory = instance.Factory; _valueStore.ChildValueChanged += ValueStore_ChildValueChanged; _valueStore.ChangedAtKey += (o, e) => AnyValueChanged?.Invoke(this, e); Name.OnChange += _valueStore.SetValueName; }
/// <summary> /// Constructor /// </summary> public ShowTestPropertiesCommand(IImageManager imageManager, IObservableValue <SingleTest> selectedTest, BindableCollection <ResourcePropertyModel> testProperties4Debug, XMLRepository xmlRepository) { DisplayInfo = new DisplayInfo { Description = Resources.ImportAndShowProperties, Image16 = imageManager.GetImage16Path("Import") }; Command = new RelayCommand(_ => { FillUiWithImportedTest(testProperties4Debug, xmlRepository.ShowTestProperties(selectedTest.Value.TestIDNumber)); }, _ => (selectedTest.Value != null)); }
/// <summary> /// Initializes a new instance of the <see cref="RxObserver{T}"/> class. /// </summary> /// <param name="sharedState">The shared state.</param> /// <param name="observable">The observable.</param> /// <param name="exceptionHandler">The exception handler.</param> /// <param name="initialValue">The initial value.</param> internal RxObserver(ISharedState sharedState, IObservable <T> observable, T initialValue, Action <Exception> exceptionHandler) { if (observable is null) { throw new ArgumentNullException(nameof(observable)); } this.sharedState = sharedState ?? throw new ArgumentNullException(nameof(sharedState)); this.exceptionHandler = exceptionHandler ?? throw new ArgumentNullException(nameof(exceptionHandler)); this.sharedState.RunInAction(() => { this.observableValue = new ObservableValue <T>(this.sharedState, $"RxObserver<{typeof(T)}>", this.sharedState.ReferenceEnhancer()); this.observableValue.Value = initialValue; observable.Subscribe(this); }); }
protected virtual void CurrencyValueChanged(IObservableValue <TimeSpan> observable) { var val = observable.Value; if (_textFormat != null) { DisplayingText.text = string.Format(_textFormat, val.Days, val.Hours, val.Minutes, val.Seconds); } else if (DisplaySimple) { DisplayingText.text = val.ToString(); } else { DisplayingText.text = val.ToReadableString(); } }
public CreatureViewModel(IObservable <Unit> untapAll, int power, int toughness, BaseViewModel parent, params Ability[] abilities) : base(parent) { _power = this.CreateProperty("Power", power); _toughness = this.CreateProperty("Toughness", toughness); _abilities = this.CreateProperty("Abilities", abilities); this.CreateActiveProperty <bool>( "IsTapped", "Toggle", "Tap", (toggle, tap) => Observable .Merge <bool?>( untapAll.Select(_ => false as bool?), toggle.Select(_ => default(bool?)), tap.Select(_ => true as bool?)) .Scan(false, (previous, isTapped) => isTapped.HasValue ? isTapped.Value : !previous), false); }
public void SetCurrentValue(object value) { IObservableValue oldObservableValue = currentValue as IObservableValue; if (oldObservableValue != null) { oldObservableValue.ValueChanged -= OnObservableValueChanged; } currentValue = value; IObservableValue newObservableValue = currentValue as IObservableValue; if (newObservableValue != null) { newObservableValue.ValueChanged += OnObservableValueChanged; } SetValue(); }
public void SetAnimationValue(object value) { IObservableValue oldObservableValue = animationValue as IObservableValue; if (oldObservableValue != null) { oldObservableValue.ValueChanged -= OnObservableValueChanged; } animationValue = value; IObservableValue newObservableValue = animationValue as IObservableValue; if (newObservableValue != null) { newObservableValue.ValueChanged += OnObservableValueChanged; } SetValue(); }
public void SetBaseValue(int priority, object value) { IObservableValue oldObservableValue = baseValues[priority] as IObservableValue; if (oldObservableValue != null) { oldObservableValue.ValueChanged -= OnObservableValueChanged; } baseValues[priority] = value; IObservableValue newObservableValue = baseValues[priority] as IObservableValue; if (newObservableValue != null) { newObservableValue.ValueChanged += OnObservableValueChanged; } SetValue(); }
public void bind(IObservableValue <T> observable) { checkIsDisposed(); /* * if (isBound) * { * throw new Exception("Cannot bind to another property because " + name + " is already bound to " + boundTo.name); * } */ if (boundTo != observable) { if (boundTo != null) { boundTo.OnChanged -= BoundTo_OnUpdate; boundTo = null; } boundTo = observable; observable.OnChanged += BoundTo_OnUpdate; set(boundTo.get()); } }
public ObservableInstanceMethod(TType instance, MethodInfo methodInfo) { if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } if (methodInfo.IsStatic) { throw new ArgumentException("Specified method is static.", "methodInfo"); } if (!methodInfo.DeclaringType.IsAssignableFrom(typeof(TType))) { throw new ArgumentException("Method declaring type is not assignable from instance type.", "methodInfo"); } if (!typeof(TResult).IsAssignableFrom(methodInfo.ReturnType)) { throw new ArgumentException("Method return type is not assignable to result.", "methodInfo"); } if (methodInfo.GetParameters().Length != 0) { throw new ArgumentException("Method takes parameters.", "methodInfo"); } this.result = new MutableValue <TResult>(); this.methodInfo = methodInfo; this.Instance = new MutableValue <TType>(instance, ValidateInstanceValue); this.Result = result.AsReadOnly(); // Whenever the instance changes, we will refresh the result // by invoking the method. Subscribing to this change will // immediately provide the current value, which will cause us // to immediately refresh. this.Instance.Changed.Subscribe(InstanceValueChanged); }
private void ValChanged(IObservableValue <bool> observable) { _toggle.onValueChanged.RemoveListener(Toggled); _toggle.isOn = observable.Value; _toggle.onValueChanged.AddListener(Toggled); }
public ReadOnlyObservableValue(IObservableValue source) { this.source = source; source.ValueChanged += (sender, e) => ValueChanged.Raise(this, e); }
public ReadOnlyObservableValue(IObservableValue source) { this.source = source; source.ValueChanged += (sender, e) => ValueChanged.Raise(this, e); }