public ItemsViewModel()
        {
            Title            = "Browse";
            Restaurants      = new ObservableCollection <Restaurant>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Restaurant>(this, "AddItem", async(obj, restaurant) =>
            {
                var newRestaurant = restaurant as Restaurant;
                Restaurants.Add(newRestaurant);
                await DataStore.AddItemAsync(newRestaurant);
            });
        }
示例#2
0
        public RestaurantsViewModel()
        {
            Title            = "Browse";
            Items            = new ObservableRangeCollection <Restaurant>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewRestaurantPage, Restaurant>(this, "AddRestaurant", async(obj, item) =>
            {
                var _item = item as Restaurant;
                Items.Add(_item);
                await DataStore.AddItemAsync(_item);
            });
        }
示例#3
0
        public TablonViewModel()
        {
            Title            = "Tablón";
            Anuncios         = new ObservableCollection <Anuncio>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NuevoAnuncioView, Anuncio>(this, EnumEventos.AddAnuncio.ToString(), async(obj, item) =>
            {
                var newItem = item as Anuncio;
                Anuncios.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
        public SkillsGroupViewModel()
        {
            Title            = "Browse";
            SkillsGrp        = new ObservableCollection <SkillsGroup>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, SkillsGroup>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as SkillsGroup;
                SkillsGrp.Add(newItem);
                bool test = await DataStore.AddItemAsync(newItem);
            });
        }
示例#5
0
        public ItemsViewModel()
        {
            Title            = "Browse";
            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
示例#6
0
 public async void SaveItem()
 {
     Item.Category = SelectedCategory.Name;
     if (isEditMode)
     {
         await DataStore.UpdateItemAsync(Item);
     }
     else
     {
         await DataStore.AddItemAsync(Item);
     }
     MessagingCenter.Send(this, "AddItem", Item);
 }
        public ProveedoresViewModel()
        {
            Title                  = "Browse";
            Proveedores            = new ObservableCollection <Proveedor>();
            LoadProveedoresCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Proveedor>(this, "AddProveedor", async(obj, proveedor) =>
            {
                var newProveedor = proveedor as Proveedor;
                Proveedores.Add(newProveedor);
                await DataStore.AddItemAsync(newProveedor);
            });
        }
        public FavMoviesViewModel()
        {
            Title            = "Browse";
            FavMovies        = new ObservableCollection <FavMovie>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <TabbedPage1, FavMovie>(this, "AddItem", async(obj, item) =>
            {
                var newFavMovie = item as FavMovie;
                FavMovies.Add(newFavMovie);
                await DataStore.AddItemAsync(newFavMovie);
            });
        }
示例#9
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                Items.Clear();
                var client = new UdpClient()
                {
                    EnableBroadcast = true,
                    DontFragment    = true
                };
                var data = await DataStore.GetItemsAsync();

                foreach (var item in data)
                {
                    Items.Add(item);
                }
                var buffer = new byte[] { (byte)'d' };
                _ = Task.Run(async() =>
                {
                    while (true)
                    {
                        var result = await client.ReceiveAsync();
                        var str    = Encoding.ASCII.GetString(result.Buffer);
                        var item   = new Item
                        {
                            Description = str,
                            Id          = str,
                            Text        = "Smart Lock"
                        };
                        var exists = await DataStore.GetItemAsync(item.Id);
                        if (exists is null)
                        {
                            await DataStore.AddItemAsync(item);
                            Items.Add(item);
                        }
                    }
                });

                await client.SendAsync(buffer, buffer.Length, "192.168.1.255", 1002);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public ItemsViewModel()
        {
            Title            = "Notatka";
            Items            = new ObservableCollection <Note>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            if (Application.Current.Properties.ContainsKey("Title"))
            {
                NameVisibility = !(bool)Application.Current.Properties["Title"];
            }

            MessagingCenter.Subscribe <NewItemPage, Note>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Note;
                Items.Add(_item);
                await DataStore.AddItemAsync(_item);
                await ExecuteLoadItemsCommand();
            });

            MessagingCenter.Subscribe <ItemDetailPage, Note>(this, "DeleteItem", async(obj, item) =>
            {
                var _item = item as Note;
                Items.Remove(_item);
                await DataStore.DeleteItemAsync(_item);
                await ExecuteLoadItemsCommand();
            });

            MessagingCenter.Subscribe <EditItemPage, Note>(this, "EditItem", async(obj, item) =>
            {
                var _item = item as Note;
                await DataStore.UpdateItemAsync(_item);
                await ExecuteLoadItemsCommand();
                await ExecuteLoadItemsCommand();
            });

            MessagingCenter.Subscribe <MockDataStore>(this, "Refresh", async(obj) =>
            {
                await ExecuteLoadItemsCommand();
            });

            MessagingCenter.Subscribe <App>(this, "Refresh", async(obj) =>
            {
                await ExecuteLoadItemsCommand();
            });

            MessagingCenter.Subscribe <SettingsViewModel>(this, "ChangedNameEvent", async(obj) =>
            {
                NameVisibility = !NameVisibility;
                await ExecuteLoadItemsCommand();
            });
        }
示例#11
0
        public ItemsViewModel()
        {
            Title            = "Points";
            Items            = new ObservableCollection <PointEntry>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            // Used to subscribe to the ItemDetailPage when the message AddItem message is sent the following code will be executed
            MessagingCenter.Subscribe <ItemDetailPage, PointEntry>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as PointEntry;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
示例#12
0
        /// <summary>
        /// The save event handler.
        /// </summary>
        private async void OnSave()
        {
            var newItem = new Item()
            {
                Id          = Guid.NewGuid().ToString(),
                Text        = this.Text,
                Description = this.Description,
            };

            await DataStore.AddItemAsync(newItem);

            // This will pop the current page off the navigation stack
            await Shell.Current.GoToAsync("..");
        }
        public ExpensesPage()
        {
            Title            = "Despesas";
            Items            = new ObservableRangeCollection <Expense>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            RefreshCommand   = new Command(Load);
            _service         = new ExpensesAzureRest();

            MessagingCenter.Subscribe <NewExpansePage, Expense>(this, "AddExpense", async(obj, item) =>
            {
                Items.Add(item);
                await DataStore.AddItemAsync(item);
            });
        }
示例#14
0
        public QuestionsListViewModel()
        {
            Questions            = new ObservableCollection <Question>();
            LoadQuestionsCommand = new Command(async(args) => {
                await ExecuteLoadQuestionsCommand();
            });

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                //Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
示例#15
0
        public ItemsViewModel()
        {
            Title       = "Consulta Agenda CSA " + DateTime.Today.Year.ToString();
            ListaAgenda = new List <AgendaRis>();

            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
        public ItemsViewModel()
        {
            Title = "Browse";

            Items            = new ObservableCollection <Delivery>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Delivery>(this, "AddDelivery", async(obj, delivery) =>
            {
                var newDelivery = delivery as Delivery;
                Items.Add(newDelivery);
                await DataStore.AddItemAsync(newDelivery);
            });
        }
示例#17
0
        public ItemsViewModel()
        {
            Title             = "Events";
            Items             = new ObservableRangeCollection <Event>();
            LoadItemsCommand  = new Command(async() => await ExecuteLoadItemsCommand());
            DeleteItemCommand = new Command <Event>(async(myEvent) => await ExecuteDeleteItemCommand(myEvent));

            MessagingCenter.Subscribe <NewItemPage, Event>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Event;
                await DataStore.AddItemAsync(_item);
                await ExecuteLoadItemsCommand();
            });
        }
示例#18
0
 public MeetPeopleViewModel()
 {
     Title               = "Browse";
     Items               = new ObservableCollection <PeopleMeet>();
     ScannItemsCommand   = new Command(async() => await ExecuteScanItemsCommand());
     LoadItemsCommand    = new Command(async() => await ExecuteLoadItemsCommand());
     StartMeetingCommand = new Command(async() => await ExecuteStartMeetingCommand());
     MessagingCenter.Subscribe <NewItemPage, PeopleMeet>(this, "AddItem", async(obj, item) =>
     {
         var newItem = item as PeopleMeet;
         Items.Add(newItem);
         await DataStore.AddItemAsync(newItem);
     });
 }
示例#19
0
 public ItemsViewModel(INavigation navigation)
 {
     Title            = "Browse";
     Items            = new ObservableCollection <Students>();
     LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
     _navigation      = navigation;
     SomeText         = "blablabla";
     MessagingCenter.Subscribe <NewItemPage, Students>(this, "AddItem", async(obj, item) =>
     {
         var newItem = item as Students;
         Items.Add(newItem);
         await DataStore.AddItemAsync(newItem);
     });
 }
示例#20
0
        public ItemsViewModel()
        {
            Title = "Список";
            Items = new ObservableCollection <Item>();

            LoadItemsCommand   = new Command(async() => await ExecuteLoadItemsCommandAsync());
            DeleteItemCommand  = new Command(async item => await ExecuteDeleteItemCommandAsync((Item)item));
            ImportItemsCommand = new Command(async items => await ExecuteImportItemsCommandAsync((Item[])items));

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                await DataStore.AddItemAsync(item);
                LoadItemsCommand.Execute(null);
            });
        }
示例#21
0
        public VersesMemorizedViewModel()
        {
            Title            = "Memorized";
            BookDatas        = new ObservableCollection <BookData>();
            MemoryBooks      = new ObservableCollection <MemoryBookGroup>();
            Items            = new ObservableCollection <Verse>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Verse>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Verse;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
示例#22
0
        public WorkoutViewModel()
        {
            Title            = "Workouts";
            Items            = new ObservableCollection <Item>();
            Exercises        = new ObservableCollection <Exercise>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Item;
                //_item.ID = await App.Database.GetItemsAsync().Count;
                Items.Add(_item);
                await DataStore.AddItemAsync(_item);
            });
        }
示例#23
0
        public ItemsViewModel()
        {
            Title            = "Http demo";
            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Item;
                Items.Add(_item);
                await DataStore.AddItemAsync(_item);
                // save to file
                //await DataStore.SaveFile(Items.ToString());
            });
        }
示例#24
0
        public IQPViewModel(Page ExtPP)
        {
            ParentPage = ExtPP;

            Title               = "IQP";
            IQPItems            = new ObservableCollection <IQPItem>();
            LoadIQPItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, IQPItem>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as IQPItem;
                IQPItems.Add(_item);
                await DataStore.AddItemAsync(_item);
            });
        }
示例#25
0
        public ItemsViewModel(string filter)
        {
            Store = new DataStore(filter);

            Title            = filter;
            Items            = new ObservableRangeCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Item;
                Items.Add(_item);
                await Store.AddItemAsync(_item);
            });
        }
示例#26
0
        public ItemsViewModel()
        {
            Title            = "Places";
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            Places           = new ObservableCollection <Place>();

            MessagingCenter.Subscribe <NewItemPage, Place>(this, "AddItem", async(obj, place) =>
            {
                var newPlace = place as Place;
                Places.Insert(0, newPlace);
                await DataStore.AddItemAsync(newPlace);

                MessagingCenter.Send(this, "ScrollUp");
            });
        }
示例#27
0
        public ItemsViewModel(INavigation navigation)
        {
            _navigation = navigation;

            Title            = "Browse";
            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            AddItemCommand   = new Command(async() =>
            {
                await _navigation.PushModalAsync(new NavigationPage(new NewItemPage()));
            });
            ShowCtlsCommand = new Command <Item>(async(item) =>
            {
                if (IsCtlsVisible == "true")
                {
                    IsCtlsVisible = "false";
                }
                else
                {
                    IsCtlsVisible = "true";
                }
                SelectedItem = item;
            });
            ItemTappedCommand = new Command <Item>(async(item) =>
            {
                //var layout = (BindableObject)sender;
                //var item = Items[1]; //(Item)layout.BindingContext;
                SelectedItem = item;
                await _navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));
            });
            SwipeLeftCommand = new Command <object>(async(item) =>
            {
                //var layout = (BindableObject)sender;
                //var item = Items[1]; //(Item)layout.BindingContext;
                //SelectedItem = item;
                //await _navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));
            });

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
#if DEBUG
            _debug = true;
#endif
        }
示例#28
0
 public ItemsViewModel()
 {
     Title            = "Browse";
     Items            = new TrulyObservableCollection <Item>();
     FlowItems        = new DLToolkit.Forms.Controls.FlowObservableCollection <Item>();
     ItemsOnPage      = new TrulyObservableCollection <Item>();
     LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
     AddItemsCommand  = new Command(async(obj) => await ExecuteAddItemsCommand(obj as string));
     //TapItemsCommand = new Command(async (obj) => await ExecuteTapItemsCommand(obj));
     MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
     {
         var _item = item as Item;
         Items.Add(_item);
         await DataStore.AddItemAsync(_item);
     });
 }
示例#29
0
        public ItemsViewModel(URLHttpParams httpParams = null)
        {
            Title            = "Mani kursi";
            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async(args) => {
                httpParams = (URLHttpParams)args ?? httpParams;
                await ExecuteLoadItemsCommand(httpParams);
            });

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var newItem = item as Item;
                Items.Add(newItem);
                await DataStore.AddItemAsync(newItem);
            });
        }
示例#30
0
        public ItemsViewModel()
        {
            Title            = "Controles On-Line App";
            Items            = new ObservableRangeCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());

            MessagingCenter.Subscribe <NewItemPage, Item>(this, "AddItem", async(obj, item) =>
            {
                var _item = item as Item;
                Items.Add(_item);
                await DataStore.AddItemAsync(_item);
            });


            //AtualizaDados();
        }