Exemplo n.º 1
0
        public EditEntryViewModel(string listId, string entryId)
        {
            UseLocation = true;

            ListId  = listId;
            EntryId = entryId;

            if (_entry == null)
            {
                _entry = new Entry();
            }

            if (_entryImage == null)
            {
                _entryImage = new EntryImage();
            }

            if (string.IsNullOrEmpty(entryId))
            {
                //Load the nearest place name, if possible
                var geo = this.GetService <IGeolocator>();

                if (geo.CurrentPosition != null)
                {
                    geo.LookupNearbyPlaces(nearestPlaceName =>
                    {
                        if (!string.IsNullOrEmpty(nearestPlaceName) && string.IsNullOrEmpty(_entry.Store))
                        {
                            _entry.Store = nearestPlaceName;
                            RaisePropertyChanged(() => Entry);
                        }
                    });
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }

            element = (EntryImage)this.Element;


            var editText = this.Control;

            if (!string.IsNullOrEmpty(element.Image))
            {
                switch (element.ImageAlignment)
                {
                case ImageAlignment.Left:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                    break;

                case ImageAlignment.Right:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                    break;
                }
            }
            editText.CompoundDrawablePadding = 25;
            Control.Background.SetColorFilter(element.LineColor.ToAndroid(), PorterDuff.Mode.SrcAtop);
        }
Exemplo n.º 3
0
        public void LoadEntry()
        {
            IsLoading = true;

            App.Azure.GetTable <Entry>().LookupAsync(EntryId).ContinueWith(t =>
            {
                var ex = t.Exception;

                if (t.Status == TaskStatus.RanToCompletion)
                {
                    _entry = t.Result;
                    RaisePropertyChanged(() => Entry);

                    if (!string.IsNullOrEmpty(_entry.ImageGuid))
                    {
                        App.Azure.GetTable <EntryImage>()
                        .Where(ei => ei.ImageGuid == _entry.ImageGuid)
                        .ToListAsync()
                        .ContinueWith(t2 =>
                        {
                            var ex2 = t2.Exception;

                            if (t2.Status == TaskStatus.RanToCompletion && t2.Result.Count > 0)
                            {
                                _entryImage = t2.Result[0];
                                RaisePropertyChanged(() => EntryImage);
                                RaisePropertyChanged(() => HasImage);
                            }

                            IsLoading = false;
                        });
                    }
                    else
                    {
                        IsLoading = false;
                    }
                }
                else
                {
                    IsLoading = false;
                    ReportError("Could not load Item!");
                }
            });
        }
Exemplo n.º 4
0
        public void LoadEntry()
        {
            if (string.IsNullOrEmpty(EntryId))
            {
                return;
            }

            IsLoading = true;

            App.Azure.GetTable <Entry>().LookupAsync(EntryId).ContinueWith(t =>
            {
                var ex = t.Exception;

                if (t.Status == TaskStatus.RanToCompletion)
                {
                    _entry = t.Result;
                    RaisePropertyChanged("Entry");

                    App.Azure.GetTable <EntryImage>().Where(ei => ei.ImageGuid == _entry.ImageGuid).ToListAsync().ContinueWith(t2 =>
                    {
                        var ex2 = t2.Exception;

                        if (t2.Status == TaskStatus.RanToCompletion && t2.Result.Count > 0)
                        {
                            _entryImage = t2.Result[0];
                            RaisePropertyChanged("EntryImage");
                            RaisePropertyChanged("HasImage");
                        }
                    });
                }

                IsLoading = false;
            });

            if (_entry == null)
            {
                _entry = new Entry();
            }

            if (_entryImage == null)
            {
                _entryImage = new EntryImage();
            }
        }