Exemplo n.º 1
0
        private void Knob_MouseMove(object sender, MouseEventArgs e)
        {
            if (!Knob.IsMouseCaptured)
            {
                return;
            }

            Point newPos = e.GetPosition(Base);

            Point deltaPos = new Point(newPos.X - _startPos.X, newPos.Y - _startPos.Y);

            double distance = Math.Round(Math.Sqrt(deltaPos.X * deltaPos.X + deltaPos.Y * deltaPos.Y));

            if (distance >= canvasWidth / 2 || distance >= canvasHeight / 2)
            {
                return;
            }
            Aileron  = deltaPos.X / 124;
            Elevator = -deltaPos.Y / 124;

            knobPosition.X = deltaPos.X;
            knobPosition.Y = deltaPos.Y;

            if (Moved == null ||
                (!(Math.Abs(_prevAileron - Aileron) > AileronStep) && !(Math.Abs(_prevElevator - Elevator) > ElevatorStep)))
            {
                return;
            }

            Moved?.Invoke(this, new VirtualJoystickEventArgs {
                Aileron = Aileron, Elevator = Elevator
            });
            _prevAileron  = Aileron;
            _prevElevator = Elevator;
        }
Exemplo n.º 2
0
    protected override void Move(Vector3 goal, bool snap = false)
    {
        Vector3 position = base.transform.position;

        if (snap || AlwaysSnapOverride)
        {
            velocity = Vector3.zero;
            base.transform.position = goal;
        }
        else
        {
            Vector3 position2 = base.transform.position;
            for (int i = 0; i < 3; i++)
            {
                float pPos           = position2[i];
                float equilibriumPos = goal[i];
                float pVel           = velocity[i];
                FeepMath.calcDampedSimpleHarmonicMotion(ref pPos, ref pVel, equilibriumPos, Time.deltaTime, SpringFrequency, SpringDamping);
                position2[i] = pPos;
                velocity[i]  = pVel;
            }
            base.transform.position = position2;
        }
        if (base.transform.position != position)
        {
            Moved.InvokeSafe();
        }
    }
Exemplo n.º 3
0
        protected override void OnDragDelta(double horizontalChange, double verticalChange)
        {
            if (!ParentLayer.IsLoaded)
            {
                this.ReleaseMouseCapture();
                return;
            }

            ParentLayer.CancelNextSelect();

            if (ParentLayer.Parent is IStoryboard)
            {
                Point canvasPosition = ApplyPositionDelta(
                    new Point(horizontalChange, verticalChange));

                Canvas.SetLeft(Target, canvasPosition.X);
                Canvas.SetTop(Target, canvasPosition.Y);
            }
            else
            {
                Thickness margin = ApplyMarginDelta(
                    new Point(horizontalChange, verticalChange));

                // Snap with Set
                ParentLayer.SetMargin(margin);
            }

            Moved?.Invoke(this, null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Moves an <see cref="IMedia"/> object to a new location
        /// </summary>
        /// <param name="media">The <see cref="IMedia"/> to move</param>
        /// <param name="parentId">Id of the Media's new Parent</param>
        /// <param name="userId">Id of the User moving the Media</param>
        public void Move(IMedia media, int parentId, int userId = 0)
        {
            using (new WriteLock(Locker))
            {
                //This ensures that the correct method is called if this method is used to Move to recycle bin.
                if (parentId == -21)
                {
                    MoveToRecycleBin(media, userId);
                    return;
                }

                if (Moving.IsRaisedEventCancelled(new MoveEventArgs <IMedia>(media, parentId), this))
                {
                    return;
                }

                media.ParentId = parentId;
                Save(media, userId);

                //Ensure that Path and Level is updated on children
                var children = GetChildren(media.Id);
                if (children.Any())
                {
                    var parentPath         = media.Path;
                    var parentLevel        = media.Level;
                    var updatedDescendents = UpdatePathAndLevelOnChildren(children, parentPath, parentLevel);
                    Save(updatedDescendents, userId);
                }

                Moved.RaiseEvent(new MoveEventArgs <IMedia>(media, false, parentId), this);

                Audit.Add(AuditTypes.Move, "Move Media performed by user", userId, media.Id);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Move Items[i] downward until it is less than or equal to its children.
        /// </summary>
        /// <param name="i"></param>
        public void SiftDown(int i)
        {
            int left  = Left(i);
            int right = Right(i);
            int smallest;

            // find the smallest of i and its two children.
            if ((left < Count) && LessThan(left, i))
            {
                smallest = left;
            }
            else
            {
                smallest = i;
            }
            if ((right < Count) && LessThan(right, smallest))
            {
                smallest = right;
            }
            if (smallest != i)
            {
                T item = Items[i];
                Items[i]        = Items[smallest];
                Items[smallest] = item;
                SiftDown(smallest);
            }
            Moved?.Invoke(Items[i], i);
        }
 private void CenterSlider_Completed(object sender, object e)
 {
     Distance = previousDistance = 0;
     Moved?.Invoke(this, new SliderEventArgs {
         Distance = Distance
     });
 }
 public void ConsumeMouseMove(MouseMoveEventArgs obj)
 {
     if (_window.MouseState.IsButtonDown(MouseButton.Left))
     {
         Moved?.Invoke(this, CreateFinger(FingerStatus.Moving));
     }
 }
Exemplo n.º 8
0
        private void Knob_MouseMove(object sender, MouseEventArgs e)
        {
            if (!Knob.IsMouseCaptured) return;

            Point newPos = e.GetPosition(Base);

            Point deltaPos = new Point(newPos.X - _startPos.X, newPos.Y - _startPos.Y);

            double distance = Math.Round(Math.Sqrt(deltaPos.X * deltaPos.X + deltaPos.Y * deltaPos.Y));
            if (distance >= canvasWidth / 2 || distance >= canvasHeight / 2)
                return;
            Elevator = -deltaPos.Y / 124;
            Aileron = deltaPos.X / 124;
          
                string setElevator = "set controls/flight/elevator " + Elevator;

                Model.Client.getInstance().Write(setElevator);
                string setAileron = "set controls/flight/aileron " + Aileron;
                Model.Client.getInstance().Write(setAileron);
           
            

            knobPosition.X = deltaPos.X;
            knobPosition.Y = deltaPos.Y;

            if (Moved == null ||
                (!(Math.Abs(_prevAileron - Aileron) > AileronStep) && !(Math.Abs(_prevElevator - Elevator) > ElevatorStep)))
                return;

            Moved?.Invoke(this, new VirtualJoystickEventArgs { Aileron = Aileron, Elevator = Elevator });
            _prevAileron = Aileron;
            _prevElevator = Elevator;

        }
Exemplo n.º 9
0
 private void Watcher_Renamed(object sender, RenamedEventArgs e)
 {
     if (Moved != null)
     {
         var Args = new MovedArticleEventArgs(this, e.OldFullPath, e.FullPath);
         Moved.Invoke(this, Args);
     }
 }
Exemplo n.º 10
0
 public override void Move(int Position_x_new, int Position_y_new)
 {
     base.Move(Position_x_new, Position_y_new);
     if (Moved != null)
     {
         Moved.Invoke();
     }
 }
Exemplo n.º 11
0
 private void OnLocationUpdated(MvxGeoLocation newLocation)
 {
     Moved?.Invoke(this,
                   new LocationMovedEventArgs
     {
         Location = newLocation
     });
 }
Exemplo n.º 12
0
 public void OnDrag(MouseEventArgs e)
 {
     if (Moving)
     {
         Position += e.DistanceMoved;
         Moved?.Invoke(this, e);
     }
 }
Exemplo n.º 13
0
        public void Move(Vector2 direction)
        {
            var timeDelta = Time.deltaTime;

            View.Body.Rotate(Vector3.up, direction.x * Model.RotateSpeed * timeDelta);
            View.Body.Translate(0, 0, direction.y * Model.MoveSpeed * timeDelta);
            Moved.SafeRaise(this);
        }
Exemplo n.º 14
0
        public virtual bool TryMove(Direction direction)
        {
            Moved?.Invoke(this, direction);
            var destination = GetIncident(direction);

            if (destination == null)
            {
                return(false);
            }

            if (destination is Wall || destination is Finish)
            {
                return(false);
            }

            if (destination is Hatch hatch)
            {
                if (!hatch.IsOpened)
                {
                    Swap(destination);
                    return(true);
                }
                destination = hatch.GetDestination(direction, canMoveObjects);
                if (destination != null)
                {
                    if (destination is Box box)
                    {
                        if (box.TryMove(direction))
                        {
                            Swap(hatch.GetDestination(direction, canMoveObjects));
                        }
                        else
                        {
                            CouldNotPassThroughHatch?.Invoke(hatch);
                        }
                    }
                    else
                    {
                        Swap(destination);
                    }
                    return(true);
                }
                CouldNotPassThroughHatch?.Invoke(hatch);
            }
            if (destination is PressurePlate plate)
            {
                plate.Activate();
                Swap(plate);
                return(true);
            }
            if (destination is Floor floor)
            {
                Swap(floor);
                return(true);
            }
            return(false);
        }
Exemplo n.º 15
0
 public void OnWindowMoved()
 {
     if (DebugStartUp)
     {
         Debug.WriteLine(Name + " moved");
     }
     UpdateConfig();
     Moved?.Invoke(this);
 }
Exemplo n.º 16
0
        internal void fireWheel(int z)
        {
            absMouse.z += z;

            if (Moved != null)
            {
                Moved.Invoke(this);
            }
        }
Exemplo n.º 17
0
        public void MoveTo(Point vector)
        {
            var position = Position;

            position.X = vector.X;
            position.Y = vector.Y;
            Position   = position;
            Moved.Invoke();
        }
Exemplo n.º 18
0
        protected override void OnValueChanged(double oldValue, double newValue)
        {
            base.OnValueChanged(oldValue, newValue);

            if (this.IsFocused && IsUnison)
            {
                Moved?.Invoke(this, newValue - oldValue);
            }
        }
Exemplo n.º 19
0
        public void GotMoved(FileInfo newPath)
        {
            var oldFile = File;

            m_upToDateFile              = new UpToDateFile(m_upToDateFile.Migrate(), newPath, s => { });
            m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute();
            m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute();
            Moved.Execute(oldFile, File);
        }
        protected void OnCollectionChangedMove(object value, int index, int oldIndex)
        {
            var eventArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, value, index, oldIndex);

            using (BlockReentrancy()) {
                CollectionChanged?.Invoke(this, eventArgs);
                Moved?.Invoke(this, eventArgs);
            }
        }
Exemplo n.º 21
0
        protected override void OnValueChanged(double oldValue, double newValue)
        {
            base.OnValueChanged(oldValue, newValue);

            if (IsUnison && _canDrag && (_isDragStarting || _thumb.IsDragging))
            {
                Moved?.Invoke(this, newValue - oldValue);
            }
        }
Exemplo n.º 22
0
        public void GotMoved(FileInfo newPath)
        {
            var oldFile = File;

            m_upToDateFile              = new UpToDateFile(m_upToDateFile.Migrate(), newPath, m_saveTo, m_backEnd);
            m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute();
            m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute();
            Moved.Execute(new Changed <FileInfo>(oldFile, File));
        }
Exemplo n.º 23
0
        internal void fireMoved(int x, int y)
        {
            absMouse.x = x;
            absMouse.y = y;

            if (Moved != null)
            {
                Moved.Invoke(this);
            }
        }
Exemplo n.º 24
0
        private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            double x = beginPosition.X + e.HorizontalChange;
            double y = beginPosition.Y + e.VerticalChange;

            this.Left = SnapToGrid(x);
            this.Top  = SnapToGrid(y);

            Moved?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 25
0
        public void MoveTo(Point vector)
        {
            var position = Position;

            position.X += vector.X;
            position.Y += vector.Y;
            Position    = position;
            Moved?.Invoke();
            // Console.WriteLine("Enemy moved to {0},{1}", Position.X, Position.Y);
        }
Exemplo n.º 26
0
        public void MoveTo(Point vector)
        {
            Moved?.Invoke();
            var position = Position;

            position.X += vector.X;
            position.Y += vector.Y;
            Position    = position;
            Moved?.Invoke();
        }
Exemplo n.º 27
0
 private void ListView_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent("myFormat"))
     {
         EquipmentDTO equip = e.Data.GetData("myFormat") as EquipmentDTO;
         Inventory.Remove(equip);
         RoomEquipment.Add(equip);
         Moved.Add(equip);
     }
 }
Exemplo n.º 28
0
 /// <summary>
 /// Remove the item at Items[i]
 /// </summary>
 /// <param name="i">Position in the Items array</param>
 public void RemoveAt(int i)
 {
     Moved?.Invoke(Items[i], -1);
     Items[i] = Items[Count - 1];
     Items.RemoveAt(Count - 1);
     if (i < Count)
     {
         SiftDown(i);
     }
 }
Exemplo n.º 29
0
        protected override void OnValueChanged(double oldValue, double newValue)
        {
            base.OnValueChanged(oldValue, newValue);

            if (this.IsFocused && IsUnison)
            {
                var delta = (newValue - oldValue) / GetRangeRate();
                Moved?.Invoke(this, delta);
            }
        }
Exemplo n.º 30
0
        private void Knob_MouseMove(object sender, MouseEventArgs e)
        {
            ///!!!!!!!!!!!!!!!!!
            /// YOU MUST CHANGE THE FUNCTION!!!!
            ///!!!!!!!!!!!!!!
            if (!Knob.IsMouseCaptured)
            {
                return;
            }

            Point newPos = e.GetPosition(Base);

            Point deltaPos = new Point(newPos.X - _startPos.X, newPos.Y - _startPos.Y);

            double distance = Math.Round(Math.Sqrt(deltaPos.X * deltaPos.X + deltaPos.Y * deltaPos.Y));

            if (distance >= canvasWidth / 2 || distance >= canvasHeight / 2)
            {
                return;
            }
            Aileron = Math.Round(2.1 * deltaPos.X / canvasWidth, 2);
            if (Aileron > 1)
            {
                Aileron = 1;
            }
            else if (Aileron < -1)
            {
                Aileron = -1;
            }
            Elevator = Math.Round(-2.1 * deltaPos.Y / canvasHeight, 2);
            if (Elevator > 1)
            {
                Elevator = 1;
            }
            else if (Elevator < -1)
            {
                Elevator = 1;
            }

            knobPosition.X = deltaPos.X;
            knobPosition.Y = deltaPos.Y;

            if (Moved == null ||
                (!(Math.Abs(_prevAileron - Aileron) > AileronStep) && !(Math.Abs(_prevElevator - Elevator) > ElevatorStep)))
            {
                return;
            }

            Moved?.Invoke(this, new VirtualJoystickEventArgs {
                Aileron = Aileron, Elevator = Elevator
            });
            _prevAileron  = Aileron;
            _prevElevator = Elevator;
        }