예제 #1
0
 public PlacesView()
 {
     Refresh();
     this.SelectionMode     = ListViewItemsSelectionMode.Single;
     this.SelectionChanged += (o, e) =>
     {
         SelectedPlaceChanged?.Invoke(this, new EventsArgs <GeolocationPlace>(this.SelectedPlace));
     };
 }
        public PlacesLocationsView()
        {
            InitializeComponent();

            bool ignorePlaceNavigation = false;

            placesView.SelectedPlaceChanged += (o, e) =>
            {
                placeEditView.RefreshWith(e.Value);
                if (!ignorePlaceNavigation)
                {
                    locationsView.NavigateTo(e.Value);
                }
                btRemovePlace.IsEnabled = e.Value != null;
                SelectedPlaceChanged?.Invoke(this, new EventsArgs <GeolocationPlace>(e.Value));
            };

            locationsView.PlaceNavigated += (o, e) =>
            {
                ignorePlaceNavigation = true;
                var placeToSelect = placesView.Places.FirstOrDefault(x => x.Name == e.Value);
                placesView.SelectedPlace = placeToSelect;
                btRemovePlace.IsEnabled  = placesView.SelectedPlace != null;
                ignorePlaceNavigation    = false;
            };

            btAddPlace.Click += (o, e) =>
            {
                var geolocationPlace = new GeolocationPlace();
                geolocationPlace.Name =
                    "Новое место " + (PlacesManager.Current.Places.Count(x => x.Name.StartsWith("Новое место")) + 1);
                geolocationPlace.Location      = locationsView.CurrentLocation;
                geolocationPlace.MetersRadious = 200;
                placesView.AddPlace(geolocationPlace);
                RefreshWith(_targets, null);
                placesView.SelectedPlace = geolocationPlace;
            };

            btRemovePlace.Click += (o, e) => {
                if (placesView.SelectedPlace != null)
                {
                    placesView.RemovePlace(placesView.SelectedPlace);
                    RefreshWith(_targets, null);
                }
            };

            placeEditView.SettingsApplied += (o, e) => {
                ignorePlaceNavigation = true;
                RefreshWith(_targets, null);
                placesView.SelectedPlace = e.Value;
                ignorePlaceNavigation    = false;
            };
        }
예제 #3
0
        public LocationsView()
        {
            InitializeComponent();
            bool ignoreUserNavigation = false;

            usersView.SelectedUserChanged += (o, e) => {
                if (usersView.SelectedUser != null)
                {
                    devicesView.Devices = usersView.SelectedUser
                                          .Geolocations
                                          .Select(x => x.Device)
                                          .Distinct()
                                          .ToArray();
                }
                else
                {
                    devicesView.Devices = new string[0];
                }
                SelectedUserChanged?.Invoke(this, new EventsArgs <IGeolocationTarget>(SelectedUser));
                devicesView.SelectedDevice = devicesView.Devices.FirstOrDefault();
            };
            devicesView.SelectedDeviceChanged += (o, e) => {
                if (!ignoreUserNavigation && SelectedUser != null)
                {
                    locationsView.NavigateTo(SelectedUser.Name, SelectedDevice);
                }
                SelectedDeviceChanged?.Invoke(this, new EventsArgs <string>(SelectedDevice));
                HideDevicesExcept(e.Value);
            };
            locationsView.UserNavigated += (o, e) => {
                ignoreUserNavigation       = true;
                usersView.SelectedUser     = usersView.Users.FirstOrDefault(x => x.Id == e.Value.UserId);
                devicesView.SelectedDevice = e.Value.DeviceId;
                ignoreUserNavigation       = false;
            };
            locationsView.SelectedPlaceChanged += (o, e) => SelectedPlaceChanged?.Invoke(this, e);

            this.Loaded += (o, e) => FitToMarkers();
        }