internal void Reset(WorldFile worldFile) { Position = worldFile.KarelStartPosition; Direction = worldFile.KarelStartDirection; PositionChanged.Invoke(this); DirectionChanged.Invoke(this); }
protected override void positionUpdated() { if (PositionChanged != null) { PositionChanged.Invoke(this.Owner); } }
/// <summary> /// Callback for the timer to report the position in the track. /// </summary> /// <param name="state">State.</param> private void ReportPosition(object state) { string trackId = null; TimeSpan totalTime = new TimeSpan(); TimeSpan currentTime = new TimeSpan(); bool doNotReportPosition; lock (this) { doNotReportPosition = _doNotReportPosition; if (!doNotReportPosition) { trackId = _trackId; totalTime = _waveStream.TotalTime; currentTime = _waveStream.CurrentTime; // Set the time when we last reported. This is required to calculate the delay for the timer when we are resuming from a pause. _lastReportTime = DateTime.Now; } } if (!doNotReportPosition) { PositionChanged?.Invoke(this, new PositionChangedEventArgs(trackId, new TrackPosition(totalTime, currentTime))); } }
protected virtual void OnPositionChanged(EventArgs e) { if (PositionChanged != null) { PositionChanged.Invoke(this, e); } }
public void OnLocationChanged(Location location) { if (location.Provider != _ActiveProvider) { if (_ActiveProvider != null && _Manager.IsProviderEnabled(_ActiveProvider)) { var pr = _Manager.GetProvider(location.Provider); var lapsed = GetTimeSpan(location.Time) - GetTimeSpan(_LastLocation.Time); if (pr.Accuracy > _Manager.GetProvider(_ActiveProvider).Accuracy && lapsed < _TimePeriod.Add(_TimePeriod)) { location.Dispose(); return; } } _ActiveProvider = location.Provider; } var previous = Interlocked.Exchange(ref _LastLocation, location); previous?.Dispose(); PositionChanged?.Invoke(this, new PositionEventArgs(location.ToPosition())); }
protected virtual void OnPositionChanged(EventArgs e) { if (_textArea.MotherTextEditorControl.IsInUpdate) { if (_firePositionChangedAfterUpdateEnd == false) { _firePositionChangedAfterUpdateEnd = true; _textArea.Document.UpdateCommited += FirePositionChangedAfterUpdateEnd; } return; } else if (_firePositionChangedAfterUpdateEnd) { _textArea.Document.UpdateCommited -= FirePositionChangedAfterUpdateEnd; _firePositionChangedAfterUpdateEnd = false; } List <FoldMarker> foldings = _textArea.Document.FoldingManager.GetFoldingsFromPosition(_line, _column); bool shouldUpdate = false; foreach (FoldMarker foldMarker in foldings) { shouldUpdate |= foldMarker.IsFolded; foldMarker.IsFolded = false; } if (shouldUpdate) { _textArea.Document.FoldingManager.NotifyFoldingsChanged(EventArgs.Empty); } PositionChanged?.Invoke(this, e); _textArea.ScrollToCaret(); }
protected override void NewTitle(string title) { if (!String.IsNullOrEmpty(title)) { double newLat, newLong, newZoom; // Incoming title should look like "6, (-27.15, 151.25)" // That is Zoom, then lat, long pair // We remove the brackets and split on the commas title = title.Replace("(", ""); title = title.Replace(")", ""); string[] parts = title.Split(new char[] { ',' }); if (Double.TryParse(parts[0], out newZoom) && newZoom != _zoom) { _zoom = newZoom; if (ZoomChanged != null) { ZoomChanged.Invoke(this, EventArgs.Empty); } } if (Double.TryParse(parts[1], out newLat) && Double.TryParse(parts[2], out newLong) && (newLat != _center.Latitude || newLong != Center.Longitude)) { _center.Latitude = newLat; _center.Longitude = newLong; if (PositionChanged != null) { PositionChanged.Invoke(this, EventArgs.Empty); } } } }
public void OnConfigured() { int w, h; if (!OverrideRedirect) { Native.GtkWindowGetSize(GtkWidget, out w, out h); var size = ClientSize = new Size(w, h); if (_lastSize != size) { Resized?.Invoke(size); _lastSize = size; } } var pos = Position; if (_lastPosition != pos) { PositionChanged?.Invoke(pos); _lastPosition = pos; } var scaling = Scaling; if (_lastScaling != scaling) { ScalingChanged?.Invoke(scaling); _lastScaling = scaling; } }
/// <summary> /// Updates the pacman positon. /// If we have no direction (ak no key pressed), just keep going the same as before. /// Otherwise check if we can use the new direction, and move. Triggers the event. /// isJump represents the "teleporting" spots on the sides of the terrain. /// </summary> private void UpdateTarget() { bool isJump; if (_dir.Count <= 0) { _target = TerrainManager.Instance.GetNextAvailableNode(x, y, _currentDir, out x, out y, out isJump); PositionChanged?.Invoke(this, new Vector2(x, y)); } else { var currX = x; var currY = y; var newTarget = TerrainManager.Instance.GetNextAvailableNode(x, y, _dir.Peek(), out x, out y, out isJump); if (currX == x && currY == y) { newTarget = TerrainManager.Instance.GetNextAvailableNode(x, y, _currentDir, out x, out y, out isJump); PositionChanged?.Invoke(this, new Vector2(currX, currY)); } else { _currentDir = _dir.Dequeue(); } _target = newTarget; } if (isJump) { transform.position = _target; } RotatePacman(); }
void backgroundAudioTimeTask() { // iterate until dispose is called while (playerClosing == false) { if (PositionChanged != null && _audioFileReader != null) { var currentPosition = Math.Truncate(_audioFileReader.CurrentTime.TotalSeconds); var currentLength = Math.Truncate(_audioFileReader.TotalTime.TotalSeconds); if (currentPosition != lastAudioPosition || currentLength != lastAudioLength) { lastAudioPosition = currentPosition; lastAudioLength = currentLength; var tsPosition = TimeSpan.FromSeconds(currentPosition); var tsLength = TimeSpan.FromSeconds(currentLength); PositionChanged.Invoke(new AudioPositionChanged(tsPosition, tsLength)); } } // sleep one frame System.Threading.Thread.Sleep(33); } }
public async Task StartListening() { if (CrossGeolocator.Current.IsListening) { return; } if (Device.RuntimePlatform.Equals(Device.Android)) { await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(5), 10, true); } else { await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 100, true, new ListenerSettings { ActivityType = ActivityType.AutomotiveNavigation, AllowBackgroundUpdates = true, DeferLocationUpdates = true, DeferralTime = TimeSpan.FromSeconds(1), ListenForSignificantChanges = false, PauseLocationUpdatesAutomatically = false }); } CrossGeolocator.Current.PositionChanged += (s, e) => { PositionChanged?.Invoke(s, e); }; }
private void OnPositionChanged(Location location) { if (PositionChanged != null) { PositionChanged.Invoke(this, new PositionChangedEventArgs(location)); } }
private void setSelectedPosition(int selectedPosition) { if (SelectedPosition == selectedPosition && TabbedCarousel.Position == SelectedPosition) { return; } for (int i = 0; i < buttonsList.Count; i++) { buttonsList[i].Children[2].BackgroundColor = selectedPosition == i ? AppThemeConstants.SelectedTabColor : AppThemeConstants.UnSelectedTabColor; Image img = buttonsList[i].Children[0] as Image; if (img != null) { img.Source = selectedPosition == i ? this.Titles[i].SelectedIcon : this.Titles[i].Icon; } Label btn = buttonsList[i].Children[1] as Label; if (btn != null) { btn.TextColor = selectedPosition == i ? AppThemeConstants.SelectedTabColor : AppThemeConstants.UnSelectedTabColor; } } if (TabbedCarousel.Position != selectedPosition) { TabbedCarousel.Position = selectedPosition; } PositionChanged?.Invoke(this, selectedPosition); if (SelectedPosition != TabbedCarousel.Position) { SelectedPosition = TabbedCarousel.Position; } }
private void mapControl_OnPositionChanged(GMap.NET.PointLatLng point) { if (PositionChanged != null) { PositionChanged.Invoke(mapControl, EventArgs.Empty); } }
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); App.LocalDb.InsertOrReplace(new Models.Location() { Id = Guid.NewGuid(), UserId = Settings.CurrentUserId, Latitude = position.Latitude, Longitude = position.Longitude, Altitude = position.Altitude, EditDate = DateTime.Now, IsToSync = true }); Debug.WriteLine("Location Added!"); PositionChanged?.Invoke(sender, e); //MessagingCenter.Send(this, MessageKey.POSITION_CHANGED, e.Position); }
private bool OnConfigured(IntPtr gtkwidget, IntPtr ev, IntPtr userdata) { var size = ClientSize; if (_lastSize != size) { Resized?.Invoke(size); _lastSize = size; } var pos = Position; if (_lastPosition != pos) { PositionChanged?.Invoke(pos); _lastPosition = pos; } var scaling = Scaling; if (_lastScaling != scaling) { ScalingChanged?.Invoke(scaling); _lastScaling = scaling; } return(false); }
public void OnLocationChanged(Location location) { PositionChanged?.Invoke(this, new PositionEventArgs() { Location = location }); }
protected void OnPositionChanged(Point offset, Point pos) { if (PositionChanged != null) { PositionChanged.Invoke(this, new VertexPositionEventArgs(offset, pos, this)); } }
public async Task OpenAsync() { await InitializeMarketsAsync(); await RealtimeSource.TryOpenAsync(); if (!Client.IsAuthenticated) { return; } Positions.Update((await Client.GetPositionsAsync(BfProductCode.FXBTCJPY, CancellationToken.None)).GetContent()); RealtimeSource.GetChildOrderEventsSource().Subscribe(coe => { var productCode = _marketSymbols[coe.ProductCode]; _markets[productCode].ForwardChildOrderEvents(coe); if (productCode == BfProductCode.FXBTCJPY && coe.EventType == BfOrderEventType.Execution) { Positions.Update(coe).ForEach(e => PositionChanged?.Invoke(this, new BfxPositionEventArgs(coe.EventDate, e))); } }); RealtimeSource.GetParentOrderEventsSource().Subscribe(poe => { _markets[_marketSymbols[poe.ProductCode]].ForwardParentOrderEvents(poe); }); }
public void ForceUpdate(Vector3 position) { if (PositionChanged != null) { PositionChanged.Invoke(position, true); } }
/// <summary> /// Handles control's MouseMove event /// </summary> /// <param name="e"></param> protected override void OnMouseMove(MouseEventArgs e) { var s = CurrentScale; var c = new PointF(e.X - CtlCenter.X, e.Y - CtlCenter.Y); var p = new PointF(c.X / s - Offset.X, c.Y / s - Offset.Y); var d = new PointF(p.X - P0.X, p.Y - P0.Y); if (MoveMode && d != PointF.Empty) { Cursor = Cursors.SizeAll; Offset = new PointF(Offset.X + d.X, Offset.Y + d.Y); if (PositionChanged != null) { PositionChanged.Invoke(this, EventArgs.Empty); } Invalidate(); MapMoved = true; } MapPointed = new PointF(-p.X - MapCenter.X, -p.Y - MapCenter.Y); if (CursorPositionChanged != null) { CursorPositionChanged.Invoke(this, EventArgs.Empty); } base.OnMouseMove(e); }
protected virtual void OnPositionChanged(ValueChangedEventArgs e) { if (!_externallySet) { PositionChanged?.Invoke(this, e); } }
private bool OnConfigured(IntPtr gtkwidget, IntPtr ev, IntPtr userdata) { int w, h; Native.GtkWindowGetSize(GtkWidget, out w, out h); var size = ClientSize = new Size(w, h); if (_lastSize != size) { Resized?.Invoke(size); _lastSize = size; } var pos = Position; if (_lastPosition != pos) { PositionChanged?.Invoke(pos); _lastPosition = pos; } var scaling = Scaling; if (_lastScaling != scaling) { ScalingChanged?.Invoke(scaling); _lastScaling = scaling; } return(false); }
public void OnLocationChanged(Location location) { if (location.Provider != activeProvider) { if (activeProvider != null && manager.IsProviderEnabled(activeProvider)) { var pr = manager.GetProvider(location.Provider); var lapsed = GetTimeSpan(location.Time) - GetTimeSpan(lastLocation.Time); if (pr.Accuracy > manager.GetProvider(activeProvider).Accuracy && lapsed < timePeriod.Add(timePeriod)) { location.Dispose(); return; } } activeProvider = location.Provider; } var previous = Interlocked.Exchange(ref lastLocation, location); if (previous != null) { previous.Dispose(); } PositionChanged?.Invoke(this, new PositionEventArgs(location.ToPosition())); }
private void VlcMediaPlayer_OnPositionChanged(object sender, VlcMediaPlayerPositionChangedEventArgs e) { Position = e.NewPosition; PositionChanged?.Invoke(this, new PositionChangedEventArgs { Position = Position }); }
void PositionChangedResponse(ServoPositionChangedResponse status) { //fire the event PositionChanged?.Invoke(_arm, new DataEventArg <ServoPositionChangedResponse>(status)); //fire the event for the correct servo GetServo(status.ServoID)?.PositionChangedResponse(status); }
public void UpdateCursorWorldPos() { CursorWorldPosition = MainWindow.GetWorldFromScreen(new Vector2( CursorElement.Rect.X + CursorElement.Rect.Width / 2, CursorElement.Rect.Y + CursorElement.Rect.Height / 2 )); PositionEvent?.Invoke(); }
private void mediaPlayer_MediaEnded(object?sender, EventArgs e) { trace("MediaEnded"); dispatcherTimer.Stop(); PositionChanged?.Invoke(this); playNextTrack(); }
public void SetPosition(double position) { if (this._position != position) { this.Position = position; PositionChanged?.Invoke(this, EventArgs.Empty); } }
//-------------------------------------------------------------------------------------------------------------------- // - Fire Position Changed Event //-------------------------------------------------------------------------------------------------------------------- protected virtual void OnPositionChange(Vector3f oldPosition, Vector3f newPosition) { GlobalPosition = Isogeometry.IsoToGlobal(Position); PositionChanged?.Invoke(this, new PositionChangedEventArgs() { OldPosition = oldPosition, NewPosition = newPosition, }); }