public CustomerOrderListViewGroupHeaderCell()
        {
            var title = new Label
            {
                FontSize = Device.OnPlatform(Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))),
                TextColor = Color.White,
                VerticalOptions = LayoutOptions.Center,
                FontAttributes = FontAttributes.Bold
            };
            title.SetBinding(Label.TextProperty, "Key");

            var contentView = new ContentView() { Content = title, HeightRequest = Sizes.MediumRowHeight, Padding = new Thickness(10, 0) };

            contentView.SetBinding(StackLayout.BackgroundColorProperty, "Key", converter: new OrderListHeaderViewBackgroudColorConverter());

            View = contentView;
        }
        public virtual void Init()
        {
            NavigationPage.SetHasNavigationBar(this, false);
        

            float wTestata = 375;
            float hTestata = 64;

            float statusBarHeight = 20;
            float wButton = 40;

            pTestata = (App.ScreenWidth * hTestata) / wTestata;

            

            BackgroundColor = Color.White;
            Color btnBackColor = Color.Transparent;

            //Testata per navigationbar
            BoxView backAlpha = new BoxView
            {
                BackgroundColor = Color.Yellow
            };

            testataImage = new Image();
            testataImage.Source = UtilityResources.testata_logo_list;
            testataImage.BackgroundColor = Color.Transparent;

            btnMenu = new ToolbarButton(UtilityResources.ico_menu);
            btnMenu.btn.Clicked += BtnMenu_Clicked;
            btnMenu.btn.BackgroundColor = btnBackColor;

            btnBack = new ToolbarButton(UtilityResources.ico_back);
            btnBack.btn.Clicked += BtnBack_Clicked;
            btnBack.BackgroundColor = btnBackColor;
            btnBack.IsVisible = false;

            btnAction = new Button();
            btnAction.TextColor = Color.Black;
            btnAction.Clicked += BtnAction_Clicked;
            btnAction.BackgroundColor = btnBackColor;
            btnAction.IsVisible = false;

            btnSave = new ToolbarButton(UtilityResources.icon_Test);
            btnSave.btn.Clicked += BtnSave_Clicked;
            btnSave.BackgroundColor = btnBackColor;
            btnSave.IsVisible = false;

            lblTitle = new Label
            {
                BackgroundColor = Color.Transparent,
                TextColor = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = 25,

                LineBreakMode = LineBreakMode.TailTruncation
            };

            relativeLayout = new RelativeLayout();

            pTestata = (App.ScreenWidth * hTestata) / wTestata;
            relativeLayout.Children.Add(testataImage,
                 Constraint.RelativeToParent((parent) => {
                     return 0;
                 }),
                 Constraint.RelativeToParent((parent) => {
                     return 0;
                 }),
                 Constraint.RelativeToParent((parent) => {
                     return parent.Width;
                 }),
                 Constraint.RelativeToParent((parent) => {
                     return pTestata;
                 })
             );

            relativeLayout.Children.Add(btnMenu,
                Constraint.RelativeToParent((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnBack,
                Constraint.RelativeToParent((parent) => {
                    return 0;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnAction,
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

            relativeLayout.Children.Add(btnSave,
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return statusBarHeight;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton * 2;
                }),
                Constraint.RelativeToParent((parent) => {
                    return wButton;
                })
            );

           
            relativeLayout.Children.Add(lblTitle,
                Constraint.RelativeToParent((parent) => {
                    return 10;
                }),
                Constraint.RelativeToParent((parent) => {
                    return pTestata;
                }),
                Constraint.RelativeToParent((parent) => {
                    return parent.Width - 20;
                }),
                Constraint.RelativeToParent((parent) => {
                    return hLblTitle;
                })
            );

            abs = new AbsoluteLayout();

            AbsoluteLayout.SetLayoutFlags(relativeLayout, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(relativeLayout, new Rectangle(0, 0, 1, 1));
            abs.Children.Add(relativeLayout);

            //****ACTIVITY INDICATOR*******//
            #region activityIndicator
            var backIndicator = new ContentView();
            backIndicator.BackgroundColor = Color.Black;
            backIndicator.IsVisible = IsLoading;
            backIndicator.Opacity = 0.5;
            backIndicator.BindingContext = this;
            backIndicator.SetBinding(ContentView.IsVisibleProperty, "IsLoading");
            AbsoluteLayout.SetLayoutFlags(backIndicator, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(backIndicator, new Rectangle(0, 0, 1, 1));
            abs.Children.Add(backIndicator);

            var actIndicator = new ActivityIndicator();
            actIndicator.IsVisible = IsLoading;
            actIndicator.IsRunning = IsLoading;
            actIndicator.BindingContext = this;
            actIndicator.BackgroundColor = Color.Transparent;
            actIndicator.Color = Color.White;
            actIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsLoading");
            actIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
            AbsoluteLayout.SetLayoutFlags(actIndicator, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(actIndicator, new Rectangle(0.5, 0.5, -1, -1));
            abs.Children.Add(actIndicator);
            #endregion

            this.Content = abs;
        }
Esempio n. 3
0
		public SimonSaysPage(ParticleDevice device)
		{
			ViewModel = new SimonSaysViewModel(device);
			BindingContext = ViewModel;
			BackgroundColor = AppColors.BackgroundColor;
			Title = $"{device.Name} Says";

			red = new Button { StyleId = "red", BackgroundColor = SimonSaysColors.Red, BorderRadius = 0 };
			blue = new Button { StyleId = "blue", BackgroundColor = SimonSaysColors.Blue, BorderRadius = 0 };
			green = new Button { StyleId = "green", BackgroundColor = SimonSaysColors.Green, BorderRadius = 0 };
			yellow = new Button { StyleId = "yellow", BackgroundColor = SimonSaysColors.Yellow, BorderRadius = 0 };

			l1 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l2 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l3 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l4 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l5 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l6 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l7 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l8 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l9 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };
			l10 = new ContentView { HorizontalOptions = LayoutOptions.FillAndExpand };

			var stackPadding = 2d;
			StackLayout lightStack = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Children = { l1, l2, l3, l4, l5, l6, l7, l8, l9, l10 },
				Padding = new Thickness(stackPadding, 0, stackPadding, 0),
				BackgroundColor = Color.Transparent
			};

			var clearSubmission = new Button
			{
				StyleId = "clearMoveButton",
				Text = "X",
				FontSize = Device.OnPlatform(10, 8, 10),
				TextColor = Color.Black,
				FontAttributes = FontAttributes.Bold,
				BorderRadius = 10,
				BackgroundColor = Color.White,
				BorderColor = Color.Black,
				BorderWidth = 1
			};
			StyledButton actionButton = new StyledButton { StyleId = "actionButton", BorderRadius = 0, TextColor = Color.White, CssStyle = "button", BorderColor = AppColors.Blue };

			var layout = new RelativeLayout();

			var buttonConstraint = Constraint.RelativeToParent((p) => (p.Width / 2) - AppSettings.Margin - AppSettings.ItemPadding / 2);

			layout.Children.Add(red,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(yellow,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.Constant(AppSettings.Margin),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(blue,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToView(red, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(green,
				xConstraint: Constraint.RelativeToParent((p) => (p.Width / 2) + AppSettings.ItemPadding / 2),
				yConstraint: Constraint.RelativeToView(yellow, (p, v) => v.Height + v.Y + AppSettings.ItemPadding),
				widthConstraint: buttonConstraint,
				heightConstraint: buttonConstraint
			);

			layout.Children.Add(lightStack,
				xConstraint: Constraint.Constant(AppSettings.Margin - stackPadding),
				yConstraint: Constraint.RelativeToView(blue, (p, v) => v.Height + v.Y + AppSettings.ItemPadding * 2),
				widthConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin * 2 + stackPadding * 2),
				heightConstraint: Constraint.Constant(25) // TODO calculate the square size based on the width of the view
			);
			layout.Children.Add(clearSubmission,
				xConstraint: Constraint.RelativeToParent((p) => p.Width - AppSettings.Margin - Device.OnPlatform(10, 15, 15)),
				yConstraint: Constraint.RelativeToView(lightStack, (p, v) => Device.OnPlatform(
																				v.Y - 10,
																				v.Y - 15,
																				v.Y - 15
																			)
				),
				widthConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30)),
				heightConstraint: Constraint.Constant(Device.OnPlatform(25, 30, 30))
			);

			layout.Children.Add(actionButton,
				xConstraint: Constraint.Constant(AppSettings.Margin),
				yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight),
				widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2),
				heightConstraint: Constraint.Constant(50)
			);

			Content = layout;

			red.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("r");
			};
			blue.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("b");
			};
			green.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("g");
			};
			yellow.Clicked += async (object sender, EventArgs e) =>
			{
				await ViewModel.PlayerPressButtonAsync("y");
			};
			clearSubmission.Clicked += (object sender, EventArgs e) =>
			{
				ViewModel.ClearPlayerEntry();
			};

			red.SetBinding(Button.OpacityProperty, "RedOpacity");
			green.SetBinding(Button.OpacityProperty, "GreenOpacity");
			blue.SetBinding(Button.OpacityProperty, "BlueOpacity");
			yellow.SetBinding(Button.OpacityProperty, "YellowOpacity");

			l1.SetBinding(ContentView.BackgroundColorProperty, "L1");
			l2.SetBinding(ContentView.BackgroundColorProperty, "L2");
			l3.SetBinding(ContentView.BackgroundColorProperty, "L3");
			l4.SetBinding(ContentView.BackgroundColorProperty, "L4");
			l5.SetBinding(ContentView.BackgroundColorProperty, "L5");
			l6.SetBinding(ContentView.BackgroundColorProperty, "L6");
			l7.SetBinding(ContentView.BackgroundColorProperty, "L7");
			l8.SetBinding(ContentView.BackgroundColorProperty, "L8");
			l9.SetBinding(ContentView.BackgroundColorProperty, "L9");
			l10.SetBinding(ContentView.BackgroundColorProperty, "L10");

			clearSubmission.SetBinding(Button.IsVisibleProperty, "ShowClearButton");
			actionButton.SetBinding(Button.BackgroundColorProperty, "ActionColor");
			actionButton.SetBinding(Button.TextProperty, "ActionText");
			actionButton.SetBinding(Button.CommandProperty, "ActionCommand");
		}