public EventOverviewViewModel(SharingSpace sharingSpace, List <Models.Object> objectList)
        {
            SharingSpace = sharingSpace;
            //ObjectList = objectList;
            Items = new ObservableRangeCollection <Photo>();


            TakePhotoCommand = new Command(async() => await TakePhoto());
            RefreshCommand   = new Command(async() => await Refresh());

            //// get photos from directory
            var documentsDirectory  = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            var documents2Directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            documentsDirectory += "/PeopleApp/";

            //string[] files = System.IO.Directory.GetFiles(documentsDirectory, "*.jp*g");
            //foreach (var item in files)
            //{
            //    Console.WriteLine(item.ToString());
            //}
            //if (files.Length == 0)
            //{
            //    Console.Error.WriteLine("No matching files found.");
            //    Environment.Exit(1);
            //}

            // Execute the refresh command to get photos
            RefreshCommand.Execute(null);
        }
        private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var vm = BindingContext as EventJoinViewModel;

            var product = e.Item as SharingSpaceView;

            selectedSharingSpace = vm.HideOrShowProduct(product);
        }
Exemplo n.º 3
0
 public CreateSharingSpaceBViewModel(SharingSpace sharingSpace, List <DimensionView> dimensions, CreateSharingSpaceBPage page)
 {
     this.SharingSpace = sharingSpace;
     this.Dimensions   = dimensions;
     _page             = page;
     ReloadTags();
     RemoveTagCommand = new BaseCommand <TagItem>((arg) => RemoveTag(arg));
 }
Exemplo n.º 4
0
 public CreateSharingSpaceBPage(SharingSpace sharingSpace, List <DimensionView> dimensions)
 {
     BindingContext = vm = new CreateSharingSpaceBViewModel(sharingSpace, dimensions, this);
     Resources      = new ResourceDictionary();
     //Resources.Add("TagValidatorFactory", new Func<string, object>((arg) => (BindingContext as CreateSharingSpaceBViewModel)?.ValidateAndReturn(arg)));
     Resources.Add("TagValidatorFactory", new Func <string, object>(
                       (arg) => vm?.ValidateAndReturn(arg)));
     InitializeComponent();
     MessagingCenter.Subscribe <CreateSharingSpaceBViewModel, SharingSpace>(this, "NavigateToEventOverview", OnSharingSpaceSubmission);
     //NavigationPage.SetHasNavigationBar(this, false);  // Hide nav bar
 }
        // add the user name as parameter
        public EventOverviewPage(SharingSpace sharingSpace, List <Models.Object> objectList)
        {
            this.sharingSpace            = sharingSpace ?? throw new ArgumentNullException();
            Settings.CurrentSharingSpace = sharingSpace.Id;

            BindingContext = vm = new EventOverviewViewModel(sharingSpace, objectList);
            InitializeComponent();
            // Capitalize event title
            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            eventName.Text = textInfo.ToTitleCase(sharingSpace.Descriptor);
        }
Exemplo n.º 6
0
        private async void NextButton_Clicked(object sender, EventArgs e)
        {
            // save sharing space and constraints
            SharingSpace sharingSpace = new SharingSpace
            {
                CreationDate     = DateTime.Now,
                CreationLocation = LatitudeLabel.Detail + ", " + LongitudeLabel.Detail,
                Descriptor       = eventDescriptor.Text,
                Id     = Utilities.NewGuid(),
                UserId = Settings.UserId
            };

            DateTime startDate = dateStart.Date + timeStart.Time;
            DateTime endDate   = dateEnd.Date + timeEnd.Time;

            Models.Constraint timeConstraint1 = new Models.Constraint {
                Operator = "begin", Value = startDate.ToString()
            };
            Models.Constraint timeConstraint2 = new Models.Constraint {
                Operator = "end", Value = endDate.ToString()
            };
            Models.Constraint locationConstraint1 = new Models.Constraint {
                Operator = "range", Value = mySlider.Value.ToString()
            };
            Models.Constraint locationConstraint2 = new Models.Constraint {
                Operator = "latitude", Value = LatitudeLabel.Detail
            };
            Models.Constraint locationConstraint3 = new Models.Constraint {
                Operator = "longitude", Value = LongitudeLabel.Detail
            };
            //var constraintId = Guid.NewGuid().ToString();
            Models.Constraint locationConstraint4 = new Models.Constraint {
                Operator = "fulladdress", Value = fullAddress
            };
            var timeConstraintList = new List <Models.Constraint> {
                timeConstraint1, timeConstraint2
            };
            var locationConstraintList = new List <Models.Constraint> {
                locationConstraint1, locationConstraint2, locationConstraint3, locationConstraint4
            };
            List <DimensionView> dimensions = new List <DimensionView>
            {
                new DimensionView {
                    Label = "Time", Interval = true, ConstraintList = timeConstraintList
                },
                new DimensionView {
                    Label = "Location", Interval = true, ConstraintList = locationConstraintList
                }
            };

            await Navigation.PushAsync(new CreateSharingSpaceBPage(sharingSpace, dimensions));
        }
Exemplo n.º 7
0
 public SharingSpaceView(SharingSpace sharingSpace, bool isVisible)
 {
     base.Id               = sharingSpace.Id;
     base.Descriptor       = sharingSpace.Descriptor;
     base.CreationLocation = sharingSpace.CreationLocation;
     base.CreationDate     = sharingSpace.CreationDate;
     base.CreatedAt        = sharingSpace.CreatedAt;
     base.UpdatedAt        = sharingSpace.UpdatedAt;
     base.UserId           = sharingSpace.UserId;
     base.Version          = sharingSpace.Version;
     base.Verified         = sharingSpace.Verified;
     IsVisible             = isVisible;
 }
        // this region needs to be removed
        #region Operations on Tables

        public async Task <SharingSpace> AddSharingSpace(SharingSpace sharingSpace)
        {
            await InitializeAsync();

            // manipulate the input

            await sharingSpaceTable.CreateItemAsync(sharingSpace);

            await SyncOfflineCacheAsync();

            //return coffee
            return(sharingSpace);
        }
        private async void OnSelectedSharingSpace(Abstractions.BaseViewModel source, SharingSpace sharingSpace)
        {
            try
            {
                var objectList = await _apiServices.GetObjectsBySharingSpace(sharingSpace.Id);

                Navigation.InsertPageBefore(new EventOverviewPage(sharingSpace, objectList), this);//Navigation.NavigationStack.OfType<EventHistoryPage>().FirstOrDefault()); // this);
                await Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error :" + ex.Message);
            }
        }
Exemplo n.º 10
0
        //async Task CreateSharingSpace()
        //{
        //    if (IsBusy)
        //        return;
        //    IsBusy = true;

        //    try
        //    {
        //        //await Application.Current.MainPage.Navigation.PushAsync(new Views.CreateSharingSpaceAPage());
        //        IsBusy = true;

        //        var sharingSpace = await CloudService.AddSharingSpace(new SharingSpace { UserId = Settings.UserId, Descriptor = "A very special event", CreationLocation = "Anglet", CreationDate = DateTime.Now });
        //        Items.Add(sharingSpace);
        //        //SortCoffees();
        //    }
        //    catch (Exception ex)
        //    {
        //        Debug.WriteLine($"[TaskList] Error in CreateSharingSpace: {ex.Message}");
        //        await Application.Current.MainPage.DisplayAlert("Sharing space Not Created", ex.Message, "OK");
        //    }
        //    finally
        //    {
        //        IsBusy = false;
        //    }
        //}

        async Task LoadMore(SharingSpace item)
        {
            if (IsBusy)
            {
                Debug.WriteLine($"LoadMore: bailing because IsBusy = true");
                return;
            }

            // If we are not displaying the last one in the list, then return.
            if (!Items.Last().Id.Equals(item.Id))
            {
                Debug.WriteLine($"LoadMore: bailing because this id is not the last id in the list");
                return;
            }

            // If we don't have more items, return
            if (!hasMoreItems)
            {
                Debug.WriteLine($"LoadMore: bailing because we don't have any more items");
                return;
            }

            IsBusy = true;
            var table = await CloudService.GetTableAsync <SharingSpace>();

            try
            {
                var list = await table.ReadItemsAsync(Items.Count, 20);

                if (list.Count > 0)
                {
                    Debug.WriteLine($"LoadMore: got {list.Count} more items");
                    Items.AddRange(list);
                }
                else
                {
                    Debug.WriteLine($"LoadMore: no more items: setting hasMoreItems= false");
                    hasMoreItems = false;
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("LoadMore Failed", ex.Message, "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Add a sharing space object to the remote database.
        /// </summary>
        /// <param name="sharingSpace">The sharing space to be added</param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <HttpResponseMessage> PostSharingSpaceAsync(SharingSpace sharingSpace, string token)
        {
            var client = new HttpClient();

            var         json    = JsonConvert.SerializeObject(sharingSpace);
            HttpContent content = new StringContent(json);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            content.Headers.Add("ZUMO-API-VERSION", "2.0.0");
            content.Headers.Add("X-ZUMO-AUTH", token);

            var response = await client.PostAsync(Constants.BaseApiAddress + "tables/sharingspace", content);

            return(response);
        }
Exemplo n.º 12
0
        public EventDetailViewModel(SharingSpace sharingSpace = null)
        {
            // save the id of current sharing space
            Settings.CurrentSharingSpace = sharingSpace.Id;

            SaveCommand   = new Command(async() => await SaveAsync());
            DeleteCommand = new Command(async() => await DeleteAsync());

            if (sharingSpace != null)
            {
                CurrentSharingSpace = sharingSpace;
                Title = "Event Description";
            }
            else
            {
                CurrentSharingSpace = new SharingSpace {
                    Descriptor = "New Item", CreationLocation = "Anglet", CreationDate = DateTime.UtcNow
                };
                Title = "New Item";
            }
        }
 public EventDetail(SharingSpace sharingSpace = null)
 {
     InitializeComponent();
     BindingContext = new EventDetailViewModel(sharingSpace);
 }
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            ICollection <SharingSpace> sharingSpaces = null;
            var sharingSpaceTable = await CloudService.GetTableAsync <SharingSpace>();

            // checks if there is already a selected sharing space if not the history page will appear
            if (!String.IsNullOrEmpty(Settings.CurrentSharingSpace))
            {
                //SharingSpace sharingSpace = await sharingSpaceTable.ReadItemAsync(Settings.CurrentSharingSpace);
                SharingSpace sharingSpace = await _apiServices.GetSharingSpaceById(Settings.CurrentSharingSpace, Settings.AccessToken);

                var objectList = await _apiServices.GetObjectsBySharingSpace(sharingSpace.Id);

                Navigation.InsertPageBefore(new EventOverviewPage(sharingSpace, objectList), this);
                await Navigation.PopAsync();

                return;
                //await Navigation.PushAsync(new EventOverviewPage());
            }

            try
            {
                //sharingSpaces = await _apiServices.GetSharingSpaceAsync(Settings.AccessToken);
                sharingSpaces = await sharingSpaceTable.ReadAllItemsAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[TaskDetail] Load error: {ex.Message}");
                await Application.Current.MainPage.DisplayAlert("Load Events Failed", ex.Message, "OK");
            }

            // checks if there is already a selected sharing space if not the history page will appear
            //if (!String.IsNullOrEmpty(Settings.CurrentSharingSpace))
            //{
            //    //var sharingSpace = await CloudService.GetSharingSpace(Settings.CurrentSharingSpace);
            //    SharingSpace sharingSpace = await sharingSpaceTable.ReadItemAsync(Settings.CurrentSharingSpace);
            //    Navigation.InsertPageBefore(new EventOverviewPage(sharingSpace), this);
            //    await Navigation.PopAsync();
            //    //await Navigation.PushAsync(new EventOverviewPage());
            //}
            // else if there is events list them otherwise open no event page
            if (sharingSpaces.Count > 0)
            {
                try
                {
                    //Navigation.InsertPageBefore(new EventList(sharingSpaces.ToList()), this);
                    Navigation.InsertPageBefore(new EventHistoryPage(), this);
                    await Navigation.PopAsync();

                    //await Navigation.PushAsync(new EventList(sharingSpaces));
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"Load error: {ex.Message}");
                    await Application.Current.MainPage.DisplayAlert("Couldn't load page", ex.Message, "OK");
                }
            }
            else
            {
                //Add NoExistingEventsPage (You do not have any events yet. Do you want to create now...)
                Navigation.InsertPageBefore(new CreateSharingSpaceAPage(), this);
                await Navigation.PopAsync();

                //await Navigation.PushAsync(new CreateSharingSpaceAPage());
            }
        }
Exemplo n.º 15
0
        private async void OnSharingSpaceSubmission(CreateSharingSpaceBViewModel source, SharingSpace sharingSpace)
        {
            // var objectList = _apiServices.GetObjectsBySharingSpace(SharingSpace.Id);
            var objectList = await _apiServices.GetObjectsBySharingSpace(sharingSpace.Id);

            Navigation.InsertPageBefore(new EventOverviewPage(sharingSpace, objectList), Navigation.NavigationStack.FirstOrDefault());
            await Navigation.PopToRootAsync();
        }