예제 #1
0
 public void ToAddView(AddView addview)
 {
     OverwriteRootPage(addview);
     // currentPageContent = addview.GetLayout();
     navigationStack[currentPageContainer].Add(add_view_name);
     navigationParams[currentPageContainer].Add(new List <object>()
     {
         addview
     });
 }
예제 #2
0
        public BarcodeScannerPage(AddView addView) : base()
        {
            scannerView = new ZXingScannerView()
            {
                AutomationId = "zxingScannerView"
            };
            scannerView.OnScanResult += async r =>
            {
                scannerView.IsAnalyzing = false;
                scannerView.IsScanning  = false;

                HttpClient          httpClient = new HttpClient();
                Uri                 uri        = new Uri(string.Format("https://api.upcitemdb.com/prod/trial/lookup?upc={0}", r.Text));
                HttpResponseMessage response   = await httpClient.GetAsync(uri);

                Console.WriteLine("BarcodeScannerPage 31 got http response");

                if (response.IsSuccessStatusCode)
                {
                    JsonTextReader jsonTextReader = new JsonTextReader(new System.IO.StringReader(await response.Content.ReadAsStringAsync()));
                    JsonSerializer jsonSerializer = new JsonSerializer();
                    BarcodeItem    barcodeItem    = jsonSerializer.Deserialize <BarcodeItem>(jsonTextReader);

                    if (barcodeItem == null || barcodeItem.items.Length == 0)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            ContentManager.pageController.ReturnToPrevious();
                            ContentManager.pageController.ShowAlert("Scan Result", "Unfortunately, the barcode cannot be found in the databse.", "Help Expanding Barcode Database", "Exit", null, null);
                        });
                        return;
                    }
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        var itemName = barcodeItem.items[0].title;
                        ContentManager.pageController.ReturnToPrevious();
                        ContentManager.pageController.ShowAlert("Scan Result", "Item Name: " + barcodeItem.items[0].title, "Use", "Cancel", () => { addView.SetProductName(itemName); }, null);
                    });
                }
            };
            scannerOverlay = new ZXingDefaultOverlay()
            {
                TopText         = "Zesty scanner top text",
                BottomText      = "Zesty scanner bottom text",
                ShowFlashButton = scannerView.HasTorch,
                AutomationId    = "zxingDefaultOverlay"
            };
            var grid = new Grid();

            grid.Children.Add(scannerView);
            grid.Children.Add(scannerOverlay);

            Content = grid;
        }
예제 #3
0
        public void ToScanPage(AddView addview)
        {
            var scannerPage = new BarcodeScannerPage(addview);

            OverwriteRootPage(scannerPage);
            scannerPage.StartScanning();
            navigationStack[currentPageContainer].Add(scan_page_name);
            navigationParams[currentPageContainer].Add(new List <object>()
            {
            });
        }
예제 #4
0
        public UnplacedPage(Action <Item> localUnplacedEvent, Action <Item> baseUnplaceEvent, Action <Item> deleteItemLocal, Action <Item> deleteItemBase)
        {
            var titleGrid    = new TopPage("Items", useReturnButton: false).GetGrid();
            var addNewButton = new ImageButton()
            {
                Source = ContentManager.addIcon, BackgroundColor = Color.Transparent, Margin = new Thickness(side_margin, between_margin)
            };

            // Renewing contents in meta grid
            metaGrid = GridManager.GetGrid(ContentManager.metaGridName);
            GridManager.AddGridItem(metaGrid, ContentManager.MetaItemBase.Values, true);

            var addView = new AddView(localUnplacedEvent, baseUnplaceEvent, "", false);

            searchAllBar = new SearchBar()
            {
                Margin = new Thickness(side_margin, 0)
            };
            searchAllBar.Text       = ContentManager.defaultSearchAllBarText;
            searchAllBar.TextColor  = Color.Black;
            searchAllBar.Focused   += (obj, args) => searchAllBar.Text = "";
            searchAllBar.Unfocused += (obj, args) => { if (searchAllBar.Text.Length == 0)
                                                       {
                                                           searchAllBar.Text = ContentManager.defaultSearchAllBarText;
                                                       }
            };
            searchAllBar.Unfocused += (obj, args) => GridManager.FilterItemGrid(ContentManager.MetaItemBase.Values, metaGrid, searchAllBar.Text);
            addNewButton.Clicked   += (obj, args) => { addView.ResetForm(); ContentManager.pageController.ToAddView(addView); };

            var sortSelectorIcon = new Image()
            {
                Source = ContentManager.sortIcon
            };
            var sortSelector = new Picker()
            {
                Margin      = new Thickness(side_margin, between_margin),
                ItemsSource = new List <string>()
                {
                    expIndicatorString, alphaIndicatorString
                },
            };

            sortSelector.SelectedIndexChanged += (obj, args) =>
            {
                switch (sortSelector.SelectedItem)
                {
                case expIndicatorString: GridOrganizer.SortItemGrid(metaGrid, GridOrganizer.ItemSortingMode.Expiration_Close); break;

                case alphaIndicatorString: GridOrganizer.SortItemGrid(metaGrid, GridOrganizer.ItemSortingMode.A_Z); break;
                }
            };


            gridScroll = new ScrollView()
            {
                Margin = new Thickness(side_margin),
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
                HeightRequest = Height * 0.8,
                Content       = metaGrid
            };

            AbsoluteLayout.SetLayoutBounds(titleGrid, new Rectangle(0, 0, 1, TopPage.top_bar_height_proportional));
            AbsoluteLayout.SetLayoutFlags(titleGrid, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(searchAllBar, new Rectangle(0, 0.13, 0.8, .1));
            AbsoluteLayout.SetLayoutFlags(searchAllBar, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(addNewButton, new Rectangle(0, .25, 100, 100));
            AbsoluteLayout.SetLayoutFlags(addNewButton, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(sortSelector, new Rectangle(1, 0.13, .2, .1));
            AbsoluteLayout.SetLayoutFlags(sortSelector, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(sortSelectorIcon, AbsoluteLayout.GetLayoutBounds(sortSelector));
            AbsoluteLayout.SetLayoutFlags(sortSelectorIcon, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(gridScroll, new Rectangle(0, 1, 1, .625));
            AbsoluteLayout.SetLayoutFlags(gridScroll, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(addView, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(addView, AbsoluteLayoutFlags.All);
            content = new AbsoluteLayout()
            {
                Children =
                {
                    titleGrid,
                    searchAllBar,
                    addNewButton,
                    sortSelectorIcon,
                    sortSelector,
                    gridScroll
                }
            };

            Content = content;
        }
예제 #5
0
        // DirectGridFootIndex: when page loads, partial grids directly goes to the set of items with the first item being this index.
        public CabinetAddPage(string _storageName, int directGridFootIndex = 0)
        {
            storageName = _storageName;

            storageView = ContentManager.GetStorageView(storageName);
            storageView.WidthRequest    = ContentManager.screenWidth;
            storageView.HeightRequest   = ContentManager.screenHeight * .75;
            storageView.VerticalOptions = LayoutOptions.EndAndExpand;
            animateStorage();

            async void animateStorage()
            {
                await storageView.LinearInterpolator(animation_offestX, 200, (d) => { storageView.TranslationY = animation_offestX - d; });
            }

            //-- set up unplaced grid
            unplacedGrid               = GridManager.GetGrid(ContentManager.unplacedGridName);
            partialUnplacedGrid        = GridManager.InitializeGrid(ContentManager.pUnplacedGridName, 2, 4, GridLength.Star, GridLength.Star);
            partialUnplacedGrid.Margin = new Thickness(grid_margin, 0);
            // add listener to set TouchEffect for each new item added. If grid already exist
            partialUnplacedGrid.ChildAdded += (o, v) =>
            {
                EffectManager.UpdateScreenTouchBounds(v.Element as ItemLayout, storageName, UpdateShelf);
            };
            // Add listener to remove partial unplaced grid child
            unplacedGrid.ChildRemoved += (o, a) =>
            {
                foreach (ItemLayout child in partialUnplacedGrid.Children)
                {
                    if ((a.Element as ItemLayout).ItemData.ID == child.ItemData.ID)
                    {
                        partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
                        break;
                    }
                }
            };
            Console.WriteLine("CabinetAddPage 42 Unplaced children length " + unplacedGrid.Children.Count);
            // initialize grid by constraining UnplacedGrid and Converter
            itemLayoutCopier = (v) =>
            {
                return(new ItemLayout(50, 50, (v as ItemLayout).ItemData)
                       .AddMainImage()
                       .AddExpirationMark()
                       .AddTitle()
                       .AddInfoIcon());
            };
            partialUnplacedGrid = GridManager.ConstrainGrid(GridManager.GetGrid(ContentManager.unplacedGridName), directGridFootIndex, directGridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            addView             = new AddView(LocalStorageController.AddItem, FireBaseController.SaveItem, storageName, true, partialUnplacedGrid);

            // title grid
            var titleGrid = new TopPage(_storageName, () =>
            {
                foreach (ItemLayout child in partialUnplacedGrid.Children)
                {
                    child.iconImage.RemoveEffect(typeof(ScreenTouch));
                }
                foreach (StorageCell child in ContentManager.GetSelectedStorage(storageName).GetGridCells())
                {
                    child.GetButton().RemoveEffect(typeof(ImageTint));
                }
                GridManager.RemoveGrid(ContentManager.pUnplacedGridName);
            }).GetGrid();


            gridFootIndex = directGridFootIndex;
            var gridPageSelectGrid = new Grid()
            {
                Margin            = new Thickness(grid_margin, 0),
                ColumnDefinitions =
                {
                    new ColumnDefinition()
                    {
                        Width = 50
                    },
                    new ColumnDefinition()
                    {
                        Width = 30
                    },
                    new ColumnDefinition()
                    {
                        Width = 30
                    },
                    new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    }
                }
            };
            var nextPage = new ImageButton()
            {
                Source = ContentManager.countIcon
            };

            nextPage.Clicked += (obj, args) =>
            {
                Console.WriteLine("CabinetAddPage grid foot index " + gridFootIndex);
                gridFootIndex      += 7;
                partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            };
            var lastPage = new ImageButton()
            {
                Source = ContentManager.countIcon, Rotation = 180
            };

            lastPage.Clicked += (obj, args) =>
            {
                Console.WriteLine("CabinetAddPage grid foot index " + gridFootIndex);
                gridFootIndex       = gridFootIndex - 7 < 0 ? 0 : gridFootIndex - 7;
                partialUnplacedGrid = GridManager.ConstrainGrid(unplacedGrid, gridFootIndex, gridFootIndex + 7, partialUnplacedGrid, itemLayoutCopier, true);
            };
            var addNewButton = new ImageButton()
            {
                Source = ContentManager.addIcon, BackgroundColor = Color.Transparent
            };

            addNewButton.Clicked += (obj, args) => { addView.ResetForm(); ContentManager.pageController.ToAddView(addView); };
            var searchBar = new SearchBar()
            {
                Text = ContentManager.defaultSearchAllBarText, MinimumWidthRequest = 300
            };

            searchBar.Focused   += (obj, args) => searchBar.Text = "";
            searchBar.Unfocused += (obj, args) =>
            {
                if (searchBar.Text.Length == 0)
                {
                    searchBar.Text = ContentManager.defaultSearchAllBarText;
                }
                GridManager.FilterItemGrid(ContentManager.UnplacedItemBase.Values, partialUnplacedGrid, searchBar.Text);
            };

            gridPageSelectGrid.Children.Add(lastPage, 1, 0);
            gridPageSelectGrid.Children.Add(nextPage, 2, 0);
            gridPageSelectGrid.Children.Add(addNewButton, 0, 0);
            gridPageSelectGrid.Children.Add(searchBar, 3, 0);

            pageContainer = new AbsoluteLayout();
            pageContainer.BackgroundColor = ContentManager.ThemeColor;
            ContentManager.AddOnBackgroundChangeListener(c => pageContainer.BackgroundColor = c);
            pageContainer.Children.Add(titleGrid, new Rectangle(0, 0, 1, TopPage.top_bar_height_proportional), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(storageView, new Rectangle(1, 1, 1, .5), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(gridPageSelectGrid, new Rectangle(0, .12, 1, .09), AbsoluteLayoutFlags.All);
            pageContainer.Children.Add(partialUnplacedGrid, new Rectangle(0, .28, 1, .3), AbsoluteLayoutFlags.All);

            Content = new AbsoluteLayout()
            {
                Children =
                {
                    pageContainer
                }
            };
            AbsoluteLayout.SetLayoutBounds(pageContainer, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(pageContainer, AbsoluteLayoutFlags.All);
        }