/// <summary>
 /// Notifies subscribers of the property change.
 /// </summary>
 /// <param name = "propertyName">Name of the property.</param>
 public virtual void NotifyOfPropertyChange(string propertyName)
 {
     if (IsNotifying)
     {
         Execute.OnUiThread(() => OnPropertyChanged(new PropertyChangedEventArgs(propertyName)));
     }
 }
Exemple #2
0
        public virtual void NotifyOfPropertyChange([System.Runtime.CompilerServices.CallerMemberName] string propertyName = null)
        {
#endif
            if (IsNotifying)
            {
                Execute.OnUiThread(() => OnPropertyChanged(new PropertyChangedEventArgs(propertyName)));
            }
        }
 /// <summary>
 /// Raises a change notification indicating that all bindings should be refreshed.
 /// </summary>
 public void Refresh()
 {
     Execute.OnUiThread(() => {
         OnPropertyChanged(new PropertyChangedEventArgs("Count"));
         OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
         OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
     });
 }
        /// <summary>
        /// Adds the range.
        /// </summary>
        /// <param name = "items">The items.</param>
        public virtual void AddRange(IEnumerable <T> items)
        {
            Execute.OnUiThread(() => {
                var previousNotificationSetting = IsNotifying;
                IsNotifying = false;
                var index   = Count;
                foreach (var item in items)
                {
                    InsertItemBase(index, item);
                    index++;
                }
                IsNotifying = previousNotificationSetting;

                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            });
        }
        /// <summary>
        /// Removes the range.
        /// </summary>
        /// <param name = "items">The items.</param>
        public virtual void RemoveRange(IEnumerable <T> items)
        {
            Execute.OnUiThread(() => {
                var previousNotificationSetting = IsNotifying;
                IsNotifying = false;
                foreach (var item in items)
                {
                    var index = IndexOf(item);
                    if (index >= 0)
                    {
                        RemoveItemBase(index);
                    }
                }
                IsNotifying = previousNotificationSetting;

                OnPropertyChanged(new PropertyChangedEventArgs("Count"));
                OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
                OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            });
        }
Exemple #6
0
            void Closing(object sender, CancelEventArgs e)
            {
                if (e.Cancel)
                {
                    return;
                }

                var guard = (IGuardClose)model;

                if (actuallyClosing)
                {
                    actuallyClosing = false;
                    return;
                }

                bool runningAsync = false, shouldEnd = false;

                guard.CanClose(canClose => {
                    Execute.OnUiThread(() => {
                        if (runningAsync && canClose)
                        {
                            actuallyClosing = true;
                            view.Close();
                        }
                        else
                        {
                            e.Cancel = !canClose;
                        }

                        shouldEnd = true;
                    });
                });

                if (shouldEnd)
                {
                    return;
                }

                runningAsync = e.Cancel = true;
            }
 /// <summary>
 /// Sets the item at the specified position.
 /// </summary>
 /// <param name = "index">The index to set the item at.</param>
 /// <param name = "item">The item to set.</param>
 protected override sealed void SetItem(int index, T item)
 {
     Execute.OnUiThread(() => SetItemBase(index, item));
 }
 /// <summary>
 /// Clears the items contained by the collection.
 /// </summary>
 protected override sealed void ClearItems()
 {
     Execute.OnUiThread(ClearItemsBase);
 }
 /// <summary>
 /// Removes the item at the specified position.
 /// </summary>
 /// <param name = "index">The position used to identify the item to remove.</param>
 protected override sealed void RemoveItem(int index)
 {
     Execute.OnUiThread(() => RemoveItemBase(index));
 }