RestrictionCollection

Namespace: Itinero
We found 10 examples in language CSharp for this search. You will see 45 fragments of code.
        public static void AddRestriction(MediaRestrictions.RestrictionType incomingRestriction)
        {
            //check if already exist
            foreach (MediaRestrictions.RestrictionType restrictionFromCollection in RestrictionCollection)
            {
                if (incomingRestriction == restrictionFromCollection)
                    throw new ApplicationException();
            }
            RestrictionCollection.Add(incomingRestriction);
        }

        public static void RemoveRestriction(MediaRestrictions.RestrictionType incomingRestriction)
        {
            foreach(MediaRestrictions.RestrictionType restrictionFromCollection in RestrictionCollection )
            {
                if (incomingRestriction == restrictionFromCollection)
                    RestrictionCollection.TryTake(out incomingRestriction);
            }
        }


		protected override void OnItemAdding(ViewportRestriction item)
		{
			if (item == null)
				throw new ArgumentNullException("item");
		}

		protected override void OnItemAdded(ViewportRestriction item)
		{
			item.Changed += OnItemChanged;
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Attach(viewport);
			}
		}

		private void OnItemChanged(object sender, EventArgs e)
		{
			OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
		}

		protected override void OnItemRemoving(ViewportRestriction item)
		{
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Detach(viewport);
			}
			item.Changed -= OnItemChanged;
		}

		internal DataRect Apply(DataRect oldVisible, DataRect newVisible, Viewport2D viewport)
		{
			DataRect res = newVisible;
			foreach (var restriction in this)
			{
				res = restriction.Apply(oldVisible, res, viewport);
			}
			return res;
		}


		protected override void OnItemAdding(ViewportRestriction item)
		{
			if (item == null)
				throw new ArgumentNullException("item");
		}

		protected override void OnItemAdded(ViewportRestriction item)
		{
			item.Changed += OnItemChanged;
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Attach(viewport);
			}
		}

		private void OnItemChanged(object sender, EventArgs e)
		{
			OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
		}

		protected override void OnItemRemoving(ViewportRestriction item)
		{
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Detach(viewport);
			}
			item.Changed -= OnItemChanged;
		}

		public DataRect Apply(DataRect oldVisible, DataRect newVisible, Viewport2D viewport)
		{
			DataRect res = newVisible;
			foreach (var restriction in this)
			{
				res = restriction.Apply(oldVisible, res, viewport);
			}
			return res;
		}


		protected override void OnItemAdding(ViewportRestriction item)
		{
			if (item == null)
				throw new ArgumentNullException("item");
		}

		protected override void OnItemAdded(ViewportRestriction item)
		{
			item.Changed += OnItemChanged;
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Attach(viewport);
			}
		}

		private void OnItemChanged(object sender, EventArgs e)
		{
			OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
		}

		protected override void OnItemRemoving(ViewportRestriction item)
		{
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Detach(viewport);
			}
			item.Changed -= OnItemChanged;
		}

		internal DataRect Apply(DataRect oldVisible, DataRect newVisible, Viewport2D viewport)
		{
			DataRect res = newVisible;
			foreach (var restriction in this)
			{
				res = restriction.Apply(oldVisible, res, viewport);
			}
			return res;
		}


		protected override void OnItemAdding(ViewportRestriction item)
		{
			if (item == null)
				throw new ArgumentNullException("item");
		}

		protected override void OnItemAdded(ViewportRestriction item)
		{
			item.Changed += OnItemChanged;
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Attach(viewport);
			}
		}

		private void OnItemChanged(object sender, EventArgs e)
		{
			OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
		}

		protected override void OnItemRemoving(ViewportRestriction item)
		{
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Detach(viewport);
			}
			item.Changed -= OnItemChanged;
		}

		internal DataRect Apply(DataRect oldVisible, DataRect newVisible, Viewport2D viewport)
		{
			DataRect res = newVisible;
			foreach (var restriction in this)
			{
				res = restriction.Apply(oldVisible, res, viewport);
			}
			return res;
		}


		protected override void OnItemAdding(ViewportRestriction item)
		{
			if (item == null)
				throw new ArgumentNullException("item");
		}

		protected override void OnItemAdded(ViewportRestriction item)
		{
			item.Changed += OnItemChanged;
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Attach(viewport);
			}
		}

		private void OnItemChanged(object sender, EventArgs e)
		{
			OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
		}

		protected override void OnItemRemoving(ViewportRestriction item)
		{
			ISupportAttachToViewport attachable = item as ISupportAttachToViewport;
			if (attachable != null)
			{
				attachable.Detach(viewport);
			}
			item.Changed -= OnItemChanged;
		}

		internal DataRect Apply(DataRect oldVisible, DataRect newVisible, Viewport2D viewport)
		{
			DataRect res = newVisible;
			foreach (var restriction in this)
			{
				res = restriction.Apply(oldVisible, res, viewport);
			}
			return res;
		}


        private void OnHostElementSizeChanged(object sender, SizeChangedEventArgs e)
        {
            SetValue(OutputPropertyKey, new Rect(e.NewSize));
            CoerceValue(VisibleProperty);
        }

        private void fitToViewRestrictions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (IsFittedToView)
            {
                CoerceValue(VisibleProperty);
            }
        }

        private void restrictions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            CoerceValue(VisibleProperty);
        }

        private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Viewport2D viewport = (Viewport2D)d;
            viewport.UpdateTransform();
            viewport.RaisePropertyChangedEvent(e);
        }

        public BindingExpressionBase SetBinding(DependencyProperty property, BindingBase binding)
        {
            return BindingOperations.SetBinding(this, property, binding);
        }

        /// <summary>
        /// Forces viewport to go to fit to view mode - clears locally set value of <see cref="Visible"/> property
        /// and sets it during the coercion process to a value of united content bounds of all charts inside of <see cref="Plotter"/>.
        /// </summary>
        public void FitToView()
        {
            if (!IsFittedToView)
            {
                ClearValue(VisibleProperty);
                CoerceValue(VisibleProperty);
            }
        }


		private void OnHostElementSizeChanged(object sender, SizeChangedEventArgs e)
		{
			SetValue(OutputPropertyKey, new Rect(e.NewSize));
			CoerceValue(VisibleProperty);
		}

		private void fitToViewRestrictions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
		{
			if (IsFittedToView)
			{
				CoerceValue(VisibleProperty);
			}
		}

		private void restrictions_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
		{
			CoerceValue(VisibleProperty);
		}
		private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
      if (e.Property.Name == "Output") {
        var rectArray = new Rect[] { (Rect)e.NewValue , (Rect)e.OldValue };
        if (!rectArray.Except(_rectArray).Any()) return;
        _rectArray = rectArray;
      }
			Viewport2D viewport = (Viewport2D)d;
			viewport.UpdateTransform();
			viewport.RaisePropertyChangedEvent(e);
		}

		public BindingExpressionBase SetBinding(DependencyProperty property, BindingBase binding)
		{
			return BindingOperations.SetBinding(this, property, binding);
		}

		/// <summary>
		/// Forces viewport to go to fit to view mode - clears locally set value of <see cref="Visible"/> property
		/// and sets it during the coercion process to a value of united content bounds of all charts inside of <see cref="Plotter"/>.
		/// </summary>
		public void FitToView()
		{
			if (!IsFittedToView)
			{
				ClearValue(VisibleProperty);
				CoerceValue(VisibleProperty);
			}
		}


        /// <summary>
        /// Updates this restriction collection.
        /// </summary>
        /// <return>Returns true if there are restrictions.</return>
        public bool Update(uint vertex)
        {
            if (_vertex == vertex)
            {
                return true;
            }

            _vertex = vertex;

            return _update(this, _vertex);
        }

        /// <summary>
        /// Adds a new restriction.
        /// </summary>
        public void Add(Restriction restriction)
        {
            if (_count >= _restrictions.Length)
            {
                Array.Resize(ref _restrictions, _restrictions.Length * 2);
            }
            _restrictions[_count] = restriction;
            _count++;
        }

        /// <summary>
        /// Clears all restrictions.
        /// </summary>
        public void Clear()
        {
            _count = 0;
        }


        /// <summary>
        /// Updates this restriction collection.
        /// </summary>
        /// <return>Returns true if there are restrictions.</return>
        public bool Update(uint vertex)
        {
            if (_vertex == vertex)
            {
                return true;
            }

            _vertex = vertex;

            return _update(this, _vertex);
        }

        /// <summary>
        /// Adds a new restriction.
        /// </summary>
        public void Add(Restriction restriction)
        {
            if (_count >= _restrictions.Length)
            {
                Array.Resize(ref _restrictions, _restrictions.Length * 2);
            }
            _restrictions[_count] = restriction;
            _count++;
        }

        /// <summary>
        /// Clears all restrictions.
        /// </summary>
        public void Clear()
        {
            _count = 0;
        }

Itinero.Algorithms.Restrictions.RestrictionCollection : Object

Constructors :

public RestrictionCollection(Func<RestrictionCollection, UInt32, Boolean> update = )

Methods :

public Boolean Update(UInt32 vertex = )
public Restriction get_Item(Int32 i = )
public Int32 get_Count()
public UInt32 get_Vertex()
public Void Add(Restriction restriction = )
public Void Clear()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()