コード例 #1
0
        public App()
        {
            InitializeComponent();

            DependencyService.Register <MockDataStore>();
            DependencyService.Get <INotificationService>().Initialize();
            //MainPage = new DebugBackgroundCounter();

            notificationService = DependencyService.Get <INotificationService>();
            notificationService.NotificationReceived += (sender, eventArgs) =>
            {
                var evtData = (NotificationEventArgs)eventArgs;
                Global.notifTitle       = evtData.Title;
                Global.notifDescription = evtData.Message;
            };

            if (Global.notifTitle != null)
            {
                string tmp  = Global.notifDescription;
                int    tmp1 = Global.notifCurrentIndex;
                string tmp2 = Global.notifFullDescrip;
                string tmp3 = Global.notifCurrentTitle;

                MainPage = new ItemDetailPage();
            }
            else
            {
                MainPage = new MainPage();
            }
        }
コード例 #2
0
        public void DisplayAlert(Alert item)
        {
            Task.Run(async() =>
            {
                var locator = CrossGeolocator.Current;

                var position    = await locator.GetLastKnownLocationAsync();
                double distance = 1;
                if (position != null)
                {
                    distance = new Coordinates(position.Latitude, position.Longitude)
                               .DistanceTo(
                        new Coordinates(item.Lat, item.Lon),
                        UnitOfLength.Kilometers
                        );
                }

                if (distance <= item.Distance)
                {
                    var dataStore = new MockDataStore();
                    await dataStore.AddItemAsync(item);
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        var view = new ItemDetailPage(new ItemDetailViewModel(item));
                        await MainPage.Navigation.PushModalAsync(view);
                    });
                }
            });
        }
コード例 #3
0
        public App()
        {
            InitializeComponent();


            MainPage = new ItemDetailPage(); // MainPage();
        }
コード例 #4
0
        public void Setup()
        {
            // Initilize Xamarin Forms
            MockForms.Init();

            //This is your App.xaml and App.xaml.cs, which can have resources, etc.
            app = new App();
            Application.Current = app;

            page = new ItemDetailPage(new GenericViewModel <ItemModel>(new ItemModel()));
        }
コード例 #5
0
        public async void SetView(string title, ViewType type, object context, IEnumerable<object> items, object selectedItem)
        {
            switch (type)
            {
                case ViewType.Home:
                    {
                        this.Breadcrumb = title;

                        var page = new GroupedItemsPage(this);
                        page.DataContext = this.DataSource;

                        Window.Current.Content = page;
                        Window.Current.Activate();

                        await this.DataSource.LoadAsync(page.Dispatcher);
                        _UpdateTile();
                        page.Items = this.DataSource.ImageSets;
                        
                        break;
                    }
                case ViewType.Collection:
                    {
                        this.Breadcrumb = string.Format("{0} -> {1}", "MetroFlickr", title);

                        var page = new GroupedItemsPage(this);
                        page.DataContext = context;
                        page.Items = items;

                        Window.Current.Content = page;
                        Window.Current.Activate();

                        break;
                    }
                case ViewType.Detail:
                    {
                        this.Breadcrumb = string.Format("{0} -> {1}", "MetroFlickr", title);

                        var page = new ItemDetailPage(this);
                        page.DataContext = context;
                        page.Items = items;
                        page.Item = selectedItem;

                        Window.Current.Content = page;
                        Window.Current.Activate();

                        break;
                    }
                
            }

            this.CurrentViewType = type;

        }
コード例 #6
0
        private async void OnItemSelected(CatFact fact)
        {
            if (fact == null)
            {
                return;
            }

            //Navigate
            var secondPage = new ItemDetailPage(fact);
            await Application.Current.MainPage.Navigation.PushAsync(secondPage);

            //Shell
            //await Shell.Current.GoToAsync($"catdetail?text={fact.Text}");
        }
コード例 #7
0
        public void Next()
        {
            var items        = (ObservableCollection <Models.Item>)Application.Current.Properties["Items"];
            int currentIndex = items.IndexOf(Item);
            int maxIndex     = items.Count;
            var item         = items[0];

            if (currentIndex + 1 < maxIndex)
            {
                item = items[currentIndex + 1] as Item;
            }

            var page = new ItemDetailPage(new ItemDetailViewModel(item));
            var app  = Application.Current as App;

            app.SetMainPage(page);
        }
コード例 #8
0
        public void DeleteWhenThereIsOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 10, Defense = 6
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);

            testItem.ItemNum = 1;

            testItemDetailPage = new ItemDetailPage(testItem, dataAccess);

            testItemDetailPage.TestDeleteItem_Clicked();

            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(0, temp.Count);
        }
コード例 #9
0
        public void DeleteWhenThereAreMoreThanOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 3, Health = 4, Speed = 10, Defense = 6
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Health = 3, Speed = 4, Defense = 5
            });

            testItemDetailPage = new ItemDetailPage(testItem, dataAccess);

            testItem.ItemNum = 1;

            testItemDetailPage.TestDeleteItem_Clicked();

            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(3, temp[0].Health);
        }
コード例 #10
0
        async void ItemsListView_ItemTapped(ListView sender, Xamarin.Forms.ItemTappedEventArgs e)
        {
            ItemDetailEditViewModel model = (ItemDetailEditViewModel)sender.SelectedItem;

            var    REMOVE_OPT            = "Remove";
            var    SHOW_DETAILS_OPT      = "View Details";
            string SWAP_WITH_PARENT_OPT  = null;
            string MAKE_PRIMARY_LOCATION = null;

            if (model.Item.Domain.Name.Equals(Constants.locationDomainName))
            {
                MAKE_PRIMARY_LOCATION = "Replace with Selected Location";
            }

            if (model.ItemLocationInformation != null)
            {
                if (model.ItemLocationInformation.LocationItem != null)
                {
                    SWAP_WITH_PARENT_OPT = "Use Parent";
                }
            }

            var prompt = "Options for " + model.MultiItemUpdateListingDisplayText;

            var action = await DisplayActionSheet(prompt, "Cancel", REMOVE_OPT, SHOW_DETAILS_OPT, MAKE_PRIMARY_LOCATION, SWAP_WITH_PARENT_OPT);

            if (action == REMOVE_OPT || action == MAKE_PRIMARY_LOCATION)
            {
                viewModel.removeFromUpdatableItemList(model);

                if (action == MAKE_PRIMARY_LOCATION)
                {
                    var selectedLocation = viewModel.SelectedLocation;
                    if (selectedLocation != null)
                    {
                        var selectedLocationModel = new ItemDetailEditViewModel(selectedLocation);
                        viewModel.addToUpdatableItemList(selectedLocationModel);
                    }

                    viewModel.SelectedLocation = model.Item;
                }
            }
            else if (action == SHOW_DETAILS_OPT)
            {
                var item        = model.Item;
                var viewModel   = new ItemDetailViewModel(item);
                var detailsPage = ItemDetailPage.CreateItemDetailPage(viewModel);

                await Navigation.PushAsync(detailsPage);
            }
            else if (action == SWAP_WITH_PARENT_OPT)
            {
                var locInfo = model.ItemLocationInformation;
                var parent  = locInfo.LocationItem;

                var domainName = parent.Domain.Name;

                var proceed = true;

                if (viewModel.StatusMode)
                {
                    if (!domainName.Equals(Constants.inventoryDomainName))
                    {
                        await DisplayAlert("Cannot Swap", "Only inventory items have status.", "OK");

                        proceed = false;
                    }
                }

                if (proceed)
                {
                    viewModel.removeFromUpdatableItemList(model);

                    var newModel = new ItemDetailEditViewModel(parent);
                    viewModel.addToUpdatableItemList(newModel);
                }
            }

            sender.SelectedItem = null;
        }
        public EditItemDetailPage(Item item, ItemDetailPage detailPage)
        {
            InitializeComponent();

            this.viewModel  = new ItemDetailEditViewModel(item);
            this.detailPage = detailPage;
            BindingContext  = this.viewModel;

            var domain = item.Domain;

            addEditBindingToEditItemsStackLayout(domain.ItemIdentifier1Label, "Item.ItemIdentifier1");

            if (domain.ItemIdentifier2Label != null && !domain.Name.Equals(Constants.machineDesignDomainName))
            {
                addEditBindingToEditItemsStackLayout(domain.ItemIdentifier2Label, "Item.ItemIdentifier2");
            }

            if (item.Domain.Name.Equals(Constants.inventoryDomainName))
            {
                viewModel.LoadItemStatus();
                viewModel.LoadItemLocationInformation();

                var propertyApi = CdbApiFactory.Instance.propertyTypeApi;
                var type        = propertyApi.GetInventoryStatusPropertyType();

                statusPicker = new Picker
                {
                    Title = "Item Status",
                };
                foreach (var allowedValue in type.SortedAllowedPropertyValueList)
                {
                    statusPicker.Items.Add(allowedValue.Value);
                }

                var statusString = viewModel.ItemStatusString;
                if (statusPicker.Items.Contains(statusString))
                {
                    statusPicker.SelectedItem = statusString;
                }

                addEditBindingToEditItemsStackLayout("QR Id", "QrIdEntry", null, Keyboard.Numeric);
                addEditBindingToEditItemsStackLayout("Status", null, statusPicker);

                // Add Location

                Label itemValueLabel = new Label {
                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
                };
                itemValueLabel.SetBinding(Label.TextProperty, "ItemLocationInformation.LocationString");
                var buttonChangeLocation = new Button {
                    Text = "Change Location"
                };
                var buttonClearLocation = new Button {
                    Text = "Clear Location"
                };
                buttonChangeLocation.Clicked += ChangeLocationEventHandler;
                buttonClearLocation.Clicked  += ClearLocationEventHandler;

                addEditBindingToEditItemsStackLayout("Location", null, itemValueLabel);
                EditItemsStackLayout.Children.Add(buttonChangeLocation);
                EditItemsStackLayout.Children.Add(buttonClearLocation);
                addEditBindingToEditItemsStackLayout("Location Details ", "ItemLocationInformation.LocationDetails");
            }
        }