Exemplo n.º 1
0
        public override void OnMouseClicked()
        {
            int relativeYPosition = Context.UiManager.MousePosition.Y - Position.Y;

            if (relativeYPosition < Width)
            {
                Moved.Raise(-1);
            }
            else if (relativeYPosition > Size.Y - Width)
            {
                Moved.Raise(1);
            }
        }
 /// <summary>
 /// Handles when the <see cref="IRefractionEffect.PositionProvider"/> moves.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs{Vector2}"/> instance containing the event data.</param>
 void PositionProvider_Moved(ISpatial sender, EventArgs <Vector2> e)
 {
     // Avoid needless calculations on finding the position when there are no listeners for Moved
     if (Moved != null)
     {
         var oldValue = Position;
         _center = sender.Center;
         Moved.Raise(this, EventArgsHelper.Create(oldValue));
     }
     else
     {
         _center = sender.Center;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the <see cref="Entity"/>'s <see cref="Position"/> directly without any chance to be overridden.
        /// This should only be used for synchronization.
        /// </summary>
        /// <param name="newPosition">The new <see cref="Position"/> value.</param>
        protected internal void SetPositionRaw(Vector2 newPosition)
        {
            if (newPosition == Position)
            {
                return;
            }

            var oldPos = Position;

            _position = newPosition;

            // Notify listeners
            OnMoved(oldPos);
            if (Moved != null)
            {
                Moved.Raise(this, EventArgsHelper.Create(oldPos));
            }
        }
Exemplo n.º 4
0
        public void ChangeCategory(Topic topic, int newCategory)
        {
            var eventArgs = new TopicEventArgs()
            {
                Topic = topic
            };

            if (Moving.RaiseAndContinue(this, eventArgs))
            {
                topic.ParentId = newCategory;
                _databaseContext.Database.Save(topic);

                Moved.Raise(this, eventArgs);
            }
            else
            {
                CancelledByEvent.Raise(this, eventArgs);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Raises the Moved event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void RaiseMoved(NodeMovedEventArgs e)
 {
     Moved.Raise(this, e);
 }