Exemple #1
0
        public iOSTimePickerPageCS()
        {
            Xamarin.Forms.TimePicker timePicker = new Xamarin.Forms.TimePicker
            {
                Time = new TimeSpan(14, 00, 00)
            };

            Button button = new Button
            {
                Text = "Toggle TimePicker UpdateMode"
            };

            button.Clicked += (sender, e) =>
            {
                switch (timePicker.On <iOS>().UpdateMode())
                {
                case UpdateMode.Immediately:
                    timePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished);
                    break;

                case UpdateMode.WhenFinished:
                    timePicker.On <iOS>().SetUpdateMode(UpdateMode.Immediately);
                    break;
                }
            };
            timePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished);

            Title   = "TimePicker UpdateMode";
            Content = new StackLayout
            {
                Margin   = new Thickness(10),
                Children =
                {
                    timePicker,
                    button
                }
            };
        }
        public dataPicker()
        {
            Grid gr = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            pick = new Xamarin.Forms.Picker
            {
                Title = "keeld"
            };
            pick.Items.Add("C#");
            pick.Items.Add("python");
            pick.Items.Add("C++");
            pick.Items.Add("VisualBasic");
            pick.Items.Add("Java");

            gr.Children.Add(pick, 0, 0);
            pick.SelectedIndexChanged += Pick_SelectedIndexChanged;

            editor = new Editor {
                Placeholder = "vali keel"
            };

            editor = new Editor {
                Placeholder = "vali keel nimekirjas"
            };
            gr.Children.Add(editor, 1, 0);

            dpicker = new DatePicker
            {
                Format      = "D",
                MinimumDate = DateTime.Now.AddDays(-10),
                MaximumDate = DateTime.Now.AddDays(10),
            };
            dpicker.DateSelected += Dpicker_DateSelected;

            gr.Children.Add(dpicker, 1, 1);

            entry = new Entry {
                Text = "vali kuupäev"
            };

            timepicker = new TimePicker()
            {
                Time = new TimeSpan(DateTime.Now.Hour + 2, DateTime.Now.Minute, DateTime.Now.Second)
            };
            Content = gr;

            frame = new Frame()
            {
                BorderColor     = Color.Purple,
                HasShadow       = true,
                BackgroundColor = Color.LightBlue,
                Content         = new Label {
                    Text = "хаю-хай"
                }
            };
        }
Exemple #3
0
        public TimePickerHandler(NativeComponentRenderer renderer, XF.TimePicker timePickerControl) : base(renderer, timePickerControl)
        {
            TimePickerControl = timePickerControl ?? throw new ArgumentNullException(nameof(timePickerControl));

            Initialize(renderer);
        }
Exemple #4
0
        public Person(List <PriceInfo> prices)
        {
            try
            {
                _prices    = prices;
                this.Title = "Новый клиент";
                _submitBtn = new Image {
                    Source = "checked.png", BackgroundColor = Color.Transparent
                };
                _submitBtn.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    TappedCallback = async(v, o) =>
                    {
                        if (!isValidInfo())
                        {
                            await DisplayAlert("Недостаточно информации", "Проверьте, все ли данные заполнены.", "OK");
                            return;
                        }


                        var currentPrice = _selectedPrice == null ? new PriceInfo {
                            Name = "Без прайса", Id = -1, Time = _time.Time, Price = Convert.ToDecimal(_price.Text), Vehicle = _prices[0].Vehicle
                        } : _selectedPrice;
                        var clientInfo = new ClientInfo {
                            Name = _clientName.Text.TrimEnd(), Phone = _phoneNumber.Text, DocumentType = _selectedDocumentType, Number = _documentNumber.Text, Serial = _documentSerial.Text
                        };
                        AddNewRentInfo(new RentModel(clientInfo, currentPrice));
                        await Navigation.PopToRootAsync();
                    }
                });
                ///имя клиента
                _clientName = new Entry
                {
                    HorizontalOptions       = LayoutOptions.FillAndExpand,
                    VerticalOptions         = LayoutOptions.Start,
                    TextColor               = Color.Black, Text = "",
                    Placeholder             = "Введите имя клиента",
                    FontSize                = 20,
                    HorizontalTextAlignment = TextAlignment.Center
                };
                _clientName.Unfocused += _clientName_Unfocused;
#if DEBUG
                _clientName.Text = "sdfdsfs";
#endif
                ///время
                _timeLbl = new Label {
                    Text = "Время: ", FontSize = 18, VerticalTextAlignment = TextAlignment.Center
                };
                _time = new Xamarin.Forms.TimePicker {
                    Format = @"HH:mm", Time = new TimeSpan(0, 0, 0), IsVisible = false
                };
                _times = new Picker {
                    Title = "Выберите время", VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center
                };
                foreach (var item in _prices)
                {
                    _times.Items.Add(item.Name);
                }
                _times.SelectedIndexChanged += _times_SelectedIndexChanged;
                _customImg = new Image {
                    Scale = 0.5, Opacity = 20, Source = "edit.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                _customProperty = new Switch {
                    IsToggled = false, HorizontalOptions = LayoutOptions.EndAndExpand
                };
                _customProperty.PropertyChanged += _customProperty_PropertyChanged;

                ///Телефон клиента
                _phoneNumber = new Entry {
                    WidthRequest = 230, IsEnabled = false, TextColor = Color.Black, Text = "", Placeholder = "Добавить  телефон", FontSize = 18, Keyboard = Keyboard.Telephone,
                };
                _phoneNumber.TextChanged += _phoneNumber_TextChanged;
                _phoneExist = new Switch {
                    IsToggled = false, HorizontalOptions = LayoutOptions.EndAndExpand
                };
                _phoneExist.PropertyChanged += _phoneExist_PropertyChanged;
                _phoneImg = new Image {
                    Scale = 0.5, Opacity = 0.2, Source = "smartphone.png", HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center
                };
                ///Документ
                _isDriverLicense = new Button {
                    Opacity = 0.2, HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 20, WidthRequest = 60, Text = "ВУ", BackgroundColor = Color.LightPink, TextColor = Color.DarkRed
                };
                _isDriverLicense.Clicked += _isDriverLicense_Clicked;
                _isPassport = new Button {
                    Opacity = 1, HorizontalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 45, Text = "РФ", BackgroundColor = Color.DarkRed, TextColor = Color.White
                };
                _isPassport.Clicked += _isPassport_Clicked;
                _isStud              = new Button {
                    Opacity = 0.2, HorizontalOptions = LayoutOptions.CenterAndExpand, HeightRequest = 30, WidthRequest = 65, Text = "СБ", BackgroundColor = Color.MediumBlue, TextColor = Color.White
                };
                _isStud.Clicked += _isStud_Clicked;
                DocButtons       = new Dictionary <string, Button>();
                DocButtons.Add("РФ", _isPassport);
                DocButtons.Add("ВУ", _isDriverLicense);
                DocButtons.Add("СБ", _isStud);
                _documentNumber = new Entry {
                    Placeholder = " Номер ", Keyboard = Keyboard.Numeric
                };
                _documentSerial = new Entry {
                    Placeholder = "Серия", Keyboard = Keyboard.Numeric
                };
                ///Цена
                _priceLbl = new Label {
                    Text = "Внесено: ", FontSize = 18, VerticalTextAlignment = TextAlignment.Center
                };
                _price = new Entry {
                    WidthRequest = 90, Placeholder = "Сумма", Keyboard = Keyboard.Numeric
                };

                var ClientLayer = new StackLayout
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Padding           = new Thickness(15, 15, 15, 0),
                    Children          = { _clientName }
                };

                DateInfoLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = new Thickness(10),
                    Children          = { _timeLbl, _times, _time, _customProperty, _customImg }
                };
                var PhoneInfoLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = new Thickness(10),
                    Children          = { _phoneNumber, _phoneExist, _phoneImg }
                };
                PriceInfoLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = new Thickness(10),
                    Children          = { _priceLbl, _price }
                };
                var DocumentLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Padding           = new Thickness(10),
                    Children          = { _isPassport, _isDriverLicense, _isStud }
                };
                var DocumentNumberLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Padding           = new Thickness(5),
                    Children          = { _documentSerial, _documentNumber }
                };

                var SmbLayer = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Padding           = new Thickness(10),
                    Children          = { _submitBtn }
                };

                Content = new StackLayout
                {
                    Children =
                    {
                        ClientLayer,
                        DateInfoLayer,
                        PhoneInfoLayer,
                        PriceInfoLayer,
                        DocumentLayer,
                        DocumentNumberLayer,
                        SmbLayer
                    }
                };
            }
            catch (Exception ex)
            {
                App.Database.SaveError(new Mob.Dto.Error {
                    Date = DateTime.Now, Invoker = this.GetType().Name, Message = ex.Message
                });
            }
        }