예제 #1
0
 public TwoWayReactivePropertyBinding(IReactiveObject source, ReactiveProperty <T> reactiveProperty)
     : base(
         new OneWayReactivePropertyBinding <T, TSource>(source, reactiveProperty),
         new OneWayToSourceReactivePropertyBinding <T, TSource>(source, reactiveProperty),
         BindingResolutionMode.Immediate)
 {
 }
예제 #2
0
        private static void ItemsSourceChanged(
            IReactiveObject source, ReactivePropertyChangeEventArgs <IEnumerable> change)
        {
            var itemsControl = (ItemsControl)source;

            if (change.OldValue is INotifyCollectionChanged)
            {
                itemsControl.changingItems.Dispose();
            }

            var observableCollection = change.NewValue as INotifyCollectionChanged;

            if (observableCollection != null)
            {
                itemsControl.changingItems =
                    Observable.FromEventPattern <NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(
                        handler => new NotifyCollectionChangedEventHandler(handler),
                        handler => observableCollection.CollectionChanged += handler,
                        handler => observableCollection.CollectionChanged -= handler).Subscribe(
                        itemsControl.OnNextItemChange);
            }

            itemsControl.isItemsSourceNew = true;
            itemsControl.InvalidateMeasure();
        }
예제 #3
0
        private static void OnIsCheckedPropertyChanged(
            IReactiveObject source, ReactivePropertyChangeEventArgs <bool?> args)
        {
            var button = source as ToggleButton;

            if (button == null)
            {
                return;
            }

            bool?newValue = args.NewValue;

            if (newValue == true)
            {
                button.OnChecked();
            }
            else if (newValue == false)
            {
                button.OnUnchecked();
            }
            else
            {
                button.OnIndeterminate();
            }
        }
        public IReactiveObject GetMainViewModel(bool createNew = true)
        {
            if (createNew)
            {
                this.currentMainViewModel = (IReactiveObject)Activator.CreateInstance(this.mainViewModelType.AsType());
            }

            return(this.currentMainViewModel);
        }
        /// <summary>
        ///     Invalidates the sender's Measure layout pass when a <see cref = "ReactiveProperty{T}">ReactiveProperty</see> value is changed.
        /// </summary>
        /// <typeparam name = "T">The type of the <see cref = "ReactiveProperty{T}">ReactiveProperty</see>.</typeparam>
        /// <param name = "sender">The ReactiveObject whose <see cref = "ReactiveProperty{T}">ReactiveProperty</see> has changed.</param>
        /// <param name = "args">An instance of <see cref = "ReactivePropertyChangeEventArgs{T}">ReactivePropertyChangeEventArgs</see> that carries information about the change.</param>
        public static void InvalidateMeasure <T>(IReactiveObject sender, ReactivePropertyChangeEventArgs <T> args)
        {
            var uiElement = sender as IElement;

            if (uiElement != null)
            {
                uiElement.InvalidateMeasure();
            }
        }
예제 #6
0
 public PropertyHelper(IReactiveObject source, IObservable <TRet> observable, string propertyName)
 {
     observable.Subscribe(
         v =>
     {
         source.RaisePropertyChanging(propertyName);
         Value = v;
         source.RaisePropertyChanged(propertyName);
     });
 }
예제 #7
0
        public static void RaisePropertyChanged <T>(this IReactiveObject reactiveObject,
                                                    Expression <Func <T> > propertyExpression)
        {
            var memberExpr = propertyExpression.Body as MemberExpression;

            if (memberExpr == null)
            {
                throw new ArgumentException("propertyExpression should represent access to a member");
            }
            string memberName = memberExpr.Member.Name;

            // ReSharper disable once ExplicitCallerInfoArgument
            reactiveObject.RaisePropertyChanged(memberName);
        }
예제 #8
0
        private static void ChildPropertyChangedCallback(
            IReactiveObject source, ReactivePropertyChangeEventArgs <IElement> change)
        {
            var border = (Border)source;

            border.InvalidateMeasure();

            IElement oldChild = change.OldValue;

            if (oldChild != null)
            {
                oldChild.VisualParent = null;
            }

            IElement newChild = change.NewValue;

            if (newChild != null)
            {
                newChild.VisualParent = border;
            }
        }
예제 #9
0
        private static void ContentPropertyChangedCallback(
            IReactiveObject source, ReactivePropertyChangeEventArgs <IElement> change)
        {
            var contentControl = (ContentControl)source;

            contentControl.InvalidateMeasure();

            IElement oldContent = change.OldValue;

            if (oldContent != null)
            {
                oldContent.VisualParent = null;
            }

            IElement newContent = change.NewValue;

            if (newContent != null)
            {
                newContent.VisualParent = contentControl;
            }

            contentControl.OnContentChanged(oldContent, newContent);
        }
예제 #10
0
        private static void ItemsPanelChanged(IReactiveObject source, ReactivePropertyChangeEventArgs <Panel> change)
        {
            var   itemsControl = (ItemsControl)source;
            Panel newPanel     = change.NewValue;
            Panel oldPanel     = change.OldValue;

            if (oldPanel != null)
            {
                oldPanel.VisualParent = null;
            }

            if (newPanel != null)
            {
                if (!(newPanel.Children is ITemplatedList <IElement>))
                {
                    throw new NotSupportedException(
                              "ItemsControl requires a panel whose Children collection implements ITemplatedList<IElement>");
                }

                newPanel.VisualParent = itemsControl;
            }

            itemsControl.InvalidateMeasure();
        }
 /// <summary>
 /// Gets the underlying observable from the IReactiveObject instance.
 /// </summary>
 /// <param name="reactiveObject">The reactive object to get the atom for.</param>
 /// <returns>The IAtom instance to get.</returns>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when there is no observable object internally.</exception>
 public static IObservable GetObservable(this IReactiveObject reactiveObject)
 {
     return(GetObservable((object)reactiveObject));
 }
예제 #12
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange)
 {
     ((TestBindingObject)source).widthPropertyChangedCalledbackCount++;
 }
예제 #13
0
 public OneWayReactivePropertyBinding(IReactiveObject source, ReactiveProperty <TSourceProp> reactiveProperty)
     : base(BindingResolutionMode.Immediate)
 {
     this.SourceObservable = source.GetObservable <TSourceProp, TSource>(reactiveProperty).Select(Convert);
 }
예제 #14
0
        private static void ItemsSourceChanged(
            IReactiveObject source, ReactivePropertyChangeEventArgs<IEnumerable> change)
        {
            var itemsControl = (ItemsControl)source;
            if (change.OldValue is INotifyCollectionChanged)
            {
                itemsControl.changingItems.Dispose();
            }

            var observableCollection = change.NewValue as INotifyCollectionChanged;
            if (observableCollection != null)
            {
                itemsControl.changingItems =
                    Observable.FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(
                        handler => new NotifyCollectionChangedEventHandler(handler), 
                        handler => observableCollection.CollectionChanged += handler, 
                        handler => observableCollection.CollectionChanged -= handler).Subscribe(
                            itemsControl.OnNextItemChange);
            }

            itemsControl.isItemsSourceNew = true;
            itemsControl.InvalidateMeasure();
        }
예제 #15
0
 public static LazyProperty <T> CreateLazy <T>(this IReactiveObject reactive, Expression <Func <T> > nameExpression, Expression <Func <T> > valueExpression)
 {
     return(reactive.Reactor.CreateLazy <T>(nameExpression, valueExpression));
 }
예제 #16
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange)
 {
     ((TestBindingObject)source).widthPropertyChangedCalledbackCount++;
 }
예제 #17
0
파일: Border.cs 프로젝트: redbadger/XPF
        private static void ChildPropertyChangedCallback(
            IReactiveObject source, ReactivePropertyChangeEventArgs<IElement> change)
        {
            var border = (Border)source;
            border.InvalidateMeasure();

            IElement oldChild = change.OldValue;
            if (oldChild != null)
            {
                oldChild.VisualParent = null;
            }

            IElement newChild = change.NewValue;
            if (newChild != null)
            {
                newChild.VisualParent = border;
            }
        }
 public static IEnumerable <T> GetServices <T>(this IReactiveObject @object, string contract = null)
 {
     return(Locator.Current.GetServices <T>(contract));
 }
예제 #19
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs <double> reactivePropertyChange)
 {
     ((TestBindingObject)source).WidthChangedCallback(
         reactivePropertyChange.OldValue, reactivePropertyChange.NewValue);
 }
예제 #20
0
 private static void WidthChangedCallback(
     IReactiveObject source, ReactivePropertyChangeEventArgs<double> reactivePropertyChange)
 {
     ((TestBindingObject)source).WidthChangedCallback(
         reactivePropertyChange.OldValue, reactivePropertyChange.NewValue);
 }
예제 #21
0
 public static Property <T> Create <T>(this IReactiveObject reactive, string name, Expression <Func <T> > valueExpression)
 {
     return(reactive.Reactor.Create <T>(name, valueExpression));
 }
예제 #22
0
        /// <summary>
        /// Raises the <see cref="PropertyChanged"/> event.
        /// </summary>
        /// <param name="propertyName"></param>
        protected void OnPropertyChanged(string propertyName)
        {
            IReactiveObject reactive = this as IReactiveObject;

            reactive.RaisePropertyChanged(propertyName);
        }
예제 #23
0
 public static Property <T> Create <T>(this IReactiveObject reactive, Expression <Func <T> > nameExpression, T defaultValue = default(T))
 {
     return(reactive.Reactor.Create <T>(nameExpression, defaultValue));
 }
예제 #24
0
 public MainWindow(IReactiveObject viewModel, IBackgroundManager backgroundManager)
 {
     InitializeComponent();
     DataContext = viewModel;
     backgroundManager.SetBackgroudApp(null, "notepad++");
 }
예제 #25
0
 public static Property <T> Create <T>(this IReactiveObject reactive, string name, T defaultValue = default(T))
 {
     return(reactive.Reactor.Create <T>(name, defaultValue));
 }
예제 #26
0
파일: UIElement.cs 프로젝트: redbadger/XPF
 private static void DataContextChanged(IReactiveObject source, ReactivePropertyChangeEventArgs<object> args)
 {
     ((UIElement)source).InvalidateMeasureOnDataContextInheritors();
 }
예제 #27
0
 private static void DataContextChanged(IReactiveObject source, ReactivePropertyChangeEventArgs <object> args)
 {
     ((UIElement)source).InvalidateMeasureOnDataContextInheritors();
 }
예제 #28
0
 public OneWayToSourceReactivePropertyBinding(IReactiveObject source, ReactiveProperty <T> reactiveProperty)
     : base(source.GetObserver <T, TSource>(reactiveProperty))
 {
 }
예제 #29
0
        private static void ItemsPanelChanged(IReactiveObject source, ReactivePropertyChangeEventArgs<Panel> change)
        {
            var itemsControl = (ItemsControl)source;
            Panel newPanel = change.NewValue;
            Panel oldPanel = change.OldValue;

            if (oldPanel != null)
            {
                oldPanel.VisualParent = null;
            }

            if (newPanel != null)
            {
                if (!(newPanel.Children is ITemplatedList<IElement>))
                {
                    throw new NotSupportedException(
                        "ItemsControl requires a panel whose Children collection implements ITemplatedList<IElement>");
                }

                newPanel.VisualParent = itemsControl;
            }

            itemsControl.InvalidateMeasure();
        }
예제 #30
-1
        private static void OnIsCheckedPropertyChanged(
            IReactiveObject source, ReactivePropertyChangeEventArgs<bool?> args)
        {
            var button = source as ToggleButton;
            if (button == null)
            {
                return;
            }

            bool? newValue = args.NewValue;
            if (newValue == true)
            {
                button.OnChecked();
            }
            else if (newValue == false)
            {
                button.OnUnchecked();
            }
            else
            {
                button.OnIndeterminate();
            }
        }