public override void Show() { SizeChanged?.Invoke(this, ClientWidth, ClientHeight); LocationChanged?.Invoke(this, 0, 0); _window.Center(); _window.MakeKeyAndOrderFront(_window); }
public void SetLocation(Point location) { Location[0] = location.X; Location[1] = location.Y; LocationChanged?.Invoke(this, EventArgs.Empty); Changed?.Invoke(this, EventArgs.Empty); }
void _windowLocationChangeHook_WinEventReceived(object sender, WinEventHook.WinEventArgs winEventArgs) { #if DEBUG Logger.WinEvents.Verbose($"{winEventArgs.EventType} - Window {winEventArgs.WindowHandle:X} ({Win32Helper.GetClassName(winEventArgs.WindowHandle)} - Object/Child {winEventArgs.ObjectId} / {winEventArgs.ChildId} - Thread {winEventArgs.EventThreadId} at {winEventArgs.EventTimeMs}"); #endif LocationChanged?.Invoke(this, EventArgs.Empty); }
private void InvokeLocationChanged(LocationChangeEventArgs e) { if (LocationChanged != null) { LocationChanged.Invoke(this, e); } }
private static void Locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { App.Dispatcher?.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { LocationChanged?.Invoke(null, args); }); }
static void ReadNextBytes(int offset) { byte [] buffer = new byte [bufSize]; var result = Socket.InputStream.BeginRead(buffer, offset, bufSize, delegate { string raw = string.Join(", ", buffer); string ascii = encoder.GetString(buffer); WriteLine("RAW:\t" + raw); WriteLine("ASCII:\t" + ascii); WriteLine("----"); if (ascii.Contains("STATE") && ascii.Contains("0")) { NoFish?.Invoke(null, EventArgs.Empty); } else if (ascii.Contains("STATE") && ascii.Contains("1")) { YesFish?.Invoke(null, EventArgs.Empty); } //$GPGLL,5821.95899,N,02641.45598,e,085306.00,a,a * 6f if (ascii.Contains("GPGLL")) { string [] pieces = ascii.Split(','); double lat; double lon; try { double.TryParse(pieces [1], out lat); double.TryParse(pieces [3], out lon); if (lat > 0 && lon > 0) { LocationEventArgs args = new LocationEventArgs(); args.Lat = lat / 100; args.Lon = lon / 100; LocationChanged?.Invoke(null, args); } } catch { } } if (!reading) { return; } if (buffer [buffer.Length - 1] == 0) { ReadNextBytes(0); } else { ReadNextBytes(bufSize); } }, null); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Callback, called when the window procedure. </summary> /// /// <param name="message"> [in,out] The message. </param> /// /// <returns> An int. </returns> //////////////////////////////////////////////////////////////////////////////////////////////////// private bool WndProcCallback(ref WindowHookManager.HookMessage message) { switch (message.HookMsgType) { case WindowHookManager.HookMsgType.DPICHANGED: //Note that if the method is enabled and handles scaling, I am afraid to return // true because the originally installed WndProc will not be called and I don't // know what effect that will have regarding a DPI change. Considering that // this entire class removes the window border and TitleBar, there shouldn't be // any issue related to returning false and allowing other listeners to be // notified. _ = ScaleContentForDpiIfEnabled(); DpiChanged?.Invoke(this, EventArgs.Empty); break; case WindowHookManager.HookMsgType.WINDOWPOSCHANGED: LocationChanged?.Invoke(this, EventArgs.Empty); break; } //If you do not handle the message then return false. There may be times when you handle the // message and still need to return false so that other custom callbacks as well as the // original WndProc that was attached to the Window can be called. return(false); }
// Asynchronously listens for changes in GPS location updates public async Task StartListening() { // Check to see if we are currently listening for updates if (CrossGeolocator.Current.IsListening) { return; } // Check what Target OS Platform we are running on whenever the app starts if (Device.RuntimePlatform.Equals(Device.Android)) { await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 100, true); } else { // Start listening for changes in location within the Background for iOS await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 100, true, new ListenerSettings { ActivityType = ActivityType.AutomotiveNavigation, AllowBackgroundUpdates = true, DeferLocationUpdates = true, DeferralDistanceMeters = 500, // 1 DeferralTime = TimeSpan.FromSeconds(1), ListenForSignificantChanges = false, // true PauseLocationUpdatesAutomatically = false }); } // EventHandler to determine whenever the GPS position changes CrossGeolocator.Current.PositionChanged += (sender, e) => { // Raise our LocationChanged EventHandler, using the Coordinates LocationChanged.Invoke(sender, e); }; }
public bool SelectProfile(ProfileMeta info) { lock (lockobj) { using (MyStopWatch.Measure()) { try { var p = Profile.Load(info.Location); UnregisterChangedEventHandlers(); if (ActiveProfile != null) { ActiveProfile.Dispose(); Profiles.Where(x => x.Id == ActiveProfile.Id).First().IsActive = false; } ActiveProfile = p; info.IsActive = true; System.Threading.Thread.CurrentThread.CurrentUICulture = ActiveProfile.ApplicationSettings.Language; System.Threading.Thread.CurrentThread.CurrentCulture = ActiveProfile.ApplicationSettings.Language; Locale.Loc.Instance.ReloadLocale(ActiveProfile.ApplicationSettings.Culture); LocaleChanged?.Invoke(this, null); ProfileChanged?.Invoke(this, null); LocationChanged?.Invoke(this, null); RegisterChangedEventHandlers(); } catch (Exception ex) { Logger.Debug(ex.Message + Environment.NewLine + ex.StackTrace); return(false); } return(true); } } }
protected virtual void OnLocationChanged() { if (LocationChanged != null) { LocationChanged.Invoke(this, EventArgs.Empty); } }
void _windowLocationChangeHook_WinEventReceived(object sender, WinEventHook.WinEventArgs winEventArgs) { #if DEBUG //Logger.WinEvents.Verbose(string.Format("{winEventArgs.EventType} - Window {winEventArgs.WindowHandle:X} ({Win32Helper.GetClassName(winEventArgs.WindowHandle)} - Object/Child {winEventArgs.ObjectId} / {winEventArgs.ChildId} - Thread {winEventArgs.EventThreadId} at {winEventArgs.EventTimeMs}"); Logger.WinEvents.Verbose(string.Format("{0} - Window {1:X} ({2} - Object/Child {3} / {4} - Thread {5} at {6}", winEventArgs.EventType, winEventArgs.WindowHandle, Win32Helper.GetClassName(winEventArgs.WindowHandle), winEventArgs.ObjectId, winEventArgs.ChildId, winEventArgs.EventThreadId, winEventArgs.EventTimeMs)); #endif LocationChanged.Invoke(this, EventArgs.Empty); }
protected virtual void OnLocationChanged() { LocationChanged?.Invoke(this, EventArgs.Empty); foreach (var c in Controls) { c.Location = c.Location; } }
public override void OnReceive(Context context, Intent intent) { switch (intent.Action) { case Constants.Action.LOCATION_CHANGED: LocationChanged?.Invoke(this, new LocationChangedEventArgs(intent.GetParcelableExtra(Constants.Extra.LOCATION_DATA) as Location)); break; } }
void OnGeolocatorPositionChanged(Geolocator sender, PositionChangedEventArgs args) { BasicGeoposition coordinate = args.Position.Coordinate.Point.Position; Device.BeginInvokeOnMainThread(() => { LocationChanged?.Invoke(this, new GeographicLocation(coordinate.Latitude, coordinate.Longitude)); }); }
public void Move(float dt) { var prevLoc = Location; Location += Speed * dt; DeltaLocation += Location - prevLoc; LocationChanged?.Invoke(this, EventArgs.Empty); Changed?.Invoke(this, EventArgs.Empty); }
public void AddLocation(RideLocationDto location) { Debug.WriteLine(location); lastLocation = location; LocationChanged?.Invoke(new LocationChangedEventArgs { Location = location }); }
public void OnLocationChanged(CLLocationCoordinate2D location) { var args = new LocationEventArgs { Latitude = location.Latitude, Longitude = location.Longitude }; LocationChanged?.Invoke(this, args); }
public void ChangeLatitude(double latitude) { var hemisphereType = ActiveProfile.AstrometrySettings.HemisphereType; if ((hemisphereType == Hemisphere.SOUTHERN && latitude > 0) || (hemisphereType == Hemisphere.NORTHERN && latitude < 0)) { latitude = -latitude; } ActiveProfile.AstrometrySettings.Latitude = latitude; LocationChanged?.Invoke(this, null); }
/// <summary> /// Method called every frame. /// </summary> private void Update() { if (Input.GetKeyUp(KeyCode.Space)) { Invoke("CallThrowBalloon", 1f); } // Broadcast location change OnLocationChanged?.Invoke(slot.position, slot.rotation * throwVelocity); }
void ILocationListener.OnLocationChanged(ALocation location) { var l = new Location( location.Latitude, location.Longitude, location.Accuracy, UNIX_EPOCH.AddMilliseconds(location.Time)); LatestLocation = l; LocationChanged?.Invoke(this, l); }
public async Task <Geocoordinate> GetLocation(CancellationToken ct) { if (await GetIsPermissionGranted(ct)) { LocationChanged?.Invoke(this, new LocationChangedEventArgs(_geoCoordinate)); return(_geoCoordinate); } throw new InvalidOperationException("Location permission was not granted."); }
void OnDisplayLocationChanged(Display display, int x, int y) { if ((_flags & WindowFlags.UpdatingDisplay) == 0) { _flags |= WindowFlags.UpdatingWindow; Left = x; Top = y; _flags &= ~WindowFlags.UpdatingWindow; } LocationChanged?.Invoke(this, System.EventArgs.Empty); }
public override void SetLocation(int x, int y) { if (x < Sizes.Collection["game"].Width - 200 && x > -5 && y > -5 && y < Sizes.Collection["game"].Height) { Location = new Point(x, y); X = x; Y = y; LocationChanged?.Invoke(); } }
public virtual void SetLocation(int x, int y) { Location = new Point(x, y); X = x; Y = y; if (!InBounds()) { GotOutOfScreen?.Invoke(); } LocationChanged?.Invoke(); }
public void OnLocationChanged(Android.Locations.Location location) { if (location != null) { LocationEventArgs args = new LocationEventArgs { Latitude = location.Latitude, Longitude = location.Longitude }; LocationChanged?.Invoke(this, args); } ; }
/// <summary> /// Handles PositionChanged events from CrossGeolocator.Current by calling the local LocationChanged event property /// </summary> private void HandlerLocationChangedEvent(object sender, PositionEventArgs args = null) { var now = DateTime.Now; if (now.Subtract(lastLocationHandle).TotalSeconds > deferralTime.TotalSeconds * 0.75) { var location = new Location(args?.Position); if (location.DistanceToOther(CenterOfCurrentGame) < DiameterOfCurrentGame) { lastLocationHandle = now; LocationChanged?.Invoke(location); } } }
protected virtual void OnLocationChanged() { Redraw(); if (Controls != null) { for (int i = 0; i < Controls.Count; i++) { Controls[i].OnLocationChanged(); } } if (LocationChanged != null) { LocationChanged.Invoke(this, EventArgs.Empty); } }
public async void SetLocation(Location location) { // if the location actually changed, then notify listeners and save it if (Location == null || location.Latitude != Location.Latitude || location.Longitude != Location.Longitude) { Location = location; if (LocationChanged != null) { LocationChanged.Invoke(this, EventArgs.Empty); } Application.Current.Properties["Latitude"] = location.Latitude; Application.Current.Properties["Longitude"] = location.Longitude; await Application.Current.SavePropertiesAsync(); } }
protected override void OnWindowPositionChanged(Rect rcBoundingBox) { DpiScale dpiScale = VisualTreeHelper.GetDpi(this); base.OnWindowPositionChanged(rcBoundingBox); Rect newRect = ScaleRectDownFromDPI(rcBoundingBox, dpiScale); Rect finalRect; if (ParentScrollViewer != null) { ParentScrollViewer.ScrollChanged += ParentScrollViewer_ScrollChanged; ParentScrollViewer.SizeChanged += ParentScrollViewer_SizeChanged; ParentScrollViewer.Loaded += ParentScrollViewer_Loaded; } if (Scrolling || Resizing) { if (ParentScrollViewer == null) { return; } MatrixTransform tr = RootVisual.TransformToDescendant(ParentScrollViewer) as MatrixTransform; var scrollRect = new Rect(new Size(ParentScrollViewer.ViewportWidth, ParentScrollViewer.ViewportHeight)); var c = tr.TransformBounds(newRect); var intersect = Rect.Intersect(scrollRect, c); if (!intersect.IsEmpty) { tr = ParentScrollViewer.TransformToDescendant(this) as MatrixTransform; intersect = tr.TransformBounds(intersect); finalRect = ScaleRectUpToDPI(intersect, dpiScale); } else { finalRect = intersect = new Rect(); } int x1 = (int)Math.Round(finalRect.X); int y1 = (int)Math.Round(finalRect.Y); int x2 = (int)Math.Round(finalRect.Right); int y2 = (int)Math.Round(finalRect.Bottom); SetRegion(x1, y1, x2, y2); this.Scrolling = false; this.Resizing = false; } LocationChanged?.Invoke(this, new EventArgs()); }
public LocationTracker() { locationManager = new CLLocationManager(); // Request authorization for iOS 8 and above. if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationManager.RequestWhenInUseAuthorization(); } locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs args) => { CLLocationCoordinate2D coordinate = args.Locations[0].Coordinate; LocationChanged?.Invoke(this, new GeographicLocation(coordinate.Latitude, coordinate.Longitude)); }; }