public TaskItemCell ()
		{
			var label = new Label {
				YAlign = TextAlignment.Center
			};
			var stripe = new BoxView {
				Color = Color.Red
			};
			label.SetBinding (Label.TextProperty, new Binding ("Name"));
			stripe.SetBinding (BoxView.IsVisibleProperty, new Binding ("Completed"));

			var layout = new RelativeLayout {
				HorizontalOptions = LayoutOptions.StartAndExpand,
				VerticalOptions = LayoutOptions.StartAndExpand
			};
			layout.Children.Add (
				label, 
				Constraint.RelativeToParent (p => 20),
				Constraint.RelativeToParent (p => 0),
				Constraint.RelativeToParent (p => p.Width - 40),
				Constraint.RelativeToParent (p => p.Height));
			layout.Children.Add (
				stripe, 
				Constraint.RelativeToParent (p => 10),
				Constraint.RelativeToParent (p => (p.Height / 2) - 1),
				Constraint.RelativeToParent (p => p.Width - 20),
				Constraint.RelativeToParent (p => 2));
			View = layout;
		}
		public MainPageCS ()
		{
			ItemTemplate = new DataTemplate (() => {
				var nameLabel = new Label {
					FontSize = Device.GetNamedSize (NamedSize.Medium, typeof(Label)),
					HorizontalOptions = LayoutOptions.Center
				};
				nameLabel.SetBinding (Label.TextProperty, "Name");

				var colorBoxView = new BoxView {
					WidthRequest = 200,
					HeightRequest = 200,
					HorizontalOptions = LayoutOptions.Center,
					VerticalOptions = LayoutOptions.CenterAndExpand
				};
				colorBoxView.SetBinding (BoxView.ColorProperty, "Color");

				return new ContentPage {
					Padding = new Thickness (0, Device.OnPlatform (40, 40, 0), 0, 0),
					Content = new StackLayout {
						Children = {
							nameLabel,
							colorBoxView
						}
					}
				};
			});

			ItemsSource = ColorsDataModel.All;
		}
        public ListViewDemoPage()
        {
            Label header = new Label
            {
                Text = "ListView",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            // Define some data.
            List<Person> people = new List<Person>
            {
                new Person("Abigail", new DateTime(1975, 1, 15), Color.Aqua),
                new Person("Bob", new DateTime(1976, 2, 20), Color.Black),
                new Person("Cathy", new DateTime(1977, 3, 10), Color.Blue),
                new Person("David", new DateTime(1978, 4, 25), Color.Fuschia),
                new Person("Eugenie", new DateTime(1979, 5, 5), Color.Gray),
                new Person("Freddie", new DateTime(1980, 6, 30), Color.Green),
                new Person("Greta", new DateTime(1981, 7, 15), Color.Lime),
                new Person("Harold", new DateTime(1982, 8, 10), Color.Maroon),
                new Person("Irene", new DateTime(1983, 9, 25), Color.Navy),
                new Person("Jonathan", new DateTime(1984, 10, 10), Color.Olive),
                new Person("Kathy", new DateTime(1985, 11, 20), Color.Purple),
                new Person("Larry", new DateTime(1986, 12, 5), Color.Red),
                new Person("Monica", new DateTime(1975, 1, 5), Color.Silver),
                new Person("Nick", new DateTime(1976, 2, 10), Color.Teal),
                new Person("Olive", new DateTime(1977, 3, 20), Color.White),
                new Person("Pendleton", new DateTime(1978, 4, 10), Color.Yellow),
                new Person("Queenie", new DateTime(1979, 5, 15), Color.Aqua),
                new Person("Rob", new DateTime(1980, 6, 30), Color.Blue),
                new Person("Sally", new DateTime(1981, 7, 5), Color.Fuschia),
                new Person("Timothy", new DateTime(1982, 8, 30), Color.Green),
                new Person("Uma", new DateTime(1983, 9, 10), Color.Lime),
                new Person("Victor", new DateTime(1984, 10, 20), Color.Maroon),
                new Person("Wendy", new DateTime(1985, 11, 5), Color.Navy),
                new Person("Xavier", new DateTime(1986, 12, 30), Color.Olive),
                new Person("Yvonne", new DateTime(1987, 1, 10), Color.Purple),
                new Person("Zachary", new DateTime(1988, 2, 5), Color.Red)
            };

            // Create the ListView.
            ListView listView = new ListView
            {
                // Source of data items.
                ItemsSource = people,

                // Define template for displaying each item.
                // (Argument of DataTemplate constructor is called for 
                //      each item; it must return a Cell derivative.)
                ItemTemplate = new DataTemplate(() =>
                {
                    // Create views with bindings for displaying each property.
                    Label nameLabel = new Label();
                    nameLabel.SetBinding(Label.TextProperty, "Name");

                    Label birthdayLabel = new Label();
                    birthdayLabel.SetBinding(Label.TextProperty,
                        new Binding("Birthday", BindingMode.OneWay, 
                                    null, null, "Born {0:d}"));

                    BoxView boxView = new BoxView();
                    boxView.SetBinding(BoxView.ColorProperty, "FavoriteColor");

                    // Return an assembled ViewCell.
                    return new ViewCell
                    {
                        View = new StackLayout
                        {
                            Padding = new Thickness(0, 5),
                            Orientation = StackOrientation.Horizontal,
                            Children = 
                            {
                                boxView,
                                new StackLayout
                                {
                                    VerticalOptions = LayoutOptions.Center,
                                    Spacing = 0,
                                    Children = 
                                    {
                                        nameLabel,
                                        birthdayLabel
                                    }
                                }
                            }
                        }
                    };
                })
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    listView
                }
            };
        }
Beispiel #4
0
        public TaxaListPage(string title)
        {
            Title = title;
               //InitializeComponent();
               ToolbarItem editItem = new ToolbarItem { Text = "EDIT" };
               ToolbarItems.Add(editItem);
               editItem.Clicked += EditItem_Clicked;

               ListView listView = new ListView
               {
                    ItemsSource = Application.TaxaList,
                    ItemTemplate = new DataTemplate(() =>
                    {

                         Label taxonNameLbl = new Label();
                         taxonNameLbl.SetBinding(Label.TextProperty, "Name");
                         taxonNameLbl.HorizontalTextAlignment = TextAlignment.Start;

                         Editor taxonEditor = new Editor();
                         taxonEditor.SetBinding(Editor.TextProperty, "Data", BindingMode.TwoWay);
                         taxonEditor.Keyboard = Keyboard.Text;
                         taxonEditor.Focused += TaxonEditor_Focused;
                         taxonEditor.Completed += TaxonEditor_Completed;
                         taxonEditor.HorizontalOptions = LayoutOptions.FillAndExpand;
                         taxonEditor.VerticalOptions = LayoutOptions.FillAndExpand;
                         taxonEditor.HeightRequest = 75;
                         //taxonEditor.WidthRequest = ;

                         BoxView colorBox = new BoxView();
                         colorBox.WidthRequest = 10;
                         colorBox.HeightRequest = 75;
                         //colorBox.VerticalOptions = LayoutOptions.FillAndExpand;
                         colorBox.SetBinding(BoxView.ColorProperty, "Color");

                         return new ViewCell
                         {
                              View = new StackLayout
                              {
                                   Padding = new Thickness(0, 5),
                                   Spacing = 5,
                                   //HeightRequest = 300,
                                   IsClippedToBounds = true,
                                   Orientation = StackOrientation.Horizontal,
                                   VerticalOptions = LayoutOptions.FillAndExpand,
                                   Children = {
                                        colorBox,
                                        new StackLayout {
                                             Orientation = StackOrientation.Vertical,
                                             //HeightRequest = 200,
                                             HorizontalOptions = LayoutOptions.FillAndExpand,
                                             VerticalOptions = LayoutOptions.FillAndExpand,
                                             Spacing = 5,

                                             Children = { taxonNameLbl, taxonEditor }
                                        }
                                   }
                              }
                         };
                    })
               };
               //listView.VerticalOptions = LayoutOptions.FillAndExpand;
               listView.HasUnevenRows = true;
               listView.IsPullToRefreshEnabled = true;
               listView.Refreshing += ListView_Refreshing;
               Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
               Content = new StackLayout { Children = { listView } };
        }
Beispiel #5
0
        public RangeSliderView()
        {
            // Path
            _sliderPath = new BoxView();

            _sliderPath.SetBinding(BoxView.ColorProperty, new Binding(path: "BarColor", source: this));

            AbsoluteLayout.SetLayoutFlags(_sliderPath, AbsoluteLayoutFlags.None);

            this.Children.Add(_sliderPath);

            // Left Button
            _leftButton = new Image();

            AbsoluteLayout.SetLayoutFlags(_leftButton, AbsoluteLayoutFlags.None);

            var leftButtonPanGesture = new PanGestureRecognizer();

            leftButtonPanGesture.PanUpdated += LeftButtonPanGesture;

            _leftButton.GestureRecognizers.Add(leftButtonPanGesture);

            _leftButton.SetBinding(Image.SourceProperty, new Binding(path: "HandleImageSource", source: this));

            this.Children.Add(_leftButton);

            // Right Button
            _rightButton = new Image();

            AbsoluteLayout.SetLayoutFlags(_rightButton, AbsoluteLayoutFlags.None);

            var rightButtonPanGesture = new PanGestureRecognizer();

            rightButtonPanGesture.PanUpdated += RightButtonPanGesture;

            _rightButton.GestureRecognizers.Add(rightButtonPanGesture);

            _rightButton.SetBinding(Image.SourceProperty, new Binding(path: "HandleImageSource", source: this));

            this.Children.Add(_rightButton);

            // Left Bubble
            _leftBubble = new RangeSliderBubble() { IsVisible = this.ShowBubbles, Text = this.LeftValue.ToString("#0") };

            AbsoluteLayout.SetLayoutFlags(_leftBubble, AbsoluteLayoutFlags.None);

            _leftBubble.SetBinding(RangeSliderBubble.SourceProperty, new Binding(path: "BubbleImageSource", source: this));

            this.Children.Add(_leftBubble);

            // Right Bubble
            _rightBubble = new RangeSliderBubble() { IsVisible = this.ShowBubbles, Text = this.RightValue.ToString("#0") };

            AbsoluteLayout.SetLayoutFlags(_rightBubble, AbsoluteLayoutFlags.None);

            _rightBubble.SetBinding(RangeSliderBubble.SourceProperty, new Binding(path: "BubbleImageSource", source: this));

            this.Children.Add(_rightBubble);
        }
		public ChangeLEDColorPage(ParticleDevice device, Dictionary<string, string> variables)
		{
			Title = "RBG LED";
			BackgroundColor = AppColors.BackgroundColor;
			ViewModel = new ChangeLEDColorViewModel(device, variables);
			BindingContext = ViewModel;

			var indicator = new ActivityIndicator { HeightRequest = Device.OnPlatform(50, 30, 50) };
            var colorPreview = new BoxView { HeightRequest = 100 };
			var redSlider = new Slider { StyleId = "redSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var greenSlider = new Slider { StyleId = "greenSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var blueSlider = new Slider { StyleId = "blueSlider", Minimum = 0, Maximum = 255, Value = 0 };
			var push = new StyledButton
			{
				StyleId = "pushRGBvalueButton",
				Text = "PUSH TO PHOTON",
				BackgroundColor = AppColors.Blue,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				VerticalOptions = LayoutOptions.Fill
			};
			var lightShow = new StyledButton
			{
				StyleId = "startLightShowButton",
				Text = "START A LIGHT SHOW",
				BackgroundColor = AppColors.Green,
				CssStyle = "button",
				BorderRadius = 0,
				HeightRequest = AppSettings.ButtonHeight,
				VerticalOptions = LayoutOptions.End
			};
            var previewLabel = new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start };
            var rLabel = new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start };
            var gLabel = new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start };
            var bLabel = new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start };

            Func<RelativeLayout, View, double> layoutAfterPrevious = (p, v) => Device.OnPlatform(
                                                                                    v.Y + v.Height + 5,
                                                                                    v.Y + v.Height + 5,
                                                                                    v.Y + v.Height + 2);

            RelativeLayout relativeLayout = new RelativeLayout();
            relativeLayout.Children.Add(previewLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.Constant(10)
            );
            relativeLayout.Children.Add(colorPreview,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(previewLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight * 2)
            );
            relativeLayout.Children.Add(rLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(colorPreview, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(redSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(rLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(gLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(redSlider, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(greenSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(gLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(bLabel,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(greenSlider, layoutAfterPrevious)
            );
            relativeLayout.Children.Add(blueSlider,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(bLabel, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2)
            );
            relativeLayout.Children.Add(indicator,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(blueSlider, layoutAfterPrevious),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(Device.OnPlatform(50,50,25))
            );
            relativeLayout.Children.Add(lightShow,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
            );
            relativeLayout.Children.Add(push,
                xConstraint: Constraint.Constant(AppSettings.Margin),
                yConstraint: Constraint.RelativeToView(lightShow, (p, v) => v.Y - AppSettings.ButtonHeight - 10),
                widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
                heightConstraint: Constraint.Constant(AppSettings.ButtonHeight)
            );
            


   //         StackLayout layout = new StackLayout
			//{
			//	VerticalOptions = LayoutOptions.CenterAndExpand,
			//	Padding = new Thickness(AppSettings.Margin, 10, AppSettings.Margin, AppSettings.Margin),
			//	Spacing = 10,
			//	Children = {
			//		new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start },
			//		colorPreview,
			//		new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start },
			//		redSlider,
			//		new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start },
			//		greenSlider,
			//		new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start },
			//		blueSlider,
			//		indicator,
			//		push,
			//		lightShow
			//	}
			//};

			if (Device.OS == TargetPlatform.iOS)
			{
				push.FontFamily = "SegoeUI-Light";
				push.FontSize = 16;
				push.TextColor = Color.FromHex("#ffffff");

				lightShow.FontFamily = "SegoeUI-Light";
				lightShow.FontSize = 16;
				lightShow.TextColor = Color.FromHex("#ffffff");
			}

            var off = new ToolbarItem { Text = "LEDs Off" };

            Content = relativeLayout;


            indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");
            if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android)
                indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");

            redSlider.SetBinding(Slider.ValueProperty, "R", BindingMode.TwoWay);
			greenSlider.SetBinding(Slider.ValueProperty, "G", BindingMode.TwoWay);
			blueSlider.SetBinding(Slider.ValueProperty, "B", BindingMode.TwoWay);
			colorPreview.SetBinding(BoxView.BackgroundColorProperty, "ColorBoxColor");
			push.SetBinding(Button.CommandProperty, "PushColorCommand");
			lightShow.SetBinding(Button.CommandProperty, "LightShowCommand");
			off.SetBinding(ToolbarItem.CommandProperty, "LedsOffCommand");

			ToolbarItems.Add(off);
		}
		    public MyDataTemplateSelector ()
		    {
			    _evenTemplate = new DataTemplate (() => {
				    // Create views with bindings for displaying each property.
				    Label nameLabel = new Label ();
				    nameLabel.SetBinding (Label.TextProperty, "Name");

				    Label birthdayLabel = new Label ();
				    birthdayLabel.SetBinding (Label.TextProperty,
											  new Binding ("Birthday", BindingMode.OneWay,
														   null, null, "Born {0:d}"));

				    BoxView boxView = new BoxView ();
				    boxView.SetBinding (BoxView.ColorProperty, "FavoriteColor");

				    // Return an assembled ViewCell.
				    return new ViewCell {
					    View = new StackLayout {
						    Padding = new Thickness (0, 5),
						    Orientation = StackOrientation.Horizontal,
						    Children = {
							    new Image {
								    HeightRequest = 40,
								    WidthRequest = 40,
								    Source = new UriImageSource {
									    //											CacheValidity = TimeSpan.FromSeconds (10),
									    Uri = new Uri ("https://xamarin.com/content/images/pages/index/xamarin-studio-icon.png"),
								    }
							    },
							    boxView,
							    new StackLayout {
								    VerticalOptions = LayoutOptions.Center,
								    Spacing = 0,
								    Children = {
									    nameLabel,
									    birthdayLabel
								    }
							    }
						    }
					    }
				    };
			    });

			    _oddTemplate = new DataTemplate (() => {
				    // Create views with bindings for displaying each property.
				    Label nameLabel = new Label ();
				    nameLabel.SetBinding (Label.TextProperty, "Name");

				    Label birthdayLabel = new Label ();
				    birthdayLabel.SetBinding (Label.TextProperty,
											  new Binding ("Birthday", BindingMode.OneWay,
														   null, null, "Born {0:d}"));

				    BoxView boxView = new BoxView ();
				    boxView.SetBinding (BoxView.ColorProperty, "FavoriteColor");

				    // Return an assembled ViewCell.
				    return new ViewCell {
					    View = new StackLayout {
						    Padding = new Thickness (0, 5),
						    Orientation = StackOrientation.Horizontal,
						    Children = {
							    new Image {
								    HeightRequest = 40,
								    WidthRequest = 40,
								    Source = new UriImageSource {
									    //											CacheValidity = TimeSpan.FromSeconds (10),
									    Uri = new Uri ("https://xamarin.com/content/images/pages/index/xamarin-studio-icon.png"),
								    }
							    },

							    new StackLayout {
								    VerticalOptions = LayoutOptions.Center,
								    Spacing = 0,
								    Children = {
									    birthdayLabel,
									    nameLabel,
								    }
							    },
							    boxView,
						    }
					    }
				    };
			    });
		    }
Beispiel #8
0
        public NamedColorPage(bool includeBigLabel)
        {
            // This binding is necessary to label the tabs in
            //      the TabbedPage.
            this.SetBinding(ContentPage.TitleProperty, "Name");

            // BoxView to show the color.
            BoxView boxView = new BoxView
            {
                WidthRequest = 100,
                HeightRequest = 100,
                HorizontalOptions = LayoutOptions.Center
            };
            boxView.SetBinding(BoxView.ColorProperty, "Color");

            // Function to create six Labels.
            Func<string, string, Label> CreateLabel = (string source, string fmt) =>
            {
                Label label = new Label {
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    XAlign = TextAlignment.End
                };
                label.SetBinding(Label.TextProperty,
                    new Binding(source, BindingMode.OneWay, null, null, fmt));

                return label;
            };

            // Build the page
            this.Content = new StackLayout
            {
                Children =
                {
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                        Children =
                        {
                            CreateLabel("Color.R", "R = {0:F2}"),
                            CreateLabel("Color.G", "G = {0:F2}"),
                            CreateLabel("Color.B", "B = {0:F2}"),
                        }
                    },
                    boxView,
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.CenterAndExpand,
                        Children =
                        {
                            CreateLabel("Color.Hue", "Hue = {0:F2}"),
                            CreateLabel("Color.Saturation", "Saturation = {0:F2}"),
                            CreateLabel("Color.Luminosity", "Luminosity = {0:F2}")
                        }
                    }
                }
            };

            // Add in the big Label at top for CarouselPage.
            if (includeBigLabel)
            {
                Label bigLabel = new Label
                {
                    FontSize = 50,
                    HorizontalOptions = LayoutOptions.Center
                };
                bigLabel.SetBinding(Label.TextProperty, "Name");

                (this.Content as StackLayout).Children.Insert(0, bigLabel);
            }
        }
        public NamedColorPage()
        {
            // This binding is necessary to label the tabs in
            // the TabbedPage.
            this.SetBinding(ContentPage.TitleProperty, "Name");
            // BoxView to show the color.
            BoxView boxView = new BoxView
            {
                WidthRequest = 100,
                HeightRequest = 100,
                HorizontalOptions = LayoutOptions.Center
            };
            boxView.SetBinding(BoxView.ColorProperty, "Color");

            // Build the page
            this.Content = boxView;
        }
        public ChartSettingsPage()
        {
            Title = "настройки";
            BackgroundColor = Color.FromHex ("#DCDCDC");

            var grd = new Grid () { Padding = Device.OnPlatform (10, 8, 10) };
            grd.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
            grd.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
            grd.RowDefinitions.Add (new RowDefinition ());

            {
                var lbl = new Label () {
                    Text = "ФИЛЬТРЫ",
                    FontSize = 14,
                    HorizontalOptions = LayoutOptions.Center,
                    FontAttributes = FontAttributes.Bold,
                    TextColor = Color.FromHex ("#4487CA")
                };
                Grid.SetRow (lbl, 0);
                grd.Children.Add (lbl);
            }

            {
                var downGrid = new Grid () { RowSpacing = 10 };
                downGrid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
                downGrid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
                downGrid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });
                downGrid.RowDefinitions.Add (new RowDefinition () { Height = GridLength.Auto });

                {
                    var lbl = new Label () { Text = "Скрытие/отображение серий", FontSize = 13 };
                    Grid.SetRow (lbl, 0);
                    downGrid.Children.Add (lbl);
                }

                {
                    var grdSwt = new Grid ();
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition () { Width = GridLength.Auto });
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition ());

                    var bx = new BoxView () {
                        HeightRequest = Device.OnPlatform (8, 10, 0),
                        WidthRequest = 40,
                        VerticalOptions = LayoutOptions.Center
                    };
                    bx.SetBinding (BoxView.ColorProperty, new Binding ("WColor"));
                    grdSwt.Children.Add (bx);

                    Switch swt;
                    if (Device.OS == TargetPlatform.Android) {
                        swt = new Switch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                    } else {
                        swt = new ExtendedSwitch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                        swt.SetBinding (ExtendedSwitch.TintColorProperty, new Binding ("WColor"));
                    }
                    swt.SetBinding (Switch.IsToggledProperty, new Binding ("IsWvisible"));
                    Grid.SetColumn (swt, 1);
                    grdSwt.Children.Add (swt);

                    Grid.SetRow (grdSwt, 1);
                    downGrid.Children.Add (grdSwt);
                }

                {
                    var grdSwt = new Grid ();
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition () { Width = GridLength.Auto });
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition ());

                    var bx = new BoxView () {
                        HeightRequest = Device.OnPlatform (8, 10, 0),
                        WidthRequest = 40,
                        VerticalOptions = LayoutOptions.Center
                    };
                    bx.SetBinding (BoxView.ColorProperty, new Binding ("QnColor"));
                    grdSwt.Children.Add (bx);

                    Switch swt;
                    if (Device.OS == TargetPlatform.Android) {
                        swt = new Switch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                    } else {
                        swt = new ExtendedSwitch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                        swt.SetBinding (ExtendedSwitch.TintColorProperty, new Binding ("QnColor"));
                    }
                    swt.SetBinding (Switch.IsToggledProperty, new Binding ("IsQnVisible"));
                    Grid.SetColumn (swt, 1);
                    grdSwt.Children.Add (swt);

                    Grid.SetRow (grdSwt, 2);
                    downGrid.Children.Add (grdSwt);
                }

                {
                    var grdSwt = new Grid ();
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition () { Width = GridLength.Auto });
                    grdSwt.ColumnDefinitions.Add (new ColumnDefinition ());

                    var bx = new BoxView () {
                        HeightRequest = Device.OnPlatform (8, 10, 0),
                        WidthRequest = 40,
                        VerticalOptions = LayoutOptions.Center
                    };
                    bx.SetBinding (BoxView.ColorProperty, new Binding ("QjColor"));
                    grdSwt.Children.Add (bx);

                    Switch swt;
                    if (Device.OS == TargetPlatform.Android) {
                        swt = new Switch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                    } else {
                        swt = new ExtendedSwitch () {
                            VerticalOptions = LayoutOptions.Center,
                            HeightRequest = 35,
                            HorizontalOptions = LayoutOptions.End
                        };
                        swt.SetBinding (ExtendedSwitch.TintColorProperty, new Binding ("QjColor"));
                    }
                    swt.SetBinding (Switch.IsToggledProperty, new Binding ("IsQjVisible"));
                    Grid.SetColumn (swt, 1);
                    grdSwt.Children.Add (swt);

                    Grid.SetRow (grdSwt, 3);
                    downGrid.Children.Add (grdSwt);
                }

                Grid.SetRow (downGrid, 1);
                grd.Children.Add (downGrid);
            }

            Content = grd;
        }
        public RangeSliderView()
        {
            // Active Bar
            _activeBar = new BoxView();

            _activeBar.SetBinding(BoxView.ColorProperty, new Binding(path: "ActiveBarColor", source: this));

            AbsoluteLayout.SetLayoutFlags(_activeBar, AbsoluteLayoutFlags.None);

            this.Children.Add(_activeBar);

            // Inactive Left Bar
            _inActiveLeftBar = new BoxView();

            _inActiveLeftBar.SetBinding(BoxView.ColorProperty, new Binding(path: "InactiveBarColor", source: this));

            AbsoluteLayout.SetLayoutFlags(_inActiveLeftBar, AbsoluteLayoutFlags.None);

            this.Children.Add(_inActiveLeftBar);

            // Inactive Right Bar
            _inActiveRightBar = new BoxView();

            _inActiveRightBar.SetBinding(BoxView.ColorProperty, new Binding(path: "InactiveBarColor", source: this));

            AbsoluteLayout.SetLayoutFlags(_inActiveRightBar, AbsoluteLayoutFlags.None);

            this.Children.Add(_inActiveRightBar);

            // Left Button
            _leftButton = new Image();

            AbsoluteLayout.SetLayoutFlags(_leftButton, AbsoluteLayoutFlags.None);

            var leftButtonPanGesture = new PanGestureRecognizer();

            leftButtonPanGesture.PanUpdated += LeftButtonPanGesture;

            _leftButton.GestureRecognizers.Add(leftButtonPanGesture);

            _leftButton.SetBinding(Image.SourceProperty, new Binding(path: "HandleImageSource", source: this));

            this.Children.Add(_leftButton);

            // Right Button
            _rightButton = new Image();

            AbsoluteLayout.SetLayoutFlags(_rightButton, AbsoluteLayoutFlags.None);

            var rightButtonPanGesture = new PanGestureRecognizer();

            rightButtonPanGesture.PanUpdated += RightButtonPanGesture;

            _rightButton.GestureRecognizers.Add(rightButtonPanGesture);

            _rightButton.SetBinding(Image.SourceProperty, new Binding(path: "HandleImageSource", source: this));

            this.Children.Add(_rightButton);

            // Left Bubble
            _leftBubble = new RangeSliderBubble() { IsVisible = this.ShowBubbles, Text = this.LeftValue.ToString("#0") };

            AbsoluteLayout.SetLayoutFlags(_leftBubble, AbsoluteLayoutFlags.None);

            _leftBubble.SetBinding(RangeSliderBubble.SourceProperty, new Binding(path: "BubbleImageSource", source: this));
            _leftBubble.SetBinding(RangeSliderBubble.FontFamilyProperty, new Binding(path: "FontFamily", source: this));
            _leftBubble.SetBinding(RangeSliderBubble.FontSizeProperty, new Binding(path: "FontSize", source: this));
            _leftBubble.SetBinding(RangeSliderBubble.TextColorProperty, new Binding(path: "TextColor", source: this));

            this.Children.Add(_leftBubble);

            // Right Bubble
            _rightBubble = new RangeSliderBubble() { IsVisible = this.ShowBubbles, Text = this.RightValue.ToString("#0") };

            AbsoluteLayout.SetLayoutFlags(_rightBubble, AbsoluteLayoutFlags.None);

            _rightBubble.SetBinding(RangeSliderBubble.SourceProperty, new Binding(path: "BubbleImageSource", source: this));
            _rightBubble.SetBinding(RangeSliderBubble.FontFamilyProperty, new Binding(path: "FontFamily", source: this));
            _rightBubble.SetBinding(RangeSliderBubble.FontSizeProperty, new Binding(path: "FontSize", source: this));
            _rightBubble.SetBinding(RangeSliderBubble.TextColorProperty, new Binding(path: "TextColor", source: this));

            this.Children.Add(_rightBubble);
        }
Beispiel #12
0
		protected override void Init ()
		{
			var people = new ObservableCollection<Person> {
				new Person ("Abigail", new DateTime (1975, 1, 15), Color.Aqua),
				new Person ("Bob", new DateTime (1976, 2, 20), Color.Black),
				new Person ("Cathy", new DateTime (1977, 3, 10), Color.Blue),
#pragma warning disable 618
				new Person ("David", new DateTime (1978, 4, 25), Color.Fuschia),
#pragma warning restore 618
			};

			var buttonAdd = new Button {
				Text = "Add",
				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center,
			};

			var buttonRemove = new Button {
				Text = "Remove",
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Center,
			};

			var buttonScrollToBottom = new Button {
				Text = "Bottom",
				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center,
			};

			var buttonStack = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				Children = {
					buttonAdd,
					buttonRemove,
					buttonScrollToBottom,
				}
			};

			var listView = new ListView {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				ItemsSource = people,
				ItemTemplate = new DataTemplate (() =>
				{
					var nameLabel = new Label ();
					var birthdayLabel = new Label ();
					var boxView = new BoxView ();

					var stack = new StackLayout {
						Padding = new Thickness (0, 5),
						Orientation = StackOrientation.Horizontal,
						BackgroundColor = Color.Black,
						Children = {
							boxView,
							new StackLayout {
								VerticalOptions = LayoutOptions.Center,
								Spacing = 0,
								Children = {
									nameLabel,
									birthdayLabel
								}
							}
						}
					};

					nameLabel.SetBinding (Label.TextProperty, "Name");
					birthdayLabel.SetBinding (Label.TextProperty, new Binding ("Birthday", BindingMode.OneWay, null, null, "Born {0:d}"));
					boxView.SetBinding (BoxView.ColorProperty, "FavoriteColor");
					stack.SetBinding (BackgroundColorProperty, "BackgroundColor");

					return new ViewCell {
						View = stack
					};
				})
			};

			buttonAdd.Clicked += (sender, e) =>
			{
				var person = new Person (string.Format ("Name {0}", _count++), DateTime.Today, Color.Blue);

				people.Add (person);

				listView.ScrollTo (person, ScrollToPosition.End, true);

			};

			buttonRemove.Clicked += (sender, e) => people.RemoveAt (people.Count - 1);

			buttonScrollToBottom.Clicked += (sender, e) =>
			{
				var person = people[people.Count - 1];

				listView.ScrollTo (person, ScrollToPosition.End, true);
			};

			Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5);

			Content = new StackLayout {
				Orientation = StackOrientation.Vertical,
				Children = {
					buttonStack,
					listView,
				}
			};
		}