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; }
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(); } }
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); }
/// <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); } }
/// <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)); } }
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; }
private void Watcher_Renamed(object sender, RenamedEventArgs e) { if (Moved != null) { var Args = new MovedArticleEventArgs(this, e.OldFullPath, e.FullPath); Moved.Invoke(this, Args); } }
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(); } }
private void OnLocationUpdated(MvxGeoLocation newLocation) { Moved?.Invoke(this, new LocationMovedEventArgs { Location = newLocation }); }
public void OnDrag(MouseEventArgs e) { if (Moving) { Position += e.DistanceMoved; Moved?.Invoke(this, e); } }
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); }
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); }
public void OnWindowMoved() { if (DebugStartUp) { Debug.WriteLine(Name + " moved"); } UpdateConfig(); Moved?.Invoke(this); }
internal void fireWheel(int z) { absMouse.z += z; if (Moved != null) { Moved.Invoke(this); } }
public void MoveTo(Point vector) { var position = Position; position.X = vector.X; position.Y = vector.Y; Position = position; Moved.Invoke(); }
protected override void OnValueChanged(double oldValue, double newValue) { base.OnValueChanged(oldValue, newValue); if (this.IsFocused && IsUnison) { Moved?.Invoke(this, newValue - oldValue); } }
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); } }
protected override void OnValueChanged(double oldValue, double newValue) { base.OnValueChanged(oldValue, newValue); if (IsUnison && _canDrag && (_isDragStarting || _thumb.IsDragging)) { Moved?.Invoke(this, newValue - oldValue); } }
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)); }
internal void fireMoved(int x, int y) { absMouse.x = x; absMouse.y = y; if (Moved != null) { Moved.Invoke(this); } }
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); }
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); }
public void MoveTo(Point vector) { Moved?.Invoke(); var position = Position; position.X += vector.X; position.Y += vector.Y; Position = position; Moved?.Invoke(); }
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); } }
/// <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); } }
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); } }
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; }