Beispiel #1
0
		protected override void Init()
		{
			var ts = new TableSection();
			var tr = new TableRoot { ts };
			var tv = new TableView(tr);

			var sc = new SwitchCell
			{
				Text = "Toggle switch; nothing should crash"
			};

			var button = new Button();
			button.SetBinding(Button.TextProperty, new Binding("On", source: sc));

			var vc = new ViewCell
			{
				View = button
			};
			vc.SetBinding(IsEnabledProperty, new Binding("On", source: sc));

			ts.Add(sc);
			ts.Add(vc);

			Content = tv;
		}
Beispiel #2
0
		protected override void Init ()
		{
			var layout = new StackLayout ();
			var button = new Button { Text = "Click" };
			var tablesection = new TableSection { Title = "Switches" };
			var tableview = new TableView { Intent = TableIntent.Form, Root = new TableRoot { tablesection } };
			var viewcell1 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Switch 1", HorizontalOptions = LayoutOptions.StartAndExpand },
						new Switch { AutomationId = "switch1", HorizontalOptions = LayoutOptions.End, IsToggled = true }
					}
				}
			};
			var viewcell2 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						new Label { Text = "Switch 2", HorizontalOptions = LayoutOptions.StartAndExpand },
						new Switch { AutomationId = "switch2", HorizontalOptions = LayoutOptions.End, IsToggled = true }
					}
				}
			};
			Label label = new Label { Text = "Switch 3", HorizontalOptions = LayoutOptions.StartAndExpand };
			Switch switchie = new Switch { AutomationId = "switch3", HorizontalOptions = LayoutOptions.End, IsToggled = true, IsEnabled = false };
			switchie.Toggled += (sender, e) => {
				label.Text = "FAIL";
			};
			var viewcell3 = new ViewCell {
				View = new StackLayout {
					HorizontalOptions = LayoutOptions.FillAndExpand,
					Orientation = StackOrientation.Horizontal,
					Children = {
						label,
						switchie,
					}
				}
			};

			tablesection.Add (viewcell1);
			tablesection.Add (viewcell2);
			tablesection.Add (viewcell3);

			button.Clicked += (sender, e) => {
				if (_removed)
					tablesection.Insert (1, viewcell2);
				else
					tablesection.Remove (viewcell2);

				_removed = !_removed;
			};

			layout.Children.Add (button);
			layout.Children.Add (tableview);

			Content = layout;
		}
Beispiel #3
0
		public void SetViewBeforeBindingContext ()
		{
			var context = new object ();
			var view = new View ();
			var cell = new ViewCell ();
			cell.View = view;
			cell.BindingContext = context;
			Assert.AreSame (context, view.BindingContext);
		}
			public ViewCellContainer(Context context, IVisualElementRenderer view, ViewCell viewCell, View parent, BindableProperty unevenRows, BindableProperty rowHeight) : base(context)
			{
				_view = view;
				_parent = parent;
				_unevenRows = unevenRows;
				_rowHeight = rowHeight;
				_viewCell = viewCell;
				AddView(view.ViewGroup);
				UpdateIsEnabled();
			}
 private void UpdateCell (ViewCell cell)
 {
     if (this.viewCell != null) {
         //this.viewCell.SendDisappearing ();
         this.viewCell.PropertyChanged -= new PropertyChangedEventHandler (this.HandlePropertyChanged);
     }
     this.viewCell = cell;
     this.viewCell.PropertyChanged += new PropertyChangedEventHandler (this.HandlePropertyChanged);
     //this.viewCell.SendAppearing ();
     this.UpdateView ();
 }
Beispiel #6
0
			protected override Cell CreateDefault (object item)
			{
				var cell = new ViewCell ();

				cell.View = new StackLayout {
					BackgroundColor = Color.Green,
					Children = {
						new Label { Text = "Success" }
					}
				};

				return cell;
			}
			public void Update(ViewCell cell)
			{
				Performance.Start();

				var renderer = GetChildAt(0) as IVisualElementRenderer;
				var viewHandlerType = Registrar.Registered.GetHandlerType(cell.View.GetType()) ?? typeof(Platform.DefaultRenderer);
				if (renderer != null && renderer.GetType() == viewHandlerType)
				{
					Performance.Start("Reuse");
					_viewCell = cell;

					cell.View.DisableLayout = true;
					foreach (VisualElement c in cell.View.Descendants())
						c.DisableLayout = true;

					Performance.Start("Reuse.SetElement");
					renderer.SetElement(cell.View);
					Performance.Stop("Reuse.SetElement");

					Platform.SetRenderer(cell.View, _view);

					cell.View.DisableLayout = false;
					foreach (VisualElement c in cell.View.Descendants())
						c.DisableLayout = false;

					var viewAsLayout = cell.View as Layout;
					if (viewAsLayout != null)
						viewAsLayout.ForceLayout();

					Invalidate();

					Performance.Stop("Reuse");
					Performance.Stop();
					return;
				}

				RemoveView(_view.ViewGroup);
				Platform.SetRenderer(_viewCell.View, null);
				_viewCell.View.IsPlatformEnabled = false;
				_view.ViewGroup.Dispose();

				_viewCell = cell;
				_view = Platform.CreateRenderer(_viewCell.View);

				Platform.SetRenderer(_viewCell.View, _view);
				AddView(_view.ViewGroup);

				UpdateIsEnabled();

				Performance.Stop();
			}
Beispiel #8
0
		public void SetParentBeforeView ()
		{
			var parent = new View { Platform = new UnitPlatform () };
			var child = new View ();
			var viewCell = new ViewCell ();

			Assert.Null (viewCell.View);
			Assert.DoesNotThrow (() => viewCell.Parent = parent);

			viewCell.View = child;
			Assert.AreSame (parent, viewCell.Parent);
			Assert.AreSame (viewCell, child.Parent);
			Assert.AreSame (parent.Platform, child.Platform);
		}
Beispiel #9
0
		//issue 550
		public void SetBindingContextBeforeParent ()
		{
			var parent = new View { 
				Platform = new UnitPlatform (),
				BindingContext = new object (),
			};

			var itemcontext = new object ();
			var cell = new ViewCell { View = new Label ()};
			cell.BindingContext = itemcontext;
			cell.Parent = parent;

			Assert.AreSame (itemcontext, cell.View.BindingContext);
		}
		public void ParentsViewCells ()
		{
			ViewCell viewCell = new ViewCell { View = new Label () };
			var table = new TableView {
				Platform = new UnitPlatform (),
				Root = new TableRoot {
					new TableSection {
						viewCell
					}
				}
			};

			Assert.AreEqual (table, viewCell.Parent);
			Assert.AreEqual (viewCell, viewCell.View.Parent);
			Assert.AreEqual (table.Platform, viewCell.View.Platform);
		}
		public void ParentsAddedViewCells ()
		{
			var viewCell = new ViewCell { View = new Label () };
			var section = new TableSection (); 
			var table = new TableView {
				Platform = new UnitPlatform (),
				Root = new TableRoot {
					section
				}
			};

			section.Add (viewCell);

			Assert.AreEqual (table, viewCell.Parent);
			Assert.AreEqual (viewCell, viewCell.View.Parent);
			Assert.AreEqual (table.Platform, viewCell.View.Platform);
		}
Beispiel #12
0
		public Issue1777 ()
		{
			StackLayout stackLayout = new StackLayout();
			Content = stackLayout;

			TableView tableView = new TableView();
			stackLayout.Children.Add( tableView);

			TableRoot tableRoot = new TableRoot();
			tableView.Root = tableRoot;

			TableSection tableSection = new TableSection("Table");
			tableRoot.Add(tableSection);

			ViewCell viewCell = new ViewCell ();
			tableSection.Add (viewCell);

			ContentView contentView = new ContentView ();
			contentView.HorizontalOptions = LayoutOptions.FillAndExpand;
			viewCell.View = contentView;

			_pickerTable = new Picker ();
			_pickerTable.HorizontalOptions = LayoutOptions.FillAndExpand;
			contentView.Content = _pickerTable;

			Label label = new Label ();
			label.Text = "Normal";
			stackLayout.Children.Add (label);

			_pickerNormal = new Picker ();
			stackLayout.Children.Add (_pickerNormal);

			Button button = new Button ();
			button.Clicked += button_Clicked;
			button.Text = "do magic";
			stackLayout.Children.Add (button);

			//button_Clicked(button, EventArgs.Empty);
			_pickerTable.SelectedIndex = 0;
			_pickerNormal.SelectedIndex = 0;
		}
Beispiel #13
0
	private MoveCellHelper CreateMoveCellHelper(float startTime, ViewCell go, List<Pos2D> list)
	{
		var ret = new MoveCellHelper();
		ret.startTime = startTime;
		ret.endTime = (list.Count - 1) * moveUnitLengthTime + startTime;
		ret.cellGo = go;
		foreach (var p in list)
		{
			ret.trajectory.Add(layout.Logic2View(p));
		}
		return ret;
	}
Beispiel #14
0
			void UpdateCell(ViewCell cell)
			{
				if (_viewCell != null)
					Device.BeginInvokeOnMainThread(_viewCell.SendDisappearing);

				_viewCell = cell;
				Device.BeginInvokeOnMainThread(_viewCell.SendAppearing);

				IVisualElementRenderer renderer;
				if (_rendererRef == null || !_rendererRef.TryGetTarget(out renderer))
					renderer = GetNewRenderer();
				else
				{
					if (renderer.Element != null && renderer == Platform.GetRenderer(renderer.Element))
						renderer.Element.ClearValue(Platform.RendererProperty);

					var type = Registrar.Registered.GetHandlerType(_viewCell.View.GetType());
					if (renderer.GetType() == type || (renderer is Platform.DefaultRenderer && type == null))
						renderer.SetElement(_viewCell.View);
					else
					{
						//when cells are getting reused the element could be already set to another cell
						//so we should dispose based on the renderer and not the renderer.Element
						var platform = renderer.Element.Platform as Platform;
						platform.DisposeRendererAndChildren(renderer);
						renderer = GetNewRenderer();
					}
				}

				Platform.SetRenderer(_viewCell.View, renderer);
			}
Beispiel #15
0
        private DataTemplate ListView_ItemTemplate()
        {
            ViewCell    vCell;
            StackLayout viewCellLayout;
            Grid        gridPrincipal;
            Frame       frameImage;
            Image       imagenItem;
            Label       labelTitle;
            Label       labelDescription;
            Label       labelDateCreated;

            DataTemplate dataTemplate = new DataTemplate(() =>
            {
                vCell          = new ViewCell();
                viewCellLayout = new StackLayout();

                gridPrincipal = new Grid();

                frameImage       = new Frame();
                imagenItem       = new Image();
                labelTitle       = new Label();
                labelDescription = new Label();
                labelDateCreated = new Label();

                // viewCell properties
                vCell.View = viewCellLayout;

                // Layout in viewCell
                viewCellLayout.Padding     = new Thickness(0, 0, 0, 0);
                viewCellLayout.Orientation = StackOrientation.Horizontal;
                viewCellLayout.Children.Add(gridPrincipal);
                viewCellLayout.HeightRequest     = 130;
                viewCellLayout.WidthRequest      = 50;
                viewCellLayout.HorizontalOptions = LayoutOptions.FillAndExpand;

                // "Grid" principal
                gridPrincipal.WidthRequest      = 200;
                gridPrincipal.HeightRequest     = 100;
                gridPrincipal.VerticalOptions   = LayoutOptions.StartAndExpand;
                gridPrincipal.HorizontalOptions = LayoutOptions.FillAndExpand;
                gridPrincipal.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(0.40, GridUnitType.Star)
                });
                gridPrincipal.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(0.60, GridUnitType.Star)
                });
                gridPrincipal.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(0.2, GridUnitType.Star)
                });
                gridPrincipal.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(0.6, GridUnitType.Star)
                });
                gridPrincipal.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(0.2, GridUnitType.Star)
                });

                // Frame to imageItem

                frameImage.CornerRadius      = 90;
                frameImage.Margin            = new Thickness(10, 5, 0, 5);
                frameImage.Padding           = new Thickness(0, 0, 0, 30);
                frameImage.IsClippedToBounds = true;
                frameImage.Content           = imagenItem;
                frameImage.HasShadow         = false;
                frameImage.WidthRequest      = 100;
                frameImage.HeightRequest     = 100;
                frameImage.HorizontalOptions = LayoutOptions.StartAndExpand;
                frameImage.VerticalOptions   = LayoutOptions.FillAndExpand;

                // ImageView to display in left site
                imagenItem.SetBinding(Image.SourceProperty, "ImageSource");
                imagenItem.WidthRequest      = 300;
                imagenItem.HeightRequest     = 100;
                imagenItem.HorizontalOptions = LayoutOptions.FillAndExpand;
                imagenItem.VerticalOptions   = LayoutOptions.FillAndExpand;

                // Title label
                labelTitle.SetBinding(Label.TextProperty, "Name");
                labelTitle.FontSize                = 17;
                labelTitle.VerticalOptions         = LayoutOptions.Center;
                labelTitle.HorizontalOptions       = LayoutOptions.FillAndExpand;
                labelTitle.HorizontalTextAlignment = TextAlignment.Start;
                labelTitle.TextColor               = Color.Black;
                labelTitle.Margin = new Thickness(0, 7, 0, 0);

                // Description label
                labelDescription.SetBinding(Label.TextProperty, "Description");
                labelDescription.FontSize                = 14;
                labelDescription.VerticalOptions         = LayoutOptions.Start;
                labelDescription.HorizontalOptions       = LayoutOptions.FillAndExpand;
                labelDescription.HorizontalTextAlignment = TextAlignment.Start;
                labelDescription.TextColor               = Color.FromRgb(100, 100, 100);
                labelDescription.Margin = new Thickness(0, 3, 0, 3);

                // DateCreated label
                labelDateCreated.SetBinding(Label.TextProperty, "DateCreated");
                labelDateCreated.FontSize          = 11;
                labelDateCreated.VerticalOptions   = LayoutOptions.Center;
                labelDateCreated.HorizontalOptions = LayoutOptions.End;
                labelDateCreated.TextColor         = Color.FromRgb(120, 120, 120);
                labelDateCreated.Margin            = new Thickness(0, 0, 5, 0);

                // Añadir contenido al grid
                gridPrincipal.Children.Add(frameImage, 0, 0);
                gridPrincipal.Children.Add(labelTitle, 1, 0);
                gridPrincipal.Children.Add(labelDescription, 1, 1);
                gridPrincipal.Children.Add(labelDateCreated, 2, 0);
                gridPrincipal.RowSpacing      = 5;
                gridPrincipal.ColumnSpacing   = 10;
                gridPrincipal.BackgroundColor = Color.White;
                Grid.SetRowSpan(frameImage, 2);

                // Refresh
                lView.IsPullToRefreshEnabled = false;
                lView.Refreshing            += RefreshlViewAsync;

                // Devuelve la Cell
                return(vCell);
            });

            return(dataTemplate);
        }
Beispiel #16
0
        public UrlImageViewCellListPage()
        {
            if (DeviceInfo.Platform == DevicePlatform.iOS && DeviceInfo.Idiom == DeviceIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new UriImageSource()
            {
                Uri = new Uri((string)obj)
            });

            var dataTemplate = new DataTemplate(() =>
            {
                var cell = new ViewCell();

                var image = new Image();
                image.SetBinding(Image.SourceProperty, new Binding("Image", converter: stringToImageSourceConverter));
                image.WidthRequest  = 160;
                image.HeightRequest = 160;

                var text = new Label();
                text.SetBinding(Label.TextProperty, new Binding("Text"));
                text.SetBinding(Label.TextColorProperty, new Binding("TextColor"));

                cell.View = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        image,
                        text
                    }
                };

                return(cell);
            });

            var albums = new string[25];

            for (int n = 0; n < albums.Length; n++)
            {
                albums[n] =
                    string.Format(
                        "https://raw.githubusercontent.com/xamarin/Xamarin.Forms/main/Microsoft.Maui.Controls.ControlGallery/coffee.png?ticks={0}", n);
            }

            var label = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView
            {
                AutomationId = CellTypeList.CellTestContainerId,
                ItemsSource  = Enumerable.Range(0, albums.Length).Select(i => new UrlImageViewCellListPageModel
                {
                    Text      = "Text " + i,
                    TextColor = i % 2 == 0 ? Colors.Red : Colors.Blue,
                    Image     = albums[i]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }
Beispiel #17
0
            public void Update(ViewCell cell)
            {
                Performance.Start(out string reference);
                var renderer        = GetChildAt(0) as IVisualElementRenderer;
                var viewHandlerType = Registrar.Registered.GetHandlerTypeForObject(cell.View) ?? typeof(Platform.DefaultRenderer);
                var reflectableType = renderer as System.Reflection.IReflectableType;
                var rendererType    = reflectableType != null?reflectableType.GetTypeInfo().AsType() : (renderer != null ? renderer.GetType() : typeof(System.Object));

                if (renderer != null && rendererType == viewHandlerType)
                {
                    Performance.Start(reference, "Reuse");
                    _viewCell = cell;

                    cell.View.DisableLayout = true;
                    foreach (VisualElement c in cell.View.Descendants())
                    {
                        c.DisableLayout = true;
                    }

                    Performance.Start(reference, "Reuse.SetElement");
                    renderer.SetElement(cell.View);
                    Performance.Stop(reference, "Reuse.SetElement");

                    Platform.SetRenderer(cell.View, _view);

                    cell.View.DisableLayout = false;
                    foreach (VisualElement c in cell.View.Descendants())
                    {
                        c.DisableLayout = false;
                    }

                    var viewAsLayout = cell.View as Layout;
                    if (viewAsLayout != null)
                    {
                        viewAsLayout.ForceLayout();
                    }

                    Invalidate();

                    Performance.Stop(reference, "Reuse");
                    Performance.Stop(reference);
                    return;
                }

                RemoveView(_view.View);
                Platform.SetRenderer(_viewCell.View, null);
                _viewCell.View.IsPlatformEnabled = false;

                // Adding a special case for HandlerToRendererShim so that DisconnectHandler gets called;
                // Pending https://github.com/xamarin/Xamarin.Forms/pull/14288 being merged, we won't need the special case
                if (_view is HandlerToRendererShim htrs)
                {
                    htrs.Dispose();
                }
                else
                {
                    _view.View.Dispose();
                }

                _viewCell = cell;
                _view     = Platform.CreateRenderer(_viewCell.View, Context);

                Platform.SetRenderer(_viewCell.View, _view);
                AddView(_view.View);

                UpdateIsEnabled();
                UpdateWatchForLongPress();

                Performance.Stop(reference);
            }
        public SettingsPage()
        {
            InitializeComponent();
            bindingPaddingTopBottomConverter = (IBindingTypeConverter)App.Container.Resolve <IPaddingTopBottomConverter>();
            settings  = App.Container.Resolve <ISettingsFactory>().GetSettings();
            ViewModel = (SettingsViewModel)App.Container.Resolve <ISettingsViewModel>();

            var fontSize = settings.FontSize;

            this.Padding = new Thickness(10, getDevicePadding(), 10, 5);

            isManualFontLabel = new Label()
            {
                Text              = "Enable Manual Font",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start
            };


            isManualFont = new Switch()
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.EndAndExpand
            };


            isManualFontGrid = new TwoValueHorizontalGrid().Create(0d, 80d);
            isManualFontGrid.Children.Add(isManualFontLabel, 0, 0);
            isManualFontGrid.Children.Add(isManualFont, 1, 0);

            fontSliderLabel = new Label
            {
                Text = $"Custom Font Size is {fontSize}",
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };


            fontSlider = new Slider
            {
                Maximum           = Constants.FontSizeMax,
                Minimum           = 12,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };


            fontSliderGrid = new TwoValueHorizontalGrid().Create();
            fontSliderGrid.Children.Add(fontSliderLabel, 0, 0);
            fontSliderGrid.Children.Add(fontSlider, 1, 0);
            showConnectionErrorsLabel = new Label()
            {
                Text              = "Show Connection Errors",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Start
            };

            showConnectionErrors = new Switch()
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.End
            };

            showConnectionErrorsGrid = new TwoValueHorizontalGrid().Create();
            showConnectionErrorsGrid.Children.Add(showConnectionErrorsLabel, 0, 0);
            showConnectionErrorsGrid.Children.Add(showConnectionErrors, 1, 0);

            viewCellManualFont = new ViewCell()
            {
                View = isManualFontGrid
            };
            viewCellSlider = new ViewCell()
            {
                View = fontSliderGrid
            };
            viewCellShowErrors = new ViewCell()
            {
                View = showConnectionErrorsGrid
            };

            var stacklayout = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                Padding           = new Thickness(10, 10, 10, 10),
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var seperator1 = new StackLayout
            {
                HeightRequest     = 1,
                BackgroundColor   = Color.Gray,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            sectionLabelInterface = new Label()
            {
                Text      = "Interface",
                TextColor = Color.Gray
            };
            var seperator2 = new StackLayout
            {
                HeightRequest     = 1,
                BackgroundColor   = Color.Gray,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            sectionLabelDiagnostics = new Label()
            {
                Text      = "Diagnostics",
                TextColor = Color.Gray
            };
            stacklayout.Children.Add(sectionLabelInterface);
            stacklayout.Children.Add(seperator1);
            stacklayout.Children.Add(isManualFontGrid);
            stacklayout.Children.Add(fontSliderGrid);
            stacklayout.Children.Add(sectionLabelDiagnostics);
            stacklayout.Children.Add(seperator2);
            stacklayout.Children.Add(showConnectionErrorsGrid);

            this.Content = stacklayout;

            this
            .WhenActivated(
                disposables =>
            {
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.isManualFontGrid.Margin, vmToViewConverterOverride: bindingPaddingTopBottomConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.fontSliderGrid.Margin, vmToViewConverterOverride: bindingPaddingTopBottomConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.showConnectionErrorsGrid.Margin, vmToViewConverterOverride: bindingPaddingTopBottomConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.isManualFontLabel.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.sectionLabelInterface.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.sectionLabelDiagnostics.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this.Bind(ViewModel, vm => vm.FontSize, x => x.fontSlider.Value, vmToViewConverterOverride: bindingIntToDoubleConverter, viewToVMConverterOverride: bindingDoubleToIntConverter)
                .DisposeWith(disposables);
                this.fontSlider.Events().ValueChanged
                .Throttle(TimeSpan.FromMilliseconds(150), RxApp.MainThreadScheduler)
                .Do((x) =>
                {
                    var rounded          = Math.Round(x.NewValue);
                    fontSliderLabel.Text = $"Custom Font Size is {rounded}";
                    MessagingCenter.Send <ISettingsPage>(this, "mSettingsFontChanged");
                })
                .Select(x => Unit.Default)
                .InvokeCommand(ViewModel.FontSliderChanged)
                .DisposeWith(disposables);
                this.isManualFont.Events().Toggled
                .Select(x => Unit.Default)
                .InvokeCommand(ViewModel.IsManualFontOnClicked)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.isManualFontLabel.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this
                .Bind(this.ViewModel, x => x.IsManualFontOn, x => x.isManualFont.IsToggled)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.fontSliderLabel.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.IsManualFontOn, x => x.fontSlider.IsEnabled)
                .DisposeWith(disposables);
                this
                .OneWayBind(this.ViewModel, x => x.FontSize, x => x.showConnectionErrorsLabel.FontSize, vmToViewConverterOverride: bindingIntToDoubleConverter)
                .DisposeWith(disposables);
                this
                .Bind(this.ViewModel, x => x.ShowConnectionErrors, x => x.showConnectionErrors.IsToggled)
                .DisposeWith(disposables);
                this.BindCommand(
                    this.ViewModel,
                    x => x.ShowConnectionErrorsCommand,
                    x => x.showConnectionErrors, nameof(showConnectionErrors.Toggled))
                .DisposeWith(disposables);
            });
        }
Beispiel #19
0
        protected override void Init()
        {
            var outputLabel = new Label();
            var testButton = new Button
            {
                Text = "Can't Touch This",
                AutomationId = CantTouchButtonId
            };

            testButton.Clicked += (sender, args) => outputLabel.Text = CantTouchFailText;

            var testGrid = new Grid
            {
                Children =
                {
                    testButton,
                    new BoxView
                    {
                        Color = Color.Pink.MultiplyAlpha(0.5)
                    }
                }
            };

            // BoxView over Button prevents Button click
            var testButtonOk = new Button
            {
                Text = "Can Touch This",
                AutomationId = CanTouchButtonId
            };

            testButtonOk.Clicked += (sender, args) => outputLabel.Text = CanTouchSuccessText;

            var testGridOk = new Grid
            {
                Children =
                {
                    testButtonOk,
                    new BoxView
                    {
                        Color = Color.Pink.MultiplyAlpha(0.5),
                        InputTransparent = true
                    }
                }
            };

            var testListView = new ListView();
            var items = new[] { "Foo" };
            testListView.ItemsSource = items;
            testListView.ItemTemplate = new DataTemplate(() =>
            {
                var result = new ViewCell
                {
                    View = new Grid
                    {
                        Children =
                        {
                            new BoxView
                            {
                                AutomationId = ListTapTarget,
                                Color = Color.Pink.MultiplyAlpha(0.5)
                            }
                        }
                    }
                };

                return result;
            });

            testListView.ItemSelected += (sender, args) => outputLabel.Text = ListTapSuccessText;

            Content = new StackLayout
            {
                Children = { outputLabel, testGrid, testGridOk, testListView }
            };
        }
Beispiel #20
0
        public TeamsList()
        {
            Title = "Events";

            var teamTemplate = new DataTemplate(() =>
            {
                var grid = new Grid
                {
                    ColumnSpacing     = 20,
                    RowSpacing        = 0,
                    ColumnDefinitions = { new ColumnDefinition {
                                              Width = GridLength.Auto
                                          } },
                    RowDefinitions = { new RowDefinition {
                                           Height = GridLength.Star
                                       }, new RowDefinition{
                                           Height = GridLength.Star
                                       } }
                };

                grid.SetBinding(Grid.BackgroundColorProperty, "BackgroundColor_");
                var eventNameLabel = new Label
                {
                    VerticalTextAlignment   = TextAlignment.End,
                    HorizontalTextAlignment = TextAlignment.Start,
                    Margin   = new Thickness(12, 0, 0, 0),
                    FontSize = 18
                };
                eventNameLabel.SetBinding(Label.TextProperty, "team_name_short");

                var eventLocationLabel = new Label
                {
                    VerticalTextAlignment   = TextAlignment.Start,
                    HorizontalTextAlignment = TextAlignment.Start,
                    FontSize       = 16,
                    Opacity        = .5,
                    FontAttributes = FontAttributes.Italic,
                    Margin         = new Thickness(12, 0, 0, 0)
                };
                eventLocationLabel.SetBinding(Label.TextProperty, "team_number");

                grid.Children.Add(eventNameLabel, 0, 0);
                grid.Children.Add(eventLocationLabel, 0, 1);

                var myCell = new ViewCell {
                    View = grid
                };

                return(myCell);
            });


            var myTeam = RootPage.getData().debugTeams();             // this is changed for debugging

            myTeam[0].BackgroundColor_ = Color.FromHex("#921243");

            var list = new ListView
            {
                SelectionMode       = ListViewSelectionMode.Single,
                ItemsSource         = myTeam,
                SeparatorVisibility = SeparatorVisibility.None,
                SeparatorColor      = Color.Transparent,
                HasUnevenRows       = false,
                RowHeight           = 80,       // figure onIdiom out
                ItemTemplate        = teamTemplate,
            };

            list.ItemTapped += OnItemTapped;

            if (myTeam != null)
            {
                this.Content = new StackLayout
                {
                    Children =
                    {
                        list
                    }
                };
            }
            else
            {
                this.Content = new ContentView {
                    Content = new Label {
                        Text = "There Are No Teams", HorizontalTextAlignment = TextAlignment.Center, VerticalTextAlignment = TextAlignment.Center
                    }
                };
            }
        }
Beispiel #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RepeaterViewPage"/> class.
        /// </summary>
        public RepeaterViewPage()
        {
            var viewModel = new RepeaterViewViewModel();

            BindingContext = viewModel;

            var repeater = new RepeaterView <Thing>
            {
                Spacing      = 10,
                ItemsSource  = viewModel.Things,
                ItemTemplate = new DataTemplate(() =>
                {
                    var nameLabel = new Label {
                        Font = Font.SystemFontOfSize(NamedSize.Medium)
                    };
                    nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

                    var descriptionLabel = new Label {
                        Font = Font.SystemFontOfSize(NamedSize.Small)
                    };
                    descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

                    ViewCell cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                nameLabel,
                                descriptionLabel
                            }
                        }
                    };

                    return(cell);
                })
            };

            var removeButton = new Button
            {
                Text = "Remove 1st Item",
                HorizontalOptions = LayoutOptions.Start
            };

            removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

            var addButton = new Button
            {
                Text = "Add New Item",
                HorizontalOptions = LayoutOptions.Start
            };

            addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

            Content = new StackLayout
            {
                Padding  = 20,
                Spacing  = 5,
                Children =
                {
                    new Label
                    {
                        Text = "RepeaterView Demo",
                        Font = Font.SystemFontOfSize(NamedSize.Large)
                    },
                    repeater,
                    removeButton,
                    addButton
                }
            };

            viewModel.LoadData();
        }
Beispiel #22
0
        public override void WillDisplay(UITableView tableView, UITableViewCell cell, Foundation.NSIndexPath indexPath)
        {
            var visibleCell = tableView.VisibleCells;

            if (visibleCell.Count() > 0)
            {
                var first = visibleCell.First();
                var last  = visibleCell.Last();

                var      firstCellPath = tableView.IndexPathForCell(first);
                var      lastCellPath  = tableView.IndexPathForCell(last);
                ViewCell firstViewCell = null;
                ViewCell lastViewCell  = null;

                try
                {
                    firstViewCell = first.GetType().GetProperty("ViewCell").GetValue(first) as Xamarin.Forms.ViewCell;
                    lastViewCell  = last.GetType().GetProperty("ViewCell").GetValue(last) as Xamarin.Forms.ViewCell;
                }
                catch
                {
                }

                var sectionsAmount = tableView.NumberOfSections();
                var rowsAmount     = tableView.NumberOfRowsInSection(indexPath.Section);
                if (indexPath.Section == sectionsAmount - 1 && indexPath.Row == rowsAmount - 1)
                {
                    // This is the last cell in the table
                    this._IsFirstRowVisible = false;
                    this._IsLastRowVisible  = true;
                }
                else if (indexPath.Section == 0 && (indexPath.Row == 0))
                {
                    this._IsFirstRowVisible = false;
                    this._IsLastRowVisible  = true;
                }
                else if (this._IsStartedScrolling)
                {
                    this._IsFirstRowVisible = false;
                    this._IsLastRowVisible  = false;
                }

                var handler = this.OnScrollEvent;
                // fire event
                if (handler != null)
                {
                    var evt = new TableSourceEvents
                    {
                        Y = _LastYPosition,
                        IsFirstRowVisible = this._IsFirstRowVisible,
                        IsLastRowVisible  = this._IsLastRowVisible,
                        FirstViewCell     = firstViewCell,
                        LastViewCell      = lastViewCell
                    };

                    if (firstCellPath != null)
                    {
                        evt.FirstRow = new int[] { firstCellPath.Section, firstCellPath.Row };
                    }
                    else
                    {
                        evt.FirstRow = new int[] { -1, -1 };
                    }

                    if (lastCellPath != null)
                    {
                        evt.LastRow = new int[] { lastCellPath.Section, lastCellPath.Row };
                    }
                    else
                    {
                        evt.LastRow = new int[] { -1, -1 };
                    }
                    handler(this, evt);
                }
            }
        }
Beispiel #23
0
        public ViewCellPage()
        {
            products = new VProduct[]
            {
                new VProduct("Dev Services", "Service", true,
                             "Do you need a mobile app, website, or both? Count on Mooseworks Software to collaborate with you at every stage of the project lifecycle, from concept to completion to support. ",
                             "http://mooseworkssoftware.com/wordpress/wp-content/uploads/2013/11/services1.png"),
                new VProduct("Graph", "Product", true,
                             "The Graph Control provides every graphing feature you could want: Legends, Zooming, Date/Time, Logarithmic, Inverted axes, Right and Left Y-Axes, Markers, Cursor Values, Alarms, and more, while still providing excellent performance.",
                             "http://mooseworkssoftware.com/wordpress/wp-content/uploads/2013/12/graphimage.png"),
                new VProduct("Instrumentation", "Product", false,
                             "The Instrumentation Control suite includes everything you need to create eye catching and easy to use displays.",
                             "http://mooseworkssoftware.com/wordpress/wp-content/uploads/2013/11/Screenshot1.png"),
                new VProduct("Trend Graph", "Product", true,
                             "The Trend Graph Control provides real time, scrollable charting capabilities. Memory is handled by the Trend Graph’s circular buffer, so you can add points in real time without worrying about memory growing out of control as time goes on. ",
                             "http://mooseworkssoftware.com/wordpress/wp-content/uploads/2013/12/TrendGraph2.png")
            };

            Label lblHeader = new Label
            {
                Text = "Table View",
                Font = Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold),
                HorizontalOptions = LayoutOptions.Center
            };

            TableView tableProducts = new TableView {
                Intent    = TableIntent.Data,
                Root      = new TableRoot("Products and Services"),
                RowHeight = 135
            };

            TableSection sectionServices = new TableSection("Services");
            TableSection sectionProducts = new TableSection("Products");

            foreach (VProduct product in products)
            {
                Entry txtName = new Entry();
                txtName.BindingContext = product;
                txtName.SetBinding(Entry.TextProperty, "Name", BindingMode.TwoWay);

                Switch swInStock = new Switch();
                swInStock.BindingContext = product;
                swInStock.SetBinding(Switch.IsToggledProperty, "InStock", BindingMode.TwoWay);
                swInStock.HorizontalOptions = LayoutOptions.StartAndExpand;

                Image imgProduct = new Image();
                imgProduct.Source        = product.ImageUrl;
                imgProduct.HeightRequest = 125;

                ViewCell vc = new ViewCell()
                {
                    View = new StackLayout {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.StartAndExpand,
                        Children          =
                        {
                            imgProduct,
                            new StackLayout {
                                HorizontalOptions = LayoutOptions.EndAndExpand,
                                Children          =
                                {
                                    txtName,
                                    new Label {
                                        Text = "In Stock?",
                                        Font = Font.SystemFontOfSize(NamedSize.Large)
                                    },
                                    swInStock
                                }
                            }
                        }
                    }
                };

                if (product.Category == "Service")
                {
                    sectionServices.Add(vc);
                }
                else
                {
                    sectionProducts.Add(vc);
                }
            }
            tableProducts.Root.Add(new TableSection[] { sectionServices, sectionProducts });

            Button btnSubmit = new Button {
                Text = "Submit",
                HorizontalOptions = LayoutOptions.Center
            };

            btnSubmit.Clicked += (object sender, EventArgs e) => {
                string message = "";
                foreach (VProduct product in products)
                {
                    message += product.Name + (product.InStock ? " - in stock" : " - out of stock") + ", ";
                }
                DisplayAlert("Products", message, "OK");
            };

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

            this.Content = new StackLayout {
                Children =
                {
                    lblHeader,
                    tableProducts,
                    btnSubmit
                }
            };
        }
Beispiel #24
0
 public static FluentViewCell ViewCell(ViewCell instance = null)
 {
     return(new FluentViewCell(instance));
 }
Beispiel #25
0
 public abstract void ShowCell(ref ViewCell cell);
Beispiel #26
0
        /**
         * This page will display current matches and add ability to add a new match
         * */
        public NewMatchesPage(Opponents opponent)
        {
            InitializeComponent();
            database = App.Database;
            Title    = "Opponents";

            // Layout for top items
            StackLayout topLayout = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            // Add matches to listview
            ListView matchListView = new ListView
            {
                ItemsSource = database.GetMatchesByID(opponent.ID),
                //ItemsSource = matchList,
                RowHeight     = 75,
                ItemTemplate  = new DataTemplate(typeof(matchCell)),
                HeightRequest = 750
            };


            // Add to top layout
            topLayout.Children.Add(matchListView);

            /////////// Table Section Below /////////////////////
            StackLayout tableLayout = new StackLayout {
                VerticalOptions = LayoutOptions.Center
            };
            TableView tableView = new TableView {
                Intent = TableIntent.Form
            };

            tableView.HeightRequest = 700;

            // Cells go in sections, sections in root
            DatePicker dPicker = new DatePicker {
                Date = DateTime.Now, Format = "D"
            };

            ViewCell vDate = new ViewCell();

            vDate.View = dPicker;

            // Comments section
            EntryCell eComments = new EntryCell {
                Label = "Comment: "
            };
            // Picker for Game selection
            Picker pGame = new Picker
            {
                ItemsSource        = database.GetAllGames(),
                ItemDisplayBinding = new Binding("gName"),
                Title = "Game:"
            };
            // Picker must be placed in ViewCell
            ViewCell vPicker = new ViewCell();

            vPicker.View = pGame;
            SwitchCell sWin = new SwitchCell {
                Text = "Win?"
            };

            TableSection tableSection = new TableSection("Add Match")
            {
                vDate, eComments, vPicker, sWin
            };

            tableView.Root = new TableRoot {
                tableSection
            };
            tableLayout.Children.Add(tableView);

            // Create button to add matches
            Button btnAdd = new Button {
                Text = "Add", HorizontalOptions = LayoutOptions.Center
            };

            btnAdd.Clicked += (sender, e) =>
            {
                // Check to make sure that we're updating an item already in database
                if (currentMatch != null)
                {
                    currentMatch.mDate     = dPicker.Date;
                    currentMatch.mComments = eComments.Text;
                    currentMatch.mWin      = sWin.On;
                    currentMatch.mGameID   = ((Games)pGame.SelectedItem).gID;
                    // Update match
                    database.SaveMatch(currentMatch);
                    // Update list
                    matchListView.ItemsSource = database.GetMatchesByID(currentMatch.opponent_id);

                    currentMatch = null;
                }
                else
                {
                    // Create new match to save
                    Matches newMatch = new Matches
                    {
                        mDate       = dPicker.Date,
                        mComments   = eComments.Text,
                        mGameID     = ((Games)pGame.SelectedItem).gID,
                        opponent_id = opponent.ID,
                        mWin        = sWin.On
                    };
                    // Save new match to database
                    database.SaveMatch(newMatch);
                    // Update list
                    matchListView.ItemsSource = database.GetMatchesByID(newMatch.opponent_id);
                }
            };

            matchListView.ItemTapped += (sender, e) =>
            {
                matchListView.SelectedItem = null;
                // Set current item equal to the object which was tapped
                // Used to be able to know if we need to update, or create new match
                currentMatch   = (Matches)e.Item;
                dPicker.Date   = currentMatch.mDate;
                eComments.Text = currentMatch.mComments;
                // Index needs to be offset by one, since picker and database do not
                // start at the same numbers. One start at 0 and the other other 1.
                pGame.SelectedIndex = currentMatch.mGameID - 1;
                sWin.On             = currentMatch.mWin;
            };

            // Create main layout
            StackLayout mainLayout = new StackLayout
            {
                Children = { topLayout, tableLayout, btnAdd }
            };

            Content = mainLayout;
        }
        public RepeaterViewPage()
        {
            var viewModel = new RepeaterViewViewModel();
            BindingContext = viewModel;

            var repeater = new RepeaterView<Thing>
            {
                Spacing = 10,
                ItemsSource = viewModel.Things,
                ItemTemplate = new DataTemplate(() =>
                {
                    var nameLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Medium) };
                    nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

                    var descriptionLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Small) };
                    descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

                    ViewCell cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Spacing = 0,
                            Children =
                            {
                                nameLabel,
                                descriptionLabel
                            }
                        }
                    };

                    return cell;
                })
            };

            var removeButton = new Button
            {
                Text = "Remove 1st Item",      
                HorizontalOptions = LayoutOptions.Start
            };

            removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

            var addButton = new Button
            {
                Text = "Add New Item",
                HorizontalOptions = LayoutOptions.Start
            };

            addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

            Content = new StackLayout
            {
                Padding = 20,
                Spacing = 5,
                Children = 
                {
                    new Label 
                    { 
                        Text = "RepeaterView Demo", 
                        Font = Font.SystemFontOfSize(NamedSize.Large)
                    },
                    repeater,
                    removeButton,
                    addButton
                }
            };

            viewModel.LoadData();
        }
Beispiel #28
0
		public async void ForceUpdateSizeCallsAreRateLimited()
		{
			var lv = new ListView { HasUnevenRows = true };
			var cell = new ViewCell { Parent = lv };

			int numberOfCalls = 0;
			((ICellController)cell).ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; };

			cell.ForceUpdateSize ();
			cell.ForceUpdateSize ();
			cell.ForceUpdateSize ();
			cell.ForceUpdateSize ();

			await System.Threading.Tasks.Task.Delay (TimeSpan.FromMilliseconds (150));

			Assert.AreEqual (1, numberOfCalls);
		}
 private async void TableRow_Clicked(object sender, EventArgs e)
 {
     ViewCell    vc          = (ViewCell)sender;
     Transaction transaction = (Transaction)vc.BindingContext;
     await Navigation.PushAsync(new TransactionDetail(transaction));
 }
            private View CreateView(out ViewCell viewCell, int itemViewType)
            {
                viewCell = null;
                var dataTemplate = _element.ItemTemplate;

                if (itemViewType == -1)
                {
                    viewCell = (ViewCell)dataTemplate.CreateContent();
                }
                else
                {
                    viewCell = (ViewCell)_dataTemplates[itemViewType].CreateContent();
                }

                _formsViews.Add(new WeakReference <ViewCell>(viewCell));
                var view = viewCell.View;

                var renderer = Platform.CreateRendererWithContext(view, _context);

                Platform.SetRenderer(view, renderer);

                renderer.Element.Layout(
                    new Rectangle(
                        0,
                        0,
                        _element.ItemWidth,
                        _element.ItemHeight));
                renderer.UpdateLayout();

                var itemView = renderer.View;

                int topMargin    = PlatformHelper.Instance.DpToPixels(MeasureHelper.RecyclerViewItemVerticalMarginDp);
                int bottomMargin = PlatformHelper.Instance.DpToPixels(MeasureHelper.RecyclerViewItemVerticalMarginDp);

                int width  = PlatformHelper.Instance.DpToPixels(_element.ItemWidth);
                int height = PlatformHelper.Instance.DpToPixels(_element.ItemHeight);

                itemView.LayoutParameters =
                    new FrameLayout.LayoutParams(
                        width,
                        height)
                {
                    Gravity      = GravityFlags.CenterHorizontal,
                    TopMargin    = topMargin,
                    BottomMargin = bottomMargin,
                };

                if (_element.IsLayoutLinear)
                {
                    return(itemView);
                }

                var container = new FrameLayout(_context)
                {
                    LayoutParameters = new FrameLayout.LayoutParams(
                        LayoutParams.MatchParent,
                        height + (topMargin + bottomMargin)),
                };

                container.AddView(itemView);
                return(container);
            }
        private async Task InitTableView()
        {
            User user = await Core.GetUserByEmail(UserEmail);

            List <Transaction> transactionsTemp = await Core.GetTransactionsByGroupId(user.GroupId);

            var transactions = transactionsTemp.OrderByDescending(t => t.Created);
            var layout       = new Grid();

            layout.Children.Add(new Label()
            {
                Text              = "Type",
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = new Thickness(20, 0, 0, 0)
            }, 0, 0);

            layout.Children.Add(new Label()
            {
                Text              = "Amount",
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 1, 0);

            layout.Children.Add(new Label()
            {
                Text              = "Date",
                TextColor         = Color.Black,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 2, 0);

            var tableSection = new TableSection("Transactions")
            {
                new ViewCell()
                {
                    View = layout
                }
            };

            foreach (var transaction in transactions)
            {
                var cellLayout = new Grid();
                cellLayout.HorizontalOptions = LayoutOptions.FillAndExpand;

                var typeLabel = new Label();
                typeLabel.SetBinding(Label.TextProperty, "Type", BindingMode.TwoWay, null, null);
                typeLabel.Padding           = new Thickness(20, 0, 0, 0);
                typeLabel.HorizontalOptions = LayoutOptions.FillAndExpand;

                var amountLabel = new Label();
                amountLabel.SetBinding(Label.TextProperty, "Amount", BindingMode.TwoWay, null, null);
                amountLabel.HorizontalOptions = LayoutOptions.FillAndExpand;

                var createdLabel = new Label();
                createdLabel.Text = transaction.Created.ToString("MM/dd/yy");
                createdLabel.HorizontalOptions = LayoutOptions.FillAndExpand;

                cellLayout.Children.Add(typeLabel, 0, 0);

                cellLayout.Children.Add(amountLabel, 1, 0);

                cellLayout.Children.Add(createdLabel, 2, 0);

                var viewCell = new ViewCell()
                {
                    View = cellLayout
                };
                viewCell.BindingContext = transaction;
                viewCell.Tapped        += TableRow_Clicked;

                tableSection.Add(
                    viewCell
                    );
            }


            TransactionsTable.Root = new TableRoot()
            {
                tableSection
            };
        }
Beispiel #32
0
        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="collectionView">The collection view.</param>
        /// <param name="item">The item.</param>
        /// <param name="indexPath">The index path.</param>
        /// <returns>UICollectionViewCell.</returns>
        protected virtual UICollectionViewCell GetCell(UICollectionView collectionView, ViewCell item, NSIndexPath indexPath)
        {
            var collectionCell = collectionView.DequeueReusableCell(new NSString(GridViewCell.Key), indexPath) as GridViewCell;

            if (collectionCell == null)
            {
                return(null);
            }

            collectionCell.ViewCell = item;

            return(collectionCell);
        }
Beispiel #33
0
        protected override void Init()
        {
            var layout = new StackLayout();
            var button = new Button {
                Text = "Click"
            };
            var tablesection = new TableSection {
                Title = "Switches"
            };
            var tableview = new TableView {
                Intent = TableIntent.Form, Root = new TableRoot {
                    tablesection
                }
            };
            var viewcell1 = new ViewCell
            {
                View = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        new Label  {
                            Text = "Switch 1", HorizontalOptions = LayoutOptions.StartAndExpand
                        },
                        new Switch {
                            AutomationId = "switch1", HorizontalOptions = LayoutOptions.End, IsToggled = true
                        }
                    }
                }
            };
            var viewcell2 = new ViewCell
            {
                View = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        new Label  {
                            Text = "Switch 2", HorizontalOptions = LayoutOptions.StartAndExpand
                        },
                        new Switch {
                            AutomationId = "switch2", HorizontalOptions = LayoutOptions.End, IsToggled = true
                        }
                    }
                }
            };
            Label label = new Label {
                Text = "Switch 3", HorizontalOptions = LayoutOptions.StartAndExpand
            };
            Switch switchie = new Switch {
                AutomationId = "switch3", HorizontalOptions = LayoutOptions.End, IsToggled = true, IsEnabled = false
            };

            switchie.Toggled += (sender, e) =>
            {
                label.Text = "FAIL";
            };
            var viewcell3 = new ViewCell
            {
                View = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        label,
                        switchie,
                    }
                }
            };

            tablesection.Add(viewcell1);
            tablesection.Add(viewcell2);
            tablesection.Add(viewcell3);

            button.Clicked += (sender, e) =>
            {
                if (_removed)
                {
                    tablesection.Insert(1, viewcell2);
                }
                else
                {
                    tablesection.Remove(viewcell2);
                }

                _removed = !_removed;
            };

            layout.Children.Add(button);
            layout.Children.Add(tableview);

            Content = layout;
        }
Beispiel #34
0
        protected override void Init()
        {
            var instructions =
                @"In the picker below, select the option labeled 'Two'. If the selection immediately disappears, the test has failed.
In the TimePicker below, change the time to 5:21 PM. If the selection immediately disappears, the test has failed.
In the DatePicker below, change the date to May 25, 1977. If the selection immediately disappears, the test has failed.";

            var tableInstructions = new Label
            {
                Text = instructions
            };

            var picker = new Picker();

            var pickerItems = new List <string> {
                "One", "Two", "Three"
            };

            foreach (string item in pickerItems)
            {
                picker.Items.Add(item);
            }

            var datePicker = new DatePicker();
            var timePicker = new TimePicker();

            var tableView = new TableView()
            {
                BackgroundColor = Color.Green
            };

            var tableSection = new TableSection();

            var pickerCell = new ViewCell {
                View = picker
            };
            var datepickerCell = new ViewCell {
                View = datePicker
            };
            var timepickerCell = new ViewCell {
                View = timePicker
            };

            tableSection.Add(pickerCell);
            tableSection.Add(timepickerCell);
            tableSection.Add(datepickerCell);

            var tableRoot = new TableRoot()
            {
                tableSection
            };

            tableView.Root = tableRoot;

            var listItems = new List <string> {
                "One"
            };

            var listView = new ListView
            {
                Header          = instructions,
                BackgroundColor = Color.Pink,
                ItemTemplate    = new DataTemplate(typeof(CustomCell)),
                ItemsSource     = listItems
            };

            var nonListDatePicker = new DatePicker();
            var nonListTimePicker = new TimePicker();
            var nonListPicker     = new Picker();

            foreach (string item in pickerItems)
            {
                nonListPicker.Items.Add(item);
            }

            Content = new StackLayout
            {
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.Fill,
                Children          =
                {
                    new Label {
                        Text = instructions
                    },
                    nonListPicker,
                    nonListDatePicker,
                    nonListTimePicker,
                    tableInstructions,
                    tableView,
                    listView
                }
            };
        }
Beispiel #35
0
        private void Initialize()
        {
            SetBinding(StackLayout.IsVisibleProperty, new Binding("IsRunning", BindingMode.OneWay, new NegateBooleanConverter()));
            BackgroundColor = Color.FromHex("#FFFFFF");

            ListView listView = new ListView();

            listView.SeparatorColor = Color.FromHex("#B6B6B6");
            listView.RowHeight      = 130;
            listView.SetBinding(ListView.ItemsSourceProperty, new Binding("Pesquisas", BindingMode.OneWay));
            listView.ItemTemplate = new DataTemplate(() =>
            {
                ViewCell cell          = new ViewCell();
                StackLayout layoutList = new StackLayout();
                layoutList.Padding     = new Thickness(16, 0, 0, 0);
                layoutList.Orientation = StackOrientation.Horizontal;

                StackLayout layoutImage     = new StackLayout();
                layoutImage.Orientation     = StackOrientation.Vertical;
                layoutImage.VerticalOptions = LayoutOptions.Center;

                Image img = new Image()
                {
                    Source = "pesquisa.png"
                };

                layoutImage.Children.Add(img);

                StackLayout layoutLabel     = new StackLayout();
                layoutLabel.Padding         = new Thickness(10, 0, 0, 0);
                layoutLabel.Orientation     = StackOrientation.Vertical;
                layoutLabel.VerticalOptions = LayoutOptions.Center;

                Label lbl = new Label()
                {
                    FontSize  = 19,
                    TextColor = Color.FromHex("#212121")
                };
                lbl.SetBinding(Label.TextProperty, new Binding("pesquisa01.nomepesquisa", BindingMode.OneWay));

                Label lbl2 = new Label()
                {
                    FontSize  = 14,
                    TextColor = Color.FromHex("#212121")
                };

                lbl2.SetBinding(Label.TextProperty, new Binding("nome", BindingMode.OneWay));

                Label lbl3 = new Label()
                {
                    FontSize  = 14,
                    TextColor = Color.FromHex("#212121")
                };

                lbl3.SetBinding(Label.TextProperty, new Binding("pesquisa01.DSDATACONSOLIDADA", BindingMode.OneWay));

                layoutLabel.Children.Add(lbl);
                layoutLabel.Children.Add(lbl2);
                layoutLabel.Children.Add(lbl3);

                layoutList.Children.Add(layoutImage);
                layoutList.Children.Add(layoutLabel);

                cell.View = layoutList;

                return(cell);
            });

            listView.ItemTapped += ListView_ItemTapped;

            Children.Add(listView);
        }
Beispiel #36
0
        public ViewCell EmpleadoCellTemplate()
        {
            var TemplateEmpleado = new ViewCell();

//			Labels del template
            var nombreLabel     = new Label();
            var apellidoLabel   = new Label();
            var fotoPerfilImage = new CircleImage
            {
                Aspect            = Aspect.AspectFit,
                BorderColor       = Color.Black,
                BorderThickness   = 3,
                HeightRequest     = 25,
                WidthRequest      = 25,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                FillColor         = Color.Black
            };

//			Asignamos las propiedades bindeables, estas propiedades son las del BindingContext,
//			el cual es el modelo de nuestra Collection en este caso es Empleado.

            nombreLabel.SetBinding(Label.TextProperty, "Nombre");
            apellidoLabel.SetBinding(Label.TextProperty, "Apellido");
            fotoPerfilImage.SetBinding(Image.SourceProperty, "FotoPerfil");

            /*
             * Creamos Context Actions, los cuales responderan a un swipe sobre un item  en IOS
             * y long press en Android
             */
            Xamarin.Forms.MenuItem delete = new Xamarin.Forms.MenuItem();
            delete.Text          = "Eliminar";
            delete.IsDestructive = true;
            delete.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, ".");
            delete.Clicked += (object sender, EventArgs e) =>
            {
                var mi   = ((Xamarin.Forms.MenuItem)sender);
                var item = mi.CommandParameter as Empleado;
                ListData.Remove(item);
            };
            TemplateEmpleado.ContextActions.Add(delete);

            Xamarin.Forms.MenuItem edit = new Xamarin.Forms.MenuItem();
            edit.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, ".");
            edit.Clicked += (object sender, EventArgs e) =>
            {
                var mi   = (Xamarin.Forms.MenuItem)sender;
                var item = mi.CommandParameter as Empleado;
//				Aqui podriamos Abrir unPage ParamArrayAttribute edicion de datos del Empleado
//				Navigation.PushModalAsync(new EmpleadoInfo(item));
            };
            edit.Text = "Editar";

            TemplateEmpleado.ContextActions.Add(edit);

            var stack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 10,
                Padding     = 5,
                Children    =
                {
                    fotoPerfilImage,
                    new StackLayout {
                        Orientation = StackOrientation.Vertical,
                        Spacing     = 2,
                        Children    =
                        {
                            nombreLabel,
                            apellidoLabel
                        }
                    }
                }
            };

            TemplateEmpleado.View = stack;
            return(TemplateEmpleado);
        }
Beispiel #37
0
        private void CreateToolBar()
        {
            bookmarkTitle = new Grid();

            bookmarkTitle.HeightRequest = 40;
            bookmarkTitle.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            bookmarkTitle.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = 32
            });
            bookmarkTitle.RowDefinitions.Add(new RowDefinition()
            {
                Height = 38
            });
            bookmarkTitle.RowDefinitions.Add(new RowDefinition()
            {
                Height = 2
            });
            bookmarkTitle.VerticalOptions = LayoutOptions.Start;
            Frame frame3 = new Frame()
            {
                BackgroundColor = Color.FromHex("#E0E0E0")
            };

            Grid.SetColumnSpan(frame3, 2);
            Grid.SetRow(frame3, 1);

            bookmarkTitle.Children.Add(frame3);

            bookmarkTitle.RowSpacing = 10;

            bookmarkTitleText.HorizontalOptions = LayoutOptions.Start;
            bookmarkTitleText.VerticalOptions   = LayoutOptions.Center;
            bookmarkTitleText.Margin            = new Thickness(10, 10, 0, 0);
            bookmarkTitleText.FontSize          = 15;
            bookmarkTitleText.TextColor         = Color.FromHex("#000000");
            bookmarkTitleText.FontFamily        = "SegoeUI";
            bookmarkTitleText.FontAttributes    = FontAttributes.Bold;
            bookmarkTitle.Children.Add(bookmarkTitleText);


            Button closeButton = new Button()
            {
                WidthRequest = 30, HeightRequest = 30
            };

            closeButton.Text = "\uE701";

            closeButton.FontFamily        = "ms-appx:///Syncfusion.SfPdfViewer.XForms.UWP/Final_PDFViewer_UWP_FontUpdate.ttf#Final_PDFViewer_UWP_FontUpdate";
            closeButton.FontSize          = 12;
            closeButton.TextColor         = Color.FromHex("#000000");
            closeButton.BackgroundColor   = Color.Transparent;
            closeButton.HorizontalOptions = LayoutOptions.End;
            closeButton.VerticalOptions   = LayoutOptions.End;
            closeButton.Clicked          += CloseButton_Clicked;
            Grid.SetColumn(closeButton, 1);
            Grid.SetRow(closeButton, 0);
            Grid.SetColumn(bookmarkTitleText, 0);
            Grid.SetRow(bookmarkTitleText, 0);
            bookmarkTitle.Children.Add(closeButton);
            Grid.SetRow(bookmarkTitle, 0);

            bookPane.Children.Add(bookmarkTitle);

            Grid.SetRow(bookmarkView, 1);
            bookmarkView.HorizontalOptions = LayoutOptions.StartAndExpand;
            bookmarkView.VerticalOptions   = LayoutOptions.StartAndExpand;

            bookmarkView.Margin      = new Thickness(0, 3, 0, 0);
            bookmarkView.ItemsSource = listViewItemsSource;
            bookmarkView.ItemTapped += BookmarkView_ItemTapped;

            bookmarkView.ItemTemplate = new DataTemplate(() =>
            {
                ViewCell viewCell = new ViewCell();
                Grid view         = new Grid();
                Grid viewChild    = new Grid();
                viewChild.SetBinding(Grid.MarginProperty, "MarginForDesktop");
                view.HeightRequest = 40;

                viewChild.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = 40
                });
                viewChild.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Star)
                });
                viewChild.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = 40
                });


                Label bookmarkTitle             = new Label();
                bookmarkTitle.HorizontalOptions = LayoutOptions.StartAndExpand;

                bookmarkTitle.LineBreakMode   = LineBreakMode.TailTruncation;
                bookmarkTitle.VerticalOptions = LayoutOptions.Center;
                bookmarkTitle.SetBinding(Label.TextProperty, "Title");
                bookmarkTitle.FontFamily = "SegoeUI";
                bookmarkTitle.FontSize   = 13;
                Grid.SetColumn(bookmarkTitle, 1);

                Grid.SetRow(bookmarkTitle, 0);
                viewChild.Children.Add(bookmarkTitle);



                Button backToParentButton = new Button()
                {
                    Text = FontMappingHelper.BookmarkBackward, TextColor = Color.FromHex("8A000000"), BackgroundColor = Color.Transparent
                };
                backToParentButton.FontFamily        = FontMappingHelper.BookmarkFont;
                backToParentButton.FontSize          = 24;
                backToParentButton.Clicked          += BackToParentButton_Clicked;
                backToParentButton.HorizontalOptions = LayoutOptions.Start;
                backToParentButton.VerticalOptions   = LayoutOptions.Start;
                Grid.SetRow(backToParentButton, 0);
                Grid.SetColumn(backToParentButton, 0);
                viewChild.Children.Add(backToParentButton);
                backToParentButton.SetBinding(IsVisibleProperty, "IsBackToParentButtonVisible");

                Button expandButton = new Button()
                {
                    Text = FontMappingHelper.BookmarkForward, TextColor = Color.FromHex("8A000000"), BackgroundColor = Color.Transparent
                };
                expandButton.SetBinding(SfFontButton.CommandParameterProperty, ".");
                expandButton.FontFamily        = FontMappingHelper.BookmarkFont;
                expandButton.FontSize          = 24;
                expandButton.Clicked          += BookmarkExpand_Clicked;
                expandButton.HorizontalOptions = LayoutOptions.End;
                expandButton.VerticalOptions   = LayoutOptions.End;
                Grid.SetRow(expandButton, 0);
                Grid.SetColumn(expandButton, 2);
                viewChild.Children.Add(expandButton);
                expandButton.SetBinding(IsVisibleProperty, "IsExpandButtonVisible");



                view.Children.Add(viewChild);
                viewCell.View = view;

                return(viewCell);
            });

            bookPane.Children.Add(bookmarkView);

            BackgroundColor       = Color.FromHex("#F6F6F6");
            bookPane.WidthRequest = 280;


            bookPane.Children.Add(this);
        }
Beispiel #38
0
        public UrlImageViewCellListPage()
        {
            if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet)
            {
                Padding = new Thickness(0, 0, 0, 60);
            }

            var stringToImageSourceConverter = new GenericValueConverter(
                obj => new UriImageSource()
            {
                Uri = new Uri((string)obj)
            });

            var dataTemplate = new DataTemplate(() => {
                var cell = new ViewCell();

                var image = new Image();
                image.SetBinding(Image.SourceProperty, new Binding("Image", converter: stringToImageSourceConverter));
                image.WidthRequest  = 160;
                image.HeightRequest = 160;

                var text = new Label();
                text.SetBinding(Label.TextProperty, new Binding("Text"));
                text.SetBinding(Label.TextColorProperty, new Binding("TextColor"));

                cell.View = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        image,
                        text
                    }
                };

                return(cell);
            });

            var albums = new[] {
                "https://evolve.xamarin.com/images/sessions/joseph-mayo-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jon-skeet-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rachel-reese-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/mike-james-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/daniel-cazzulino-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/michael-hutchinson-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/laurent-bugnion-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/craig-dunn-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/charles-petzold-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jason-smith-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/frank-krueger-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/james-clancey-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/daniel-plaisted-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jesse-liberty-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/miguel-de-icaza-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rene-ruppert-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/brent-schooley-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/adrian-stevens-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/rodrigo-kumpera-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/alex-corrado-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jonathan-pryor-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/michael-stonis-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/jeremie-laval-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/james-montemagno-icon.jpg",
                "https://evolve.xamarin.com/images/sessions/brett-duncavage-icon.jpg"
            };

            var label = new Label {
                Text = "I have not been selected"
            };

            var listView = new ListView {
                AutomationId = CellTypeList.CellTestContainerId,
                ItemsSource  = Enumerable.Range(0, albums.Length).Select(i => new {
                    Text        = "Text " + i,
                    TextColor   = i % 2 == 0 ? Color.Red : Color.Blue,
                    Detail      = "Detail " + i,
                    DetailColor = i % 2 == 0 ? Color.Red : Color.Blue,
                    Image       = albums[i]
                }),
                ItemTemplate = dataTemplate
            };

            listView.ItemSelected += (sender, args) => label.Text = "I was selected";

            Content = new StackLayout {
                Children = { label, listView }
            };
        }
Beispiel #39
0
 public void Update(ViewCell cell)
 {
     IVisualElementRenderer visualElementRenderer = this.GetChildAt(0) as IVisualElementRenderer;
 }
Beispiel #40
0
		public Issue2615 ()
		{
			Title = "Test Blank Rows";

			var tableView = new TableView ();
			tableView.HasUnevenRows = true;

			var tableHeaderSection = new TableSection ();

			var viewHeaderCell = new ViewCell ();

			var headerCellLayout = new StackLayout ();
			headerCellLayout.Orientation = StackOrientation.Vertical;
			headerCellLayout.Spacing = 6;
			headerCellLayout.HorizontalOptions = LayoutOptions.Fill;
			headerCellLayout.VerticalOptions = LayoutOptions.Fill;

			var largeNumberLabel = new Label ();
			largeNumberLabel.FontFamily = "HelveticaNeue-Light";
			largeNumberLabel.FontSize = 52;
			largeNumberLabel.Text = "90";
			largeNumberLabel.TextColor = Color.FromRgb(0.00392156885936856, 0.47843137383461, 0.996078431606293);
			largeNumberLabel.HorizontalOptions = LayoutOptions.Center;
			largeNumberLabel.VerticalOptions = LayoutOptions.Fill;
			headerCellLayout.Children.Add(largeNumberLabel);

			var nameLabel = new Label ();
			nameLabel.FontFamily = "HelveticaNeue-Light";
			nameLabel.FontSize = 17;
			nameLabel.Text = "Name: John Doe";
			nameLabel.HorizontalOptions = LayoutOptions.CenterAndExpand;
			nameLabel.VerticalOptions = LayoutOptions.Center;
			headerCellLayout.Children.Add(nameLabel);

			viewHeaderCell.Height = 100;
			viewHeaderCell.View = headerCellLayout;
			tableHeaderSection.Add (viewHeaderCell);
			tableView.Root.Add (tableHeaderSection);

			for (int sectionNumber = 1; sectionNumber < 11; sectionNumber++) {
				var tableSection = new TableSection ("Section #" + sectionNumber);

				for (int cellNumber = 1; cellNumber < 11; cellNumber++) {

					var viewCell = new ViewCell ();
					var viewCellLayout = new StackLayout ();
					viewCellLayout.Orientation = StackOrientation.Horizontal;
					viewCellLayout.Spacing = 6;
					viewCellLayout.Padding = new Thickness (20, 10);
					viewCellLayout.HorizontalOptions = LayoutOptions.Center;
					viewCellLayout.VerticalOptions = LayoutOptions.Center;

					var titleLabel = new Label ();
					titleLabel.FontFamily = "HelveticaNeue-Light";
					titleLabel.FontSize = 17;
					titleLabel.Text = "Cell #" + cellNumber;
					viewCellLayout.Children.Add(titleLabel);

					viewCell.View = viewCellLayout;

					tableSection.Add (viewCell);
				}

				tableView.Root.Add (tableSection);

			}

			Content = tableView;

		}
Beispiel #41
0
		static void UpdateIsEnabled(ViewTableCell cell, ViewCell viewCell)
		{
			cell.UserInteractionEnabled = viewCell.IsEnabled;
			cell.TextLabel.Enabled = viewCell.IsEnabled;
		}
Beispiel #42
0
		protected override void Init ()
		{
			var instructions =
				@"In the picker below, select the option labeled 'Two'. If the selection immediately disappears, the test has failed.
In the TimePicker below, change the time to 5:21 PM. If the selection immediately disappears, the test has failed.
In the DatePicker below, change the date to May 25, 1977. If the selection immediately disappears, the test has failed.";

			var tableInstructions = new Label {
				Text = instructions
			};

			var picker = new Picker ();

			var pickerItems = new List<string> { "One", "Two", "Three" };

			foreach(string item in pickerItems)
			{
				picker.Items.Add(item);
			}

			var datePicker = new DatePicker ();
			var timePicker = new TimePicker ();

			var tableView = new TableView() { BackgroundColor = Color.Green };

			var tableSection = new TableSection();

			var pickerCell = new ViewCell { View = picker };
			var datepickerCell = new ViewCell { View = datePicker };
			var timepickerCell = new ViewCell { View = timePicker };

			tableSection.Add(pickerCell);
			tableSection.Add(timepickerCell);
			tableSection.Add(datepickerCell);

			var tableRoot = new TableRoot() {
				tableSection
			};

			tableView.Root = tableRoot;

			var listItems = new List<string> { "One" };

			var listView = new ListView
			{
				Header = instructions,
				BackgroundColor = Color.Pink,
				ItemTemplate = new DataTemplate(typeof(CustomCell)),
				ItemsSource = listItems
			};

			var nonListDatePicker = new DatePicker();
			var nonListTimePicker = new TimePicker();
			var nonListPicker = new Picker();

			foreach(string item in pickerItems)
			{
				nonListPicker.Items.Add(item);
			}

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				HorizontalOptions = LayoutOptions.Fill,
				Children = {
					new Label { Text = instructions },
					nonListPicker, 
					nonListDatePicker,
					nonListTimePicker,
					tableInstructions,
					tableView,
					listView
				}
			};
		}
Beispiel #43
0
        private void ViewCell_Tapped(object sender, EventArgs e)
        {
            ViewCell obj = (ViewCell)sender;

            obj.View.BackgroundColor = Color.FromHex("#F0EEEF");
        }
Beispiel #44
0
        protected override void Init()
        {
            var outputLabel = new Label();
            var testButton  = new Button
            {
                Text         = "Can't Touch This",
                AutomationId = CantTouchButtonId
            };

            testButton.Clicked += (sender, args) => outputLabel.Text = CantTouchFailText;

            var boxView = new BoxView
            {
                AutomationId = "nontransparentBoxView",
                Color        = Color.Pink.MultiplyAlpha(0.5)
            };

            // Bump up the elevation on Android so the Button is covered (FastRenderers)
            boxView.On <Android>().SetElevation(10f);

            var testGrid = new Grid
            {
                AutomationId = "testgrid",
                Children     =
                {
                    testButton,
                    boxView
                }
            };

            // BoxView over Button prevents Button click
            var testButtonOk = new Button
            {
                Text         = "Can Touch This",
                AutomationId = CanTouchButtonId
            };

            testButtonOk.Clicked += (sender, args) =>
            {
                outputLabel.Text = CanTouchSuccessText;
            };

            var testGridOk = new Grid
            {
                AutomationId = "testgridOK",
                Children     =
                {
                    testButtonOk,
                    new BoxView
                    {
                        AutomationId     = "transparentBoxView",
                        Color            = Color.Pink.MultiplyAlpha(0.5),
                        InputTransparent = true
                    }
                }
            };

            var testListView = new ListView();
            var items        = new[] { "Foo" };

            testListView.ItemsSource  = items;
            testListView.ItemTemplate = new DataTemplate(() =>
            {
                var result = new ViewCell
                {
                    View = new Grid
                    {
                        Children =
                        {
                            new BoxView
                            {
                                AutomationId = ListTapTarget,
                                Color        = Color.Pink.MultiplyAlpha(0.5)
                            }
                        }
                    }
                };

                return(result);
            });

            testListView.ItemSelected += (sender, args) => outputLabel.Text = ListTapSuccessText;

            Content = new StackLayout
            {
                AutomationId = "Container Stack Layout",
                Children     = { outputLabel, testGrid, testGridOk, testListView }
            };
        }
Beispiel #45
0
        private void CargarListaHojas()
        {
            var listaHojas = new List <ClaseHoja>();
            var esTeclaPar = false;

            foreach (var datosHoja in _listaHojas)
            {
                //Sólo lista hojas que contengan la palabra App (es el sufijo que tendrán las hojas para carga de movimientos, las otras son para cálculos y análisis).
                if (!datosHoja.Title.Text.Contains("App"))
                {
                    continue;
                }

                var linkHoja         = datosHoja.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null).HRef.ToString();
                var linkHistoricos   = datosHoja.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null).HRef.ToString();
                var estaSeleccionada = CuentaUsuario.ObtenerLinkHojaConsulta() == linkHoja; // Tiene que ser la actualmente seleccionada
                var estaUsada        = CuentaUsuario.VerificarHojaUsada(linkHoja);          // Tiene que haber sido seleccionada alguna vez.
                var esHistorico      = CuentaUsuario.VerificarHojaHistoricosUsada(linkHistoricos);
                var esPuntosVenta    = CuentaUsuario.VerificarHojaPuntosVentaUsada(linkHoja);

                if (estaSeleccionada || estaUsada)
                {
                    continue;                                                //Si la hoja está siendo usada para inventario o fue seleccionada en el paso anterior no la exponemos para históricos.
                }
                var hoja = new ClaseHoja(linkHistoricos, datosHoja.Title.Text, false, false, esHistorico, esPuntosVenta, esTeclaPar, linkHoja);
                listaHojas.Add(hoja);
                esTeclaPar = !esTeclaPar;
            }

            var vista = new ListView
            {
                RowHeight         = 60,
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Fill,
                ItemsSource       = listaHojas,
                ItemTemplate      = new DataTemplate(() =>
                {
                    var nombreHoja = new Label
                    {
                        FontSize          = 18,
                        TextColor         = Color.FromHex("#1D1D1B"),
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    };
                    nombreHoja.SetBinding(Label.TextProperty, "Nombre");

                    var icono = new Image
                    {
                        VerticalOptions   = LayoutOptions.Center,
                        HorizontalOptions = LayoutOptions.End,
                        HeightRequest     = App.AnchoRetratoDePantalla * .09259
                    };
                    icono.SetBinding(Image.SourceProperty, "ArchivoIcono");
                    icono.SetBinding(IsVisibleProperty, "TieneImagen");

                    var tecla = new StackLayout
                    {
                        Padding     = 7,
                        Orientation = StackOrientation.Horizontal,
                        Children    = { nombreHoja, icono }
                    };
                    tecla.SetBinding(BackgroundColorProperty, "ColorFondo");

                    var celda = new ViewCell {
                        View = tecla
                    };

                    celda.Tapped += (sender, args) =>
                    {
                        var hoja = (ClaseHoja)((ViewCell)sender).BindingContext;
                        EnviarPaginaPuntosVenta(hoja.Link, hoja.LinkHistoricoCeldas);
                        celda.View.BackgroundColor = Color.Silver;
                    };

                    return(celda);
                })
            };

            ContenedorHojas.Children.Clear();
            ContenedorHojas.Children.Add(vista);
        }
Beispiel #46
0
		public async void ForceUpdateSizeWillNotBeCalledIfParentIsNotAListViewWithUnevenRows ()
		{
			var lv = new ListView { HasUnevenRows = false };
			var cell = new ViewCell { Parent = lv };

			int numberOfCalls = 0;
			((ICellController)cell).ForceUpdateSizeRequested += (object sender, System.EventArgs e) => { numberOfCalls++; };

			cell.ForceUpdateSize ();

			await System.Threading.Tasks.Task.Delay (TimeSpan.FromMilliseconds (16));

			Assert.AreEqual (0, numberOfCalls);
		}
        public JobDetailsPage(JobService service)
        {
            this.jobService = service;

            this.Title = "Appointment Details";

            TableSection mainSection = new TableSection("Customer Details");

            mainSection.Add(new DataElementCell("CustomerName", "Customer"));
            mainSection.Add(new DataElementCell("Title", "Customer Notes"));
            mainSection.Add(new DataElementCell("CustomerAddress", "Address")
            {
                Height = 60
            });
            mainSection.Add(new DataElementCell("CustomerPhoneNumber", "Telephone"));

            var statusCell = new DataElementCell("Status");

            statusCell.ValueLabel.SetBinding <Job>(Label.TextColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
            mainSection.Add(statusCell);

            var workSection     = new TableSection("Work Performed");
            var workRowTemplate = new DataTemplate(typeof(SwitchCell));

            workRowTemplate.SetBinding(SwitchCell.TextProperty, "Name");
            workRowTemplate.SetBinding(SwitchCell.OnProperty, "Completed");
            //workRowTemplate.SetValue(TextCell.TextColorProperty, Color.White);

            // I don't have images working on Android yet
            //if (Device.OS == TargetPlatform.iOS)
            //	equipmentRowTemplate.SetBinding (ImageCell.ImageSourceProperty, "ThumbImage");

            var workListView = new ListView {
                RowHeight    = 50,
                ItemTemplate = workRowTemplate
            };

            workListView.SetBinding <Job>(ListView.ItemsSourceProperty, job => job.Items);

            var workCell = new ViewCell {
                View = workListView
            };

            workSection.Add(workCell);

            var actionsSection = new TableSection("Actions");

            TextCell completeJob = new TextCell {
                Text      = "Mark Completed",
                TextColor = AppStyle.DefaultActionColor
            };

            completeJob.Tapped += async delegate {
                await this.CompleteJobAsync();
            };

            actionsSection.Add(completeJob);

            var table = new TableView
            {
                Intent          = TableIntent.Form,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HasUnevenRows   = true,
                Root            = new TableRoot("Root")
                {
                    mainSection, workSection, actionsSection,
                }
            };

            this.Content = new ScrollView {
                Orientation = ScrollOrientation.Vertical,
                Content     = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Children    = { new JobHeaderView(leftPadding: 10, colorBackground: true), table }
                }
            };

            this.BindingContextChanged += delegate
            {
                if (SelectedJob != null && SelectedJob.Items != null)
                {
                    workCell.Height = SelectedJob.Items.Count * workListView.RowHeight;
                }
            };
        }
Beispiel #48
0
        protected override void Init()
        {
            var grid = new Grid
            {
                Padding           = 10,
                ColumnDefinitions = { new ColumnDefinition {
                                          Width = new GridLength(1, GridUnitType.Star)
                                      } },
                RowDefinitions = { new RowDefinition {
                                       Height = new GridLength(1, GridUnitType.Auto)
                                   }, new RowDefinition{
                                       Height = new GridLength(1, GridUnitType.Auto)
                                   } }
            };

            grid.Children.Add(new Label {
                Text = "I am initially visible."
            }, 0, 0);

            Label target = new Label {
                Text = "Success", AutomationId = "lblSuccess", IsVisible = false, TextColor = Color.Red
            };

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

            var tableView = new TableView {
                HasUnevenRows = true, Intent = TableIntent.Settings
            };

            ViewCell viewCell = new ViewCell {
                View = grid
            };
            TableSection item = new TableSection
            {
                viewCell,
                new ImageCell {
                    ImageSource = "cover1.jpg"
                }
            };

            tableView.Root.Add(item);

            var button = new Button
            {
                Text         = "Click me",
                AutomationId = "btnClick",
                Command      = new Command(() =>
                {
                    target.IsVisible = true;
                    viewCell.ForceUpdateSize();
                })
            };

            var label = new Label {
                Text = "Tap the button to expand the cell. If the cell does not expand and the red text is on top of the image, this test has failed."
            };

            Content = new StackLayout {
                Children = { label, button, tableView }, Margin = 20
            };
        }
Beispiel #49
0
        protected override void Init()
        {
            ListView list = new ListView();

            list.BackgroundColor = Color.Yellow;
            list.ItemsSource     =
                Enumerable
                .Range(0, 1000)
                .Select(x => String.Join("", Enumerable.Range(0, 100)))
                .ToArray();

            list.ItemTemplate = new DataTemplate(() =>
            {
                ViewCell cell = new ViewCell();

                Label label         = new Label();
                label.LineBreakMode = LineBreakMode.NoWrap;
                label.SetBinding(Label.TextProperty, ".");

                cell.View = label;
                return(cell);
            });

            Label labelScrollBarState = new Label();

            Content = new StackLayout()
            {
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    new Label()
                    {
                        Text = "Click the buttons to toggle scrollbar visibility and validate they works"
                    },
                    labelScrollBarState,
                    list,
                    new Button()
                    {
                        Text    = "Toggle Horizontal",
                        Command = new Command(() =>
                        {
                            switch (list.HorizontalScrollBarVisibility)
                            {
                            case ScrollBarVisibility.Always:
                                list.HorizontalScrollBarVisibility = ScrollBarVisibility.Default;
                                break;

                            case ScrollBarVisibility.Default:
                                list.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
                                break;

                            case ScrollBarVisibility.Never:
                                list.HorizontalScrollBarVisibility = ScrollBarVisibility.Always;
                                break;
                            }
                            UpdateScrollVisibility(list, labelScrollBarState);
                        })
                    },
                    new Button()
                    {
                        Text    = "Toggle Vertical",
                        Command = new Command(() =>
                        {
                            switch (list.VerticalScrollBarVisibility)
                            {
                            case ScrollBarVisibility.Always:
                                list.VerticalScrollBarVisibility = ScrollBarVisibility.Default;
                                break;

                            case ScrollBarVisibility.Default:
                                list.VerticalScrollBarVisibility = ScrollBarVisibility.Never;
                                break;

                            case ScrollBarVisibility.Never:
                                list.VerticalScrollBarVisibility = ScrollBarVisibility.Always;
                                break;
                            }
                            UpdateScrollVisibility(list, labelScrollBarState);
                        })
                    },
                }
            };

            UpdateScrollVisibility(list, labelScrollBarState);
        }
 static void UpdateIsEnabled(ViewTableCell cell, ViewCell viewCell)
 {
     cell.UserInteractionEnabled = viewCell.IsEnabled;
     cell.TextLabel.Enabled      = viewCell.IsEnabled;
 }
        void DisplayContent()
        {
            List <Message> messageListOfStudent = this.messageList.FindAll(
                delegate(Message message)
            {
                return(message.StudentId == this.message.StudentId && message.Id != this.message.Id);
            }
                );

            string descriptionLabelText = "Other messages from " + this.message.StudentId + ":";

            if (messageListOfStudent.Count < 1)
            {
                descriptionLabelText = this.message.StudentId + " did not send other messages";
            }

            Label studentIdLabel = new Label();

            studentIdLabel.Text              = this.message.StudentId;
            studentIdLabel.FontAttributes    = FontAttributes.Bold;
            studentIdLabel.FontSize          = 15;
            studentIdLabel.HorizontalOptions = LayoutOptions.Center;

            Label messageLabel = new Label();

            messageLabel.Text              = this.message.StudentMessage;
            messageLabel.FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            messageLabel.VerticalOptions   = LayoutOptions.Center;
            messageLabel.HorizontalOptions = LayoutOptions.Center;

            Label descriptionLabel = new Label();

            descriptionLabel.Text              = descriptionLabelText;
            descriptionLabel.FontSize          = 15;
            descriptionLabel.VerticalOptions   = LayoutOptions.Center;
            descriptionLabel.HorizontalOptions = LayoutOptions.Center;

            ListView listView = new ListView
            {
                // Source of data items.
                ItemsSource = messageListOfStudent,
                // Height of the items
                RowHeight = 100,

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

                    Label messageLabel2 = new Label();
                    messageLabel2.SetBinding(Label.TextProperty, "StudentMessage");
                    messageLabel2.LineBreakMode = LineBreakMode.TailTruncation; // trucate message

                    // Return an assembled ViewCell.
                    ViewCell viewCell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Padding     = new Thickness(0, 10),
                            Orientation = StackOrientation.Horizontal,
                            Children    =
                            {
                                new StackLayout
                                {
                                    VerticalOptions =
                                        LayoutOptions.Center,
                                    Spacing  = 10,
                                    Children =
                                    {
                                        messageLabel2
                                    }
                                }
                            }
                        }
                    };

                    return(viewCell);
                })
            };

            // Accomodate iPhone status bar.
            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                this.Padding = new Thickness(10, 0, 0, 0);
                break;

            default:
                this.Padding = new Thickness(10, 10, 5, 0);
                break;
            }

            this.Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Spacing         = 30,
                Children        =
                {
                    studentIdLabel,
                    messageLabel,
                    descriptionLabel,
                    listView
                }
            };
        }
Beispiel #52
0
				public _40333NavPusher(string title)
				{
					Title = title;

					_listView.ItemTemplate = new DataTemplate(() =>
					{
						var lbl = new Label();
						lbl.SetBinding(Label.TextProperty, ".");
						lbl.AutomationId = lbl.Text;

						var result = new ViewCell
						{
							View = new StackLayout
							{
								Orientation = StackOrientation.Horizontal,
								Children =
								{
									lbl
								}
							}
						};

						return result;
					});

					_listView.ItemsSource = new[] { "1", ClickThisId, StillHereId };
					_listView.ItemTapped += OnItemTapped;

					Content = new StackLayout {
						Children = { _listView }
					};
				}
Beispiel #53
0
		protected override void Init ()
		{
			var btnCustom1 = new Button () {
				AutomationId = "btnCustomCellTable",
				Text = "Custom Table Cell" ,
				HorizontalOptions = LayoutOptions.Start
			};
			var btnCustom1Enabled = new Button () {
				AutomationId = "btnCustomCellTableEnabled",
				Text = "Custom Table Cell Enabled" ,
				HorizontalOptions = LayoutOptions.Start
			};

			var btnCustom = new Button () {
				AutomationId = "btnCustomCellListView",
				Text = "Custom Cell" ,
				HorizontalOptions = LayoutOptions.Start
			};
		
			var btnCustomEnabled = new Button () {
				AutomationId = "btnCustomCellListViewEnabled",
				Text = "Custom Cell Enabled" ,
				HorizontalOptions = LayoutOptions.Start
			};

			btnCustom.Clicked += (object sender, EventArgs e) => {
				DisplayAlert ("Clicked", "I was clicked even disabled", "ok");
			};
			btnCustom1.Clicked += (object sender, EventArgs e) => {
				DisplayAlert ("Clicked", "I was clicked even disabled", "ok");
			};

			btnCustom1Enabled.Clicked += (object sender, EventArgs e) => {
				DisplayAlert ("Clicked", "I was clicked", "ok");
			};
			btnCustomEnabled.Clicked += (object sender, EventArgs e) => {
				DisplayAlert ("Clicked", "I was clicked", "ok");
			};

			var customCell = new ViewCell () {
				IsEnabled = false,
				View = new StackLayout { Children = { btnCustom } }
			};

			var customCellEnabled = new ViewCell () {
				View = new StackLayout { Children = { btnCustomEnabled } }
			};

			var customTableCell = new ViewCell () {
				IsEnabled = false,
				View = new StackLayout { Children = { btnCustom1 } }
			};

			var customTableCellEnabled = new ViewCell () {
				View = new StackLayout { Children = { btnCustom1Enabled } }
			};

			var tableview = new TableView () {
				Intent = TableIntent.Form,
				Root = new TableRoot (),
				VerticalOptions = LayoutOptions.Start
			};

			tableview.Root.Add (new TableSection () { customTableCell, customTableCellEnabled });

			var listview = new ListView { VerticalOptions = LayoutOptions.Start };
			var listview2 = new ListView { VerticalOptions = LayoutOptions.Start };

			listview.ItemTemplate = new DataTemplate (() => customCell);
			listview2.ItemTemplate = new DataTemplate (() => customCellEnabled);
			listview2.ItemsSource = listview.ItemsSource = new List<string> () { "1" };
		
			Content = new StackLayout {
				Orientation = StackOrientation.Vertical,
				VerticalOptions = LayoutOptions.Start,
				Children = { tableview, listview, listview2 }
			};
		}