コード例 #1
0
 public NodeDependencyAggregate(IPoint location, IObservableValue <bool> errorState, IObservableValue <string> name, IObjectFactory factory)
 {
     Location   = location;
     ErrorState = errorState;
     Name       = name;
     Factory    = factory;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public LaminarValue(ITypeDefinitionProvider provider, IObservableValue <bool> isUserEditable, IObjectFactory factory) : base()
 {
     SetTypeDefinitionProvider(provider);
     IsUserEditable = isUserEditable;
     _factory       = factory;
     OnChange      += (o, val) => NotifyPropertyChanged(nameof(TrueValue));
 }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
 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;
 }
コード例 #6
0
 public NodeDependencyAggregate(IPoint location, IObservableValue <bool> errorState, IEditableNodeLabel name, INodeComponentList fieldList, IObjectFactory factory)
 {
     Location   = location;
     ErrorState = errorState;
     Name       = name;
     Factory    = factory;
     FieldList  = fieldList;
 }
コード例 #7
0
        public MainPageViewModel()
        {
            _navigationValue = this.CreateProperty <INavigationController>("NavigationController");

            this.Subscriptions.Add(_navigationValue.WhereNotNull().Subscribe(navigation => navigation.Navigate <GettingStartedPage>()));

            this.CreateCommand <NavigationViewSelection>("NavigationCommand", this.Navigate);
        }
コード例 #8
0
 public void unBind()
 {
     if (boundTo != null)
     {
         boundTo.OnChanged -= BoundTo_OnUpdate;
         boundTo            = null;
     }
 }
コード例 #9
0
        public VisualNodeComponent(IObservableValue <string> name, IOpacity opacity) : base(opacity)
        {
            Name = name;

            VisualComponentList = new List <IVisualNodeComponent>()
            {
                this
            };
        }
コード例 #10
0
 public void unbind()
 {
     if (bound != null)
     {
         bound.OnChange -= ObservedChanged;
         OnChange       -= ThisChanged;
         bound           = null;
     }
 }
コード例 #11
0
        public ReadOnlyValue(IObservableValue <T> value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            this.value = value;
        }
コード例 #12
0
 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;
     };
 }
コード例 #13
0
 private void CurrencyValueChanged(IObservableValue <int> observable)
 {
     if (B.Value != 0)
     {
         Image.fillAmount = A.Value / (float)B.Value;
     }
     else
     {
         Image.fillAmount = 1;
     }
 }
コード例 #14
0
 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));
 }
コード例 #15
0
        /// <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));
        }
コード例 #16
0
        /// <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));
        }
コード例 #17
0
        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
            };
        }
コード例 #18
0
        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));
        }
コード例 #19
0
        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;
        }
コード例 #20
0
        /// <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));
        }
コード例 #21
0
ファイル: RxObserver.cs プロジェクト: vanderstack/Cortex.Net
        /// <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);
            });
        }
コード例 #22
0
    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();
        }
    }
コード例 #23
0
        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);
        }
コード例 #24
0
        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();
        }
コード例 #25
0
        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();
        }
コード例 #26
0
        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();
        }
コード例 #27
0
        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());
            }
        }
コード例 #28
0
        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);
        }
コード例 #29
0
 private void ValChanged(IObservableValue <bool> observable)
 {
     _toggle.onValueChanged.RemoveListener(Toggled);
     _toggle.isOn = observable.Value;
     _toggle.onValueChanged.AddListener(Toggled);
 }
コード例 #30
0
 public ReadOnlyObservableValue(IObservableValue source)
 {
     this.source          = source;
     source.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);
 }
コード例 #31
0
ファイル: ObservableValue.cs プロジェクト: highzion/Granular
 public ReadOnlyObservableValue(IObservableValue source)
 {
     this.source = source;
     source.ValueChanged += (sender, e) => ValueChanged.Raise(this, e);
 }