Inheritance: MonoBehaviour
Exemplo n.º 1
0
        private void UpdatePosition()
        {
            if (_previousPin != null)
            {
                _map.Pins.Remove(_previousPin);
            }
            else
            {
                _previousPin = new Pin();
            }

            _map.Pins.Clear();

            var zoomLat = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.LatitudeDegrees;
            var zoomLon = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.LongitudeDegrees;
            var zoomRad = _map.VisibleRegion == null ? 6.0 : _map.VisibleRegion.Radius.Miles;
            
            _map.MoveToRegion(new MapSpan(_mapViewModel.UserPosition, zoomLat, zoomLon ));

            // _map.MoveToRegion(MapSpan.FromCenterAndRadius(_mapViewModel.UserPosition, Distance.FromMiles(zoomRad)));
            MapSpan temp = _map.VisibleRegion;

            GetWeb();

            //Add the pin.
            Position pinPos = new Position(_mapViewModel.UserPosition.Latitude, _mapViewModel.UserPosition.Longitude);
            _previousPin.Position = pinPos;
            _previousPin.Label = "My Location";
            _previousPin.Type = PinType.Generic;
            _map.Pins.Add(_previousPin);

            UpdateServerUser();
        }
Exemplo n.º 2
0
		public MapPageCS ()
		{
			var customMap = new CustomMap {
				MapType = MapType.Street,
				WidthRequest = App.ScreenWidth,
				HeightRequest = App.ScreenHeight
			};

			var pin = new Pin {
				Type = PinType.Place,
				Position = new Position (37.79752, -122.40183),
				Label = "Xamarin San Francisco Office",
				Address = "394 Pacific Ave, San Francisco CA"
			};

			var position = new Position (37.79752, -122.40183);
			customMap.Circle = new CustomCircle {
				Position = position,
				Radius = 1000
			};

			customMap.Pins.Add (pin);
			customMap.MoveToRegion (MapSpan.FromCenterAndRadius (position, Distance.FromMiles (1.0)));

			Content = customMap;
		}
		private async Task FetchData() {
			var apiService = new FatSubsService ();
			var apiResult = await apiService.GetDetailsAsync ();
			if (apiResult != null) {
				Model = apiResult;
				var coder = new Geocoder ();
				var portlandPositions = await coder.GetPositionsForAddressAsync ("Portland, Oregon");
				if (portlandPositions.Any()) {
					Portland = portlandPositions.ElementAt (0);
				}

				var positions = await coder.GetPositionsForAddressAsync (Model.Location.Address);
				foreach (var pos in positions) {
					var location = new Pin () {
						Position = pos,
						Address = Model.Location.Address,
						Type = PinType.Place,
						Label = Model.Location.Name
					};

					if (UpdateMapCommand != null) {
						UpdateMapCommand.Execute (location);
					}
				}
			}

		}
		public void Evaluate(int SpreadMax)
		{
			if (FContextDirty)
			{
				if (FInFullHouseContext[0] == null)
					FInFullHouseContext = null;
				else
				{
					FContext = FInFullHouseContext[0].FullHouseNode;
				}
			}

			if (FInDo[0])
				FContext.Update += OnUpdate;

			if (FCornersDirty)
			{
				lock(FWorldCorners)
				{
					FOutWorld.SliceCount = FWorldCorners.Count;
					for (int i = 0; i < FWorldCorners.Count; i++)
						FOutWorld[i] = FWorldCorners[i];
				}

				lock (FDepthCorners)
				{
					FOutDepth.SliceCount = FDepthCorners.Count;
					for (int i = 0; i < FDepthCorners.Count; i++)
						FOutDepth[i] = FDepthCorners[i];
				}
			}
		}
Exemplo n.º 5
0
        public GetGeoXaml()
        {
            InitializeComponent();

            map.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromKilometers(4d)));

            button.Clicked += async (sender, e) =>
            {
                var locator = CrossGeolocator.Current;
                locator.DesiredAccuracy = 50;

                var location = await locator.GetPositionAsync(10000);

                LatLabel.Text = "Lat: " + location.Latitude.ToString("N6");
                LonLabel.Text = "Lon: " + location.Longitude.ToString("N6");

                var addr = await getAddress.GetJsonAsync(location.Latitude, location.Longitude) ?? "取得できませんでした";

                AddrLabel.Text = "Address: " + addr;

                // Map を移動させてピン打ち
                map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(location.Latitude, location.Longitude), Distance.FromKilometers(4d)));
                if (map.Pins.Count() > 0)
                    map.Pins.Clear();
                pin = new Pin
                {
                    Position = new Position(location.Latitude, location.Longitude),
                    Label = addr,
                };
                map.Pins.Add(pin);
            };
        }
Exemplo n.º 6
0
        public MainPage()
        {
            InitializeComponent();

            Set.Clicked += async (sender, e) =>
            {
                double latitude = MyMap.VisibleRegion.Center.Latitude;
                double longitude = MyMap.VisibleRegion.Center.Longitude;

                var weather = await weatherService.GetCurrentWeather(latitude, longitude);
                var position = new Xamarin.Forms.Maps.Position(latitude, longitude);
                var pin = new Pin
                {
                    Type = PinType.Generic,
                    Position = position,
                    Label = $"{weather.main.temp}°C",
                    Address = $"{weather.description}",
                };
                MyMap.Pins.Add(pin);
            };

            Cancel.Clicked += (sender, e) =>
            {
                if (MyMap.Pins.Count > 0)
                {
                    MyMap.Pins.Remove(MyMap.Pins.Last());
                }
            };
        }
 /// <summary>
 ///  Construct a new TristatePort object
 /// </summary>
 /// <param name="pin">
 ///   A <see cref="Pin"/> type representing a pin
 /// </param>
 /// <exception cref="ActivatePinException"></exception>
 public TristatePort(Pin pin)
 {
     this._p = pin;
     bool export = this._Export(_p);
     if(!export)
         throw new ActivatePinException("Pin is working, stop first!");
 }
        public static LedGraphicDisplay GetMax7219GraphicLedDisplay(Spi port, Pin latch, int numDevices)
        {
            IEnumerable<Led> finalList = new List<Led>();
            for (int i = 0; i < numDevices; i++)
            {
                Max7219 driver;

                driver = new Max7219(port, latch, i);

                var tempList = new List<Led>();

                // We have to re-order the LEDs from the Max7219
                {
                    for (int k = 62; k >= 56; k--)
                    {
                        for (int m = k; m >= 0; m -= 8)
                        {
                            tempList.Add(driver.Leds[m]);
                        }
                    }

                    for (int k = 63; k >= 0; k -= 8)
                    {
                        tempList.Add(driver.Leds[k]);
                    }
                }

                finalList = finalList.Concat(tempList);
            }

            var display = new LedGraphicDisplay(finalList.ToList(), 8 * numDevices, 8);

            return display;
        }
        /// <summary>
        /// Construct a new analog feedback servo from an analog pin and a speed controller
        /// </summary>
        /// <param name="analogIn">The analog in pin to use for position feedback</param>
        /// <param name="Controller">The speed controller to use to control the motor</param>
        public AnalogFeedbackServo(Pin analogIn, MotorSpeedController Controller) 
        {
            this.analogIn = analogIn;
            this.controller = Controller;
            analogIn.Mode = PinMode.AnalogInput;
            isRunning = true;
            controlLoopTask = new Task(async() =>
            {
                while (isRunning)
                {
                    var oldPosition = ActualPosition;
                    var newPosition = analogIn.AnalogValue;
                    ActualPosition = newPosition;

                    var error = GoalPosition - ActualPosition;

                    if (Math.Abs(error) > ErrorThreshold)
                        controller.Speed = Utilities.Constrain(K * error, -1.0, 1.0);
                    else
                    {
                        controller.Speed = 0;
                        //Debug.WriteLine("goal achieved");
                    }
                    await Task.Delay(10);
                }
            });
            controlLoopTask.Start();
        }
Exemplo n.º 10
0
        public MapController(Entity entity)
        {
            try {
                Entity = entity;

                Title = Entity.EntityTypeName;

                _map = new MKMapView ();

                _pin = new Pin(Entity);

                _map.Frame = View.Bounds;
                _map.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

                _map.AddAnnotation(_pin);

                _map.Region = new MKCoordinateRegion (_pin.Coordinate, new MKCoordinateSpan (0.01, 0.01));

                View.AddSubview (_map);

                _map.SelectAnnotation(_pin, true);

            } catch (Exception error) {
                Log.Error (error);
            }
        }
        private void Locate()
        {
            if (vm != null)
            {
                var position = new XLabs.Platform.Services.Geolocation.Position();
                //default position
                position.Longitude = vm.Longitude;
                position.Latitude = vm.Latitude;

                var pin = new Pin
                {
                    Type = PinType.Place,
                    Position = new Position(vm.Latitude, vm.Longitude),
                    Label = "Accident Location",
                    Address = ""
                };

                map.Circle = new CustomCircle
                {
                    Position = position,
                    Radius = 800
                };

                map.Pins.Add(pin);

                map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(vm.Latitude, vm.Longitude
                    ), Distance.FromMiles(0.9)));
            }
           
        }
Exemplo n.º 12
0
 public void NodeDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     try
     {
         string MName = e.Node.Name + "_NodeDoubleClick";
         MethodInfo methodInfo = this.GetType().GetMethods().Where(n => n.Name.Equals(MName)).FirstOrDefault();
         if (methodInfo != null)
         {
             SENDER = sender;
             TNMCEA = e;
             TREENODE = e.Node;
             if (e.Node.Tag is Pin)
             {
                 PIN = e.Node.Tag as Pin;
                 NdataBaseHelper.DBFullName = PIN.DataBasePath;
             }
             methodInfo.Invoke(this, new object[] { });//调用MName名字的函数
             DoubleClick_OK = true;
         }
         else
         {
             DoubleClick_OK = false;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 13
0
		public MapPage ()
		{
			NavigationPage.SetHasNavigationBar (this, true);

			Title = "Austin, Texas";

			/* DON'T FORGET
			 * Xamarin.QuickUIMaps.Init (); 
			 */
			var map = new Map(new MapSpan(new Position(30.26535, -97.738613), 0.05, 0.05))
			{
				MapType = MapType.Street,
				HeightRequest = 508
			};
			map.BackgroundColor = Color.White;

			Pin pin;
			map.Pins.Add(pin = new Pin()
				{
					Label = "Evolve 2013", 
					Position = new Position(30.26535, -97.738613),
					Type = PinType.Place
				});

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.StartAndExpand,
				Children = {
					map

				}
			};
		}
        public TeamMembers()
        {
            InitializeComponent();

            this.Title = PageResources.DefaultPageTitle;

            // CJP TODO, need to move team member service to ioc container
            TeamMemberService service = new TeamMemberService();
            var teamMemberList = service.GetTestData();

            MyMap.MoveToRegion(MapSpan.FromCenterAndRadius(
                new Position(32.8946723, -96.9774144), Distance.FromMiles(1)));

            foreach (var teamMember in teamMemberList)
            {
                var position = new Position(teamMember.UserLocation.Latitude, teamMember.UserLocation.Longitude); // Latitude, Longitude
                var pin = new Pin
                {
                    Type = PinType.SearchResult,
                    Position = position,
                    Label = teamMember.User.Name,
                    Address = teamMember.UserLocation.AddressName
                };

                MyMap.Pins.Add(pin);

                // CJP TODO, need add MediaPlayer for pop sound playback foreach teamMember
            }

        }
Exemplo n.º 15
0
        public SevenSegSpi(Spi SPIModule, Pin csPin, int numDevices = 1)
        {
            this.SPIModule = SPIModule;
            SPIModule.Start(SPIMode.Mode00, 1);
            this.csPin = csPin;

            if(numDevices<=0 || numDevices>8 )
                throw new Exception("This library supports 1 to 8 displays.");

            this.numDevices = numDevices;

            this.csPin.DigitalValue = true;

             spiData = new byte[numDevices*2];

            for(int i=0; i<numDevices; i++)
            {
                spiTransfer(OP_DISPLAYTEST, 0, i);
                //scanlimit is set to max on startup
                setScanLimit(7, i);
                //decode is done in source
                spiTransfer(OP_DECODEMODE, 0, i);
                clearDisplay(i);
                //we go into shutdown-mode on startup
                shutdown(false, i);
                setIntensity(10, i);
            }
        }
Exemplo n.º 16
0
        public Wire(Pin pin)
        {
            if (pin == null)
                throw new ArgumentNullException("pin");

            Input = pin;
        }
        public StoreMapPage()
        {
            var map = new Map (
                         MapSpan.FromCenterAndRadius (
                             new Position (30.0219504, -89.8830829), Distance.FromMiles (0.3))) {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // pin first address
            var positionA = new Position (30.517174,-90.463322);

            var pinA = new Pin {
                Type = PinType.Place,
                Position = positionA,
                Label = "Store A (HQ)",
                Address = "100 Janes Lane, \n Hammond, LA, \n 70401"
            };
            map.Pins.Add (pinA);

            // pin second address
            var positionB = new Position (37.42565,-122.13535);

            var pinB = new Pin {
                Type = PinType.Place,
                Position = positionB,
                Label = "Store B",
                Address = "Silicon Valley, Palo Alto, CA, \n 94025"
            };
            map.Pins.Add (pinB);

            // pin third address
            var positionC = new Position (42.360091,-71.09416);

            var pinC = new Pin {
                Type = PinType.Place,
                Position = positionC,
                Label = "Store C",
                Address = "Boston, MA, \n 02481"
            };
            map.Pins.Add (pinC);

            // add the slider
            var slider = new Slider (1, 18, 1);
            slider.ValueChanged += (sender, e) => {
                var zoomLevel = e.NewValue; // between 1 and 18
                var latlongdegrees = 360 / (Math.Pow (2, zoomLevel));
                //Debug.WriteLine(zoomLevel + " -> " + latlongdegrees);
                if (map.VisibleRegion != null)
                    map.MoveToRegion (new MapSpan (map.VisibleRegion.Center, latlongdegrees, latlongdegrees));
            };

            var stackLayout = new StackLayout { Spacing = 0 };
            stackLayout.Children.Add (map);
            stackLayout.Children.Add (slider);

            Content = stackLayout;
        }
Exemplo n.º 18
0
        public async Task<Pin> LoadPin()
        {
            Position p = _GeoCodingService.NullPosition;
            var address = Lead.AddressString;

            //Lookup Lat/Long all the time.
            //TODO: Only look up if no value, or if address properties have changed.
            //if (Contact.Latitude == 0)
            if (true)
            {
                p = await _GeoCodingService.GeoCodeAddress(address);
                //p = p == null ? Utils.NullPosition : p;

                Lead.Latitude = p.Latitude;
                Lead.Longitude = p.Longitude;
            }

            var pin = new Pin
            {
                Type = PinType.Place,
                Position = p,
                Label = Lead.DisplayName,
                Address = address
            };

            return pin;
        }
 internal DHTTemperatureAndHumiditySensor(GrovePi device, Pin pin, DHTModel model)
 {
     if (device == null) throw new ArgumentNullException(nameof(device));
     _device = device;
     _pin = pin;
     _model = model;
 }
Exemplo n.º 20
0
 internal TemperatureSensor(IGrovePi device, Pin pin, TemperatureSensorModel model)
 {
     if (device == null) throw new ArgumentNullException(nameof(device));
     _device = device;
     _pin = pin;
     _model = model;
 }
Exemplo n.º 21
0
 internal RotaryAngleSensor(GrovePi device, Pin pin)
 {
     if (device == null) throw new ArgumentNullException(nameof(device));
     device.PinMode(_pin, PinMode.Input);
     _device = device;
     _pin = pin;
 }
Exemplo n.º 22
0
 public void AnalogWrite(Pin pin, byte value)
 {
     lock (deviceLock)
     {
         var buffer = new byte[] { (byte)Command.AnalogWrite, (byte)pin, value, Constants.Unused };
         DirectAccess.Write(buffer);
     }
 }
Exemplo n.º 23
0
 public override void setupPins()
 {
     pins = new Pin[3];
     pins[0] = new Pin("I1");
     pins[1] = new Pin("I2");
     pins[2] = new Pin("O");
     pins[2].output = true;
 }
Exemplo n.º 24
0
 public override void setupPins()
 {
     pins = new Pin[3];
     pins[0] = new Pin("X");
     pins[0].output = true;
     pins[1] = new Pin("Y");
     pins[2] = new Pin("Z");
 }
Exemplo n.º 25
0
 public PinSchedule(DateTime date, Pin pin, int value, ScheduleTypes type = ScheduleTypes.Once, int interval = 0)
 {
     _date = date;
     _pin = pin;
     _value = value;
     _type = type;
     _interval = interval;
 }
Exemplo n.º 26
0
 public int AnalogRead(Pin pin)
 {
     var buffer = new[]
     {(byte) Commands.DigitalRead, (byte) Commands.AnalogRead, (byte) pin, Constants.Unused, Constants.Unused};
     DirectAccess.Write(buffer);
     DirectAccess.Read(buffer);
     return buffer[1] * 256 + buffer[2];
 }
Exemplo n.º 27
0
 /// <summary>
 ///  Construct a new InputPort object
 /// </summary>
 /// <param name="pin">
 ///   A <see cref="Pin"/> type representing a pin
 /// </param>
 /// <exception cref="ActivatePinException"></exception>
 public InputPort(Pin pin)
 {
     this._p = pin;
     bool export = this._Export(_p);
     if (!export)
         throw new ActivatePinException("Pin is working, stop first!");
     File.WriteAllText(GPIO_PATH + _p.ToString().Split('_')[1] + "/direction", Direction.IN.ToString().ToLower());
 }
Exemplo n.º 28
0
        private Pin _rs_pin; // LOW: command.  HIGH: character.

        #endregion Fields

        #region Constructors

        public Adafruit292CharacterLcd(byte address = 0x20)
        {
            _i2c = new MCP23008(address, null);

            _rs_pin = Pin.GP1;
            _enable_pin = Pin.GP2;
            _data_pins[0] = Pin.GP3;
            _data_pins[1] = Pin.GP4;
            _data_pins[2] = Pin.GP5;
            _data_pins[3] = Pin.GP6;

            _data_mask = _data_pins[0] | _data_pins[1] | _data_pins[2] | _data_pins[3];

            _displayFunction = LCD_4BITMODE | LCD_2LINE | LCD_5x8DOTS;

            // turn on backlight
            _i2c.PinDirection(Pin.GP7, Direction.Output);
            _i2c.WritePin(Pin.GP7, true);

            for (int i = 0; i < 4; ++i)
            {
                _i2c.PinDirection(_data_pins[i], Direction.Output);
            }

            _i2c.PinDirection(_rs_pin, Direction.Output);
            _i2c.PinDirection(_enable_pin, Direction.Output);

            Thread.Sleep(50);  // minimum 40ms post-power-up delay

            _i2c.WritePin(_rs_pin, false);
            _i2c.WritePin(_enable_pin, false);

            // Send function set command sequence
            SendCommand((byte)(LCD_FUNCTIONSET | (byte)0x03));
            Thread.Sleep(5);  // wait more than 4.1ms
            SendCommand((byte)(LCD_FUNCTIONSET | (byte)0x03));
            Thread.Sleep(5);
            SendCommand((byte)(LCD_FUNCTIONSET | (byte)0x03));
            Thread.Sleep(1);
            SendCommand((byte)(LCD_FUNCTIONSET | (byte)0x02));
            Thread.Sleep(1);

            // finally, set # lines, font size, etc.
            SendCommand((byte)(LCD_FUNCTIONSET | _displayFunction));
            Thread.Sleep(1);

            _displayControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
            EnableDisplay(true);

            // Initialize to default text direction (for romance languages)
            _displayMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
            // set the entry mode
            SendCommand((byte)(LCD_ENTRYMODESET | _displayMode));

            Thread.Sleep(100);
            Backlight(true);
            Clear();
        }
        public BaseDX11RenderStateSimple(IPluginHost host,IIOFactory iofactory)
        {
            this.FHost = host;
            this.FIOFactory = iofactory;

            InputAttribute attr = this.GetEnumPin();
            attr.CheckIfChanged = true;
            this.FInPreset = this.FIOFactory.CreatePin<EnumEntry>(attr);
        }
Exemplo n.º 30
0
        public LamanPin ()
        {
            peta = new Map
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.1949718, 106.8208304), Distance.FromKilometers(1)));
            var posisi = new Position(-6.1949718, 106.8208304);
            var pin = new Pin
            {
                Type = PinType.Place,
                Position = posisi,
                Label = "Hotel Indonesia",
                Address = "apa ya?"
            };

            peta.Pins.Add(pin);

            var pinLagi = new Button {Text = "Pin Lagi."};
            pinLagi.Clicked += (sender, e) =>
            {
                peta.Pins.Add(new Pin
                {
                    Position = new Position(-6.2279962, 106.6528529),
                    Label = "Jalan NN no 75."
                });
                peta.Pins.Add(new Pin
                {
                    Position = new Position(-6.2266733, 106.6554782),
                    Label = "Jalan Haji Jali."
                });
                peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.2257428, 106.6548106),
                    Distance.FromKilometers(2)));
            };

            var balikLagi = new Button {Text = "Kembali Ke HI."};
            balikLagi.Clicked += (sender, e) =>
            {
                peta.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(-6.1949718, 106.8208304), Distance.FromKilometers(2)));
            };

            var butts = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = {pinLagi, balikLagi}
            };

            Content = new StackLayout
            {
                Spacing = 0,
                Children = {peta, butts}
            };
        }
Exemplo n.º 31
0
 internal PinClickedEventArgs(Pin pin, Position point, int numOfTaps)
 {
     Pin       = pin;
     Point     = point;
     NumOfTaps = numOfTaps;
 }
Exemplo n.º 32
0
        private async void OnSearchEntryCompleted(object sender, EventArgs e)
        {
            this.SearchEntry.Unfocus();

            if (String.IsNullOrEmpty(this.SearchEntry.Text) ||
                String.IsNullOrWhiteSpace(this.SearchEntry.Text))
            {
                return;
            }

            if (!CrossConnectivity.Current.IsConnected)
            {
                DependencyService.Get <IMessageHelper>().LongAlert($"Gagal memuat. Periksa kembali koneksi internet anda.");
                return;
            }

            AutoCompleteLocationResult results = null;

            try
            {
                results = await AutoCompleteLocationService.GetPlaces(this.SearchEntry.Text);
            }
            catch (Exception ex)
            {
                await this.DisplayAlert("Error", ex.Message, "OK");

                return;
            }

            if (results == null)
            {
                await this.DisplayAlert("Lokasi Tidak Ditemukan", "Geocoder tidak dapat menemukan lokasi yang anda tuju.", "OK");

                return;
            }

            this.MyMap.Pins.Clear();

            Location location = await AutoCompleteLocationService.GetPlace(results.AutoCompletePlaces.First().Place_ID);

            Position position = new Position(
                location.Latitude,
                location.Longitude);

            Pin locatedPin = new Pin()
            {
                Type     = PinType.Place,
                Label    = this.SearchEntry.Text,
                Address  = this.SearchEntry.Text,
                Position = position,
                Flat     = true
            };

            this.MyMap.Pins.Add(locatedPin);

            this.MyMap.MoveToRegion(
                MapSpan.FromCenterAndRadius(
                    position,
                    Distance.FromMeters(
                        MAP_SPAN_RADIUS)));

            var pins = await CreatePins(position);

            foreach (Pin pin in pins)
            {
                this.MyMap.Pins.Add(pin);
            }
        }
Exemplo n.º 33
0
 protected override void OnUpdateZIndex(Pin outerItem, PushPin nativeItem)
 {
     //not implemented
 }
Exemplo n.º 34
0
 public SliceRenderer(int slice, Pin <DX11Resource <DX11Layer> > layer)
 {
     this.slice.Add(slice);
     this.FLayerIn = layer;
 }
Exemplo n.º 35
0
        private async void StartActuator()
        {
            try
            {
                Log.Informational("Starting application.");

                SimpleXmppConfiguration xmppConfiguration = SimpleXmppConfiguration.GetConfigUsingSimpleConsoleDialog("xmpp.config",
                                                                                                                      Guid.NewGuid().ToString().Replace("-", string.Empty), // Default user name.
                                                                                                                      Guid.NewGuid().ToString().Replace("-", string.Empty), // Default password.
                                                                                                                      FormSignatureKey, FormSignatureSecret, typeof(App).GetTypeInfo().Assembly);

                Log.Informational("Connecting to XMPP server.");

                xmppClient = xmppConfiguration.GetClient("en", typeof(App).GetTypeInfo().Assembly, false);
                xmppClient.AllowRegistration(FormSignatureKey, FormSignatureSecret);

                if (xmppConfiguration.Sniffer && MainPage.Sniffer != null)
                {
                    xmppClient.Add(MainPage.Sniffer);
                }

                if (!string.IsNullOrEmpty(xmppConfiguration.Events))
                {
                    Log.Register(new XmppEventSink("XMPP Event Sink", xmppClient, xmppConfiguration.Events, false));
                }

                if (!string.IsNullOrEmpty(xmppConfiguration.ThingRegistry))
                {
                    thingRegistryClient = new ThingRegistryClient(xmppClient, xmppConfiguration.ThingRegistry);

                    thingRegistryClient.Claimed += (sender, e) =>
                    {
                        ownerJid = e.JID;
                        Log.Informational("Thing has been claimed.", ownerJid, new KeyValuePair <string, object>("Public", e.IsPublic));
                        this.RaiseOwnershipChanged();
                    };

                    thingRegistryClient.Disowned += (sender, e) =>
                    {
                        Log.Informational("Thing has been disowned.", ownerJid);
                        ownerJid = string.Empty;
                        this.Register();                            // Will call this.OwnershipChanged() after successful registration.
                    };

                    thingRegistryClient.Removed += (sender, e) =>
                    {
                        Log.Informational("Thing has been removed from the public registry.", ownerJid);
                    };
                }

                if (!string.IsNullOrEmpty(xmppConfiguration.Provisioning))
                {
                    provisioningClient = new ProvisioningClient(xmppClient, xmppConfiguration.Provisioning);
                }

                Timer ConnectionTimer = new Timer((P) =>
                {
                    if (xmppClient.State == XmppState.Offline || xmppClient.State == XmppState.Error || xmppClient.State == XmppState.Authenticating)
                    {
                        try
                        {
                            Log.Informational("Reconnecting.");
                            xmppClient.Reconnect();
                        }
                        catch (Exception ex)
                        {
                            Log.Critical(ex);
                        }
                    }
                }, null, 60000, 60000);

                xmppClient.OnStateChanged += (sender, NewState) =>
                {
                    Log.Informational(NewState.ToString());

                    switch (NewState)
                    {
                    case XmppState.Connected:
                        connected = true;

                        if (!registered && this.thingRegistryClient != null)
                        {
                            this.Register();
                        }

                        break;

                    case XmppState.Offline:
                        immediateReconnect = connected;
                        connected          = false;

                        if (immediateReconnect)
                        {
                            xmppClient.Reconnect();
                        }
                        break;
                    }
                };

                xmppClient.OnPresenceSubscribe += (sender, e) =>
                {
                    Log.Informational("Subscription request received from " + e.From + ".");

                    e.Accept();                         // TODO: Provisioning

                    RosterItem Item = xmppClient.GetRosterItem(e.FromBareJID);
                    if (Item == null || Item.State == SubscriptionState.None || Item.State == SubscriptionState.From)
                    {
                        xmppClient.RequestPresenceSubscription(e.FromBareJID);
                    }

                    xmppClient.SetPresence(Availability.Chat);
                };

                xmppClient.OnPresenceUnsubscribe += (sender, e) =>
                {
                    Log.Informational("Unsubscription request received from " + e.From + ".");
                    e.Accept();
                };

                xmppClient.OnRosterItemUpdated += (sender, e) =>
                {
                    if (e.State == SubscriptionState.None && e.PendingSubscription != PendingSubscription.Subscribe)
                    {
                        xmppClient.RemoveRosterItem(e.BareJid);
                    }
                };

                gpio = GpioController.GetDefault();
                if (gpio != null)
                {
                    int c = gpio.PinCount;
                    int i;

                    for (i = 0; i < c; i++)
                    {
                        if (gpio.TryOpenPin(i, GpioSharingMode.Exclusive, out GpioPin Pin, out GpioOpenStatus Status) && Status == GpioOpenStatus.PinOpened)
                        {
                            gpioPins[i] = new KeyValuePair <GpioPin, KeyValuePair <TextBlock, TextBlock> >(Pin,
                                                                                                           MainPage.Instance.AddPin("GPIO" + i.ToString(), Pin.GetDriveMode(), Pin.Read().ToString()));

                            Pin.ValueChanged += async(sender, e) =>
                            {
                                if (!this.gpioPins.TryGetValue(sender.PinNumber, out KeyValuePair <GpioPin, KeyValuePair <TextBlock, TextBlock> > P))
                                {
                                    return;
                                }

                                PinState Value = e.Edge == GpioPinEdge.FallingEdge ? PinState.LOW : PinState.HIGH;

                                if (this.sensorServer.HasSubscriptions(ThingReference.Empty))
                                {
                                    DateTime TP = DateTime.Now;
                                    string   s  = "GPIO" + sender.PinNumber.ToString();

                                    this.sensorServer.NewMomentaryValues(
                                        new EnumField(ThingReference.Empty, TP, s, Value, FieldType.Momentary, FieldQoS.AutomaticReadout));
                                }

                                await P.Value.Value.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => P.Value.Value.Text = Value.ToString());
                            };
                        }
                    }
                }

                DeviceInformationCollection Devices = await Microsoft.Maker.Serial.UsbSerial.listAvailableDevicesAsync();

                foreach (DeviceInformation DeviceInfo in Devices)
                {
                    if (DeviceInfo.IsEnabled && DeviceInfo.Name.StartsWith("Arduino"))
                    {
                        Log.Informational("Connecting to " + DeviceInfo.Name);
                        arduinoUsb = new UsbSerial(DeviceInfo);
                        arduinoUsb.ConnectionEstablished += () =>
                        {
                            Log.Informational("USB connection established.");
                        };

                        arduino              = new RemoteDevice(arduinoUsb);
                        arduino.DeviceReady += async() =>
                        {
                            Log.Informational("Device ready.");

                            Dictionary <int, bool> DisabledPins = new Dictionary <int, bool>();
                            Dictionary <string, KeyValuePair <Enum, string> > Values = new Dictionary <string, KeyValuePair <Enum, string> >();
                            PinMode  Mode;
                            PinState State;
                            string   s;
                            ushort   Value;

                            foreach (byte PinNr in arduino.DeviceHardwareProfile.DisabledPins)
                            {
                                DisabledPins[PinNr] = true;
                            }

                            foreach (byte PinNr in arduino.DeviceHardwareProfile.AnalogPins)
                            {
                                if (DisabledPins.ContainsKey(PinNr))
                                {
                                    continue;
                                }

                                s = "A" + (PinNr - arduino.DeviceHardwareProfile.AnalogOffset).ToString();
                                if (arduino.DeviceHardwareProfile.isAnalogSupported(PinNr))
                                {
                                    arduino.pinMode(s, PinMode.ANALOG);
                                }

                                Mode  = arduino.getPinMode(s);
                                Value = arduino.analogRead(s);

                                Values[s] = new KeyValuePair <Enum, string>(Mode, Value.ToString());
                            }

                            foreach (byte PinNr in arduino.DeviceHardwareProfile.DigitalPins)
                            {
                                if (DisabledPins.ContainsKey(PinNr) || (PinNr > 6 && PinNr != 13))                                      // Not sure why this limitation is necessary. Without it, my Arduino board (or the Microsoft Firmata library) stops providing me with pin update events.
                                {
                                    continue;
                                }

                                if (PinNr == 13)
                                {
                                    arduino.pinMode(13, PinMode.OUTPUT);                                        // Onboard LED.
                                    arduino.digitalWrite(13, PinState.HIGH);
                                }
                                else
                                {
                                    if (arduino.DeviceHardwareProfile.isDigitalInputSupported(PinNr))
                                    {
                                        arduino.pinMode(PinNr, PinMode.INPUT);
                                    }
                                }

                                s     = "D" + PinNr.ToString();
                                Mode  = arduino.getPinMode(PinNr);
                                State = arduino.digitalRead(PinNr);

                                Values[s] = new KeyValuePair <Enum, string>(Mode, State.ToString());
                            }

                            await MainPage.Instance.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                lock (arduinoPins)
                                {
                                    foreach (KeyValuePair <string, KeyValuePair <Enum, string> > P in Values)
                                    {
                                        arduinoPins[P.Key] = MainPage.Instance.AddPin(P.Key, P.Value.Key, P.Value.Value);
                                    }
                                }
                            });

                            this.SetupControlServer();
                        };

                        arduino.AnalogPinUpdated += async(pin, value) =>
                        {
                            KeyValuePair <TextBlock, TextBlock> P;
                            DateTime TP = DateTime.Now;

                            lock (this.arduinoPins)
                            {
                                if (!this.arduinoPins.TryGetValue(pin, out P))
                                {
                                    return;
                                }
                            }

                            if (this.sensorServer.HasSubscriptions(ThingReference.Empty))
                            {
                                this.sensorServer.NewMomentaryValues(
                                    new Int32Field(ThingReference.Empty, TP, pin + ", Raw",
                                                   value, FieldType.Momentary, FieldQoS.AutomaticReadout),
                                    new QuantityField(ThingReference.Empty, TP, pin,
                                                      value / 10.24, 2, "%", FieldType.Momentary, FieldQoS.AutomaticReadout));
                            }

                            await P.Value.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => P.Value.Text = value.ToString());
                        };

                        arduino.DigitalPinUpdated += async(pin, value) =>
                        {
                            KeyValuePair <TextBlock, TextBlock> P;
                            DateTime TP = DateTime.Now;
                            string   s  = "D" + pin.ToString();

                            lock (this.arduinoPins)
                            {
                                if (!this.arduinoPins.TryGetValue("D" + pin.ToString(), out P))
                                {
                                    return;
                                }
                            }

                            if (this.sensorServer.HasSubscriptions(ThingReference.Empty))
                            {
                                this.sensorServer.NewMomentaryValues(
                                    new EnumField(ThingReference.Empty, TP, s, value, FieldType.Momentary, FieldQoS.AutomaticReadout));
                            }

                            await P.Value.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => P.Value.Text = value.ToString());
                        };

                        arduinoUsb.ConnectionFailed += message =>
                        {
                            Log.Error("USB connection failed: " + message);
                        };

                        arduinoUsb.ConnectionLost += message =>
                        {
                            Log.Error("USB connection lost: " + message);
                        };

                        arduinoUsb.begin(57600, SerialConfig.SERIAL_8N1);
                        break;
                    }
                }

                sensorServer = new SensorServer(xmppClient, provisioningClient, true);
                sensorServer.OnExecuteReadoutRequest += (Sender, Request) =>
                {
                    DateTime           Now    = DateTime.Now;
                    LinkedList <Field> Fields = new LinkedList <Field>();
                    DateTime           TP     = DateTime.Now;
                    string             s;
                    bool ReadMomentary = Request.IsIncluded(FieldType.Momentary);
                    bool ReadStatus    = Request.IsIncluded(FieldType.Status);

                    Log.Informational("Readout requested", string.Empty, Request.Actor);

                    foreach (KeyValuePair <GpioPin, KeyValuePair <TextBlock, TextBlock> > Pin in gpioPins.Values)
                    {
                        if (ReadMomentary && Request.IsIncluded(s = "GPIO" + Pin.Key.PinNumber.ToString()))
                        {
                            Fields.AddLast(new EnumField(ThingReference.Empty, TP, s,
                                                         Pin.Key.Read(), FieldType.Momentary, FieldQoS.AutomaticReadout));
                        }

                        if (ReadStatus && Request.IsIncluded(s = "GPIO" + Pin.Key.PinNumber.ToString() + ", Mode"))
                        {
                            Fields.AddLast(new EnumField(ThingReference.Empty, TP, s,
                                                         Pin.Key.GetDriveMode(), FieldType.Status, FieldQoS.AutomaticReadout));
                        }
                    }

                    if (arduinoPins != null)
                    {
                        foreach (KeyValuePair <string, KeyValuePair <TextBlock, TextBlock> > Pin in arduinoPins)
                        {
                            byte i;

                            if (ReadMomentary && Request.IsIncluded(s = Pin.Key))
                            {
                                if (s.StartsWith("D") && byte.TryParse(s.Substring(1), out i))
                                {
                                    Fields.AddLast(new EnumField(ThingReference.Empty, TP, s,
                                                                 arduino.digitalRead(i), FieldType.Momentary, FieldQoS.AutomaticReadout));
                                }
                                else
                                {
                                    ushort Raw     = arduino.analogRead(s);
                                    double Percent = Raw / 10.24;

                                    Fields.AddLast(new Int32Field(ThingReference.Empty, TP, s + ", Raw",
                                                                  Raw, FieldType.Momentary, FieldQoS.AutomaticReadout));

                                    Fields.AddLast(new QuantityField(ThingReference.Empty, TP, s,
                                                                     Percent, 2, "%", FieldType.Momentary, FieldQoS.AutomaticReadout));
                                }
                            }

                            if (ReadStatus && Request.IsIncluded(s = Pin.Key + ", Mode"))
                            {
                                if (s.StartsWith("D") && byte.TryParse(s.Substring(1), out i))
                                {
                                    Fields.AddLast(new EnumField(ThingReference.Empty, TP, s,
                                                                 arduino.getPinMode(i), FieldType.Status, FieldQoS.AutomaticReadout));
                                }
                                else
                                {
                                    Fields.AddLast(new EnumField(ThingReference.Empty, TP, s,
                                                                 arduino.getPinMode(s), FieldType.Status, FieldQoS.AutomaticReadout));
                                }
                            }
                        }
                    }

                    Request.ReportFields(true, Fields);
                };

                if (arduino == null)
                {
                    this.SetupControlServer();
                }

                xmppClient.Connect();
            }
            catch (Exception ex)
            {
                Log.Emergency(ex);

                MessageDialog Dialog = new MessageDialog(ex.Message, "Error");
                await Dialog.ShowAsync();
            }
        }
Exemplo n.º 36
0
 public void CardChargeSucceeded()
 {
     _creditCard.GetBalance(Pin.From("1234")).Should().Be(Money.From(45));
 }
Exemplo n.º 37
0
        private async Task populateMap(List <Person> people)
        {
            mapLocsProperties.Clear();
            mapRef.Pins.Clear();
            double avgLat  = 0;
            double avgLong = 0;
            double minLat  = 90;
            double maxLat  = -90;
            double minLong = 180;
            double maxLong = -180;

            foreach (Person person in people)
            {
                //Person person = await DataStore.GetItemAsync(ids[0]);

                //Person person = people.FirstOrDefault(p => p.Id == id);
                string address = person.Address.ToString();
                try
                {
                    Location location = await GeocodeThis(address);

                    locs.Add(location);
                    Pin apin = new Pin()
                    {
                        Position = new Position(location.Latitude, location.Longitude),
                        Label    = person.Name
                    };
                    if (location.Latitude > maxLat)
                    {
                        maxLat = location.Latitude;
                    }
                    if (location.Latitude < minLat)
                    {
                        minLat = location.Latitude;
                    }
                    if (location.Longitude > maxLong)
                    {
                        maxLong = location.Longitude;
                    }
                    if (location.Longitude < minLong)
                    {
                        minLong = location.Longitude;
                    }
                    //avgLat += location.Latitude;
                    //avgLong += location.Longitude;
                    mapRef.Pins.Add(apin);
                    mapLocsProperties.Add(new MapLocation(address, person.Name, new Position(location.Latitude, location.Longitude)));
                    //TODO Map by name
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Exception:{ex} Outside Geocoding");
                }
            }
            var dist = Location.CalculateDistance(maxLat, maxLong, minLat, minLong, DistanceUnits.Kilometers) / 2;

            avgLat  = (maxLat - minLat) / 2 + minLat;
            avgLong = (maxLong - minLong) / 2 + minLong;

            Console.WriteLine("{maxLat}, {minLat}, {maxLong}, {minLong}, {dist}, {avgLat}, {avgLong}");
            Console.WriteLine($"{maxLat}, {minLat}, {maxLong}, {minLong}, {dist}, {avgLat}, {avgLong}");

            //avgLat /= mapLocsProperties.Count;
            //avgLong /= mapLocsProperties.Count;
            Console.WriteLine($"{avgLat}, {avgLong}, {mapLocsProperties.Count}");
            //new Position(avgLat, avgLong);mapLocsProperties[0].Position
            mapRef.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(avgLat, avgLong), Distance.FromKilometers(dist > 20?dist:20)));
            //Console.WriteLine($"Check Formating: \n{address}");
        }
Exemplo n.º 38
0
        /// <summary>
        /// Writes VerilogWrite object to a verilog file
        /// </summary>
        /// <param name="circuit">CircuitRec object to be written to
        /// Verilog</param>
        /// <param name="filename">String containing the desired verilog filename</param>
        public Boolean write(CircuitRec.CircuitRec circuit, String filename)
        {
            String dir = Path.GetDirectoryName(filename);

            String modName = Path.GetFileNameWithoutExtension(filename);

            // Calls VerilogWriter to write the .v file

            // Module Name
            Module M = new Module(modName);

            // Inputs to Module
            List <Pin> inputs  = new List <Pin>();
            List <Pin> outputs = new List <Pin>();
            List <Pin> wires   = new List <Pin>();
            Pin        temp;

            //Loops through each superwire and pulls out the inputs
            //and outputs
            foreach (Mesh new_wire in circuit.Meshes)
            {
                if (new_wire.IOType.Equals(WirePolarity.Input))
                {
                    temp = new Pin(PinPolarity.Input, new_wire.Name, new_wire.Bussize);
                    inputs.Add(temp);
                }
                else if (new_wire.IOType.Equals(WirePolarity.Output))
                {
                    temp = new Pin(PinPolarity.Ouput, new_wire.Name, new_wire.Bussize);
                    outputs.Add(temp);
                }
                else
                {
                    temp = new Pin(PinPolarity.Wire, new_wire.Name, new_wire.Bussize);
                    wires.Add(temp);
                }
            }

            M.addInputs(inputs);
            M.addOutputs(outputs);
            M.addWires(wires);

            // Outputs of Symbols
            String output_name = "";
            int    symbolSize  = 1;

            //Loops through each symbol, determines the superwire name
            //of the inputs and outputs and add them to the module
            foreach (BaseSymbol new_symb in circuit.Symbols)
            {
                List <Pin> symbInputs  = new List <Pin>();
                List <Pin> symbOutputs = new List <Pin>();
                Pin        temporary;

                //Look at the wires connected to the symbol
                foreach (Wire symb_wire in new_symb.InputWires)
                {
                    //Loop through each superwire attached to the gate to determine
                    //which the inputwire belongs to.  Add it to the gate's input
                    foreach (Mesh sup in new_symb.ConMeshes)
                    {
                        if (sup.AllConnectedWires.Contains(symb_wire))
                        {
                            temporary = new Pin(PinPolarity.Input, sup.Name, sup.Bussize);
                            symbInputs.Add(temporary);
                            break;
                        }
                    }
                }

                //Look at the output wires of the sympol
                foreach (Wire symb_wire in new_symb.OutputWires)
                {
                    //Figure out which superwire each output is attacked to and add it
                    //to the list of outputs
                    foreach (Mesh sup in new_symb.ConMeshes)
                    {
                        if (sup.AllConnectedWires.Contains(symb_wire))
                        {
                            temporary = new Pin(PinPolarity.Ouput, sup.Name, sup.Bussize);
                            symbOutputs.Add(temporary);
                            break;
                        }
                    }
                }

                M.addGate(new_symb.Name, new_symb.SymbType, symbOutputs, symbInputs);
            }

            //Writes the verilog module
            return(M.printModule(dir, modName));
        }
Exemplo n.º 39
0
        public PinsPage()
        {
            InitializeComponent();

            Pin pinTokyo   = null;
            Pin pinNewYork = null;

            // Tokyo pin
            buttonAddPinTokyo.Clicked += (sender, e) =>
            {
                pinTokyo = new Pin()
                {
                    Type     = PinType.Place,
                    Label    = "Tokyo SKYTREE",
                    Address  = "Sumida-ku, Tokyo, Japan",
                    Position = new Position(35.71d, 139.81d),
                    Rotation = 33.3f,
                    Tag      = "id_tokyo"
                };

                map.Pins.Add(pinTokyo);
                map.MoveToRegion(MapSpan.FromCenterAndRadius(pinTokyo.Position, Distance.FromMeters(5000)));

                ((Button)sender).IsEnabled     = false;
                buttonRemovePinTokyo.IsEnabled = true;
            };

            buttonRemovePinTokyo.Clicked += (sender, e) =>
            {
                map.Pins.Remove(pinTokyo);
                pinTokyo = null;
                ((Button)sender).IsEnabled  = false;
                buttonAddPinTokyo.IsEnabled = true;
            };
            buttonRemovePinTokyo.IsEnabled = false;

            // New York pin
            buttonAddPinNewYork.Clicked += (sender, e) =>
            {
                pinNewYork = new Pin()
                {
                    Type     = PinType.Place,
                    Label    = "Central Park NYC",
                    Address  = "New York City, NY 10022",
                    Position = new Position(40.78d, -73.96d),
                    Tag      = "id_new_york"
                };

                map.Pins.Add(pinNewYork);
                map.MoveToRegion(MapSpan.FromCenterAndRadius(pinNewYork.Position, Distance.FromMeters(5000)));

                ((Button)sender).IsEnabled       = false;
                buttonRemovePinNewYork.IsEnabled = true;
            };

            buttonRemovePinNewYork.Clicked += (sender, e) =>
            {
                map.Pins.Remove(pinNewYork);
                pinNewYork = null;
                ((Button)sender).IsEnabled    = false;
                buttonAddPinNewYork.IsEnabled = true;
            };
            buttonRemovePinNewYork.IsEnabled = false;

            // Clear Pins
            buttonClearPins.Clicked += (sender, e) =>
            {
                map.Pins.Clear();

                pinTokyo   = null;
                pinNewYork = null;
                buttonAddPinTokyo.IsEnabled      = true;
                buttonAddPinNewYork.IsEnabled    = true;
                buttonRemovePinTokyo.IsEnabled   = false;
                buttonRemovePinNewYork.IsEnabled = false;
            };

            // Select New York Pin
            buttonSelectPinNewYork.Clicked += (sender, e) =>
            {
                if (pinNewYork == null)
                {
                    DisplayAlert("Error", "New York is not added.", "Close");
                    return;
                }

                map.SelectedPin = pinNewYork;
            };

            // Clear Pin Selection
            buttonClearSelection.Clicked += (sender, e) =>
            {
                if (map.SelectedPin == null)
                {
                    DisplayAlert("Error", "Pin is not selected.", "Close");
                    return;
                }

                map.SelectedPin = null;
            };

            map.PinClicked += Map_PinClicked;;

            // Selected Pin changed
            map.SelectedPinChanged += SelectedPin_Changed;

            map.InfoWindowClicked += InfoWindow_Clicked;
        }
Exemplo n.º 40
0
 public static void OnPinRemoved(Pin pin)
 {
     Interface.CallHook(nameof(OnPinRemoved), pin);
 }
Exemplo n.º 41
0
 public IUltrasonicRangerSensor BuildUltraSonicSensor(Pin pin)
 {
     return(DoBuild(x => new UltrasonicRangerSensor(x, pin)));
 }
Exemplo n.º 42
0
 public ILed BuildLed(Pin pin)
 {
     return(DoBuild(x => new Led(x, pin)));
 }
Exemplo n.º 43
0
        private Business GetBusinessFromPin(Pin pin)
        {
            Position pos = pin.Position;

            return((Application.Current as App).CachedBusinesses.FirstOrDefault(b => b.Longitude == pos.Longitude && b.Latitude == pos.Latitude));
        }
Exemplo n.º 44
0
 /// <summary>
 /// Call when after marker delete.
 /// You can override your custom renderer for customize marker.
 /// </summary>
 /// <param name="outerItem">the pin.</param>
 /// <param name="innerItem">thr marker.</param>
 protected virtual void OnMarkerDeleted(Pin outerItem, Marker innerItem)
 {
 }
Exemplo n.º 45
0
 /// <summary>
 /// Call when before marker create.
 /// You can override your custom renderer for customize marker.
 /// </summary>
 /// <param name="outerItem">the pin.</param>
 /// <param name="innerItem">the marker options.</param>
 protected virtual void OnMarkerCreating(Pin outerItem, MarkerOptions innerItem)
 {
 }
Exemplo n.º 46
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (this.appeared)
            {
                return;
            }

            this.LoadingLayout.IsVisible = true;

            try
            {
                await Task.Delay(100); // workaround for #30 [Android]Map.Pins.Add doesn't work when page OnAppearing

                var myLocation = await LocationService.GetCurrentLocation(this.ViewModel);

                if (myLocation == null)
                {
                    return;
                }

                Position position = new Position(
                    myLocation.Latitude,
                    myLocation.Longitude);

                await this.MyMap.AnimateCamera(
                    CameraUpdateFactory.NewCameraPosition(
                        new CameraPosition(
                            position,
                            15d,
                            0d,
                            0d)),
                    TimeSpan.FromSeconds(1));

                this.MyMap.Pins.Clear();

                Pin locatedPin = new Pin()
                {
                    Type     = PinType.Place,
                    Label    = "Lokasi saya",
                    Position = position,
                    Flat     = true
                };
                this.MyMap.Pins.Add(locatedPin);

                var pins = await CreatePins(position);

                this.LoadingLayout.IsVisible = true;
                foreach (Pin pin in pins)
                {
                    this.MyMap.Pins.Add(pin);
                }
            }
            catch
            {
            }

            this.appeared = true;

            this.LoadingLayout.IsVisible = false;
        }
Exemplo n.º 47
0
            public WhenHadEnoughMoneyOnCard()
            {
                Given(() => _creditCard = new CreditCard(Money.From(50), Pin.From("1234")));

                When(() => Subject.Charge(_creditCard, Pin.From("1234"), Money.From(5)));
            }
Exemplo n.º 48
0
        async Task GetAllEquipmentList()
        {
            loading.IsVisible = true;

            var content = await CommonFunction.CallWebService(0, null, Ultis.Settings.SessionBaseURI, ControllerUtil.getAllEqURL(), this);

            clsResponse equipment_response = JsonConvert.DeserializeObject <clsResponse>(content);

            if (equipment_response.IsGood)
            {
                equipmentList = JObject.Parse(content)["Result"].ToObject <List <clsTruckingModel> >();

                var latitudes  = new List <double>();
                var longitudes = new List <double>();

                foreach (clsTruckingModel equipment in equipmentList)
                {
                    if (equipment.Latitude != "")
                    {
                        var pin = new Pin
                        {
                            Position = new Position(Convert.ToDouble(equipment.Latitude), Convert.ToDouble(equipment.Longitude)),
                            Label    = equipment.TruckId + "/" + equipment.BackColor.ToUpper()
                        };

                        latitudes.Add(Convert.ToDouble(equipment.Latitude));
                        longitudes.Add(Convert.ToDouble(equipment.Longitude));


                        string detail = "";

                        foreach (clsCaptionValue details in equipment.Details)
                        {
                            if (details.Caption.Equals("Engine") || details.Caption.Equals("Speed (Km)"))
                            {
                                detail += details.Caption + ": " + details.Value + "\r\n";
                            }
                            else if (details.Caption.Equals("Odometer"))
                            {
                                detail += details.Caption + ": " + details.Value;
                            }
                        }

                        pin.Address  = detail;
                        pin.Clicked += Pin_Clicked2;
                        pins.Add(pin);
                    }
                }

                GoogleMap.MapPins = pins;

                foreach (Pin pin in pins)
                {
                    GoogleMap.Pins.Add(pin);
                }

                double lowestLat   = latitudes.Min();
                double highestLat  = latitudes.Max();
                double lowestLong  = longitudes.Min();
                double highestLong = longitudes.Max();
                double finalLat    = (lowestLat + highestLat) / 2;
                double finalLong   = (lowestLong + highestLong) / 2;
                double distance    = DistanceCalculation.GeoCodeCalc.CalcDistance(lowestLat, lowestLong, highestLat, highestLong, DistanceCalculation.GeoCodeCalcMeasurement.Kilometers);

                GoogleMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(finalLat, finalLong), Distance.FromKilometers(distance)));
            }

            loading.IsVisible = false;
        }
Exemplo n.º 49
0
 protected override void OnUpdateAddress(Pin outerItem, ClusteredMarker nativeItem)
 => nativeItem.Snippet = outerItem.Address;
Exemplo n.º 50
0
        void Initialize()
        {
            // Initialize shader code.
            vertexShaderCode = new ShaderCode(BindingStage.VertexShader);

            {
                // We register inputs.
                vertexShaderCode.InputOperation.AddInput(PinComponent.Position, PinFormat.Floatx2);  //< Position.
                vertexShaderCode.InputOperation.AddInput(PinComponent.TexCoord0, PinFormat.Floatx2); //< Texture coordinate.
                vertexShaderCode.InputOperation.AddInput(PinComponent.User0, PinFormat.Floatx4);     //< Custom attribute 0.
                vertexShaderCode.InputOperation.AddInput(PinComponent.User1, PinFormat.UInteger);    //< Fill ID.


                // Position transform array (dynamically sized).
                ConstantOperation positionTransformOp = vertexShaderCode.CreateConstant("PositionTransform",
                                                                                        PinFormat.Float4x4, Pin.NotArray, null);

                // Texture transform array (dynamically sized).
                ConstantOperation textureTransformOp = vertexShaderCode.CreateConstant("TextureTransform",
                                                                                       PinFormat.Float4x4, Pin.NotArray, null);

                // We expand the position.
                ExpandOperation expandPos = new ExpandOperation(PinFormat.Floatx4, ExpandType.AddOnesAtW);
                expandPos.BindInputs(vertexShaderCode.InputOperation.PinAsOutput(PinComponent.Position));

                // We transform position by matrix.
                MultiplyOperation multiply = new MultiplyOperation();
                multiply.BindInputs(positionTransformOp.Outputs[0], expandPos.Outputs[0]);
                Pin position = multiply.Outputs[0];

                // We expand texture coordinate.
                ExpandOperation expandTex = new ExpandOperation(PinFormat.Floatx4, ExpandType.AddOnesAtW);
                expandTex.BindInputs(vertexShaderCode.InputOperation.PinAsOutput(PinComponent.TexCoord0));

                // We transform by matrix.
                MultiplyOperation multiply2 = new MultiplyOperation();
                multiply2.BindInputs(textureTransformOp.Outputs[0], expandTex.Outputs[0]);
                Pin texcoord = multiply2.Outputs[0];


                // We register outputs.
                vertexShaderCode.OutputOperation.AddComponentAndLink(PinComponent.Position, position);
                vertexShaderCode.OutputOperation.AddComponentAndLink(PinComponent.TexCoord0, texcoord);
                vertexShaderCode.OutputOperation.AddComponentAndLink(PinComponent.User0,
                                                                     vertexShaderCode.InputOperation.PinAsOutput(PinComponent.User0));
                vertexShaderCode.OutputOperation.AddComponentAndLink(PinComponent.User1,
                                                                     vertexShaderCode.InputOperation.PinAsOutput(PinComponent.User1));
            }
            vertexShaderCode.Immutable = true;

            pixelShaderCode = new ShaderCode(BindingStage.PixelShader);

            {
                // We register inputs.
                pixelShaderCode.InputOperation.AddInput(PinComponent.Position, PinFormat.Floatx4);  //< Position.
                pixelShaderCode.InputOperation.AddInput(PinComponent.TexCoord0, PinFormat.Floatx4); //< Texture coordinate.
                pixelShaderCode.InputOperation.AddInput(PinComponent.User0, PinFormat.Floatx4);     //< Custom attribute 0.
                pixelShaderCode.InputOperation.AddInput(PinComponent.User1, PinFormat.UInteger);    //< Fill ID.

                // We resgister interface constants.
                ConstantOperation interfaceConstant = pixelShaderCode.CreateConstant("Fills", PinFormat.Interface,
                                                                                     Pin.DynamicArray, null);

                // TODO: distance from border must be "evaluated".

                // We  convert position/tex coordinate.
                SwizzleOperation swizzlePos = new SwizzleOperation(SwizzleMask.XY);
                swizzlePos.BindInputs(pixelShaderCode.InputOperation.PinAsOutput(PinComponent.Position));
                Pin position = swizzlePos.Outputs[0];

                SwizzleOperation swizzleTex = new SwizzleOperation(SwizzleMask.XY);
                swizzleTex.BindInputs(pixelShaderCode.InputOperation.PinAsOutput(PinComponent.TexCoord0));
                Pin texcoord = swizzleTex.Outputs[0];

                // We now add the fill operation.
                FillElementOperation fillOperation = new FillElementOperation();
                fillOperation.BindInputs(position, texcoord, pixelShaderCode.InputOperation.PinAsOutput(PinComponent.User0),
                                         pixelShaderCode.InputOperation.PinAsOutput(PinComponent.User1), interfaceConstant.Outputs[0]);

                // The output is colour.
                pixelShaderCode.OutputOperation.AddComponentAndLink(PinComponent.RenderTarget0, fillOperation.Outputs[0]);
            }
            pixelShaderCode.Immutable = true;

            // Depth-stencil state.
            depthStencilState = new DepthStencilState();
            depthStencilState.DepthTestEnabled  = false;
            depthStencilState.DepthWriteEnabled = false;

            // Blend state
            blendState = new BlendState();
            blendState.AlphaBlendDestination = BlendOperand.One;
            blendState.AlphaBlendSource      = BlendOperand.Zero;
            blendState.AlphaBlendOperation   = BlendOperation.Add;

            blendState.BlendDestination = BlendOperand.SrcAlphaInverse;
            blendState.BlendSource      = BlendOperand.SrcAlpha;
            blendState.BlendOperation   = BlendOperation.Add;

            // We enable blending.
            blendState[0] = true;

            // Rasterization state.
            rasterizationState                      = new RasterizationState();
            rasterizationState.FrontFacing          = Facing.CCW;
            rasterizationState.CullMode             = CullMode.None;
            rasterizationState.FillMode             = FillMode.Solid;
            rasterizationState.MultiSamplingEnabled = true; //< May change that in future.


            // We intern all states.
            depthStencilState  = StateManager.Intern(depthStencilState);
            blendState         = StateManager.Intern(blendState);
            rasterizationState = StateManager.Intern(rasterizationState);
        }
Exemplo n.º 51
0
 private void MapPinsSet(Pin pin)
 {
     _partyLocation.Pins.Add(pin);
 }
Exemplo n.º 52
0
 protected override void OnUpdateLabel(Pin outerItem, ClusteredMarker nativeItem)
 => nativeItem.Title = outerItem.Label;
Exemplo n.º 53
0
 protected override void OnUpdateTransparency(Pin outerItem, PushPin nativeItem)
 {
     //not implemented
 }
Exemplo n.º 54
0
 protected override void OnUpdateType(Pin outerItem, ClusteredMarker nativeItem)
 {
 }
Exemplo n.º 55
0
 internal GPIO(Pin pin, Transport transport, int period = 0) : base(pin, transport, period)
 {
     this.OnGetContinuousDatacb += OnGetButtonSensorData;
 }
Exemplo n.º 56
0
        private async void TrackMeAsync()
        {
            var current = await CrossGeolocator.Current.GetPositionAsync();

            current.Accuracy = 30;
            float bearing = float.Parse(current.Heading.ToString());


            var pinsUsuario = new Pin
            {
                Label        = "Eu estou aqui",
                IsDraggable  = true,
                Icon         = BitmapDescriptorFactory.FromBundle("pinManopla.png"),
                Transparency = 3 / 10f,
                Flat         = true
            };



            Device.BeginInvokeOnMainThread(() =>
            {
                pinsUsuario.Position = new Position(current.Latitude, current.Longitude);
                pinsUsuario.Rotation = bearing;


                lstRotaFuga = new List <RotaFuga>();


                lstRotaFuga = new RestRotaFuga().RestGet();

                foreach (var item in lstRotaFuga)
                {
                    var pins = new Pin
                    {
                        Label = item.Endereco,


                        Icon         = BitmapDescriptorFactory.FromBundle("pinPontoEncontro.png"),
                        Transparency = 3 / 10f,
                        Flat         = true
                    };
                    pins.Position = new Position(double.Parse(item.Latitude), double.Parse(item.Longitude));
                    pins.Rotation = bearing;
                    //pins.Clicked += new EventHandler(ChamarCuidador);
                    map.Pins.Add(pins);
                }



                //foreach (var item in lstEnfermeiras)
                //{
                //    var pins = new Pin
                //    {
                //        Label = item.Nome,


                //        Icon = BitmapDescriptorFactory.FromBundle("pinEnfermagem.png"),
                //        Transparency = 3 / 10f,
                //        Flat = true
                //    };
                //    pins.Position = new Position(double.Parse(item.Latitude.Replace(".", ",")), double.Parse(item.Longitude.Replace(".", ",")));
                //    pins.Rotation = bearing;
                //    pins.Clicked += new EventHandler(ChamarEnfermagem);
                //    map.Pins.Add(pins);
                //}



                map.Pins.Add(pinsUsuario);
                map.IsTrafficEnabled  = true;
                map.IsShowingUser     = true;
                map.IsIndoorEnabled   = true;
                map.MyLocationEnabled = true;

                map.MoveCamera(CameraUpdateFactory.NewPosition(new Position(current.Latitude, current.Longitude)));
            });
        }
Exemplo n.º 57
0
 protected override void OnUpdateInfoWindowAnchor(Pin outerItem, PushPin nativeItem)
 {
     //not implemented
 }
        public CustomMapPage()
        {
            InitializeComponent();

            var map = new Map(MapSpan.FromCenterAndRadius(
                                  new Position(49.619335, 20.698595), Distance.FromMiles(0.75)))
            {
                IsShowingUser   = true,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var position1 = new Position(49.625150, 20.692775);
            var position2 = new Position(49.625247, 20.690861);
            var position3 = new Position(49.628702, 20.689008);
            var position4 = new Position(49.628726, 20.690247);
            var position5 = new Position(49.620495, 20.694799);
            var position6 = new Position(49.616928, 20.704588);

            var position7 = new Position(49.606776, 20.702306);  //Pkp

            var position8 = new Position(49.626263, 20.690385);  //Rezydencja

            var position9 = new Position(49.627790, 20.690492);  //synagoga

            var position10 = new Position(49.625014, 20.693392); //dom gotycki

            var position11 = new Position(49.623370, 20.692184); //kapliczka

            var position12 = new Position(49.622277, 20.695019); //Sokół



            var pin1 = new Pin
            {
                Type     = PinType.Place,
                Position = position1,
                Label    = "Bazylika",
                Address  = "www.intilaq.tn",
            };

            var pin2 = new Pin
            {
                Type     = PinType.Place,
                Position = position2,
                Label    = "Ratusz",
                Address  = "www.groupe-telnet.com"
            };

            var pin3 = new Pin
            {
                Type     = PinType.Place,
                Position = position3,
                Label    = "Ruiny Zamku Królewskiego",
                Address  = "www.kromberg-schubert.com"
            };

            var pin4 = new Pin
            {
                Type     = PinType.Place,
                Position = position4,
                Label    = "Zegar kwiatowy",
                Address  = "www.kromberg-schubert.com"
            };

            var pin5 = new Pin
            {
                Type     = PinType.Place,
                Position = position5,
                Label    = "Planty",
                Address  = "Planty "
            };

            var pin6 = new Pin
            {
                Type     = PinType.Place,
                Position = position6,
                Label    = "Cmentarz Komunalny",
                Address  = "www.kromberg-schubert.com"
            };


            var pin7 = new Pin
            {
                Type     = PinType.Place,
                Position = position7,
                Label    = "Dworzec PKP",
                Address  = "www.intilaq.tn",
            };

            var pin8 = new Pin
            {
                Type     = PinType.Place,
                Position = position8,
                Label    = "Rezydencja Lubomirskich",
                Address  = "www.groupe-telnet.com"
            };

            var pin9 = new Pin
            {
                Type     = PinType.Place,
                Position = position9,
                Label    = "Dawna Synagoga",
                Address  = "www.kromberg-schubert.com"
            };

            var pin10 = new Pin
            {
                Type     = PinType.Place,
                Position = position10,
                Label    = "Dom Gotycki",
                Address  = "www.kromberg-schubert.com"
            };

            var pin11 = new Pin
            {
                Type     = PinType.Place,
                Position = position11,
                Label    = "Kapliczka Szwedzka",
                Address  = "Planty "
            };

            var pin12 = new Pin
            {
                Type     = PinType.Place,
                Position = position12,
                Label    = "Sokół",
                Address  = "www.kromberg-schubert.com"
            };



            map.Pins.Add(pin1);
            map.Pins.Add(pin2);
            map.Pins.Add(pin3);
            map.Pins.Add(pin4);
            map.Pins.Add(pin5);
            map.Pins.Add(pin6);
            map.Pins.Add(pin7);
            map.Pins.Add(pin8);
            map.Pins.Add(pin9);
            map.Pins.Add(pin10);
            map.Pins.Add(pin11);
            map.Pins.Add(pin12);

            Content = map;
        }
Exemplo n.º 59
0
 //------------------------------------------------------------------------------------------------------------------------
 internal LightSensor(Pin pin, Transport transport, int period = 0) : base(pin, transport, period)
 {
     this.OnGetContinuousDatacb += OnGetLightSensorData;
 }
Exemplo n.º 60
0
 /// <summary>
 /// Construction with generator.
 /// </summary>
 internal PinBinder([NotNull] CodeGenerator g, [NotNull] Pin p)
 {
     generator = g;
     pin       = p;
 }