예제 #1
0
        /// <summary>
        /// The on done clicked.
        /// </summary>
        public void OnDoneClicked()
        {
            var selectedColor         = Color;
            var recentColorItems      = RecentColorItems;
            var recentColorsGridItems = _recentColorsGrid.Items;

            var mostRecentColorItem = recentColorItems.FirstOrDefault(i => i.Color == selectedColor);

            if (mostRecentColorItem != null)
            {
                recentColorsGridItems.Remove(mostRecentColorItem);
                recentColorItems.Remove(mostRecentColorItem);
            }
            else
            {
                mostRecentColorItem = new PredefinedColorItem(selectedColor, selectedColor.ToString());
            }

            recentColorItems.Insert(0, mostRecentColorItem);
            recentColorsGridItems.Insert(0, mostRecentColorItem);

            DoneClicked?.Invoke(this, new RoutedEventArgs());
        }
        public DatePickerView()
        {
            _datePicker = new BlankDatePicker
            {
                BackgroundColor = Color.Transparent
            };
            Input = _datePicker;
            _datePicker.SetBinding(Entry.TextProperty,
                                   new Binding(nameof(EntryText))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _datePicker.SetBinding(Entry.FontAttributesProperty,
                                   new Binding(nameof(EntryFontAttributes))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.FontFamilyProperty,
                                   new Binding(nameof(EntryFontFamily))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.FontSizeProperty,
                                   new Binding(nameof(EntryFontSize))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.PlaceholderProperty,
                                   new Binding(nameof(EntryPlaceholder))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.PlaceholderColorProperty,
                                   new Binding(nameof(EntryPlaceholderColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.HorizontalTextAlignmentProperty,
                                   new Binding(nameof(EntryHorizontalTextAlignment))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(Entry.TextColorProperty,
                                   new Binding(nameof(EntryTextColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(HeightRequestProperty,
                                   new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(MarginProperty,
                                   new Binding(nameof(EntryMargin))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            //_datePicker.SetBinding(BlankDatePicker.FormatProperty,
            //    new Binding(nameof(Format)) { Source = this, Mode = BindingMode.OneWay });
            //_datePicker.SetBinding(BlankDatePicker.MinimumDateProperty,
            //    new Binding(nameof(MinimumDate)) { Source = this, Mode = BindingMode.OneWay });
            //_datePicker.SetBinding(BlankDatePicker.MaximumDateProperty,
            //    new Binding(nameof(MaximumDate)) { Source = this, Mode = BindingMode.OneWay });
            //_datePicker.SetBinding(BlankDatePicker.DateProperty,
            //    new Binding(nameof(Date)) { Source = this, Mode = BindingMode.TwoWay });

            _datePicker.SetBinding(IsEnabledProperty,
                                   new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter()
            });
            _datePicker.SetBinding(InputTransparentProperty,
                                   new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(HeightRequestProperty,
                                   new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _datePicker.SetBinding(BlankDatePicker.DoneButtonTextProperty,
                                   new Binding(nameof(DoneButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.CancelButtonTextProperty,
                                   new Binding(nameof(CancelButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.UpdateModeProperty,
                                   new Binding(nameof(UpdateMode))
            {
                Source = this, Mode = BindingMode.OneWay
            });


            _datePicker.Focused      += FocusEntry;
            _datePicker.Unfocused    += UnfocusEntry;
            _datePicker.DateSelected += Date_Selected;
            _datePicker.TextChanged  += SendEntryTextChanged;

            _datePicker.DoneClicked   += (sender, e) => DoneClicked?.Invoke(this, e);
            _datePicker.CancelClicked += (sender, e) => CancelClicked?.Invoke(this, e);

            FloatingLabelWithoutAnimation();

            Children.Add(_datePicker, 2, 3, 1, 2);
        }
예제 #3
0
        public DatePickerView()
        {
            _datePicker = new BlankDatePicker
            {
                BackgroundColor   = Color.Transparent,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            _datePicker.SetBinding(DatePicker.FontAttributesProperty,
                                   new Binding(nameof(EntryFontAttributes))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.FontFamilyProperty,
                                   new Binding(nameof(EntryFontFamily))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.FontSizeProperty,
                                   new Binding(nameof(EntryFontSize))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.PlaceholderProperty,
                                   new Binding(nameof(EntryPlaceholder))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.PlaceholderColorProperty,
                                   new Binding(nameof(EntryPlaceholderColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.HorizontalTextAlignmentProperty,
                                   new Binding(nameof(EntryHorizontalTextAlignment))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.TextColorProperty,
                                   new Binding(nameof(EntryTextColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(HeightRequestProperty,
                                   new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _datePicker.SetBinding(DatePicker.FormatProperty,
                                   new Binding(nameof(Format))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.MinimumDateProperty,
                                   new Binding(nameof(MinimumDate))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.MaximumDateProperty,
                                   new Binding(nameof(MaximumDate))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(DatePicker.DateProperty,
                                   new Binding(nameof(Date))
            {
                Source = this, Mode = BindingMode.TwoWay
            });

            _datePicker.SetBinding(BlankDatePicker.DoneButtonTextProperty,
                                   new Binding(nameof(DoneButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _datePicker.SetBinding(BlankDatePicker.CancelButtonTextProperty,
                                   new Binding(nameof(CancelButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _pFrame = new Frame
            {
                Padding         = 0,
                HasShadow       = false,
                BackgroundColor = Color.Transparent,
                Content         = _datePicker
            };
            _pFrame.SetBinding(IsEnabledProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter()
            });
            _pFrame.SetBinding(InputTransparentProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _pFrame.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            TextAlignmentCommand = new Command(() => TextAlignmentChanged());

            _datePicker.Focused      += FocusEntry;
            _datePicker.Unfocused    += UnfocusEntry;
            _datePicker.DateSelected += Date_Selected;

            _datePicker.DoneClicked   += (sender, e) => DoneClicked?.Invoke(this, e);
            _datePicker.CancelClicked += (sender, e) => CancelClicked?.Invoke(this, e);

            Children.Add(_pFrame, 2, 3, 1, 2);
        }
예제 #4
0
        public PickerView()
        {
            _picker = new BlankPicker
            {
                BackgroundColor = Color.Transparent,
            };
            _picker.SetBinding(Picker.FontAttributesProperty,
                               new Binding(nameof(EntryFontAttributes))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.FontFamilyProperty,
                               new Binding(nameof(EntryFontFamily))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.FontSizeProperty,
                               new Binding(nameof(EntryFontSize))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.PlaceholderProperty,
                               new Binding(nameof(EntryPlaceholder))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.PlaceholderColorProperty,
                               new Binding(nameof(EntryPlaceholderColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.HorizontalTextAlignmentProperty,
                               new Binding(nameof(EntryHorizontalTextAlignment))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.TextColorProperty,
                               new Binding(nameof(EntryTextColor))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _picker.SetBinding(Picker.ItemsSourceProperty,
                               new Binding(nameof(ItemsSource))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(Picker.SelectedIndexProperty,
                               new Binding(nameof(SelectedIndex))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _picker.SetBinding(Picker.SelectedItemProperty,
                               new Binding(nameof(SelectedItem))
            {
                Source = this, Mode = BindingMode.TwoWay
            });
            _picker.SetBinding(Picker.TitleProperty,
                               new Binding(nameof(Title))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            //Todo For Xamarin.Forms 4.0
            //_picker.SetBinding(Picker.TitleColorProperty,
            //new Binding(nameof(TitleColor)) { Source = this, Mode = BindingMode.OneWay });

            _picker.SetBinding(BlankPicker.DoneButtonTextProperty,
                               new Binding(nameof(DoneButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _picker.SetBinding(BlankPicker.CancelButtonTextProperty,
                               new Binding(nameof(CancelButtonText))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            _pFrame = new Frame
            {
                Padding         = 0,
                HasShadow       = false,
                BackgroundColor = Color.Transparent,
                Content         = _picker
            };
            _pFrame.SetBinding(IsEnabledProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay, Converter = new InverseBooleanConverter()
            });
            _pFrame.SetBinding(InputTransparentProperty,
                               new Binding(nameof(IsReadOnly))
            {
                Source = this, Mode = BindingMode.OneWay
            });
            _pFrame.SetBinding(HeightRequestProperty,
                               new Binding(nameof(EntryHeightRequest))
            {
                Source = this, Mode = BindingMode.OneWay
            });

            TextAlignmentCommand = new Command(() => TextAlignmentChanged());

            _picker.Focused              += FocusEntry;
            _picker.Unfocused            += UnfocusEntry;
            _picker.SelectedIndexChanged += IndexChanged;

            _picker.DoneClicked   += (sender, e) => DoneClicked?.Invoke(this, e);
            _picker.CancelClicked += (sender, e) => CancelClicked?.Invoke(this, e);

            Children.Add(_pFrame, 2, 3, 1, 2);
        }