Esempio n. 1
0
        public Page2()
        {
            //Параметры страницы
            Title           = "Заказать";
            IconImageSource = "Accept.png";
            using (var reader = new StringReader("^contentpage { background-color: RGB(30,30,30); }"))
            {
                this.Resources.Add(StyleSheet.FromReader(reader));
            }

            for (int i = 0; i < Save.list.Count; i++)
            {
                sum += Save.list[i].Price;
            }

            cost.Text       = "Итого:" + sum.ToString();
            phone.Keyboard  = Keyboard.Telephone;
            gift.Toggled   += MethodToggle;
            accept.Clicked += ButtonAccept;

            StackLayout stackLayout = new StackLayout()
            {
                Children = { ename, name, eadress, adress, ephone, phone, egift, gift, cost, accept }
            };

            this.Content = stackLayout;
        }
 public StartPage()
 {
     InitializeComponent();
     using (var reader = new StringReader("navigationpage { background-color: red; }"))
     {
         this.Resources.Add(StyleSheet.FromReader(reader));
     }
     LoadingImage.IsVisible = false;
 }
Esempio n. 3
0
 public MainPage()
 {
     InitializeComponent();
     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DemoApp.Resources.popup.css"))
         using (var reader = new StreamReader(stream))
         {
             popupStyles = StyleSheet.FromReader(reader);
         }
 }
Esempio n. 4
0
        public Page3()
        {
            Title           = "Корзина";
            IconImageSource = "Basket.png";
            //BackgroundColor = Color.FromHex("1E1E1E");

            using (var reader = new StringReader("^contentpage { background-color: RGB(30,30,30); }"))
            {
                this.Resources.Add(StyleSheet.FromReader(reader));
            }



            tempBasket = new List <Test>()
            {
            };
            tempBasket = Save.list;



            listView = new ListView
            {
                HasUnevenRows = true,
                ItemsSource   = Save.list,

                ItemTemplate = new DataTemplate(() =>// Определяем формат отображения данных
                {
                    ImageCell imageCell = new ImageCell {
                        TextColor = Color.Red, DetailColor = Color.Green
                    };
                    imageCell.SetBinding(ImageCell.TextProperty, "Name");
                    Binding companyBinding = new Binding {
                        Path = "Price", StringFormat = "Цена: {0}"
                    };
                    imageCell.SetBinding(ImageCell.DetailProperty, companyBinding);
                    imageCell.SetBinding(ImageCell.ImageSourceProperty, "ImagePath");
                    return(imageCell);
                })
            };


            listView.ItemTapped += OnListViewItemTapped;

            StackLayout stackLayout = new StackLayout()
            {
                Children = { listView }
            };

            this.Content = stackLayout;
        }
        public DiceRollerPage()
        {
            InitializeComponent();

            string style = @"
            .direction {
                color: black;
                font-size: 48;
            }

            .result {
                color: red;
                font-size: 90;
            }";

            using (var reader = new StringReader(style))
            {
                Resources.Add(StyleSheet.FromReader(reader));
            }
        }
Esempio n. 6
0
        object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
        {
            IXmlLineInfo lineInfo;

            if (!string.IsNullOrEmpty(Style) && Source != null)
            {
                lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
                throw new XamlParseException($"StyleSheet can not have both a Source and a content", lineInfo);
            }

            if (Source != null)
            {
                lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
                if (Source.IsAbsoluteUri)
                {
                    throw new XamlParseException($"Source only accepts Relative URIs", lineInfo);
                }

                var rootObjectType = (serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider)?.RootObject.GetType();
                if (rootObjectType == null)
                {
                    return(null);
                }
                var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
                var resourcePath   = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(Source, rootTargetPath);
                var resString      = DependencyService.Get <IResourcesLoader>()?.GetResource(resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
                return(StyleSheet.FromString(resString));
            }

            if (!string.IsNullOrEmpty(Style))
            {
                using (var reader = new StringReader(Style))
                    return(StyleSheet.FromReader(reader));
            }

            lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
            throw new XamlParseException($"StyleSheet require either a Source or a content", lineInfo);
        }
Esempio n. 7
0
        public Page1()
        {
            //Параметры страницы
            Title           = "Товар";
            IconImageSource = "List.png";
            using (var reader = new StringReader("^contentpage { background-color: RGB(30,30,30); }"))
            {
                this.Resources.Add(StyleSheet.FromReader(reader));
            }

            //Инициализация
            listView         = new ListView();
            basket           = new List <Test> {
            };
            temp             = new List <Test> {
            };
            cance            = new List <Test> {
            };
            marmelad         = new List <Test> {
            };
            basketCount.Text = "В корзине: " + Save.list.Count.ToString();;
            picker.Items.Add("Леденцы");
            picker.Items.Add("Мармелад");
            picker.Items.Add("Все");


            //ListView подключение к базе данных
            string           documentPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "MyCans.db3");
            SQLiteConnection db           = new SQLiteConnection(documentPath);
            var contact = db.Table <Test>().ToList();

            List <Test> myList = new List <Test>();

            foreach (Test el in contact)
            {
                myList.Add(el);
            }

            listView.HasUnevenRows = true;
            listView.ItemsSource   = myList;
            listView.ItemTemplate  = new DataTemplate(() =>
            {
                ImageCell imageCell = new ImageCell {
                    TextColor = Color.White, DetailColor = Color.Green
                };
                imageCell.SetBinding(ImageCell.TextProperty, "Name");
                Label authorLabel = new Label();
                authorLabel.SetBinding(Label.TextProperty, "Type");

                Binding companyBinding = new Binding {
                    Path = "Price", StringFormat = "Цена: {0} руб"
                };
                imageCell.SetBinding(ImageCell.DetailProperty, companyBinding);
                imageCell.SetBinding(ImageCell.ImageSourceProperty, "ImagePath");
                return(imageCell);
            });

            //+=
            listView.ItemTapped         += OnListViewItemTapped;
            picker.SelectedIndexChanged += MethodName;
            picker.SelectedIndexChanged += picker_SelectedIndexChanged;
            listView.SeparatorColor      = Color.Black;

            Search searchView = new Search();

            searchView.Test += (text) =>
            {
                if (!string.IsNullOrEmpty(text))
                {
                    listView.ItemsSource = myList.Where(u => u.Name.Contains(text));
                }
                else
                {
                    listView.ItemsSource = myList;
                }
            };

            //Подключение элементов интерфейса
            StackLayout stackLayout = new StackLayout()
            {
                Children = { picker, searchView, listView, basketCount }
            };

            this.Content = stackLayout;



            //Методы


            async void OnListViewItemTapped(object sender, ItemTappedEventArgs e)
            {
                Test tappedItem = e.Item as Test;

                bool result = await DisplayAlert("Подтвердить действие", "Вы точно хотите добавить в корзину: " + tappedItem.Name.ToString(), "Да", "Нет");


                if (result == true)
                {
                    Save.list.Add(tappedItem);
                    await DisplayAlert("Уведомление", "Вы добавили в корзину: " + tappedItem.Name.ToString(), "OK");

                    basketCount.Text = "В корзине: " + Save.list.Count.ToString();
                }
                else
                {
                    await DisplayAlert("Уведомление", "Вы отменили добавление в корзину: " + tappedItem.Name.ToString(), "OK");

                    basketCount.Text = "В корзине: " + Save.list.Count.ToString();
                }
            }

            void MethodName(object sender, EventArgs args)
            {
                marmelad.Clear();
                cance.Clear();


                for (int i = 0; i < myList.Count; i++)
                {
                    if (myList[i].Type == "Мармелад")
                    {
                        marmelad.Add(myList[i]);
                    }
                    else if (myList[i].Type == "Леденец")
                    {
                        cance.Add(myList[i]);
                    }
                }
            }

            void picker_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (picker.SelectedIndex == 0)
                {
                    listView.ItemsSource = cance;
                    searchView           = new Search();

                    searchView.Test += (text) =>
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            listView.ItemsSource = cance.Where(u => u.Name.Contains(text));
                        }
                        else
                        {
                            listView.ItemsSource = cance;
                        }
                    };

                    stackLayout = new StackLayout()
                    {
                        Children = { picker, searchView, listView, basketCount }
                    };
                    this.Content = stackLayout;
                }
                else if (picker.SelectedIndex == 1)
                {
                    listView.ItemsSource = marmelad;
                    searchView           = new Search();

                    searchView.Test += (text) =>
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            listView.ItemsSource = marmelad.Where(u => u.Name.Contains(text));
                        }
                        else
                        {
                            listView.ItemsSource = marmelad;
                        }
                    };

                    stackLayout = new StackLayout()
                    {
                        Children = { picker, searchView, listView, basketCount }
                    };
                    this.Content = stackLayout;
                }
                else if (picker.SelectedIndex == 2)
                {
                    listView.ItemsSource = myList;
                    searchView           = new Search();

                    searchView.Test += (text) =>
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            listView.ItemsSource = myList.Where(u => u.Name.Contains(text));
                        }
                        else
                        {
                            listView.ItemsSource = myList;
                        }
                    };

                    stackLayout = new StackLayout()
                    {
                        Children = { picker, searchView, listView, basketCount }
                    };
                    this.Content = stackLayout;
                }
            }
        }