Пример #1
0
        async void  SfButton_Clicked(System.Object sender, System.EventArgs e)
        {
            // Get selected item
            Shop1 selectedShop = (Shop1)this.FindByName <Syncfusion.ListView.XForms.SfListView>("shopLV").SelectedItem;

            // Fetch user
            var fetchedUser = await Data.ReadAsync <User>(Preferences.Get("UserID", null), DefaultPartitions.UserDocuments);

            // Convert fetched user to string.
            var resultUser = JsonConvert.DeserializeObject <User>(fetchedUser.JsonValue.ToString());

            // Remove points.
            resultUser.Points -= selectedShop.Points;

            // Add item to users items.
            resultUser.Items.Add(selectedShop);

            //Send user back to database
            await Data.ReplaceAsync(Preferences.Get("UserID", null), resultUser, DefaultPartitions.UserDocuments);

            //Hide popup layout
            popUpLayout.StaysOpen = false;
            popUpLayout.PopupView.ShowCloseButton = false;
            popUpLayout.IsOpen = false;
        }
Пример #2
0
        void shopLV_ItemDoubleTapped(System.Object sender, Syncfusion.ListView.XForms.ItemDoubleTappedEventArgs e)
        {
            //On double tap - show Popup Modal
            Shop1 selectedShop = (Shop1)this.FindByName <Syncfusion.ListView.XForms.SfListView>("shopLV").SelectedItem;

            popUpLayout.BindingContext            = selectedShop;
            popUpLayout.StaysOpen                 = true;
            popUpLayout.PopupView.ShowCloseButton = true;
            popUpLayout.IsOpen = true;


            //this.FindByName<Image>("PImage").Source = selectedShop.Image.ToString();
            //this.FindByName<Label>("PTitle").Text = selectedShop.Name;
            //this.FindByName<Label>("PDesc").Text = selectedShop.Description;
        }
Пример #3
0
        async void SignInAndroid()
        {
            try
            {
                if (Preferences.Get("UserID", null) == null)
                {
                    User user = new User {
                        Points = 100
                    };
                    Act1 act = new Act1 {
                        Name = "Test Activity", Color = "Blue", Image = "Walk.png", Duration = "00:00:00", DateUtc = DateTime.UtcNow
                    };
                    Food1 food = new Food1 {
                        Name = "Broc", Calories = 100, Points = 10, FID = "1", Color = "Green", Image = "test.png"
                    };
                    Achievements ach = new Achievements {
                        Name = "Test", AID = 1, Description = "Test", Image = "Test.png", Points = 100
                    };
                    Shop1 item = new Shop1 {
                        Name = "Test", Description = "test", Color = "Red", Coupon = "2002", Image = "test.png", Points = 100, SId = 1
                    };


                    user.Items.Add(item);
                    user.Foods.Add(food);
                    user.Achs.Add(ach);
                    user.Acts.Add(act);


                    Preferences.Set("UserID", user.Id.ToString());



                    Console.WriteLine("~Android~ : Successfully added user to firebase!");
                }



                await this.Navigation.PushAsync(new MainPage());
            }
            catch (Exception e)
            {
                Console.WriteLine("Debug 1: Unable to sign in");
                // Do something with sign-in failure.
            }
        }
Пример #4
0
        static void Main(string[] args)
        {

            if (File.Exists("base.txt"))
            {
                try
                {
                    StreamReader stream = new StreamReader("base.txt");
                    List<IItem> catalog = new List<IItem>();
                    while (!stream.EndOfStream)
                    {
                        string[] bd = stream.ReadLine().Split('|');
                        catalog.Add(new Shop1.GuitarItem(bd[0], bd[1], Convert.ToInt32(bd[2]), (Shop1.getMemType)(Convert.ToInt32(bd[3])), bd[4], bd[5]));
                    }

                    catalog.Add(new Shop.Shop1.Keyboard("Defender", "Color", 2000, 106, 15, "Selicon"));
                    Shop1 shop = new Shop1(catalog);
                    Console.WriteLine("Список товаров:\n");
                    Console.WriteLine("\n\n");
                    Shop1.Warehouse wareHouse = new Shop1.Warehouse(catalog);
                    wareHouse.showCatalog();

                    Console.WriteLine("\nИспользование IEnumerable<IItem>\n");
                    foreach (IItem item in shop)
                    {
                        Console.WriteLine(item.ToString());

                    }

                    Console.WriteLine("\nИспользование IList<IItem>\n");
                    for (int i = 0; i < shop.Count; i++)
                    {
                        Console.WriteLine(shop[i].ToString());
                    }
                    Console.Write("\n\nМЕНЮ сортировщика (отсортировать по полю):\n1. Фирма \n2. Модель \n3. Цена \n4. Материал \n\nВведите (через пробел) поля для сортировки:");
                    string fix = string.Empty;
                    while (true)
                    {
                        fix = Console.ReadLine();
                        List<int> column = new List<int>();
                        foreach (char ch in fix)
                        {
                            try
                            {
                                string numbStr = ch.ToString();
                                int numb = Convert.ToInt32(numbStr);
                                if (numb < 7)
                                    column.Add(numb);
                            }
                            catch (Exception)
                            { }
                        }
                        foreach (int n in column)
                        {
                            switch (n)
                            {

                                case 1:
                                    {
                                        shop.Sort(shop.comparemanufacturer, false);


                                        break;
                                    }
                                case 2:
                                    {
                                        shop.Sort(shop.compareModel, false);
                                        break;
                                    }

                                case 3:
                                    {
                                        shop.Sort(shop.comparePrice, false);


                                        break;
                                    }
                                case 4:
                                    {
                                        shop.Sort(shop.compareMaterial, false);
                                        break;
                                    }

                                default: { Console.WriteLine("Неверный номер команды!\n\n"); break; }
                            }
                        }
                        Console.WriteLine("\n\nОтсортированные товары:\n");
                        shop.ShowItems();

                        Console.ReadKey();

                    }

                }
                catch (Exception) { Console.ReadKey(); }

            }

            else
            {
                Console.WriteLine("Файл базы не создан.");
                Console.ReadKey();
            }



        }