Ejemplo n.º 1
0
        private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                Pins.Clear();
            }

            if (e.OldItems != null)
            {
                foreach (CustomPin pin in e.OldItems)
                {
                    Pins.Remove(pin.Pin);
                    pin.Pin.PropertyChanged -= OnPropertyChanged;
                }
            }

            if (e.NewItems != null)
            {
                foreach (CustomPin pin in e.NewItems)
                {
                    Pins.Add(pin.Pin);
                    pin.Pin.PropertyChanged += OnPropertyChanged;
                }
            }
        }
Ejemplo n.º 2
0
        void OnPinRemoveCommand(User user, string[] args)
        {
            if (args.Length != 1)
            {
                user.SendChatMessage(Messages.Usage, "/pin remove \"NAME\"");
                return;
            }

            if (user.Faction == null)
            {
                user.SendChatMessage(Messages.NotMemberOfFaction);
                return;
            }

            string name = Util.NormalizePinName(args[0]);
            Pin    pin  = Pins.Get(name);

            if (pin == null)
            {
                user.SendChatMessage(Messages.UnknownPin, name);
                return;
            }

            Area area = Areas.Get(pin.AreaId);

            if (area.FactionId != user.Faction.Id)
            {
                user.SendChatMessage(Messages.CannotRemovePinAreaNotOwnedByYourFaction, pin.Name, pin.AreaId);
                return;
            }

            Pins.Remove(pin);
            user.SendChatMessage(Messages.PinRemoved, pin.Name);
        }
Ejemplo n.º 3
0
        void OnPinDeleteCommand(User user, string[] args)
        {
            if (args.Length != 1)
            {
                user.SendChatMessage(Messages.Usage, "/pin delete \"NAME\"");
                return;
            }

            if (!user.HasPermission(Permission.AdminPins))
            {
                user.SendChatMessage(Messages.NoPermission);
                return;
            }

            string name = Util.NormalizePinName(args[0]);
            Pin    pin  = Pins.Get(name);

            if (pin == null)
            {
                user.SendChatMessage(Messages.UnknownPin, name);
                return;
            }

            Pins.Remove(pin);
            user.SendChatMessage(Messages.PinRemoved, pin.Name);
        }
Ejemplo n.º 4
0
        public NodePin <T> ChangePinType <T>(NodePin pin)
        {
            NodeEditor.Assertions.IsTrue(Pins.Contains(pin), string.Format("'{0}' does not contains pin '{1}'.", Name, pin.Name));

            if (Pins.Contains(pin))
            {
                var replacementPin = new NodePin <T>(pin.Name, pin.Index, this);
                Pins.Remove(pin);

                // Replace old pin with the new pin at the same index as the old pin.
                var targetList = pin.IsInput ? InputPins : OutputPins;
                targetList.Insert(targetList.IndexOf(pin), replacementPin);
                targetList.Remove(pin);

                Pins.Add(replacementPin);

                NodeEditor.Logger.Log <Node>("Swapped pin '{0}' of type '{1}' for type '{2}'", replacementPin.Name, pin.WrappedType, replacementPin.WrappedType);

                PinChanged.InvokeSafe(new NodePinChangedEvent(pin, replacementPin));

                return(replacementPin);
            }

            return(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes the pin.
        /// </summary>
        /// <param name="name">Name.</param>
        public void RemovePin(string name)
        {
            var result = Pins.Where(o => o.Name == name).ToList <IPin> ();

            if (result.Count > 0)
            {
                var pin = result.First();
                if (pin is DPin)
                {
                    var tmp = GetCorespondingSequence(pin as DPin);
                    if (tmp != null)
                    {
                        RemoveSequence(tmp.Name);
                    }
                }
                else if (pin is APin)
                {
                    var tmp = GetCorespondingCombination(pin as APin);
                    if (tmp != null)
                    {
                        RemoveMeasurementCombination(tmp);
                    }
                }
                Pins.Remove(result.First());
                if (OnPinsUpdated != null)
                {
                    OnPinsUpdated.Invoke(this, new ControllerPinUpdateArgs(result [0], UpdateOperation.Remove));
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Removes the pin.
 /// </summary>
 /// <param name="pin">Pin.</param>
 public void RemovePin(IPin pin)
 {
     Pins.Remove(pin);
     if (OnPinsUpdated != null)
     {
         OnPinsUpdated.Invoke(this, new ControllerPinUpdateArgs(pin, UpdateOperation.Remove));
     }
 }
Ejemplo n.º 7
0
 private void RemoveHiveFromMap(Hive deletedHive)
 {
     foreach (var item in Pins.ToList())
     {
         if (item.Label == deletedHive.HiveName)
         {
             Pins.Remove(item);
         }
     }
 }
Ejemplo n.º 8
0
        public PinViewModel RemoveMapPosition(MapPosition mapPosition)
        {
            var removedPin = Pins.Find(p => p.MapPosition == mapPosition);

            if (removedPin != null)
            {
                removedPin.Remove();
                Pins.Remove(removedPin);
            }
            return(removedPin);
        }
Ejemplo n.º 9
0
        private void RemovePin(object o)
        {
            if (Pins.Count == 0)
            {
                return;
            }

            var pin = Pins.LastOrDefault();

            _allPins.AddLast(pin);

            Pins.Remove(pin);

            _removePinCommand.ChangeCanExecute();
            _addPinCommand.ChangeCanExecute();
            _selectCommand.ChangeCanExecute();
        }
Ejemplo n.º 10
0
        public void SetLocation(Xamarin.Forms.Maps.Position coordinate)
        {
            var pos = new Xamarin.Forms.Maps.Position(coordinate.Latitude, coordinate.Longitude);

            MoveToRegion(MapSpan.FromCenterAndRadius(pos, Distance.FromMiles(0.1)));
#if __IOS__
            if (pin != null)
            {
                Pins.Remove(pin);
            }
            pin = new Pin {
                Position = coordinate, Address = possibleAddresses.FirstOrDefault().Split('\n')[0], Label = "Reclamo"
            };
            Pins.Add(pin);
#endif
            //if (denunciaPAge != null) denunciaPAge.Loading(false);
        }
Ejemplo n.º 11
0
        void RemovePin(NodePin pin)
        {
            Pins.Remove(pin);

            if (pin.IsInput)
            {
                InputPins.Remove(pin);
            }
            else
            {
                OutputPins.Remove(pin);
            }

            PinRemoved.InvokeSafe(pin);
            pin.Connected -= OnPinConnected;
            TriggerChange();
        }
Ejemplo n.º 12
0
        public void RemoveSelectedObject()
        {
            switch (SelectedObject)
            {
            case PinTemplate pt:
                Pins.Remove(pt);
                break;

            case DeadZoneTemplate dzt:
                DeadZones.Remove(dzt);
                break;

            case NamedFunctionTemplate nft:
                Functions.Remove(nft);
                break;
            }
        }
Ejemplo n.º 13
0
        private async void ShowPin(PinViewViewModel pin)
        {
            var newPin = (await _pinService.GetPinsAsync(App.CurrentUserId)).LastOrDefault(x => x.ID == pin.ID);
            var Pin    = newPin.ToPin();

            MapCameraPosition = new CameraPosition(Pin.Position, 5);
            if (!Pins.Contains(Pin))
            {
                Pins.Add(Pin);
                MessagingCenter.Subscribe <PinModalView>(this, Constants.MessagingCenter.DeletePin, (seconSender) =>
                {
                    Pins.Remove(Pin);
                    MessagingCenter.Unsubscribe <PinModalView>(this, Constants.MessagingCenter.DeletePin);
                });
            }

            await OnPinClickedCommand(Pin);
        }
Ejemplo n.º 14
0
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            if (parameters.TryGetValue(Constants.NavigationParameters.AddPin, out PinViewViewModel pinView))
            {
                ShowPin(pinView);
            }

            if (parameters.ContainsKey(Constants.NavigationParameters.LoadFromDataBase))
            {
                await LoadPinsFromDataBase();
                await LoadCategoriesFromDataBase();
            }
            else if (parameters.TryGetValue(Constants.NavigationParameters.DeletePin, out Pin oldPin))
            {
                Pins.Remove(oldPin);
            }

            await GetPermission();
        }
Ejemplo n.º 15
0
        private async void DrawRoute()
        {
            var to      = DataService.GetDriverRoute();
            var drivers = await DataService.GetDriverDeliveryPosition();

            Device.BeginInvokeOnMainThread(() =>
            {
                List <DriverPin> avPins = new List <DriverPin>();
                var driver = drivers.FirstOrDefault();
                if (driver != null)
                //foreach (var driver in drivers)
                {
                    DriverRoute route = Routes.FirstOrDefault(x => x.DriverInfo.DriverId == driver.DriverId);
                    if (route == null)
                    {
                        route = new DriverRoute
                        {
                            TravelMode  = TKRouteTravelMode.Driving,
                            Source      = new Position(driver.Latitude, driver.Longitude),
                            Destination = new Position(to.Latitude, to.Longitude),
                            Color       = Color.Blue,
                            LineWidth   = 20,
                            Selectable  = false,
                            DriverInfo  = new Model.DriverInfo
                            {
                                DriverId = driver.DriverId
                            }
                        };
                        Routes.Add(route);
                    }
                    else
                    {
                        route.Source = new Position(driver.Latitude, driver.Longitude);
                    }
                    DriverPin driverPin = Pins.OfType <DriverPin>().FirstOrDefault(x => x.DriverInfo.DriverId == driver.DriverId);
                    if (driverPin == null)
                    {
                        driverPin = new DriverPin()
                        {
                            Image       = Device.OnPlatform("car_icon", "car_icon", string.Empty),
                            Position    = new Position(driver.Latitude, driver.Longitude),
                            DriverInfo  = driver,
                            ShowCallout = true,
                        };
                        Pins.Add(driverPin);
                    }
                    else
                    {
                        driverPin.Position = new Position(driver.Latitude, driver.Longitude);
                    }

                    var toPin = Pins.OfType <OrderPin>().FirstOrDefault(x => x.OrderInfo.Id == driver.DriverId);
                    if (toPin == null)
                    {
                        toPin = new OrderPin
                        {
                            Position        = new Position(to.Latitude, to.Longitude),
                            DefaultPinColor = Color.Red,
                            OrderInfo       = new Model.Order {
                                Id = driver.DriverId
                            }
                        };
                        Pins.Add(toPin);
                    }
                    else
                    {
                        toPin.Position = new Position(to.Latitude, to.Longitude);
                    }
                    avPins.Add(driverPin);
                }
                //clear not use pins
                var castPins = Pins.OfType <DriverPin>();
                for (int i = 0; i < castPins.Count(); i++)
                {
                    if (avPins.FirstOrDefault(x => x.DriverInfo.DriverId == castPins.ElementAt(i).DriverInfo.DriverId) == null)
                    {
                        Routes.Remove(Routes.First(x => x.DriverInfo.DriverId == castPins.ElementAt(i).DriverInfo.DriverId));
                        Pins.Remove(Pins.OfType <OrderPin>().First(x => x.OrderInfo.Id == castPins.ElementAt(i).DriverInfo.DriverId));
                        Pins.Remove(castPins.ElementAt(i));
                        i = 0;
                    }
                }
            });
        }
Ejemplo n.º 16
0
        public FestaMapRootPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, IShowFestaMap showFesta, IMapAssociated mapParam)
        {
            _eventAggregator   = eventAggregator;
            _navigationService = navigationService;
            showFestaUsecase   = showFesta;
            _mapParams         = mapParam;

            InfoWindowClickedCommand = new DelegateCommand <InfoWindowClickedEventArgs>(async(pin) =>
            {
                var region = pin.Pin.Tag as MapRegion;
                if (region == null)
                {
                    return;
                }
                if (IsGlobalMap)
                {
                    if (region.MapObjectType.HasFlag(MapObjectEnum.STAGE))
                    {
                        await _navigationService.NavigateAsync(
                            nameof(StageEventListRootPageViewModel).GetViewNameFromRule(),
                            StageEventListRootPageViewModel.GetNavigationParameter(region.Id, region.Name));
                    }
                    else
                    {
                        var type = region.MapObjectType.HasFlag(MapObjectEnum.EXHIBITION) ? PlanningTypeEnum.EXHIBITION : PlanningTypeEnum.STALL;
                        await _navigationService.NavigateAsync(
                            "RegionSpecificPlanningListPage",
                            PlanningListRootPageViewModel.GetNavigationParameter(region.Id, region.Name, type));
                    }
                }
            });

            _eventAggregator.GetEvent <PolygonClickedEvent>().Subscribe((pin) =>
            {
                SelectedPin.Value = pin.Tag as Pin;
                MoveToRegionRequest.MoveToRegion(
                    MapSpan.FromCenterAndRadius(SelectedPin.Value.Position, Distance.FromMeters(100)));
            }).AddTo(this.Disposable);

            showFesta.Pins.ToCollectionChanged <Pin>()
            .Subscribe(change =>
            {
                switch (change.Action)
                {
                case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                    Pins?.Add(change.Value);
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                    Pins?.Remove(change.Value);
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                    Pins?.Clear();
                    break;
                }
            }).AddTo(this.Disposable);

            showFesta.Polygons.ToCollectionChanged <Polygon>()
            .Subscribe(change =>
            {
                switch (change.Action)
                {
                case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                    Polygons?.Add(change.Value);
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                    Polygons?.Remove(change.Value);
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
                    break;

                case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
                    Polygons?.Clear();
                    break;
                }
            }).AddTo(this.Disposable);

            // For iOS
            _eventAggregator.GetEvent <TabbedPageOpendEvent>().Subscribe((ev) =>
            {
                if (ev.Name != this.GetType().Name.Replace("ViewModel", ""))
                {
                    return;
                }

                IsShowingUser.Value = true;
                showFestaUsecase.InitializeAllMapObjects();
                if (IsGlobalMap)
                {
                    MoveToRegionRequest.MoveToRegion(
                        MapSpan.FromCenterAndRadius(
                            new Position(_mapParams.MapCenterLangitude, _mapParams.MapCenterLongitude),
                            Distance.FromMeters(185)));
                }
            }).AddTo(this.Disposable);

            _eventAggregator.GetEvent <LocationPermissionRequestResultEvent>()
            .Subscribe((ev) =>
            {
                IsShowingUser.Value = ev.Granted;
            });

            Title.AddTo(this.Disposable);
            SelectedPin.AddTo(this.Disposable);
            IsShowingUser.AddTo(this.Disposable);
        }
Ejemplo n.º 17
0
 public void RemovePinViewModel(PinViewModel removedPin)
 {
     removedPin.Remove();
     Pins.Remove(removedPin);
 }