Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public override void Show()
 {
     SizeChanged?.Invoke(this, ClientWidth, ClientHeight);
     LocationChanged?.Invoke(this, 0, 0);
     _window.Center();
     _window.MakeKeyAndOrderFront(_window);
 }
Ejemplo n.º 3
0
 protected virtual void OnLocationChanged()
 {
     if (LocationChanged != null)
     {
         LocationChanged.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 4
0
 private static void Locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
 {
     App.Dispatcher?.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         LocationChanged?.Invoke(null, args);
     });
 }
Ejemplo n.º 5
0
 private void InvokeLocationChanged(LocationChangeEventArgs e)
 {
     if (LocationChanged != null)
     {
         LocationChanged.Invoke(this, e);
     }
 }
Ejemplo n.º 6
0
 public void SetLocation(Point location)
 {
     Location[0] = location.X;
     Location[1] = location.Y;
     LocationChanged?.Invoke(this, EventArgs.Empty);
     Changed?.Invoke(this, EventArgs.Empty);
 }
Ejemplo n.º 7
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <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);
        }
Ejemplo n.º 8
0
        // 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);
            };
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
                }
            }
        }
Ejemplo n.º 11
0
 protected virtual void OnLocationChanged()
 {
     LocationChanged?.Invoke(this, EventArgs.Empty);
     foreach (var c in Controls)
     {
         c.Location = c.Location;
     }
 }
        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);
        }
 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;
     }
 }
Ejemplo n.º 14
0
        void OnGeolocatorPositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            BasicGeoposition coordinate = args.Position.Coordinate.Point.Position;

            Device.BeginInvokeOnMainThread(() =>
            {
                LocationChanged?.Invoke(this, new GeographicLocation(coordinate.Latitude,
                                                                     coordinate.Longitude));
            });
        }
Ejemplo n.º 15
0
        public void AddLocation(RideLocationDto location)
        {
            Debug.WriteLine(location);

            lastLocation = location;

            LocationChanged?.Invoke(new LocationChangedEventArgs {
                Location = location
            });
        }
Ejemplo n.º 16
0
        public void Move(float dt)
        {
            var prevLoc = Location;

            Location      += Speed * dt;
            DeltaLocation += Location - prevLoc;

            LocationChanged?.Invoke(this, EventArgs.Empty);
            Changed?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 17
0
        private void OnLocationChanged(object sender, MyLocationChangeEventArgs e)
        {
            var loc = e.Location.ToBinding3DLocation();

            UserLocation = loc;
            if (LocationChanged?.CanExecute(loc) ?? false)
            {
                LocationChanged.Execute(loc);
            }
        }
Ejemplo n.º 18
0
        public void OnLocationChanged(CLLocationCoordinate2D location)
        {
            var args = new LocationEventArgs
            {
                Latitude  = location.Latitude,
                Longitude = location.Longitude
            };

            LocationChanged?.Invoke(this, args);
        }
Ejemplo n.º 19
0
 protected virtual void OnLocationChanged()
 {
     if (LocationChanged != null)
     {
         foreach (Action <Point> pe in LocationChanged.GetInvocationList())
         {
             pe(_Location);
         }
     }
 }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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.");
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        public virtual void SetLocation(int x, int y)
        {
            Location = new Point(x, y);
            X        = x; Y = y;

            if (!InBounds())
            {
                GotOutOfScreen?.Invoke();
            }

            LocationChanged?.Invoke();
        }
Ejemplo n.º 25
0
 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();
     }
 }
Ejemplo n.º 26
0
 public void OnLocationChanged(Android.Locations.Location location)
 {
     if (location != null)
     {
         LocationEventArgs args = new LocationEventArgs
         {
             Latitude  = location.Latitude,
             Longitude = location.Longitude
         };
         LocationChanged?.Invoke(this, args);
     }
     ;
 }
Ejemplo n.º 27
0
        /// <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);
                }
            }
        }
Ejemplo n.º 28
0
        public sealed override void DidUpdateUserLocation(MKMapView mapView, MKUserLocation userLocation)
        {
            var coordinate = userLocation.ToBinding3DLocation();

            if (mapView is BindingMKMapView v)
            {
                v.UserCurrentLocation = coordinate;
            }
            if (LocationChanged != null)
            {
                if (LocationChanged.CanExecute(coordinate))
                {
                    LocationChanged.Execute(coordinate);
                }
            }
        }
Ejemplo n.º 29
0
        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);
            }
        }
Ejemplo n.º 30
0
        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();
            }
        }