public RotateAnimationWithAnchorsPageCS ()
		{
			Title = "Rotate Animation with Anchors";

			image = new Image { Source = ImageSource.FromFile ("monkey.png"), VerticalOptions = LayoutOptions.EndAndExpand };
			startButton = new Button { Text = "Start Animation", VerticalOptions = LayoutOptions.End };
			cancelButton = new Button { Text = "Cancel Animation", IsEnabled = false };

			image.SizeChanged += OnImageSizeChanged;
			startButton.Clicked += OnStartAnimationButtonClicked;
			cancelButton.Clicked += OnCancelAnimationButtonClicked;

			absoluteLayout = new AbsoluteLayout ();
			absoluteLayout.Children.Add (image);

			var stackLayout = new StackLayout {
				Children = {
					startButton,
					cancelButton
				}
			};

			var grid = new Grid { 
				RowDefinitions = {
					new RowDefinition { Height = new GridLength (0.8, GridUnitType.Star) },
					new RowDefinition { Height = new GridLength (0.2, GridUnitType.Star) }
				},
				Children = {
					absoluteLayout,
				}
			};

			grid.Children.Add (stackLayout, 0, 1);
			Content = grid;
		}
コード例 #2
0
		public ContentView CreateImageButton (string buttonImage, double height, double width,
			Action tappedCallback)
		{
			var grid = new Grid {
				RowDefinitions = new RowDefinitionCollection {
					new RowDefinition {
						Height = new GridLength (1, GridUnitType.Star)
					},
				},
				ColumnDefinitions = new ColumnDefinitionCollection {
					new ColumnDefinition {
						Width = new GridLength (1, GridUnitType.Star)
					},

				},
				BackgroundColor = Color.Transparent,
				HorizontalOptions = LayoutOptions.Center,
				RowSpacing = 5
			};

			var navImage = new SvgImage {
				SvgPath = string.Format ("ExtendedMap.Forms.Plugin.Abstractions.Images.{0}", buttonImage),
				SvgAssembly = typeof(CustomMapContentView).GetTypeInfo ().Assembly,
				HorizontalOptions = LayoutOptions.Center,
				HeightRequest = height,
				WidthRequest = width
			};

			grid.GestureRecognizers.Add (new TapGestureRecognizer{ Command = new Command (tappedCallback) });

			grid.Children.Add (navImage, 0, 0);

			return new ContentView { Content = grid };
		}
コード例 #3
0
		public OrderPageCode ()
		{
			Title = "Order Page - Code";
			var grid = new Grid {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness (15)
			};
			for (int x = 0; x < 7; x++) {
				grid.RowDefinitions.Add (new RowDefinition{ Height = new GridLength(50) });
			}
			grid.ColumnDefinitions.Add (new ColumnDefinition{ Width = new GridLength(90) });
			grid.ColumnDefinitions.Add (new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) });

			grid.Children.Add (new Label { Text = "Purchaser's Name:" }, 0, 0);
			grid.Children.Add (new Label { Text = "Billing Address:" }, 0, 1);
			grid.Children.Add (new Label { Text = "Tip:", FontAttributes = FontAttributes.Bold }, 0, 2);
			grid.Children.Add (new Label { Text = "Phone Number:" }, 0, 3);
			grid.Children.Add (new Label { Text = "Comments:" }, 0, 4);
			grid.Children.Add (new Entry { Placeholder = "Full Name on Card" }, 1, 0);
			grid.Children.Add (new Editor (), 1, 1);
			grid.Children.Add (new Entry{ Keyboard = Keyboard.Numeric }, 1, 2);
			grid.Children.Add (new Entry { Keyboard = Keyboard.Telephone }, 1, 3);
			grid.Children.Add (new Editor (), 1, 4);

			var fstring = new FormattedString ();
			fstring.Spans.Add (new Span { Text = "Wait! ", ForegroundColor = Color.Red });
			fstring.Spans.Add (new Span { Text = "Please double check that everything is right." });
			grid.Children.Add (new Label { FormattedText = fstring }, 1, 5);
			grid.Children.Add (new Button { TextColor = Color.White, BackgroundColor = Color.Gray, Text = "Save" }, 1, 6);
			Content = grid;
		}
コード例 #4
0
        private Grid SliderLabels()
        {
            var grid = new Grid {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) },
                }
            };

            grid.Children.Add (
                SyncLabel ("1", LayoutOptions.StartAndExpand, new Thickness (5, 0, 0, 0))
                , 0, 0);

            grid.Children.Add (
                SyncLabel ("5", LayoutOptions.Center)
                , 1, 0);

            grid.Children.Add (
                SyncLabel ("30", LayoutOptions.Center)
                , 2, 0);

            grid.Children.Add (
                SyncLabel ("60", LayoutOptions.EndAndExpand, new Thickness (0, 0, 5, 0))
                , 3, 0);

            return grid;
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="DLToolkit.Forms.Controls.FlowListViewInternalCell"/> class.
		/// </summary>
		/// <param name="flowListViewRef">Flow list view reference.</param>
		public FlowListViewInternalCell(WeakReference<FlowListView> flowListViewRef)
		{
			_flowListViewRef = flowListViewRef;
			FlowListView flowListView = null;
			flowListViewRef.TryGetTarget(out flowListView);
			_useGridAsMainRoot = !flowListView.FlowUseAbsoluteLayoutInternally;

			if (!_useGridAsMainRoot)
			{
				_rootLayout = new AbsoluteLayout()
				{
					Padding = 0d,
					BackgroundColor = flowListView.FlowRowBackgroundColor,
				};
				View = _rootLayout;
			}
			else
			{
				_rootLayoutAuto = new Grid()
				{
					RowSpacing = 0d,
					ColumnSpacing = 0d,
					Padding = 0d,
					BackgroundColor = flowListView.FlowRowBackgroundColor,
				};
				View = _rootLayoutAuto;
			}

			_flowColumnTemplate = flowListView.FlowColumnTemplate;
			_desiredColumnCount = flowListView.DesiredColumnCount;
			_flowColumnExpand = flowListView.FlowColumnExpand;
		}
コード例 #6
0
        /// <summary>
        /// More logical way to add child to Grid
        /// </summary>
        /// <param name="grid">Grid.</param>
        /// <param name="view">View.</param>
        /// <param name="row">Row.</param>
        /// <param name="column">Column.</param>
        /// <param name="rowspan">Rowspan.</param>
        /// <param name="columnspan">Columnspan.</param>
        public static void AddChild(this Xamarin.Forms.Grid grid, View view, int row, int column, int rowspan = 1, int columnspan = 1)
        {
            if (row < 0)
            {
                throw new ArgumentOutOfRangeException("row");
            }
            if (column < 0)
            {
                throw new ArgumentOutOfRangeException("column");
            }
            if (rowspan <= 0)
            {
                throw new ArgumentOutOfRangeException("rowspan");
            }
            if (columnspan <= 0)
            {
                throw new ArgumentOutOfRangeException("columnspan");
            }
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            Xamarin.Forms.Grid.SetRow((BindableObject)view, row);
            Xamarin.Forms.Grid.SetRowSpan((BindableObject)view, rowspan);
            Xamarin.Forms.Grid.SetColumn((BindableObject)view, column);
            Xamarin.Forms.Grid.SetColumnSpan((BindableObject)view, columnspan);

            grid.Children.Add(view);
        }
コード例 #7
0
 private Grid GenLowerGrid()
 {
     var grid = new Grid();
     grid.Children.Add(CreateButtonFor("Employee Details", "Employee128.png", "3"), 0, 0);
     grid.Children.Add(CreateButtonFor("Leave Details", "NotePad128.png", "4"), 1, 0);
     return grid;
 }
コード例 #8
0
        public FeedOverview()
        {
            var refreshButton = new Button {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.Center,
            Text = "Refresh"
              };
              refreshButton.SetBinding(Button.CommandProperty, "RefreshCommand");

              var template = new DataTemplate(typeof(TextCell));
              // We can set data bindings to our supplied objects.
              template.SetBinding(TextCell.TextProperty, "Title");
              template.SetBinding(TextCell.DetailProperty, "Description");

              var listView = new ListView {ItemTemplate = template};
              listView.SetBinding(ListView.ItemsSourceProperty, "FeedItems");

              // Push the list view down below the status bar on iOS.
              Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
              Content = new Grid {
            BindingContext = new FeedReaderViewModel(),

            RowDefinitions = new RowDefinitionCollection {
             new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
             new RowDefinition { Height = new GridLength (0, GridUnitType.Auto) },

               },
            Children = {
               new ViewWithGridPosition(listView, 0,0),
               new ViewWithGridPosition(refreshButton, 1,0)
             },
              };
        }
コード例 #9
0
		public FlowListViewInternalCell(FlowListView flowListView)
		{
			this.flowListView = flowListView;

			root = new Grid() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				RowSpacing = 0f,
				ColumnSpacing = 0f,
				Padding = 0f,
				RowDefinitions = new RowDefinitionCollection() {
					new RowDefinition() { Height = GridLength.Auto }
				},
				ColumnDefinitions = new ColumnDefinitionCollection()
			};

			for (int i = 0; i < this.flowListView.FlowColumnsDefinitions.Count; i++)
			{
				root.ColumnDefinitions.Add(new ColumnDefinition() {
					Width = new GridLength(1, GridUnitType.Star)
				});
			}

			View = root;
		}
コード例 #10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NControl.Controls.GalleryView"/> class.
		/// </summary>
		public GalleryView ():base()
		{
			CornerRadius = 0;
			BorderWidth = 0.0;
			IsClippedToBounds = true;
			HorizontalOptions = LayoutOptions.FillAndExpand;
			VerticalOptions = LayoutOptions.FillAndExpand;

			_childLayout = new Grid ();
			var layout = new Grid ();

			// Touch handling
			var startTime = DateTime.MinValue;

			// Handle child changes
			_children.CollectionChanged += (sender, e) => {

				_childLayout.BatchBegin();
				_childLayout.Children.Clear();

				for(var i=0; i<_children.Count; i++)
					_childLayout.Children.Add(_children[i]);				

				_childLayout.BatchCommit();
			};

			layout.Children.Add (_childLayout);

			Content = layout;
		}
コード例 #11
0
        public TestCell()
        {
            var nameLabel = new Label();
            nameLabel.SetBinding(Label.TextProperty, "Name");

            imageLabel = new Image();
            imageLabel.WidthRequest = 50;
            imageLabel.Source = PhoneCallImage;
            imageLabel.Up += ImageLabelOnUp;
            imageLabel.Down += ImageLabelOnDown;

            var grid = new Grid
            {
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition
                    {
                        
                    },
                    new ColumnDefinition
                    {
                        Width = GridLength.Auto
                    },
                }
            };
            grid.Children.Add(nameLabel, 0, 0);
            grid.Children.Add(imageLabel, 1, 0);
            View = grid;
        }
コード例 #12
0
		public GraphicIconButton()
		{
			HeightRequest = 44;
			WidthRequest = 44;

			icon = new NControlView {
				DrawingFunction = DrawIcon,
			};

			circle = new NControlView {
				DrawingFunction = DrawCircle,
			};

			Content = new Grid {
				Children = {
					circle,
					icon,
				},
			};

			OnInvalidate += (sender, e) => 
			{
				circle.Invalidate();
				icon.Invalidate();
			};
		}
コード例 #13
0
 private Grid GenGrid()
 {
     var grid = new Grid();
     grid.Children.Add(CreateButtonFor("Notifications", "Notify128.png", "1"), 0, 0);
     grid.Children.Add(CreateButtonFor("Leave Balance", "Balance128.png", "2"), 1, 0);
     return grid;
 }
コード例 #14
0
        public HolydayCell()
        {
            Label LabelName = new Label
            {
                TextColor = Color.White,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start
            };
             Label LabelDate = new Label
            {
                TextColor = Color.White,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                VerticalOptions = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start
            };
            LabelName.SetBinding(Label.TextProperty, "Name", BindingMode.TwoWay);
            LabelDate.SetBinding(Label.TextProperty, "Date", BindingMode.TwoWay);

            Grid grid = new Grid();
            var cd = new ColumnDefinition();
            cd.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(cd);
            cd = new ColumnDefinition();
            cd.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(cd);

            grid.Children.AddHorizontal(LabelName);
            grid.Children.AddHorizontal(LabelDate);
            View = grid;
        }
コード例 #15
0
        public HomePageCS()
        {
            var label = new Label {
                Text = "Label Shadow Effect",
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            label.Effects.Add (new ShadowEffect {
                Radius = 5,
                Color = Device.OnPlatform (Color.Black, Color.White, Color.Red),
                DistanceX = 5,
                DistanceY = 5
            });

            Content = new Grid {
                Padding = new Thickness (0, 20, 0, 0),
                Children = {
                    new Label {
                        Text = "Effects Demo",
                        FontAttributes = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Center
                    },
                    label
                }
            };
        }
コード例 #16
0
		public LoadingPlaceholder ()
		{
			Padding = new Thickness (20);
			Title = "Image Loading Gallery";

			var source = new UriImageSource {
				Uri = new Uri ("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"),
				CachingEnabled = false
			};

			var image = new Image {
				Source = source,
				WidthRequest = 200,
				HeightRequest = 200,
			};

			var indicator = new ActivityIndicator {Color = new Color (.5),};
			indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading");
			indicator.BindingContext = image;

			var grid = new Grid();
			grid.RowDefinitions.Add (new RowDefinition());


			grid.Children.Add (image);
			grid.Children.Add (indicator);


			Content = grid;
		}
コード例 #17
0
ファイル: ProjectEdit.cs プロジェクト: RodrigoGT/csla
    protected override void OnAppearing()
    {
      base.OnAppearing();

      if (BindingContext == null)
      {
        BindingContext = _project;

        var grid = new Grid();
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = 150 });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.VerticalOptions = LayoutOptions.StartAndExpand;
        grid.Children.Add(new Label { Text = "Name" }, 0, 0);
        var editor = new Editor();
        editor.SetBinding(Editor.TextProperty, "Name");
        grid.Children.Add(editor, 1, 0);
        label.IsVisible = false;
        label.Text = "Error in value";
        label.TextColor = Color.Red;
        grid.Children.Add(label, 1, 1);
        grid.Children.Add(new Label { Text = "Description" }, 0, 2);
        grid.Children.Add(new Editor { Text = _project.Description }, 1, 2);
        grid.Children.Add(new Label { Text = "Started" }, 0, 3);
        grid.Children.Add(new Editor { Text = _project.Started.HasValue ? _project.Started.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 3);
        grid.Children.Add(new Label { Text = "Ended" }, 0, 4);
        grid.Children.Add(new Editor { Text = _project.Ended.HasValue ? _project.Ended.GetValueOrDefault().ToShortDateString() : string.Empty }, 1, 4);
        Content = grid;
      }
    }
コード例 #18
0
ファイル: HomePage.cs プロジェクト: borrrden/SayNumbers
        /// <summary>
        /// Constructor
        /// </summary>
        public HomePage()
        {
            BackgroundImage = "bg.png";
            var masterLayout = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Spacing = 10
            };

            // Start Button
            var startButton = new Button { Text = "スタート", HorizontalOptions = LayoutOptions.Center };
            masterLayout.Children.Add(startButton);

            // Text followed by two auto expanding text areas
            var row = new StackLayout { Orientation = StackOrientation.Horizontal, Spacing = 10, Padding = new Thickness(10, 0, 10, 0) };
            row.Children.Add(new Label { Text = "範囲:" });
            masterLayout.Children.Add(row);
            var grid = new Grid();
            grid.HorizontalOptions = LayoutOptions.FillAndExpand;
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            var lowerBoundField = new Entry();
            var upperBoundField = new Entry();
            grid.Children.Add(lowerBoundField, 0, 0);
            grid.Children.Add(upperBoundField, 1, 0);
            row.Children.Add(grid);

            // Data binding
            upperBoundField.SetBinding(Entry.TextProperty, new Binding("UpperBoundText", BindingMode.TwoWay));
            lowerBoundField.SetBinding(Entry.TextProperty, new Binding("LowerBoundText", BindingMode.TwoWay));
            startButton.SetBinding(Button.CommandProperty, new Binding("StartPracticeCommand", BindingMode.OneWay));

            Content = masterLayout;
        }
コード例 #19
0
        public App()
        {
            _grid = new Grid {
                BackgroundColor = Color.Purple, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
            };

            // THIS BOX VIEW DOES NOT SHOW UP IF YOU RE-SIZE THE ROW DEFINITION
            var boxView = new BoxView { BackgroundColor = Color.Blue, VerticalOptions = LayoutOptions.End };

            var button = new Button
            {
                Text = "button",
                BackgroundColor = Color.Lime,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center
            };

            button.Clicked += (sender, e) =>
            {
                _grid.RowDefinitions[1].Height = Math.Abs(_grid.RowDefinitions[1].Height.Value - 100) < double.Epsilon ?
                                                                                                new GridLength(0) : new GridLength(100);
            };

            Grid.SetRow(boxView, 1);

            _grid.RowDefinitions.Add(new RowDefinition() { Height = 100 });
            _grid.RowDefinitions.Add(new RowDefinition() { Height = 0 }); // CHANGE THIS TO 100 and it works fine

            _grid.Children.Add(boxView);
            _grid.Children.Add(button);

            MainPage = new ContentPage { Content = _grid };
        }
コード例 #20
0
		public HomePageCS ()
		{
			label = new Label {
				Text = "Label Shadow Effect",
				FontAttributes = FontAttributes.Bold,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
			ShadowEffect.SetHasShadow (label, true);
			ShadowEffect.SetColor (label, Device.OnPlatform (Color.Black, Color.White, Color.White));
			ShadowEffect.SetRadius (label, 5);
			ShadowEffect.SetDistanceX (label, 5);
			ShadowEffect.SetDistanceY (label, 5);

			var button = new Button { Text = "Change Shadow Color", VerticalOptions = LayoutOptions.EndAndExpand };
			button.Clicked += OnButtonClicked;

			Content = new Grid { 
				Padding = new Thickness (0, 20, 0, 0),
				Children = {
					new Label {
						Text = "Effects Demo",
						FontAttributes = FontAttributes.Bold,
						HorizontalOptions = LayoutOptions.Center
					},
					label,
					button
				}
			};
		}
コード例 #21
0
ファイル: GridExample2.cs プロジェクト: mhalkovitch/Xamarim
		public GridExample2 ()
		{
			Grid grid = new Grid
			{
				VerticalOptions = LayoutOptions.FillAndExpand,
                //RowSpacing = 20,
                //ColumnSpacing = 20,
				RowDefinitions = 
				{
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = new GridLength(200, GridUnitType.Absolute) },
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto }
				},
				ColumnDefinitions = 
				{
					new ColumnDefinition { Width = GridLength.Auto },
					new ColumnDefinition { Width = GridLength.Auto },
					new ColumnDefinition { Width = GridLength.Auto }
				}
			};

			grid.Children.Add(new Label
				{
					Text = "I'm at 0,0",
                    FontSize = 30,
                    FontAttributes = FontAttributes.Bold,
				}, 0, 0);

			grid.Children.Add(new Label
				{
					Text = "Me? 1, 1",
                    FontSize = 30,
                    FontAttributes = FontAttributes.Bold,
					TextColor = Color.Black,
					BackgroundColor = Color.Lime
				}, 1, 1);

			grid.Children.Add(new Label
				{
					Text = "2, 2 here",
                    FontSize = 25,
                    FontAttributes = FontAttributes.Bold,
					TextColor = Color.White,
					BackgroundColor = Color.Red
				}, 2, 2);

			grid.Children.Add(new Label
				{
					Text = "I'm at 0,3",
                    FontSize = 30,
                    FontAttributes = FontAttributes.Bold
				}, 0, 3);


			// Padding on edges and a bit more for iPhone top status bar
			this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

			this.Content = grid;
		}
コード例 #22
0
        public CommitmentPage(Commitment commitment)
        {
            _commitment = commitment;
            BindingContext = commitment;

            var grid = new Grid() {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition(),
                    new RowDefinition(),
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) },
                }
            };

            var plannedLabel = new Label {
                Text = "I am"
            };
            plannedLabel.SetValue(Grid.RowProperty, 0);

            var plannedTextCell = new TextCell {

            };
            plannedTextCell.SetBinding(TextCell.TextProperty, "Status");
            grid.Children.Add(plannedLabel);

            Content = grid;
        }
コード例 #23
0
ファイル: IssuePage.cs プロジェクト: danielmahadi/JiraIt
        private void AddDescriptionSection(TableView table)
        {
            const int HEIGHT = 150;

            var descriptionSection = new TableSection ("Description");

            var descriptionGrid = new Grid {
                Padding = new Thickness(10),
                HeightRequest = HEIGHT,
                VerticalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }
                }
            };

            var descriptionEntry = new Editor {
                HeightRequest = HEIGHT
            };

            descriptionEntry.SetBinding (Editor.TextProperty, "Description");

            descriptionGrid.Children.Add (descriptionEntry, 0, 0);

            descriptionSection.Add (new ViewCell {
                View = descriptionGrid,
                Height = HEIGHT
            });

            table.Root.Add (descriptionSection);
        }
コード例 #24
0
        public GridLayoutPage()
        {
            var layout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding = 20
            };

            var grid = new Grid
            {
                RowSpacing = 50
            };

            grid.Children.Add(new Label { Text = "This" }, 0, 0); // Left, First element
            grid.Children.Add(new Label { Text = "text is" }, 1, 0); // Right, First element
            grid.Children.Add(new Label { Text = "in a" }, 0, 1); // Left, Second element
            grid.Children.Add(new Label { Text = "grid!" }, 1, 1); // Right, Second element

            var gridButton = new Button { Text = "So is this Button!\nClick me." };
            gridButton.Clicked += delegate
            {
                gridButton.Text = string.Format("Thanks! {0} clicks.", count++);
            };

            layout.Children.Add(grid);
            layout.Children.Add (gridButton);
            Content = layout;
        }
コード例 #25
0
			public BaseAsyncActivityTemplate() {
				// Adds the Content Presenter
				var contentPresenter = new ContentPresenter();
				Children.Add(contentPresenter, 0, 0);

				// The overlay that is presented when an Activity is Running
				var overlayGrid = new Grid { BackgroundColor = Color.FromHex("#CCCCCCCC") };
				overlayGrid.SetBinding(IsVisibleProperty, new TemplateBinding("IsActivityRunning"));

				var descriptionLabel = new Label { TextColor = Color.White };
				descriptionLabel.SetBinding(Label.TextProperty, new TemplateBinding("ActivityDescription"));

				var activityIndicator = new ActivityIndicator { Color = Color.White };
				activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, new TemplateBinding("IsActivityRunning"));

				// A layout to hold the Activity Indicator and Description
				var activityIndicatorLayout = new StackLayout {
					HorizontalOptions = LayoutOptions.Center,
					VerticalOptions = LayoutOptions.Center,
				};
				activityIndicatorLayout.Children.Add(activityIndicator);
				activityIndicatorLayout.Children.Add(descriptionLabel);

				// Finally add the indicator to the overlay and the overlay to the grid
				overlayGrid.Children.Add(activityIndicatorLayout, 0, 0);
				Children.Add(overlayGrid);
			}
コード例 #26
0
		public HomePageCS ()
		{
			var label = new Label {
				Text = "Label Shadow Effect",
				FontAttributes = FontAttributes.Bold,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
			label.Behaviors.Add (new EffectBehavior {
				Group = "Xamarin",
				Name = "LabelShadowEffect"
			});

			Content = new Grid { 
				Padding = new Thickness (0, 20, 0, 0),
				Children = {
					new Label {
						Text = "Effects Demo with a Behavior",
						FontAttributes = FontAttributes.Bold,
						HorizontalOptions = LayoutOptions.Center
					},
					label
				}
			};
		}
コード例 #27
0
        public HorizontalCell()
        {
            Grid grid = new Grid {
                Padding = new Thickness (5, 0, 5, 0),
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength (0.3, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength (0.7, GridUnitType.Star) },
                },
                RowDefinitions = {
                    new RowDefinition { Height = new GridLength (1, GridUnitType.Star) }
                }
            };

            var leftLabel = new Label {
                YAlign = TextAlignment.Center,
                XAlign = TextAlignment.Start,
            };

            var rightLabel = new Label {
                YAlign = TextAlignment.Center,
                XAlign = TextAlignment.End,
            };

            leftLabel.SetBinding<HorizontalCell> (Label.TextProperty, vm => vm.Text);
            leftLabel.SetBinding<HorizontalCell> (Label.TextColorProperty, vm => vm.TextColor);

            rightLabel.SetBinding<HorizontalCell> (Label.TextProperty, vm => vm.Detail);
            rightLabel.SetBinding<HorizontalCell> (Label.TextColorProperty, vm => vm.DetailColor);

            grid.Children.Add (leftLabel, 0, 0);
            grid.Children.Add (rightLabel, 1, 0);

            grid.BindingContext = this;
            View = grid;
        }
コード例 #28
0
        void MoveElementTo(View element, Layout <View> to)
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                if (Element.Parent is Layout <View> layout)
                {
                    var index = layout.Children.IndexOf(element);
                    layout.Children.Insert(index, to);

                    if (layout is Grid)
                    {
                        var row        = Grid.GetRow(element);
                        var rowSpan    = Grid.GetRowSpan(element);
                        var column     = Grid.GetColumn(element);
                        var columnSpan = Grid.GetColumnSpan(element);

                        Grid.SetRow(to, row);
                        Grid.SetRowSpan(to, rowSpan);
                        Grid.SetColumn(to, column);
                        Grid.SetColumnSpan(to, columnSpan);
                    }
                }
                else if (Element.Parent is ScrollView scrollView)
                {
                    scrollView.Content = to;
                }
                else if (Element.Parent is ContentView contentView)
                {
                    contentView.Content = to;
                }

                to.Children.Add(element);
            });
        }
コード例 #29
0
        public EditGateUser(GerenciarPortoesViewModel viewModel, GateDevices gateKey)
        {
            _viewModel = viewModel;
            Grid grid = new Grid();
            this.gateKey = gateKey;
            string name = gateKey.SKeyName;
            if (name.Length <= 4)
                name = gateKey.SkeyBleId;

            Title = "Editar " + name;

            removerUserGate.AnimateWithAction();
            removerUserGate.Clicked += removerUserGate_Clicked;


            grid.Children.AddVertical(listProfileDisponiveis);
            grid.Children.Add(removerUserGate);

            listProfileDisponiveis.ItemTapped += listProfileDisponiveis_ItemTapped;

            var absoluteLayout = new AbsoluteLayout();
            var background = new Image
            {
                Style = Styles.BackgroundImage
            };

            absoluteLayout.Children.Add(background, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);
            absoluteLayout.Children.Add(grid, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

            Content = absoluteLayout;
        }
コード例 #30
0
		public GridPage5 ()
		{
			Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0);
			var grid = new Grid ();

			grid.Children.Add (
				new Image() {
					Source= Device.OnPlatform("*****@*****.**", "icon.png", "")
				}, 0, 0);

			grid.Children.Add (new Label () { Text = "40", BackgroundColor = Color.Yellow}, 0, 1);
			grid.Children.Add (new Label () { Text = "Remainder", BackgroundColor = Color.Pink}, 0, 2);

			grid.RowDefinitions.Add (new RowDefinition () 
				{
					Height = new GridLength(1, GridUnitType.Auto)
				});

			grid.RowDefinitions.Add (new RowDefinition () 
				{
					Height = new GridLength(40, GridUnitType.Absolute)
				});

			grid.RowDefinitions.Add (new RowDefinition () 
				{
					Height = new GridLength(1, GridUnitType.Star)
				});

			Content = grid;
		}
コード例 #31
0
ファイル: DrawerLayout.cs プロジェクト: jsnmgpnty/Blogness2.0
		public BaseStackLayout GetBaseLayout()
		{
			var grid = new Grid
			{
				BackgroundColor = Color.White.ToFormsColor(),
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.FillAndExpand,
				RowDefinitions =
				{
					new RowDefinition { Height = GridLength.Auto }
				},
				ColumnDefinitions =
				{
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
				}
			};

			grid.Children.Add (Drawer, 0, 1, 0, 1);
			foreach (var layout in Layouts) 
			{
				grid.Children.Add (layout, 1, 4, 0, 1);
			}

			var baseLayout = new BaseStackLayout 
			{ 
				Children = { grid },
				Padding = new Thickness(0)
			};

			return baseLayout;
		}
コード例 #32
0
ファイル: LeagueCardView.cs プロジェクト: codnee/Scores-App
		public LeagueCardView(LeagueItem context)
		{
			BindingContext = context;

			Grid grid = new Grid {
				Padding = new Thickness(1,1,2,2),
				RowSpacing = 0,
				ColumnSpacing = 0,		
				BackgroundColor = Color.FromHex ("E3E3E3").MultiplyAlpha(0.5),
				RowDefinitions = {
					new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) }
				},
				ColumnDefinitions = {
					new ColumnDefinition { Width = new GridLength (4, GridUnitType.Absolute) },
					new ColumnDefinition {
						
					}
				}
			};

			grid.Children.Add (
				new FixtureCardStatusView ()
				,0,0);
			grid.Children.Add (new LeagueCardDetailsView (LeagueItem), 1, 0);

			var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 };
			tgr.Tapped += (sender, args) => {
				OnCardClicked?.Invoke (LeagueItem);
			};
			grid.GestureRecognizers.Add (tgr);
			Content = grid;
		}
コード例 #33
0
 public static void SetBackgroundSource(this Xamarin.Forms.Grid grid, string url, RenderContext context)
 {
     if (string.IsNullOrWhiteSpace(url))
     {
         return;
     }
     grid.SetBackgroundImage(new Uri(url));
 }
コード例 #34
0
        public void SetParent(object parentElement)
        {
            if (!(parentElement is XF.Grid parentGrid))
            {
                throw new ArgumentException($"Expected parent to be of type {typeof(XF.Grid).FullName} but it is of type {parentElement?.GetType().FullName}.", nameof(parentElement));
            }

            _parentGrid = parentGrid;
        }
コード例 #35
0
 //---------------------------------------------------------------------------------------------------------------
 public MultiColumnsCell(Type childCell, XamListView list)
 //---------------------------------------------------------------------------------------------------------------
 {
     _list      = list;
     _childCell = childCell;
     _grid      = new Xamarin.Forms.Grid
     {
         ColumnSpacing   = 0,
         VerticalOptions = LayoutOptions.Fill
     };
     View = _grid;
 }
コード例 #36
0
        public void Remove()
        {
            if (_parentGrid != null)
            {
                foreach (var child in _children)
                {
                    _parentGrid.Children.Remove(child);
                }

                _children.Clear();
                _parentGrid = null;
            }
        }
コード例 #37
0
 public GridHandler(NativeComponentRenderer renderer, XF.Grid gridControl) : base(renderer, gridControl)
 {
     GridControl = gridControl ?? throw new ArgumentNullException(nameof(gridControl));
 }
コード例 #38
0
        public ButtonCodePage()
        {
            _f9pButton.BackgroundImage = _f9pImage;

            Title       = "StateButtonCodePage";
            IsPresented = true;

            #region Local Elements
            hzOptionSegmentedControl.SelectIndex(3);
            hzOptionSegmentedControl.SegmentTapped += HzOptionSegmentedControl_SegmentTapped;

            vtOptionSegmentedControl.SelectIndex(3);
            vtOptionSegmentedControl.SegmentTapped += VtOptionSegmentedControl_SegmentTapped;


            var heightRequestSlider = new Slider(-1, 300, -1);
            heightRequestSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            heightRequestSlider.ValueChanged += HeightRequestSlider_ValueChanged;

            var fillSegmentedControl = new Forms9Patch.SegmentedControl
            {
                Segments =
                {
                    //new Forms9Patch.Segment("NONE"),
                    new Forms9Patch.Segment("TILE"),
                    new Forms9Patch.Segment("ASPECTFILL"),
                    new Forms9Patch.Segment("ASPECTFIT"),
                    new Forms9Patch.Segment("FILL")
                }
            };
            fillSegmentedControl.SelectIndex(3);
            fillSegmentedControl.SegmentTapped += FillSegmentedControl_SegmentTapped;

            Forms9Patch.SegmentedControl shapesSelector = new Forms9Patch.SegmentedControl
            {
                Segments =
                {
                    new Forms9Patch.Segment {
                        Text = Rectangle
                    },
                    new Forms9Patch.Segment {
                        Text = Square
                    },
                    new Forms9Patch.Segment {
                        Text = Circle
                    },
                    new Forms9Patch.Segment {
                        Text = Ellipse
                    },
                    new Forms9Patch.Segment {
                        Text = "OBROUND"
                    }
                }
            };
            shapesSelector.SelectIndex(0);
            shapesSelector.SegmentTapped += ShapesSelector_SegmentTapped;

            var outlineWidthSlider = new Xamarin.Forms.Slider
            {
                Minimum = 0,
                Maximum = 15,
                Value   = 2
            };
            outlineWidthSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1.0 / Forms9Patch.Display.Scale));
            outlineWidthSlider.ValueChanged += OutlineWidthSlider_ValueChanged;

            outlineRadiusSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            outlineRadiusSlider.ValueChanged += OutlineRadiusSlider_ValueChanged;

            var shapeAttributesSelector = new Forms9Patch.SegmentedControl
            {
                GroupToggleBehavior = Forms9Patch.GroupToggleBehavior.Multiselect,
                Segments            =
                {
                    new Forms9Patch.Segment("BACKGROUND"),
                    new Forms9Patch.Segment("OUTLINE"),
                    new Forms9Patch.Segment("SHADOW"),
                    new Forms9Patch.Segment("INVERTED")
                }
            };
            shapeAttributesSelector.SegmentTapped += ShapeAttributesSelector_SegmentTapped;

            var seg1 = new Forms9Patch.Segment("");
            var seg2 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redGridBox");
            var seg3 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.button");
            var seg4 = new Forms9Patch.Segment(null, new Forms9Patch.Image {
                Source = ImageSource.FromFile("cat.jpg"), Fill = Forms9Patch.Fill.AspectFit
            });
            var seg5 = new Forms9Patch.Segment(null, new Forms9Patch.Image {
                Source = ImageSource.FromFile("balloons.jpg"), Fill = Forms9Patch.Fill.AspectFit
            });
            var seg6 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.image");
            var seg7 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.redribbon");
            var seg8 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bubble");
            var seg9 = new Forms9Patch.Segment(null, "Forms9PatchDemo.Resources.bluebutton");

            var backgroundImageSelector = new Forms9Patch.SegmentedControl
            {
                HeightRequest           = 40,
                HasTightSpacing         = true,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TintIcon = false,
                Segments =
                {
                    seg1,
                    seg2,
                    seg3,
                    seg4,
                    seg5,
                    seg6,
                    seg7,
                    seg8,
                    seg9
                }
            };

            /*
             * backgroundImageSelector.Segments.Add(seg1);
             * backgroundImageSelector.Segments.Add(seg2);
             * backgroundImageSelector.Segments.Add(seg3);
             * backgroundImageSelector.Segments.Add(seg4);
             * backgroundImageSelector.Segments.Add(seg5);
             * backgroundImageSelector.Segments.Add(seg6);
             * backgroundImageSelector.Segments.Add(seg7);
             * backgroundImageSelector.Segments.Add(seg8);
             * backgroundImageSelector.Segments.Add(seg9);
             */
            backgroundImageSelector.SelectIndex(1);
            backgroundImageSelector.SegmentTapped += BackgroundImageSelector_SegmentTapped;

            capsInsetsTopSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsTopSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsLeftSlider.Effects.Add(capsInsetsLStepSizeEffect);
            capsInsetsLeftSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsRightSlider.Effects.Add(capsInsetsRStepSizeEffect);
            capsInsetsRightSlider.Rotation      = 180;
            capsInsetsRightSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsBottomSlider.Effects.Add(capsInsetsBStepSizeEffect);
            capsInsetsBottomSlider.ValueChanged += CapsInsetsSlider_ValueChanged;
            capsInsetsBottomSlider.Rotation      = 180;

            var outlineGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineWidth:"), 0, 0);
            outlineGrid.Children.Add(outlineWidthSlider, 0, 1);
            outlineGrid.Children.Add(new Forms9Patch.Label("Forms9Patch.Image.OutlineRadius:"), 1, 0);
            outlineGrid.Children.Add(outlineRadiusSlider, 1, 1);

            //pixelCapsSwitch.Toggled += PixelCapsSwitch_Toggled;

            var capsInsetsGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Top:"), 0, 0);
            capsInsetsGrid.Children.Add(capsInsetsTopSlider, 0, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Bottom:"), 0, 2);
            capsInsetsGrid.Children.Add(capsInsetsBottomSlider, 0, 3);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Left:"), 1, 0);
            capsInsetsGrid.Children.Add(capsInsetsLeftSlider, 1, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Right:"), 1, 2);
            capsInsetsGrid.Children.Add(capsInsetsRightSlider, 1, 3);

            capsUnitsSegmentedControl.SelectIndex(0);
            capsUnitsSegmentedControl.SegmentTapped += CapsUnitsSegmentedControl_SegmentTapped;
            antiAliasSwitch.Toggled += AntiAliasSwitch_Toggled;
            var capsInsetsAndAntiAliasGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };
            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("CapsInsets Units:"), 0, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(capsUnitsSegmentedControl, 0, 1);
            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("AntiAlias:"), 1, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(antiAliasSwitch, 1, 1);

            #endregion

            #region Content
            Master = new ContentPage
            {
                Title           = "Controls",
                BackgroundColor = Color.LightGray,
                Content         = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Padding  = new Thickness(10, 10, 20, 10),
                        Children =
                        {
                            new Forms9Patch.Label("HorizontalOptions:"),
                            hzOptionSegmentedControl,
                            new Forms9Patch.Label("VerticalOptions:"),
                            vtOptionSegmentedControl,
                            new Forms9Patch.Label("Fill / Aspect:"),
                            fillSegmentedControl,
                            new Forms9Patch.Label("ElementShape:"),
                            shapesSelector,
                            new Forms9Patch.Label("Shape attributes:"),
                            shapeAttributesSelector,
                            outlineGrid,

                            new Forms9Patch.Label("ImageSource:"),
                            backgroundImageSelector,

                            capsInsetsAndAntiAliasGrid,
                            capsInsetsGrid,

                            new Forms9Patch.Label("HeightRequest:"),
                            heightRequestSlider,


                            new Xamarin.Forms.Label {
                                Text = "Display.Scale=[" + Forms9Patch.Display.Scale + "]"
                            }
                        },
                    },
                }
            };
            Detail = new ContentPage
            {
                Title = "Images",

                Content = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new Forms9Patch.Label("Forms9Patch.Button:"),
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            _f9pButton,
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            new Forms9Patch.Label("Xamarin.Forms.Button:"),
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                            _xfButton,
                            new BoxView {
                                Color = Color.Black, HeightRequest = 1
                            },
                        }
                    }
                }
            };

            #endregion
        }
コード例 #39
0
        public void CreateTouchInterface()
        {
            this.Content = null;
            _touchPoints.Clear();

            if (this.VerticalTouchPoints <= 0 || this.HorizontalTouchPoints <= 0)
            {
                return;
            }

            var grid = new Grid
            {
                RowDefinitions    = new RowDefinitionCollection(),
                ColumnDefinitions = new ColumnDefinitionCollection(),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            for (int vIndex = 0; vIndex < this.VerticalTouchPoints; vIndex++)
            {
                grid.RowDefinitions.Add(new RowDefinition());
                if (vIndex < (this.VerticalTouchPoints - 1))
                {
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = 20
                    });
                }
            }
            for (int hIndex = 0; hIndex < this.HorizontalTouchPoints; hIndex++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                if (hIndex < (this.HorizontalTouchPoints - 1))
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = 20
                    });
                }
            }

            for (int vIndex = 0; vIndex < grid.RowDefinitions.Count; vIndex += 2)
            {
                for (int hIndex = 0; hIndex < grid.ColumnDefinitions.Count; hIndex += 2)
                {
                    var touchPoint = new GestureTouchPoint()
                    {
                        Text                    = this.TouchPointText,
                        HighlightText           = this.TouchPointHighlightText,
                        FontSize                = 30,
                        FontFamily              = string.IsNullOrEmpty(this.TouchPointFontFamily) ? "FontAwesome" : this.TouchPointFontFamily,
                        InputTransparent        = true,
                        TextColor               = this.TouchPointTextColor,
                        HighlightTextColor      = this.TouchPointHighlightTextColor,
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalOptions       = LayoutOptions.FillAndExpand,
                        VerticalOptions         = LayoutOptions.FillAndExpand
                    };

                    var tpValue = _touchPoints.Count + 1;
                    touchPoint.Value = tpValue.ToString();

                    touchPoint.SetValue(Grid.RowProperty, vIndex);
                    touchPoint.SetValue(Grid.ColumnProperty, hIndex);

                    grid.Children.Add(touchPoint);
                    _touchPoints.Add(touchPoint);
                }
            }
            this.Content = grid;
        }
コード例 #40
0
    void InitializeComponent()
    {
#if false
        Xamarin.Forms.Platform.Unity.XamlLoader.LoadXaml(
            this,
            @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ContentPage
  xmlns=""http://xamarin.com/schemas/2014/forms""
  xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
  x:Class=""Page1"">
  <Grid Padding=""16"">
    <Grid.RowDefinitions>
      <RowDefinition />
      <RowDefinition Height=""32""/>
    </Grid.RowDefinitions>

    <Grid Grid.Row=""1"">
      <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
      </Grid.ColumnDefinitions>
      <Label Grid.Column=""0"" Text=""{Binding Counter.Value}"" HorizontalTextAlignment=""Center"" FontSize=""20""/>
      <Button Grid.Column=""1"" Text=""Button"" Command=""{Binding InstantiateCommand}"" />
    </Grid>
  </Grid>
</ContentPage>
");
#else
        var grid = new Grid();
        grid.RowDefinitions.Add(new RowDefinition());
        grid.RowDefinitions.Add(new RowDefinition {
            Height = 32
        });
        grid.RowDefinitions.Add(new RowDefinition {
            Height = 32
        });
        grid.RowDefinitions.Add(new RowDefinition {
            Height = 32
        });

        var sv = new ScrollView();
        grid.Children.Add(sv, 0, 0);
        var gridsv = new Grid();
        for (int i = 0; i < 100; i++)
        {
            gridsv.RowDefinitions.Add(new RowDefinition {
                Height = 24
            });
            gridsv.Children.Add(new Label {
                Text = string.Format("Label {0}", i), FontSize = 20
            }, 0, i);
        }
        sv.Content = gridsv;

        {
            var grid2 = new Grid();
            grid2.ColumnDefinitions.Add(new ColumnDefinition());
            grid2.ColumnDefinitions.Add(new ColumnDefinition());

            grid.Children.Add(grid2, 0, 1);

            var label = new Label
            {
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Center,
                FontSize  = 20,
                TextColor = Xamarin.Forms.Color.White,
                Text      = "Default"
            };

            var entry = new Entry();

            label.SetBinding(Label.TextProperty, new Binding {
                Path = "Text", Source = entry
            });

            grid2.Children.Add(label, 0, 0);
            grid2.Children.Add(entry, 1, 0);
        }

        {
            var grid2 = new Grid();
            grid2.ColumnDefinitions.Add(new ColumnDefinition());
            grid2.ColumnDefinitions.Add(new ColumnDefinition());

            grid.Children.Add(grid2, 0, 2);

            var label = new Label
            {
                HorizontalTextAlignment = Xamarin.Forms.TextAlignment.Center,
                FontSize  = 20,
                TextColor = Xamarin.Forms.Color.White
            };
            label.SetBinding(Label.TextProperty, new Binding {
                Path = "Counter.Value"
            });
            var button = new Button
            {
                Text = "Button"
            };
            button.SetBinding(Button.CommandProperty, new Binding {
                Path = "InstantiateCommand"
            });
            button.Clicked += (s, e) =>
            {
                label.Scale = 5.0;
                label.ScaleTo(1.0);
            };

            grid2.Children.Add(label, 0, 0);
            grid2.Children.Add(button, 1, 0);
        }

        {
            var slider = new Slider();
            grid.Children.Add(slider, 0, 3);

            slider.Minimum = 0.0;
            slider.Maximum = 1.0;
            slider.Value   = 1.0;

            slider.SetBinding(Page.OpacityProperty, new Binding {
                Path = "Value", Source = slider
            });
        }

        this.Content = grid;
#endif
    }
コード例 #41
0
        static SearchView()
        {
            ImageSourceConverter    = new ByteArrayToImageSourceConverter();
            CollectionIconConverter = new BoolToCollectionIconImageConverter();
            EmptyStringConverter    = new EmptyStringToBoolConverter();
            DefaultSuggestionGroupHeaderTemplate = new DataTemplate(() =>
            {
                var viewcell                   = new ViewCell();
                Grid containingGrid            = new Grid();
                containingGrid.BackgroundColor = Color.FromHex("#4e4e4e");

                Label textLabel = new Label();
                textLabel.SetBinding(Label.TextProperty, "Key.DisplayName");
                textLabel.Margin                = new Thickness(4);
                textLabel.TextColor             = Color.White;
                textLabel.FontSize              = 14;
                textLabel.VerticalTextAlignment = TextAlignment.Center;
                containingGrid.Children.Add(textLabel);
                viewcell.View = containingGrid;
                return(viewcell);
            });
            DefaultSuggestionTemplate = new DataTemplate(() =>
            {
                var viewCell = new ViewCell();

                Grid containingGrid = new Grid();

                containingGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                containingGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Star
                });
                containingGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                Grid textStack            = new Grid();
                textStack.VerticalOptions = LayoutOptions.Center;
                textStack.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                textStack.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                Image imageView = new Image();
                imageView.SetBinding(Image.SourceProperty, nameof(SearchSuggestion.IsCollection), converter: CollectionIconConverter);
                imageView.WidthRequest    = 16;
                imageView.HeightRequest   = 16;
                imageView.Margin          = new Thickness(4);
                imageView.VerticalOptions = LayoutOptions.Center;

                Label titleLabel = new Label();
                titleLabel.SetBinding(Label.TextProperty, nameof(SearchSuggestion.DisplayTitle));
                titleLabel.VerticalOptions       = LayoutOptions.End;
                titleLabel.VerticalTextAlignment = TextAlignment.End;
                titleLabel.TextColor             = Color.Black;

                Label subtitleLabel = new Label();
                subtitleLabel.SetBinding(Label.TextProperty, nameof(SearchSuggestion.DisplaySubtitle));
                subtitleLabel.SetBinding(Label.IsVisibleProperty, nameof(SearchSuggestion.DisplaySubtitle), converter: EmptyStringConverter);
                subtitleLabel.VerticalOptions       = LayoutOptions.Start;
                subtitleLabel.VerticalTextAlignment = TextAlignment.Start;
                subtitleLabel.TextColor             = Color.Black;

                textStack.Children.Add(titleLabel);
                textStack.Children.Add(subtitleLabel);
                Grid.SetRow(titleLabel, 0);
                Grid.SetRow(subtitleLabel, 1);

                containingGrid.Children.Add(imageView);
                containingGrid.Children.Add(textStack);

                Grid.SetColumn(textStack, 1);
                Grid.SetColumn(imageView, 0);

                viewCell.View = containingGrid;
                return(viewCell);
            });
            DefaultResultTemplate = new DataTemplate(() =>
            {
                var viewCell = new ViewCell();

                Grid containingGrid    = new Grid();
                containingGrid.Padding = new Thickness(2, 4, 2, 4);

                containingGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                containingGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Star
                });
                containingGrid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                Grid textStack            = new Grid();
                textStack.VerticalOptions = LayoutOptions.Center;
                textStack.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                textStack.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });

                Image imageView = new Image();
                imageView.SetBinding(Image.SourceProperty, nameof(SearchResult.MarkerImageData), converter: ImageSourceConverter);
                imageView.WidthRequest    = 24;
                imageView.HeightRequest   = 24;
                imageView.Margin          = new Thickness(4);
                imageView.VerticalOptions = LayoutOptions.Center;

                Label titleLabel = new Label();
                titleLabel.SetBinding(Label.TextProperty, nameof(SearchResult.DisplayTitle));
                titleLabel.FontAttributes        = FontAttributes.Bold;
                titleLabel.VerticalOptions       = LayoutOptions.End;
                titleLabel.VerticalTextAlignment = TextAlignment.End;
                titleLabel.TextColor             = Color.Black;

                Label subtitleLabel = new Label();
                subtitleLabel.SetBinding(Label.TextProperty, nameof(SearchResult.DisplaySubtitle));
                subtitleLabel.SetBinding(Label.IsVisibleProperty, nameof(SearchResult.DisplaySubtitle), converter: EmptyStringConverter);
                subtitleLabel.TextColor             = Color.Black;
                subtitleLabel.VerticalOptions       = LayoutOptions.Start;
                subtitleLabel.VerticalTextAlignment = TextAlignment.Start;

                textStack.Children.Add(titleLabel);
                textStack.Children.Add(subtitleLabel);
                Grid.SetRow(titleLabel, 0);
                Grid.SetRow(subtitleLabel, 1);

                containingGrid.Children.Add(imageView);
                containingGrid.Children.Add(textStack);

                Grid.SetColumn(textStack, 1);
                Grid.SetColumn(imageView, 0);

                viewCell.View = containingGrid;
                return(viewCell);
            });

            string template =
                $@"<ControlTemplate xmlns=""http://xamarin.com/schemas/2014/forms"" xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml"" 
xmlns:esriTK=""clr-namespace:Esri.ArcGISRuntime.Toolkit.Xamarin.Forms"">
<Grid RowSpacing=""0"" ColumnSpacing=""0"" >
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width=""Auto"" />
    <ColumnDefinition Width=""*"" />
    <ColumnDefinition Width=""32"" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
    <RowDefinition Height=""Auto"" />
    <RowDefinition Height=""Auto"" />
    <RowDefinition Height=""Auto"" />
    </Grid.RowDefinitions>
    <Grid Grid.Row=""0"" Grid.ColumnSpan=""3"" BackgroundColor=""White"" />
    <ImageButton x:Name=""{nameof(PART_SourceSelectButton)}"" Grid.Column=""0"" WidthRequest=""32"" HeightRequest=""32"" Padding=""4"" BackgroundColor=""Transparent"" Margin=""0"" />
    <Entry x:Name=""{nameof(PART_Entry)}"" Grid.Column=""1"" Grid.Row=""0"" BackgroundColor=""White"" TextColor=""Black"" />
    <ImageButton x:Name=""{nameof(PART_CancelButton)}"" Grid.Column=""1"" HorizontalOptions=""End"" WidthRequest=""32"" HeightRequest=""32"" Padding=""4"" BackgroundColor=""Transparent"" />
    <ImageButton x:Name=""{nameof(PART_SearchButton)}"" Grid.Column=""2"" WidthRequest=""32"" HeightRequest=""32"" Padding=""4"" BackgroundColor=""Transparent"" />
    <ListView x:Name=""{nameof(PART_SuggestionsView)}"" Grid.Column=""0"" Grid.ColumnSpan=""3"" Grid.Row=""1"" Grid.RowSpan=""2"" HasUnevenRows=""true"" BackgroundColor=""White"" HeightRequest=""175"" />
    <ListView x:Name=""{nameof(PART_ResultView)}"" Grid.Column=""0"" Grid.ColumnSpan=""3"" Grid.Row=""1"" Grid.RowSpan=""1"" HasUnevenRows=""true"" BackgroundColor=""White"" HeightRequest=""200"" />
    <ListView x:Name=""{nameof(PART_SourcesView)}"" Grid.Column=""0"" Grid.ColumnSpan=""3"" Grid.Row=""1"" BackgroundColor=""White"" HeightRequest=""150"" />
    <Grid x:Name=""{nameof(PART_ResultContainer)}"" BackgroundColor=""White"" Grid.ColumnSpan=""3"" Grid.Row=""1"" Padding=""8""><Label x:Name=""{nameof(PART_ResultLabel)}"" HorizontalOptions=""Center"" VerticalOptions=""Center"" FontAttributes=""Bold"" /></Grid>
    <Grid x:Name=""{nameof(PART_RepeatButtonContainer)}"" BackgroundColor=""White"" Grid.Column=""0"" Grid.ColumnSpan=""3""  Grid.Row=""2"">
        <Button x:Name=""{nameof(PART_RepeatButton)}"" BackgroundColor=""#007AC2"" TextColor=""White"" CornerRadius=""0"" />
    </Grid>
</Grid>
</ControlTemplate>";

            DefaultControlTemplate = XForms.Extensions.LoadFromXaml(new ControlTemplate(), template);
        }
コード例 #42
0
        public CSharpGrid()
        {
            InitializeComponent();

            //定义网格行间隙为2,列间隙为2
            var grid = new Xamarin.Forms.Grid()
            {
                RowSpacing      = 2,
                ColumnSpacing   = 2,
                BackgroundColor = Color.FromHex("#A8A8A8")
            };

            /*
             * 定义一个5行,4列的表格
             */

            //设置行高为100
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = 100
            });
            //减去行高100后,按照1/10高度(此网格定义了10)计算
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            //减去行高100后,按照2/10高度(此网格定义了10)计算
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(2, GridUnitType.Star)
            });
            //减去行高100后,按照3/10高度(此网格定义了10)计算
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(3, GridUnitType.Star)
            });
            //减去行高100后,按照4/10高度(此网格定义了10)计算
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(4, GridUnitType.Star)
            });

            //按照1/5宽度(此网格定义了5)计算
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            //按照2/5宽度(此网格定义了5)计算
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(2, GridUnitType.Star)
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });

            //设置元素在网格的第0行0列
            var s_0_0 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_0_0.Children.Add(new Label()
            {
                Text = "第0行0列"
            });
            grid.Children.Add(s_0_0);
            Xamarin.Forms.Grid.SetRow(s_0_0, 0);
            Xamarin.Forms.Grid.SetColumn(s_0_0, 0);


            //设置元素在网格的第0行1列,跨2列
            var s_0_1 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_0_1.Children.Add(new Label()
            {
                Text = "第0行1列,跨2列"
            });
            grid.Children.Add(s_0_1);
            Xamarin.Forms.Grid.SetRow(s_0_1, 0);
            Xamarin.Forms.Grid.SetColumn(s_0_1, 1);
            Xamarin.Forms.Grid.SetColumnSpan(s_0_1, 2);

            var s_0_3 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_0_3.Children.Add(new Label()
            {
                Text = "第0行3列"
            });
            grid.Children.Add(s_0_3);
            Xamarin.Forms.Grid.SetRow(s_0_3, 0);
            Xamarin.Forms.Grid.SetColumn(s_0_3, 3);

            var s_1_0 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_1_0.Children.Add(new Label()
            {
                Text = "第1行0列"
            });
            grid.Children.Add(s_1_0);
            Xamarin.Forms.Grid.SetRow(s_1_0, 1);
            Xamarin.Forms.Grid.SetColumn(s_1_0, 0);

            var s_1_1 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_1_1.Children.Add(new Label()
            {
                Text = "第1行1列,跨3列"
            });
            grid.Children.Add(s_1_1);
            Xamarin.Forms.Grid.SetRow(s_1_1, 1);
            Xamarin.Forms.Grid.SetColumn(s_1_1, 1);
            Xamarin.Forms.Grid.SetColumnSpan(s_1_1, 3);

            var s_2_0 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_2_0.Children.Add(new Label()
            {
                Text = "第2行0列"
            });
            grid.Children.Add(s_2_0);
            Xamarin.Forms.Grid.SetRow(s_2_0, 2);
            Xamarin.Forms.Grid.SetColumn(s_2_0, 0);

            var s_2_1 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_2_1.Children.Add(new Label()
            {
                Text = "第2行1列"
            });
            grid.Children.Add(s_2_1);
            Xamarin.Forms.Grid.SetRow(s_2_1, 2);
            Xamarin.Forms.Grid.SetColumn(s_2_1, 1);

            var s_2_2 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_2_2.Children.Add(new Label()
            {
                Text = "第2行2列"
            });
            grid.Children.Add(s_2_2);
            Xamarin.Forms.Grid.SetRow(s_2_2, 2);
            Xamarin.Forms.Grid.SetColumn(s_2_2, 2);

            var s_2_3 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_2_3.Children.Add(new Label()
            {
                Text = "第2行2列"
            });
            grid.Children.Add(s_2_3);
            Xamarin.Forms.Grid.SetRow(s_2_3, 2);
            Xamarin.Forms.Grid.SetColumn(s_2_3, 3);

            var s_3_0 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_3_0.Children.Add(new Label()
            {
                Text = "第3行0列"
            });
            grid.Children.Add(s_3_0);
            Xamarin.Forms.Grid.SetRow(s_3_0, 3);
            Xamarin.Forms.Grid.SetColumn(s_3_0, 0);

            var s_3_1 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_3_1.Children.Add(new Label()
            {
                Text = "第3行1列"
            });
            grid.Children.Add(s_3_1);
            Xamarin.Forms.Grid.SetRow(s_3_1, 3);
            Xamarin.Forms.Grid.SetColumn(s_3_1, 1);

            //第3行2列,跨2行
            var s_3_2 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_3_2.Children.Add(new Label()
            {
                Text = "第3行2列,跨2行"
            });
            grid.Children.Add(s_3_2);
            Xamarin.Forms.Grid.SetRow(s_3_2, 3);
            Xamarin.Forms.Grid.SetColumn(s_3_2, 2);
            Xamarin.Forms.Grid.SetRowSpan(s_3_2, 2);

            var s_3_3 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_3_3.Children.Add(new Label()
            {
                Text = "第3行3列"
            });
            grid.Children.Add(s_3_3);
            Xamarin.Forms.Grid.SetRow(s_3_3, 3);
            Xamarin.Forms.Grid.SetColumn(s_3_3, 3);


            var s_4_0 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_4_0.Children.Add(new Label()
            {
                Text = "第4行0列"
            });
            grid.Children.Add(s_4_0);
            Xamarin.Forms.Grid.SetRow(s_4_0, 4);
            Xamarin.Forms.Grid.SetColumn(s_4_0, 0);

            var s_4_1 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_4_1.Children.Add(new Label()
            {
                Text = "第4行1列"
            });
            grid.Children.Add(s_4_1);
            Xamarin.Forms.Grid.SetRow(s_4_1, 4);
            Xamarin.Forms.Grid.SetColumn(s_4_1, 1);

            var s_4_3 = new StackLayout()
            {
                BackgroundColor = Color.FromHex("#91e2f4")
            };

            s_4_3.Children.Add(new Label()
            {
                Text = "第4行3列"
            });
            grid.Children.Add(s_4_3);
            Xamarin.Forms.Grid.SetRow(s_4_3, 4);
            Xamarin.Forms.Grid.SetColumn(s_4_3, 3);


            Content = grid;
        }
コード例 #43
0
        void SetContent()
        {
            View content = null;

            if (_layoutTypeControl.SelectedSegments[0].Text == "StackLayout")
            {
                _grid?.Children.Clear();
                if (_stack == null)
                {
                    _stack = new Xamarin.Forms.StackLayout
                    {
                        BackgroundColor = Color.LightBlue,
                        Padding         = 0,
                        Margin          = 0,
                        Spacing         = 10,
                    };
                    var stackListener = FormsGestures.Listener.For(_stack);
                    SetupTouchEvents(stackListener);
                }
                _stack.Children.Add(_boxView);
                _stack.Children.Add(_slider);
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Content in ScrollView"
                        },
                        _inScrollViewSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Long Press Enabled"
                        },
                        _longPressEnabledSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Dark Background"
                        },
                        _darkBackgroundSwitch,
                    }
                });
                _stack.Children.Add(new Xamarin.Forms.StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        new Xamarin.Forms.Label {
                            Text = "Page Padding"
                        },
                        _pagePadding,
                    }
                });
                _stack.Children.Add(_f9pButton);
                _stack.Children.Add(_xfButton);
                _stack.Children.Add(_layoutTypeControl);
                _stack.Children.Add(_touchType1);
                _stack.Children.Add(_touchType2);

                content = _stack;
            }
            else
            {
                _stack?.Children.Clear();
                if (_grid == null)
                {
                    _grid = new Xamarin.Forms.Grid
                    {
                        BackgroundColor = Color.LightGreen,
                        RowDefinitions  = new RowDefinitionCollection
                        {
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                            new RowDefinition {
                                Height = 40
                            },
                        },
                        ColumnDefinitions = new ColumnDefinitionCollection
                        {
                            new ColumnDefinition {
                                Width = new GridLength(2, GridUnitType.Star)
                            },
                            new ColumnDefinition {
                                Width = GridLength.Star
                            }
                        }
                    };
                    var gridListener = FormsGestures.Listener.For(_grid);
                    SetupTouchEvents(gridListener);
                }
                int row = 0;
                _grid.Children.Add(_boxView, 0, 2, row, ++row);
                _grid.Children.Add(_slider, 0, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Content in ScrollView"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_inScrollViewSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Long Press Enabled"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_longPressEnabledSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Dark Background"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_darkBackgroundSwitch, 1, 2, row, ++row);
                _grid.Children.Add(new Xamarin.Forms.Label {
                    Text = "Page Padding"
                }, 0, 1, row, row + 1);
                _grid.Children.Add(_pagePadding, 1, 2, row, ++row);
                _grid.Children.Add(_f9pButton, 0, 2, row, ++row);
                _grid.Children.Add(_xfButton, 0, 2, row, ++row);
                _grid.Children.Add(_layoutTypeControl, 0, 2, row, ++row);
                _grid.Children.Add(_touchType1, 0, 2, row, ++row);
                _grid.Children.Add(_touchType2, 0, 2, row, ++row);
                content = _grid;
            }
            if (_inScrollViewSwitch.IsToggled)
            {
                scrollView.Content = content;
            }
            else
            {
                Content = content;
            }
        }
コード例 #44
0
ファイル: XTitleBaseViewCell.cs プロジェクト: pav0n/XControls
        public void FormLayout(forms.View v)
        {
            this.v      = v;
            titleColumn = new forms.ColumnDefinition()
            {
                Width = titleColumnWidth
            };
            var formLayout = new forms.Grid()
            {
                RowDefinitions =
                {
                    new forms.RowDefinition()
                    {
                        Height = new forms.GridLength(1, forms.GridUnitType.Star)
                    },
                    new forms.RowDefinition()
                    {
                        Height = new forms.GridLength(1, forms.GridUnitType.Auto)
                    }
                },

                ColumnDefinitions =
                {
                    titleColumn,
                    new forms.ColumnDefinition {
                        Width = new forms.GridLength(1, forms.GridUnitType.Star)
                    },
                    new forms.ColumnDefinition {
                        Width = new forms.GridLength(1, forms.GridUnitType.Auto)
                    }
                },
                Margin     = new forms.Thickness(12, 0.5, 9, 0),
                RowSpacing = 0.5
            };

            titleColumn.Width = string.IsNullOrEmpty(Title) ? 0 : titleColumnWidth;
            label             = new forms.Label
            {
                VerticalOptions   = forms.LayoutOptions.CenterAndExpand,
                Text              = Title,
                FontSize          = TitleFontSize,
                LineBreakMode     = forms.LineBreakMode.TailTruncation,
                TextColor         = TitleColor,
                HorizontalOptions = forms.LayoutOptions.FillAndExpand,
            };

            detail = new forms.Label
            {
                VerticalOptions   = forms.LayoutOptions.FillAndExpand,
                Text              = Detail,
                FontSize          = forms.Device.GetNamedSize(forms.NamedSize.Micro, typeof(forms.Label)),
                LineBreakMode     = forms.LineBreakMode.TailTruncation,
                TextColor         = DetailColor,
                HorizontalOptions = InputHorizontalOptions
            };
            extraDetail = new forms.Label
            {
                VerticalOptions = forms.LayoutOptions.CenterAndExpand,
                Text            = ExtraDetail,
                FontSize        = forms.Device.GetNamedSize(forms.NamedSize.Micro, typeof(forms.Label)),
                LineBreakMode   = forms.LineBreakMode.TailTruncation,
                TextColor       = ExtraDetailColor
            };
            v.HorizontalOptions = InputHorizontalOptions;
            v.VerticalOptions   = forms.LayoutOptions.CenterAndExpand;
            formLayout.Children.Add(label, 0, 0);
            formLayout.Children.Add(v, 1, 0);

            formLayout.Children.Add(detail, 1, 1);
            formLayout.Children.Add(extraDetail, 2, 0);
            forms.Grid.SetRowSpan(label, 2);
            forms.Grid.SetRowSpan(extraDetail, 2);
            Tapped += FormEntryCell_Tapped;
            View    = formLayout;
            //formLayout.ForceLayout();
        }
コード例 #45
0
        public LayoutCodePage()
        {
            hzOptionSegmentedControl.SelectIndex(3);
            hzOptionSegmentedControl.SegmentTapped += SetHzLayoutOptions;

            vtOptionSegmentedControl.SelectIndex(3);
            vtOptionSegmentedControl.SegmentTapped += SetVtLayoutOptions;

            heightRequestSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            heightRequestSlider.ValueChanged += SetHeightRequest;

            fillSegmentedControl.SelectIndex(3);
            fillSegmentedControl.SegmentTapped += SetFill;

            shapesSelector.SelectIndex(0);
            shapesSelector.SegmentTapped += SetShape;

            outlineWidthSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1.0 / Forms9Patch.Display.Scale));
            outlineWidthSlider.ValueChanged += SetOutlineWidth;

            outlineRadiusSlider.Effects.Add(new Forms9Patch.SliderStepSizeEffect(1));
            outlineRadiusSlider.ValueChanged += SetOutlineRadius;

            shapeAttributesSelector.SegmentTapped += SetShapeAttributes;

            backgroundImageSelector.SelectIndex(1);
            backgroundImageSelector.SegmentTapped += SetBackgroundImage;

            capsInsetsTopSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsTopSlider.ValueChanged += SetCapsInsets;
            capsInsetsLeftSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsLeftSlider.ValueChanged += SetCapsInsets;
            capsInsetsRightSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsRightSlider.Rotation      = 180;
            capsInsetsRightSlider.ValueChanged += SetCapsInsets;
            capsInsetsBottomSlider.Effects.Add(capsInsetsTStepSizeEffect);
            capsInsetsBottomSlider.ValueChanged += SetCapsInsets;
            capsInsetsBottomSlider.Rotation      = 180;

            var outlineGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };

            outlineGrid.Children.Add(new Forms9Patch.Label("OutlineWidth:"), 0, 0);
            outlineGrid.Children.Add(outlineWidthSlider, 0, 1);
            outlineGrid.Children.Add(new Forms9Patch.Label("OutlineRadius:"), 1, 0);
            outlineGrid.Children.Add(outlineRadiusSlider, 1, 1);

            var capsInsetsGrid = new Xamarin.Forms.Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };

            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Top:"), 0, 0);
            capsInsetsGrid.Children.Add(capsInsetsTopSlider, 0, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Bottom:"), 0, 2);
            capsInsetsGrid.Children.Add(capsInsetsBottomSlider, 0, 3);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Left:"), 1, 0);
            capsInsetsGrid.Children.Add(capsInsetsLeftSlider, 1, 1);
            capsInsetsGrid.Children.Add(new Forms9Patch.Label("CapsInsets.Right:"), 1, 2);
            capsInsetsGrid.Children.Add(capsInsetsRightSlider, 1, 3);

            capsUnitsSegmentedControl.SelectIndex(0);
            capsUnitsSegmentedControl.SegmentTapped += SetCapsUnits;
            antiAliasSwitch.Toggled += SetAntiAlias;
            var capsInsetsAndAntiAliasGrid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                },
            };

            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("CapsInsets Units:"), 0, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(capsUnitsSegmentedControl, 0, 1);
            capsInsetsAndAntiAliasGrid.Children.Add(new Forms9Patch.Label("AntiAlias:"), 1, 0);
            capsInsetsAndAntiAliasGrid.Children.Add(antiAliasSwitch, 1, 1);



            var layoutTypeSegmentedController = new Forms9Patch.SegmentedControl
            {
                Segments =
                {
                    new Forms9Patch.Segment("ABSOLUTE"),
                    new Forms9Patch.Segment("FRAME"),
                    new Forms9Patch.Segment("GRID"),
                    new Forms9Patch.Segment("RELATIVE"),
                    new Forms9Patch.Segment("STACK")
                }
            };

            layoutTypeSegmentedController.SegmentTapped += (sender, e) =>
            {
                Layout layout = null;
                switch (e.Segment.Text)
                {
                case "ABSOLUTE": layout = GenerateAbsoluteLayout(); break;

                case "FRAME": layout = GenerateFrame(); break;

                case "GRID": layout = GenerateGrid(); break;

                case "RELATIVE": layout = GenerateRelativeLayout(); break;

                case "STACK": layout = GenerateStackLayout(); break;
                }
                ((ContentPage)Detail).Content = layout;
                SetLayoutProperties();
                ((ContentPage)Detail).Title = e.Segment.Text;
            };

            //Padding = new Thickness(20, 20, 0, 20);
            Master = new ContentPage
            {
                Title           = "Layout Settings",
                BackgroundColor = Color.LightGray,
                Content         = new ScrollView
                {
                    Content = new StackLayout
                    {
                        Padding  = 20,
                        Children =
                        {
                            new Forms9Patch.Label("Layout type:"),
                            layoutTypeSegmentedController,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            new Forms9Patch.Label("Xamarin.Forms.VisualElement.HorizontalOptions (Alignment):"),
                            hzOptionSegmentedControl,
                            new Forms9Patch.Label("Xamarin.Forms.VisualElement.VerticalOptions (Alignment):"),
                            vtOptionSegmentedControl,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            new Forms9Patch.Label("Forms9Patch.Image.Fill:"),
                            fillSegmentedControl,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            new Forms9Patch.Label("Forms9Patch.Image.ElementShape:"),
                            shapesSelector,
                            new Forms9Patch.Label("Shape attributes (some value vs. default value)"),
                            shapeAttributesSelector,
                            outlineGrid,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            new Forms9Patch.Label("Forms9Patch.Image.Source:"),
                            backgroundImageSelector,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            capsInsetsAndAntiAliasGrid,
                            capsInsetsGrid,

                            new BoxView {
                                HeightRequest = 1,                                                              BackgroundColor  = Color.Black
                            },

                            new Forms9Patch.Label("Xamarin.Forms.VisualElement.HeightRequest:"),
                            heightRequestSlider,
                            new Xamarin.Forms.Label {
                                Text = "Display.Scale=[" + Forms9Patch.Display.Scale + "]"
                            }
                        },
                    },
                }
            };
            Detail = new ContentPage
            {
                Title   = "ABSOLUTE",
                Content = GenerateAbsoluteLayout()
            };
            SetLayoutProperties();

            IsPresented    = true;
            MasterBehavior = MasterBehavior.Default;
        }
コード例 #46
0
        public void FormLayout(forms.View v)
        {
            var formLayout = new forms.Grid()
            {
                RowDefinitions =
                {
                    new forms.RowDefinition()
                    {
                        Height = new forms.GridLength(1, forms.GridUnitType.Star)
                    },
                    new forms.RowDefinition()
                    {
                        Height = new forms.GridLength(1, forms.GridUnitType.Auto)
                    }
                },

                ColumnDefinitions =
                {
                    new forms.ColumnDefinition {
                        Width = new forms.GridLength(1, forms.GridUnitType.Auto)
                    },
                    new forms.ColumnDefinition {
                        Width = new forms.GridLength(1, forms.GridUnitType.Star)
                    },
                    new forms.ColumnDefinition {
                        Width = new forms.GridLength(1, forms.GridUnitType.Auto)
                    }
                },
                Margin     = new forms.Thickness(12, 1, 9, 0),
                RowSpacing = 0.5
            };

            icon = new forms.Image()
            {
                VerticalOptions = forms.LayoutOptions.Center,
                Opacity         = 0.5
            };
            icon.WidthRequest = Icon == null ? 0 : 30;

            detail = new forms.Label
            {
                VerticalOptions   = forms.LayoutOptions.FillAndExpand,
                Text              = Detail,
                FontSize          = forms.Device.GetNamedSize(forms.NamedSize.Micro, typeof(forms.Label)),
                LineBreakMode     = forms.LineBreakMode.TailTruncation,
                TextColor         = DetailColor,
                HorizontalOptions = InputHorizontalOptions
            };
            extraDetail = new forms.Label
            {
                VerticalOptions = forms.LayoutOptions.FillAndExpand,
                Text            = ExtraDetail,
                FontSize        = forms.Device.GetNamedSize(forms.NamedSize.Micro, typeof(forms.Label)),
                LineBreakMode   = forms.LineBreakMode.TailTruncation,
                TextColor       = ExtraDetailColor
            };
            v.HorizontalOptions = InputHorizontalOptions;
            v.VerticalOptions   = forms.LayoutOptions.CenterAndExpand;
            formLayout.Children.Add(icon, 0, 0);
            formLayout.Children.Add(v, 1, 0);
            formLayout.Children.Add(detail, 1, 1);
            formLayout.Children.Add(extraDetail, 2, 0);
            forms.Grid.SetRowSpan(icon, 2);
            forms.Grid.SetRowSpan(extraDetail, 2);
            Tapped += FormEntryCell_Tapped;
            View    = formLayout;
        }
コード例 #47
0
 public GridListThing(Xamarin.Forms.Grid grid)
 {
     _grid = grid;
 }