Esempio n. 1
0
        private Label CreateLabel(int index)
        {
            var label = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center
            };

            label.SetBinding(AppLabel.TextProperty, new Binding(TextProperty.PropertyName, BindingMode.OneWay, _stringIndexValueConverter, index, null, this));
            label.SetBinding(AppLabel.TextColorProperty, new Binding(TextColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            label.SetBinding(AppLabel.AppFontProperty, new Binding(AppFontProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            label.SetBinding(AppLabel.FontSizeProperty, new Binding(FontSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            return(label);
        }
Esempio n. 2
0
        public AppPercent() : base()
        {
            this.SizeChanged += (sender, args) => {
                this.CalcCompletedWidth();
            };

            _completed = new ContentView
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill
            };
            _completed.SetBinding(ContentView.BackgroundColorProperty, new Binding(CompletedColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var notCompleted = new ContentView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Content           = _completed
            };

            notCompleted.SetBinding(ContentView.HeightRequestProperty, new Binding(BarHeightProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            notCompleted.SetBinding(ContentView.BackgroundColorProperty, new Binding(NotCompletedColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            _text = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                AppFont           = AppFonts.Quicksand
            };
            _text.SetBinding(AppLabel.TextColorProperty, new Binding(TextColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _text.SetBinding(AppLabel.FontSizeProperty, new Binding(TextFontSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var content = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Start,
                Orientation       = StackOrientation.Vertical
            };

            content.SetBinding(StackLayout.SpacingProperty, new Binding(SpacingProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            content.Children.Add(notCompleted);
            content.Children.Add(_text);

            this.SetText();

            this.Content = content;
        }
        private View CreateTitleText()
        {
            var label = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
            };

            label.SetBinding(AppLabel.TextProperty, new Binding(TitleProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            label.SetBinding(AppLabel.AppFontProperty, new Binding(AppFontProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            label.SetBinding(AppLabel.FontSizeProperty, new Binding(FontSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            label.SetBinding(AppLabel.TextColorProperty, new Binding(TitleTextColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var content = new ContentView
            {
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Fill,
                Padding           = new Thickness(10, 0, 0, 0),
                Content           = label
            };

            return(content);
        }
Esempio n. 4
0
        public AppCommand() : base()
        {
            _image = new Image
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
            };
            _image.SetBinding(Image.SourceProperty, new Binding(ImageSourceProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _image.SetBinding(Image.HeightRequestProperty, new Binding(ImageSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _image.SetBinding(Image.WidthRequestProperty, new Binding(ImageSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var backgroundColor = Color.FromHex("#FE3824");
            var textColor       = Color.White;

            var count = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                AppFont           = AppFonts.Quicksand,
                FontSize          = 7,
                TextColor         = textColor
            };

            count.SetBinding(AppLabel.TextProperty, new Binding(CountProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var countFrame = new Frame
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Start,
                HeightRequest     = 14,
                WidthRequest      = 14,
                CornerRadius      = 7,
                Padding           = new Thickness(0),
                BackgroundColor   = backgroundColor,
                OutlineColor      = backgroundColor,
                HasShadow         = false,
                Content           = count
            };

            countFrame.SetBinding(Frame.IsVisibleProperty, new Binding(IsCountVisibleProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var countContent = new Grid
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                RowSpacing        = 0,
                ColumnSpacing     = 0,
            };

            countContent.SetBinding(Grid.HeightRequestProperty, new Binding(ImageSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            countContent.SetBinding(Grid.WidthRequestProperty, new Binding(ImageSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            countContent.Children.Add(_image);
            countContent.Children.Add(countFrame);

            _label = new AppLabel
            {
                HorizontalOptions       = (this.Orientation == StackOrientation.Horizontal ? LayoutOptions.Start : LayoutOptions.Fill),
                VerticalOptions         = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            _label.SetBinding(AppLabel.HtmlTextProperty, new Binding(TextProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _label.SetBinding(AppLabel.TextProperty, new Binding(FlatTextProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _label.SetBinding(AppLabel.AppFontProperty, new Binding(AppFontProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _label.SetBinding(AppLabel.FontSizeProperty, new Binding(FontSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _label.SetBinding(AppLabel.IsUnderlineProperty, new Binding(IsUnderlineProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _label.SetBinding(AppLabel.FontAttributesProperty, new Binding(FontAttributesProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            _content = new StackLayout
            {
            };
            _content.SetBinding(StackLayout.HorizontalOptionsProperty, new Binding(ContentHorizontalOptionsProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _content.SetBinding(StackLayout.VerticalOptionsProperty, new Binding(ContentVerticalOptionsProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _content.SetBinding(StackLayout.OrientationProperty, new Binding(OrientationProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _content.SetBinding(StackLayout.SpacingProperty, new Binding(SpacingProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            _content.SetBinding(StackLayout.PaddingProperty, new Binding(CommandPaddingProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            _content.Children.Add(countContent);
            _content.Children.Add(_label);

            var touch = new AppLongTapView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            touch.SetBinding(AppLongTapView.CommandProperty, new Binding("LongTapCommand", BindingMode.OneWay, null, null, null, this));
            touch.SetBinding(AppLongTapView.CommandParameterProperty, new Binding("CommandParameter", BindingMode.OneWay, null, null, null, this));

            var touchGesture = new TapGestureRecognizer();

            touchGesture.Tapped += (sender, args) => {
                if ((this.Command != null) && (this.Command.CanExecute(this.CommandParameter)))
                {
                    this.FadeTo(0.6);
                    this.FadeTo(1);
                    this.Command.Execute(CommandParameter);
                }
            };

            touch.GestureRecognizers.Add(touchGesture);

            var grid = new Grid
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                RowSpacing        = 0,
                ColumnSpacing     = 0
            };

            grid.Children.Add(_content);
            grid.Children.Add(touch);

            this.SetTextColor();

            this.Content = grid;
        }
Esempio n. 5
0
        public AppSelector() : base()
        {
            var rightImage = new Image
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Source            = "selector_right"
            };

            var leftImage = new Image
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Source            = "selector_left"
            };

            leftImage.SetBinding(Image.IsVisibleProperty, new Binding("IsLeft", BindingMode.OneWay, null, null, null, this));

            _leftLabel = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                AppFont           = AppFonts.Quicksand,
            };
            _leftLabel.SetBinding(AppLabel.TextProperty, new Binding("LeftText", BindingMode.OneWay, null, null, null, this));
            _leftLabel.SetBinding(AppLabel.FontSizeProperty, new Binding("FontSize", BindingMode.OneWay, null, null, null, this));

            _rightLabel = new AppLabel
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                AppFont           = AppFonts.Quicksand,
            };
            _rightLabel.SetBinding(AppLabel.TextProperty, new Binding("RightText", BindingMode.OneWay, null, null, null, this));
            _rightLabel.SetBinding(AppLabel.FontSizeProperty, new Binding("FontSize", BindingMode.OneWay, null, null, null, this));

            var leftTouch = new ContentView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            var leftTouchGesture = new TapGestureRecognizer();

            leftTouchGesture.Tapped += (sender, args) => {
                if (!this.IsLeft)
                {
                    this.IsLeft = true;
                }
            };
            leftTouch.GestureRecognizers.Add(leftTouchGesture);

            var rightTouch = new ContentView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            var rightTouchGesture = new TapGestureRecognizer();

            rightTouchGesture.Tapped += (sender, args) => {
                if (this.IsLeft)
                {
                    this.IsLeft = false;
                }
            };
            rightTouch.GestureRecognizers.Add(rightTouchGesture);

            var content = new Grid
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                RowSpacing        = 0,
                ColumnSpacing     = 0,
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            content.Children.Add(rightImage, 0, 2, 0, 1);
            content.Children.Add(leftImage, 0, 2, 0, 1);
            content.Children.Add(_leftLabel, 0, 0);
            content.Children.Add(_rightLabel, 1, 0);
            content.Children.Add(leftTouch, 0, 0);
            content.Children.Add(rightTouch, 1, 0);

            this.Content = content;

            this.SetTextColor();
        }
Esempio n. 6
0
        public AppTripCommand() : base()
        {
            var image = new Image
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            image.SetBinding(Image.SourceProperty, new Binding("ImageSource", BindingMode.OneWay, null, null, null, this));

            var text = new AppLabel
            {
                HorizontalOptions       = LayoutOptions.Fill,
                VerticalOptions         = LayoutOptions.End,
                HorizontalTextAlignment = TextAlignment.Center
            };

            text.SetBinding(AppLabel.TextProperty, new Binding(TextProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            text.SetBinding(AppLabel.TextColorProperty, new Binding(TextColorProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            text.SetBinding(AppLabel.AppFontProperty, new Binding(AppFontProperty.PropertyName, BindingMode.OneWay, null, null, null, this));
            text.SetBinding(AppLabel.FontSizeProperty, new Binding(FontSizeProperty.PropertyName, BindingMode.OneWay, null, null, null, this));

            var textContent = new ContentView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.End,
                Padding           = new Thickness(0, 0, 0, 8),
                Content           = text
            };

            var touch = new ContentView
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };

            var touchGesture = new TapGestureRecognizer();

            touchGesture.Tapped += (sender, args) => {
                if ((this.Command != null) && (this.Command.CanExecute(this.CommandParameter)))
                {
                    this.FadeTo(0.6);
                    this.FadeTo(1);
                    this.Command.Execute(this.CommandParameter);
                }
            };
            touch.GestureRecognizers.Add(touchGesture);

            var content = new Grid
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                RowSpacing        = 0,
                ColumnSpacing     = 0
            };

            content.Children.Add(image);
            content.Children.Add(textContent);
            content.Children.Add(touch);

            this.Content = content;
        }