void PositionChanged(PositionChanged e) { var surface = _surfaces.Where(s => s.BoundingBox.Contains(e.GameObject.Body.Position)).Single(); var previousSurface = e.GameObject.Surface; e.GameObject.Surface = surface; if (previousSurface != null) _eventTriggerer.Trigger(new RemoveForceRequest(e.GameObject, previousSurface.FrictionForce)); _eventTriggerer.Trigger(new AddForceRequest(e.GameObject, surface.FrictionForce)); }
/// <inheritdoc/> private void OnListenerPositionChanged(object sender, PositionEventArgs e) { if (!IsListening) // ignore anything that might come in afterwards { return; } lock (positionSync) { lastPosition = e.Position; PositionChanged?.Invoke(this, e); } }
private async void Geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { if (args == null) { return; } CurrentPosition = args.Position; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { PositionChanged?.Invoke(this, CurrentPosition); }); }
void SetPosition(VirtualSnapshotPoint bufferPosition) { var oldPos = currentPosition; var bufPos = bufferPosition; currentPosition = new CaretPosition(bufPos, new MappingPoint(bufPos.Position, PointTrackingMode.Negative), Affinity); if (!CaretEquals(oldPos, currentPosition)) { if (imeState.CompositionStarted) { MoveImeCompositionWindow(); } PositionChanged?.Invoke(this, new CaretPositionChangedEventArgs(textView, oldPos, Position)); } }
public ReelSet(IReadOnlyList <Reel> reels) { Reels = reels; var num = 1; foreach (var reel in reels) { reel.ReelNumber = num; num++; reel.PositionChanged += (sender, args) => { PositionChanged?.Invoke(this, args); }; } }
void SetExplicitPosition(VirtualSnapshotPoint bufferPosition) { var oldPos = currentPosition; var bufPos = bufferPosition; SetPositionCore(bufPos); if (oldPos != currentPosition) { if (imeState.CompositionStarted) { MoveImeCompositionWindow(); } PositionChanged?.Invoke(this, new CaretPositionChangedEventArgs(textView, oldPos, Position)); } }
private void OnCollisionStay(Collision collision) { if (collision.gameObject.CompareTag("Ground") || collision.gameObject.CompareTag("MoveablePlatform")) { Decelerate(0.08f); } if (collision.gameObject.CompareTag("MoveablePlatform")) { Decelerate(0.08f); FollowMoveablePlatform(_isGroundedToMp, collision); } PositionChanged?.Invoke(transform.position); }
public void Start(double xNoise, double yNoise, double zNoise, double simulationTime = -1) { Task.Run(() => { Random rand = new Random(); if (simulationTime == -1) { double t = 0; double z; do { double x = x0 + vx0 * t + xNoise * (rand.NextDouble() - 0.5); double y = y0 + vy0 * t + yNoise * (rand.NextDouble() - 0.5); z = z0 + vz0 * t - 9.81 / 2.0 * 1000.0 * t * t + zNoise * (rand.NextDouble() - 0.5); if (t > 0.2 && t < 0.3) { //z -= 50; } Vector <double> position = Vector <double> .Build.DenseOfArray( new double[] { x, y, z } ); PositionChanged?.Invoke(position, t); t += 0.004; Thread.Sleep(4); } while (z >= -100); } else { for (double t = 0; t < simulationTime; t += 0.004) { double x = x0 + vx0 * t + xNoise * (rand.NextDouble() - 0.5); double y = y0 + vy0 * t + yNoise * (rand.NextDouble() - 0.5); double z = z0 + vz0 * t - 9.81 / 2.0 * 1000.0 * t * t + zNoise * (rand.NextDouble() - 0.5); Vector <double> position = Vector <double> .Build.DenseOfArray( new double[] { x, y, z } ); PositionChanged?.Invoke(position, t); Thread.Sleep(4); } } }); }
/// <summary> /// Initializes a new instance of the <see cref="MediaElement" /> class. /// </summary> public MediaElement() : base() { ContentGrid = new Grid { Name = nameof(ContentGrid) }; Content = ContentGrid; ContentGrid.HorizontalAlignment = HorizontalAlignment.Stretch; ContentGrid.VerticalAlignment = VerticalAlignment.Stretch; ContentGrid.Children.Add(ViewBox); Stretch = ViewBox.Stretch; StretchDirection = ViewBox.StretchDirection; Logger = new GenericMediaLogger <MediaElement>(this); mediaElementCore = new MediaElementCore(this, WPFUtils.IsInDesignTime); if (WPFUtils.IsInDesignTime) { // Shows an FFmpeg image if we are in design-time var bitmap = Properties.Resources.FFmpegMediaElementBackground; var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap( bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); var controlBitmap = new WriteableBitmap(bitmapSource); ViewBox.Source = controlBitmap; } else { // Bind to RoutedEvent events mediaElementCore.MediaOpening += (s, e) => RaiseMediaOpeningEvent(); mediaElementCore.MediaOpened += (s, e) => RaiseMediaOpenedEvent(); mediaElementCore.MediaClosed += (s, e) => RaiseMediaClosedEvent(); mediaElementCore.MediaFailed += (s, e) => RaiseMediaFailedEvent(e.Exception); mediaElementCore.MediaEnded += (s, e) => RaiseMediaEndedEvent(); mediaElementCore.BufferingStarted += (s, e) => RaiseBufferingStartedEvent(); mediaElementCore.BufferingEnded += (s, e) => RaiseBufferingEndedEvent(); mediaElementCore.SeekingStarted += (s, e) => RaiseSeekingStartedEvent(); mediaElementCore.SeekingEnded += (s, e) => RaiseSeekingEndedEvent(); // Bind to non-RoutedEvent events mediaElementCore.MessageLogged += (o, e) => MessageLogged?.Invoke(this, e); mediaElementCore.PositionChanged += (s, e) => PositionChanged?.Invoke(this, e); // Bind to INotifyPropertyChanged event: PropertyChanged mediaElementCore.PropertyChanged += MediaElementCore_PropertyChanged; } m_Metadata = CollectionViewSource.GetDefaultView(mediaElementCore.Metadata) as ICollectionView; }
private static void OnPositionChanged(object sender, PositionEventArgs e) { //If updating the UI, ensure you invoke on main thread var position = e.Position; var output = "Full: Lat: " + position.Latitude + " Long: " + position.Longitude; output += "\n" + $"Time: {position.Timestamp}"; output += "\n" + $"Heading: {position.Heading}"; output += "\n" + $"Speed: {position.Speed}"; output += "\n" + $"Accuracy: {position.Accuracy}"; output += "\n" + $"Altitude: {position.Altitude}"; output += "\n" + $"Altitude Accuracy: {position.AltitudeAccuracy}"; Debug.WriteLine(output); PositionChanged?.Invoke(sender, e); }
public ControlBar() { InitializeComponent(); this.Background = new SolidColorBrush(Colors.Transparent); Seekbar.TimePositionChanged += Seekbar_OnTimePositionChange; Seekbar.PositionChanged += (position) => PositionChanged?.Invoke(position); Volume.VolumeChanged += (volume) => VolumeChanged?.Invoke(volume); Play.PlayStateChanged += (play) => PlayStateChanged?.Invoke(play); Maximize.Clicked += () => MaximizeClicked?.Invoke(); Menu.AudioClicked += () => AudiosClicked?.Invoke(); Menu.SubtitlesClicked += () => SubtitlesClicked?.Invoke(); Menu.ExitClicked += () => ExitClicked?.Invoke(); Menu.ConfigClicked += () => ConfigClicked?.Invoke(); this.MouseLeave += ControlBar_MouseLeave; this.MouseEnter += ControlBar_MouseEnter; }
public AudioPlayer() { InitializeComponent(); Rewind_Button.Opacity = 0; FastForward_Button.Opacity = 0; RewindButton_Transform.TranslateX = 44; FastForwardButton_Transform.TranslateX = -44; Position_Slider.AddHandler(PointerReleasedEvent, new PointerEventHandler((s, e) => PositionChanged?.Invoke(this, new PositionChangeEventArgs(true, Player.Position))), true); GlobalKeyNotifier.KeyDown += OnKeyDown; GlobalKeyNotifier.KeyUp += OnKeyUp; }
private GpsReceiver() { _readingIsComing = false; _readingWait = new ManualResetEvent(false); _reading = null; _readingTimeoutMS = 120000; _listenerHeadings = new List <Tuple <EventHandler <PositionEventArgs>, bool> >(); _locator = CrossGeolocator.Current; _locator.DesiredAccuracy = SensusServiceHelper.Get().GpsDesiredAccuracyMeters; _locator.PositionChanged += (o, e) => { SensusServiceHelper.Get().Logger.Log("GPS position has changed.", LoggingLevel.Verbose, GetType()); PositionChanged?.Invoke(o, e); }; }
private void tracker_GazeDataReceived(IEyeTrackerDriver sender, GazeData gaze) { double?distance = gaze.GetEyeDistance(); double?relativeEyeDistance = gaze.GetRelativeEyeDistance(); var recommendation = GetRecommendation(relativeEyeDistance); // Point (0,0,0) of the TrackBox Coordinate System is in the top right corner nearest to the eye tracker from the user's // point of view (see Figure 3, Tobii Analytics SDK Developers Guide, p. 15), not the top left corner like the screen is, // so we swap the X coordinate. Y coordinate is still in the right direction. var leftEyePosition = new Point2(1 - gaze.LeftEye.EyePosition3DRelative.X, gaze.LeftEye.EyePosition3DRelative.Y); var rightEyePosition = new Point2(1 - gaze.RightEye.EyePosition3DRelative.X, gaze.RightEye.EyePosition3DRelative.Y); PositionChanged?.Invoke(this, new EyesPosition(leftEyePosition, gaze.Validity.HasLeftEye(), rightEyePosition, gaze.Validity.HasRightEye(), distance, relativeEyeDistance, recommendation)); }
public PositionSynchronizer() { Timeout = 1000; _isPosAndTradesEven = true; TimeToCheckIfPositionEqual += () => { _isPosAndTradesEven = _absPosVol == _absTradeVol; PositionChanged?.Invoke(); if (IsPosAndTradesEven) { _eventWaiter.Set(); } }; }
void ImmediateCaretPositionChanged(object sender, CaretLocationEventArgs args) { // MD doesn't fire textEditor.CaretPositionChanged until after the command has gone completely through the command chain. // Too much VS stuff depends on it getting updated earlier, so we'll use this event which fires earlier. int position = _textEditor.CaretOffset; VirtualSnapshotPoint vsp = new VirtualSnapshotPoint(_textView.TextSnapshot, position); _insertionPoint = vsp; if (args.CaretChangeReason == CaretChangeReason.Movement) { SnapshotPoint snapshotPoint = new SnapshotPoint(_textView.TextSnapshot, position); IMappingPoint mappingPoint = _textView.BufferGraph.CreateMappingPoint(snapshotPoint, PointTrackingMode.Positive); CaretPosition newCaretPosition = new CaretPosition(vsp, mappingPoint, _caretAffinity); CaretPositionChangedEventArgs eventArgs = new CaretPositionChangedEventArgs(_textView, Position, newCaretPosition); PositionChanged?.Invoke(this, eventArgs); } }
void Input_TouchEnd(TouchEndEventArgs e) { if (DateTime.UtcNow - touchStarted > TimeSpan.FromMilliseconds(200)) { return; } Ray cameraRay = camera.GetScreenRay(e.X / (float)Application.Graphics.Width, e.Y / (float)Application.Graphics.Height); var result = octree.Raycast(cameraRay, RayQueryLevel.Triangle, 100, DrawableFlags.Geometry, 0x70000000); if (result != null && result.Count > 0) { var item = result.First(); cubeNode.Position = item.Position; cubeNode.Translate(item.Normal / 50, TransformSpace.Local); PositionChanged?.Invoke(cubeNode.Position); } }
private void OnPositionChanged(DependencyPropertyChangedEventArgs e) { if (e.NewValue != null) { PositionChanged.Raise(this, new PositionChangedEventArgs { Position = (Point)e.NewValue, PreviousPosition = (Point)e.OldValue }); } if (plotter?.Viewport?.Transform?.DataTransform != null) { // Bit of a WTF, for some reason I have to apply the transform twice Point dataPoint = Position.DataToViewport(plotter.Viewport.Transform); ViewportPanel.SetX(this, dataPoint.X); ViewportPanel.SetY(this, dataPoint.Y); } }
private void updatePosition() { if (position % stepsPerTick == 0) { Position = Numbers.Constrain(Position, MinValue, MaxValue); if (Position == oldPosition) { return; } PositionChanged?.Invoke(this, new PositionChangedEventArgs { NewPosition = Position }); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Position))); oldPosition = Position; } }
private void LocationChanged(object sender, Location location) { var position = new Position { Latitude = location.Latitude, Longitude = location.Longitude, Accuracy = location.Accuracy, AltitudeAccuracy = location.Accuracy, Altitude = location.Altitude, Heading = location.Bearing, Speed = location.Speed, Timestamp = DateTimeOffset.FromUnixTimeMilliseconds(location.Time) }; LastPosition = position; System.Diagnostics.Debug.WriteLine($"PositionChanged: {position.Latitude} {position.Longitude}"); PositionChanged?.Invoke(this, new PositionEventArgs(position)); }
private void SecondTimer(object obj) { bool shouldDispatch = false; Visibility loadingVis = Visibility.Visible; string buffering = string.Empty; bool cachepause = MPVInterop.Instance.GetProperty("paused-for-cache") == "yes"; bool seekpause = MPVInterop.Instance.GetProperty("seeking") == "yes"; if ((!_loading && cachepause) || (!_loading && seekpause)) { _inc = 0; _loading = true; } if (!seekpause && !cachepause) { _loading = false; loadingVis = Visibility.Collapsed; shouldDispatch = true; } if (_inc % 10 == 0) { shouldDispatch = true; if (_loading && cachepause) { buffering = MPVInterop.Instance.GetDoubleProperty("cache-buffering-state") + "%"; } _inc = 0; } _inc++; if (shouldDispatch) { Dispatcher.Invoke(() => { if (Duration != 0) { Bar.Position = (long)Time; PositionChanged?.Invoke((long)Time); } Loading.Visibility = loadingVis; Loading.Percentage = buffering; }); } }
private void OnTimedEvent(object source, ElapsedEventArgs e) { Position %= 16; foreach (var sequencerLane in SequencerLanes) { if (sequencerLane.SequencerSteps[Position].IsActive) { Task.Run(() => // Adding a Task.Run to call play audio actually minimizes gives a real differency by 5ms. { sequencerLane.AudioPlayer.Play(); }); } } PositionChanged.Invoke(this, new PositionChangedEventArgs { Position = Position }); Position++; }
public async Task StartListeningAsync() { _isListening = true; while (_isListening) { var longitude = _currentPosition.Position.Longitude; var latitude = _currentPosition.Position.Latitude; longitude += 0.0025; _currentPosition = new Geopoint(new BasicGeoposition { Latitude = latitude, Longitude = longitude }); PositionChanged?.Invoke(this, _currentPosition); await Task.Delay(1000); } }
void TapGestureRecognizer_Tapped(object sender, EventArgs e) { Grid grid = (Grid)sender; //Button clickedButton = (Button)sender; // System.Diagnostics.Debug.WriteLine($"clicked button text : {clickedButton.Text}"); for (int i = 0; i < buttonsList.Count; i++) { if (grid == buttonsList[i]) { buttonsList[i].Children[2].BackgroundColor = AppThemeConstants.SelectedTabColor; Image img = buttonsList[i].Children[0] as Image; if (img != null) { img.Source = this.Titles[i].SelectedIcon; } Label btn = buttonsList[i].Children[1] as Label; if (btn != null) { btn.TextColor = AppThemeConstants.SelectedTabColor; } TabbedCarousel.Position = i; SelectedPosition = TabbedCarousel.Position; PositionChanged?.Invoke(this, SelectedPosition); } else { buttonsList[i].Children[2].BackgroundColor = AppThemeConstants.UnSelectedTabColor; Label btn = buttonsList[i].Children[1] as Label; if (btn != null) { btn.TextColor = AppThemeConstants.UnSelectedTabColor; } Image img = buttonsList[i].Children[0] as Image; if (img != null) { img.Source = this.Titles[i].Icon; } } } }
private void MoveThumb_DragDelta(object sender, DragDeltaEventArgs e) { if (DataContext is ContentControl designerItem) { var dragDelta = new Point(e.HorizontalChange, e.VerticalChange); var scaleTransform = designerItem.GetTransform <ScaleTransform>(); dragDelta = scaleTransform.Transform(dragDelta); var transformGroup = designerItem.GetTransform <TransformGroup>(TransformProperties.RotateGroup); dragDelta = transformGroup.Transform(dragDelta); var x = Canvas.GetLeft(designerItem) + dragDelta.X; var y = Canvas.GetTop(designerItem) + dragDelta.Y; Canvas.SetLeft(designerItem, x); Canvas.SetTop(designerItem, y); PositionChanged?.Invoke(new Point(x, y)); } }
public SmartGMapControl() { this.Loaded += new RoutedEventHandler(SmartGMapControl_Loaded); // map events OnPositionChanged += new PositionChanged(MainMap_OnCurrentPositionChanged); OnTileLoadComplete += new TileLoadComplete(MainMap_OnTileLoadComplete); OnTileLoadStart += MainMap_OnTileLoadStart; MinZoom = 1; MaxZoom = int.MaxValue; Zoom = 4; //GMapMarker it = new GMapMarker(Position); //{ // it.ZIndex = 55; // it.Shape = new CustomMarkerRed(this, it, "Welcome to Lithuania! ;}"); //} //Markers.Add(it); }
private void Sbar_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (_clamp) { _clamp = false; return; } if (_drag) { TimePosition = (long)sbar.Value; NegativeTimePosition = MaxPosition - (long)sbar.Value; TimePositionChanged?.Invoke((long)sbar.Value); } else { SetValue(PositionProperty, (long)sbar.Value); TimePositionChanged?.Invoke((long)sbar.Value); PositionChanged?.Invoke((long)sbar.Value); } }
/// <summary> /// зажата сфера /// </summary> public void OnMouseDrag() { //Detect when there is a mouse click if (Input.GetMouseButton(0)) { //Create a ray from the Mouse click position Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (plane.Raycast(ray, out float enter)) { //Get the point that is clicked Vector3 hitPoint = ray.GetPoint(enter); //Move your GameObject to the point where you clicked transform.position = hitPoint; PositionChanged?.Invoke(); } } }
public void Move() { var dPoint = new Point(0, 0); var distance = 10; switch (Player.CreaturesDirection) { case Direction.Right: dPoint.X = distance; break; case Direction.Left: dPoint.X = -distance; break; } Position = new Point(Position.X + dPoint.X, Position.Y + dPoint.Y); PositionChanged?.Invoke(this); }
public void Update() { XVelocity *= 0.9f; if (Entity.XDirection != 0) { XVelocity += _velocityChange * Entity.XDirection; } else { XVelocity *= 0.9f; if (Math.Abs(XVelocity) < 1f) { XVelocity = 0; } } XVelocity = MathHelper.Clamp(XVelocity, -_maxVelocity, _maxVelocity); CheckPlayerHit(); var currentY = Entity.Y; var currentX = Entity.X; var xMove = XVelocity; var yMove = -YVelocity; Entity.GameArea.Move(Entity, xMove, yMove, YVelocity); Grounded = Math.Abs(currentY - Entity.Y) < 0.01f; if (Grounded) { YVelocity = 0; } if (Math.Abs(currentX - Entity.X) > 0.01f || Math.Abs(currentY - Entity.Y) > 0.01f) { PositionChanged?.Invoke(this); } }
public void Move(Direction direction = null) { if (!IsPositioned && Board.GameMode != GameMode.Graphic) { Board.PositionEntity(this); } if (!Board.IsAllEntitiesPositioned) { return; } SetMovePosition(direction); int blockingEntityId; if (Board.TryMoveEntity(this, _movePosition, out blockingEntityId) == MoveResult.Clear) { PositionChanged?.Invoke(this, EventArgs.Empty); } }
private GpsReceiver() { _readingTimeout = TimeSpan.FromMinutes(2); _listenerHeadings = new List <Tuple <EventHandler <PositionEventArgs>, bool> >(); _locator = CrossGeolocator.Current; _locator.DesiredAccuracy = SensusServiceHelper.Get().GpsDesiredAccuracyMeters; _locator.PositionChanged += (o, e) => { SensusServiceHelper.Get().Logger.Log("GPS position has changed.", LoggingLevel.Verbose, GetType()); // TODO: the Position has a timestamp, but it does not get updated correctly: // // https://github.com/predictive-technology-laboratory/sensus/issues/496 // https://github.com/jamesmontemagno/GeolocatorPlugin/issues/249 // // set manually to the current time e.Position.Timestamp = DateTimeOffset.UtcNow; PositionChanged?.Invoke(o, e); }; }