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"); }
public FirstPage() : base(PageTitleConstants.FirstPage) { const string entryTextPaceHolder = "Enter text and click 'Go'"; var goButton = new StyledButton(Borders.Thin, 1) { Text = "Go", AutomationId = AutomationIdConstants.FirstPage_GoButton // This provides an ID that can be referenced in UITests }; goButton.Clicked += HandleButtonClicked; goButton.SetBinding(Button.CommandProperty, nameof(FirstViewModel.GoButtonCommand)); goButton.SetBinding(Button.CommandParameterProperty, nameof(FirstViewModel.EntryText)); var textEntry = new StyledEntry(1) { Placeholder = entryTextPaceHolder, AutomationId = AutomationIdConstants.FirstPage_TextEntry, // This provides an ID that can be referenced in UITests HorizontalTextAlignment = TextAlignment.Center, ReturnType = ReturnType.Go }; textEntry.SetBinding(Entry.TextProperty, nameof(FirstViewModel.EntryText)); textEntry.SetBinding(Entry.ReturnCommandProperty, nameof(FirstViewModel.GoButtonCommand)); textEntry.SetBinding(Entry.ReturnCommandParameterProperty, nameof(FirstViewModel.EntryText)); var textLabel = new StyledLabel { AutomationId = AutomationIdConstants.FirstPage_TextLabel, // This provides an ID that can be referenced in UITests HorizontalOptions = LayoutOptions.Center }; textLabel.SetBinding(Label.TextProperty, nameof(FirstViewModel.LabelText)); var listPageButton = new StyledButton(Borders.Thin, 1) { Text = "Go to List Page", AutomationId = AutomationIdConstants.FirstPage_ListViewButton,// This provides an ID that can be referenced in UITests }; listPageButton.Clicked += HandleListPageButtonClicked; var activityIndicator = new ActivityIndicator { AutomationId = AutomationIdConstants.FirstPage_BusyActivityIndicator, // This provides an ID that can be referenced in UITests Color = Color.White }; activityIndicator.SetBinding(IsVisibleProperty, nameof(FirstViewModel.IsActiityIndicatorRunning)); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(FirstViewModel.IsActiityIndicatorRunning)); Func <RelativeLayout, double> getTextEntryWidth = (p) => textEntry.Measure(p.Width, p.Height).Request.Width; Func <RelativeLayout, double> getGoButtonWidth = (p) => goButton.Measure(p.Width, p.Height).Request.Width; Func <RelativeLayout, double> getActivityIndicatorWidth = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width; Func <RelativeLayout, double> getTextLabelWidth = (p) => textLabel.Measure(p.Width, p.Height).Request.Width; var relativeLayout = new RelativeLayout(); relativeLayout.Children.Add(textEntry, Constraint.RelativeToParent(parent => parent.X), Constraint.RelativeToParent(parent => parent.Y), Constraint.RelativeToParent(parent => parent.Width - 20)); relativeLayout.Children.Add(goButton, Constraint.RelativeToParent(parent => parent.X), Constraint.RelativeToView(textEntry, (parent, view) => view.Y + view.Height + _relativeLayoutPadding), Constraint.RelativeToParent(parent => parent.Width - 20)); relativeLayout.Children.Add(activityIndicator, Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2), Constraint.RelativeToView(goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding)); relativeLayout.Children.Add(textLabel, Constraint.RelativeToParent(parent => parent.Width / 2 - getTextLabelWidth(parent) / 2), Constraint.RelativeToView(goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding)); relativeLayout.Children.Add(listPageButton, Constraint.RelativeToParent(parent => parent.X), Constraint.RelativeToView(goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding * 15), Constraint.RelativeToParent(parent => parent.Width - 20)); Padding = GetPagePadding(); Content = relativeLayout; }
public DeviceLandingPage(ParticleDevice device) { Title = "Mission Control"; BackgroundColor = AppColors.BackgroundColor; ViewModel = new DeviceLandingPageViewModel(device); BindingContext = ViewModel; var refreshDevice = new ToolbarItem { Icon = "ic_cached_white_24dp.png" }; var back = new ToolbarItem { Icon = "ic_clear_white.png" }; var layout = new RelativeLayout(); var indicator = new ActivityIndicator(); var deviceName = new StyledLabel { CssStyle = "h1" }; var deviceConnected = new Image { Source = "notconnected.png" }; var currentAppLabel = new StyledLabel { CssStyle = "h2" }; var variableWidget = new DashboardWidget(); var functionWidget = new DashboardWidget(); var appDescription = new StyledLabel { CssStyle = "body" }; var interactButton = new StyledButton { StyleId = "startInteractionButton", Text = "START INTERACTION", BackgroundColor = AppColors.Green, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, IsEnabled = false }; var flashButton = new StyledButton { StyleId = "flashBinaryButton", Text = "FLASH NEW APP", BackgroundColor = AppColors.Purple, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, IsEnabled = false }; var boxConstraint = Constraint.RelativeToParent(p => p.Width / 2 - AppSettings.Margin - AppSettings.ItemPadding / 2); layout.Children.Add(deviceName, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.Constant(Device.OnPlatform(AppSettings.Margin, 10, 10)), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2) ); layout.Children.Add(currentAppLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Y + v.Height + 5), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Height) ); layout.Children.Add(variableWidget, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(currentAppLabel, (p, v) => Device.OnPlatform( v.Y + v.Height + 5, v.Y + v.Height, v.Y + v.Height) ), widthConstraint: boxConstraint, heightConstraint: boxConstraint ); layout.Children.Add(functionWidget, xConstraint: Constraint.RelativeToParent(p => p.Width / 2 + AppSettings.ItemPadding / 2), yConstraint: Constraint.RelativeToView(variableWidget, (p, v) => v.Y), widthConstraint: boxConstraint, heightConstraint: boxConstraint ); layout.Children.Add(new ScrollView { Content = appDescription }, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20) ); layout.Children.Add(flashButton, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); layout.Children.Add(interactButton, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(flashButton, (p, v) => v.Y - AppSettings.ButtonHeight - 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); layout.Children.Add(indicator, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20) ); variableWidget.WidgetTitle.Text = "Variables"; functionWidget.WidgetTitle.Text = "Functions"; if (Device.OS == TargetPlatform.iOS) { interactButton.TextColor = Color.FromHex("#ffffff"); flashButton.TextColor = Color.FromHex("#ffffff"); } Content = layout; ToolbarItems.Add(refreshDevice); ToolbarItems.Add(back); indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android) { indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy"); } deviceName.SetBinding(Label.TextProperty, "Device.Name"); currentAppLabel.SetBinding(Label.TextProperty, "CurrentApp"); deviceConnected.SetBinding(Image.IsVisibleProperty, "DeviceConnected"); variableWidget.WidgetCount.SetBinding(Label.TextProperty, "VariableCount"); functionWidget.WidgetCount.SetBinding(Label.TextProperty, "FunctionCount"); interactButton.SetBinding(Button.IsEnabledProperty, "InteractButtonLock"); flashButton.SetBinding(Button.IsEnabledProperty, "FlashButtonLock"); refreshDevice.SetBinding(ToolbarItem.CommandProperty, "RefreshDeviceCommand"); appDescription.SetBinding(Label.TextProperty, "AppDescription"); interactButton.Clicked += async(object sender, EventArgs e) => { if (ViewModel.CurrentApp.ToLower().Contains("rgb led picker")) { await Navigation.PushAsync(new ChangeLEDColorPage(ViewModel.Device, ViewModel.variables)); } else if (ViewModel.CurrentApp.ToLower().Contains("simonsays")) { await Navigation.PushAsync(new SimonSaysPage(ViewModel.Device)); } else { DisplayAlert("Sorry...", "There isn't a mobile interaction with this IoT app. Try flashing either the 'Simon Says' or ' RBG LED' app.", "Ok"); } }; flashButton.Clicked += async(object sender, EventArgs e) => { var result = await DisplayActionSheet("Pick File to Flash", "Cancel", null, "RGB LED", "Shake LED", "Simon Says", "Follow me LED"); if (result != "Cancel") { var success = await ViewModel.TryFlashFileAsync(result); if (!success) { await DisplayAlert("Error", "The Device connection timed out. Please try again once the device breaths a solid cyan light", "Ok"); } } }; back.Clicked += async(object sender, EventArgs e) => { var success = await ViewModel.Device.UnclaimAsync(); //if (success) Navigation.PopModalAsync(true); }; }
public DeviceLandingPage(ParticleDevice device) { Title = "Mission Control"; BackgroundColor = AppColors.BackgroundColor; ViewModel = new DeviceLandingPageViewModel(device); BindingContext = ViewModel; var refreshDevice = new ToolbarItem { Icon = "ic_cached_white_24dp.png" }; var back = new ToolbarItem { Icon = "ic_clear_white.png" }; var layout = new RelativeLayout(); var indicator = new ActivityIndicator(); var deviceName = new StyledLabel { CssStyle = "h1" }; var deviceConnected = new Image { Source = "notconnected.png" }; var currentAppLabel = new StyledLabel { CssStyle = "h2" }; var variableWidget = new DashboardWidget(); var functionWidget = new DashboardWidget(); var appDescription = new StyledLabel { CssStyle = "body" }; var interactButton = new StyledButton { StyleId = "startInteractionButton", Text = "START INTERACTION", BackgroundColor = AppColors.Green, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, IsEnabled = false }; var flashButton = new StyledButton { StyleId = "flashBinaryButton", Text = "FLASH NEW APP", BackgroundColor = AppColors.Purple, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, IsEnabled = false }; var boxConstraint = Constraint.RelativeToParent(p => p.Width / 2 - AppSettings.Margin - AppSettings.ItemPadding / 2); layout.Children.Add(deviceName, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.Constant(Device.OnPlatform(AppSettings.Margin, 10, 10)), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2) ); layout.Children.Add(currentAppLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Y + v.Height + 5), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(deviceName, (p, v) => v.Height) ); layout.Children.Add(variableWidget, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(currentAppLabel, (p, v) => Device.OnPlatform( v.Y + v.Height + 5, v.Y + v.Height, v.Y + v.Height) ), widthConstraint: boxConstraint, heightConstraint: boxConstraint ); layout.Children.Add(functionWidget, xConstraint: Constraint.RelativeToParent(p => p.Width / 2 + AppSettings.ItemPadding / 2), yConstraint: Constraint.RelativeToView(variableWidget, (p, v) => v.Y), widthConstraint: boxConstraint, heightConstraint: boxConstraint ); layout.Children.Add(new ScrollView { Content = appDescription }, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20) ); layout.Children.Add(flashButton, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); layout.Children.Add(interactButton, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(flashButton, (p, v) => v.Y - AppSettings.ButtonHeight - 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); layout.Children.Add(indicator, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(functionWidget, (p, v) => v.Y + v.Height + 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.RelativeToView(functionWidget, (p, v) => p.Height - v.Y - v.Height - 10 - AppSettings.Margin - 2 * AppSettings.ButtonHeight - 20) ); variableWidget.WidgetTitle.Text = "Variables"; functionWidget.WidgetTitle.Text = "Functions"; if (Device.OS == TargetPlatform.iOS) { interactButton.TextColor = Color.FromHex("#ffffff"); flashButton.TextColor = Color.FromHex("#ffffff"); } Content = layout; ToolbarItems.Add(refreshDevice); ToolbarItems.Add(back); indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android) indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy"); deviceName.SetBinding(Label.TextProperty, "Device.Name"); currentAppLabel.SetBinding(Label.TextProperty, "CurrentApp"); deviceConnected.SetBinding(Image.IsVisibleProperty, "DeviceConnected"); variableWidget.WidgetCount.SetBinding(Label.TextProperty, "VariableCount"); functionWidget.WidgetCount.SetBinding(Label.TextProperty, "FunctionCount"); interactButton.SetBinding(Button.IsEnabledProperty, "InteractButtonLock"); flashButton.SetBinding(Button.IsEnabledProperty, "FlashButtonLock"); refreshDevice.SetBinding(ToolbarItem.CommandProperty, "RefreshDeviceCommand"); appDescription.SetBinding(Label.TextProperty, "AppDescription"); interactButton.Clicked += async (object sender, EventArgs e) => { if (ViewModel.CurrentApp.ToLower().Contains("rgb led picker")) await Navigation.PushAsync(new ChangeLEDColorPage(ViewModel.Device, ViewModel.variables)); else if (ViewModel.CurrentApp.ToLower().Contains("simonsays")) await Navigation.PushAsync(new SimonSaysPage(ViewModel.Device)); else DisplayAlert("Sorry...", "There isn't a mobile interaction with this IoT app. Try flashing either the 'Simon Says' or ' RBG LED' app.", "Ok"); }; flashButton.Clicked += async (object sender, EventArgs e) => { var result = await DisplayActionSheet("Pick File to Flash", "Cancel", null, "RGB LED", "Shake LED", "Simon Says", "Follow me LED"); if (result != "Cancel") { var success = await ViewModel.TryFlashFileAsync(result); if (!success) { await DisplayAlert("Error", "The Device connection timed out. Please try again once the device breaths a solid cyan light", "Ok"); } } }; back.Clicked += async (object sender, EventArgs e) => { var success = await ViewModel.Device.UnclaimAsync(); //if (success) Navigation.PopModalAsync(true); }; }
public NewUserSignUpPage() { ViewModel.SaveFailed += HandleSaveFailed; ViewModel.TakePhotoFailed += HandleTakePhotoFailed; ViewModel.SaveSuccessfullyCompleted += HandleSaveSuccessfullyCompleted; BackgroundColor = Color.FromHex("2980b9"); var passwordEntry = new StyledEntry(1) { Placeholder = "Password", IsPassword = true, HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.End, VerticalOptions = LayoutOptions.Fill, PlaceholderColor = Color.FromHex("749FA8"), ReturnType = ReturnType.Done }; passwordEntry.ReturnCommand = new Command(() => passwordEntry.Unfocus()); passwordEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.PasswordEntryText)); var usernameEntry = new StyledEntry(1) { Placeholder = "Username", HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.End, PlaceholderColor = Color.FromHex("749FA8"), ReturnType = ReturnType.Next, ReturnCommand = new Command(() => passwordEntry.Focus()) }; usernameEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.UsernameEntryText)); _saveUsernameButton = new StyledButton(Borders.Thin, 1) { Text = "Save User", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.EndAndExpand }; _saveUsernameButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); _saveUsernameButton.SetBinding(Button.CommandProperty, nameof(ViewModel.SaveButtonCommand)); _cancelButton = new StyledButton(Borders.Thin, 1) { Text = "Cancel", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End }; _cancelButton.Clicked += HandleCancelButtonClicked; _cancelButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); _cancelButton.SetBinding(Button.CommandProperty, nameof(ViewModel.CancelButtonCommand)); _takePhotoButton = new StyledButton(Borders.Thin, 1) { Text = "Take Photo", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.EndAndExpand }; _takePhotoButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoButtonCommand)); var isFacialRecognitionCompletedDescriptionLabel = new StyledLabel { Text = "Facial Recognition Completed", VerticalTextAlignment = TextAlignment.Center }; var isFacialRecognitionCompletedLabel = new FontAwesomeIcon { TextColor = Color.White, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center }; isFacialRecognitionCompletedLabel.SetBinding(Label.TextProperty, nameof(ViewModel.FontAwesomeLabelText)); if (Device.RuntimePlatform is Device.iOS) { isFacialRecognitionCompletedLabel.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionInactive)); } var activityIndicator = new ActivityIndicator { Color = Color.White, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.EndAndExpand, }; activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionActive)); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsInternetConnectionActive)); var facialRecognitionStackLayout = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, Children = { isFacialRecognitionCompletedDescriptionLabel, isFacialRecognitionCompletedLabel } }; var stackLayout = new StackLayout { Padding = new Thickness(20, 50, 20, 20), VerticalOptions = LayoutOptions.FillAndExpand, Children = { new Label { Text = "Please enter username", TextColor = Color.White, HorizontalOptions = LayoutOptions.Start }, usernameEntry, new Label { Text = "Please enter password", TextColor = Color.White, HorizontalOptions = LayoutOptions.Start }, passwordEntry, _takePhotoButton, facialRecognitionStackLayout, } }; switch (Device.RuntimePlatform) { case Device.iOS: facialRecognitionStackLayout.Children.Add(activityIndicator); break; case Device.Android: stackLayout.Children.Add(activityIndicator); break; default: throw new NotSupportedException("Device Runtime Unsupported"); } stackLayout.Children.Add(_saveUsernameButton); stackLayout.Children.Add(_cancelButton); Content = new Xamarin.Forms.ScrollView { Content = stackLayout }; On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true); }
public ChangeLEDColorPage(ParticleDevice device, Dictionary <string, string> variables) { Title = "RBG LED"; BackgroundColor = AppColors.BackgroundColor; ViewModel = new ChangeLEDColorViewModel(device, variables); BindingContext = ViewModel; var indicator = new ActivityIndicator { HeightRequest = Device.OnPlatform(50, 30, 50) }; var colorPreview = new BoxView { HeightRequest = 100 }; var redSlider = new Slider { StyleId = "redSlider", Minimum = 0, Maximum = 255, Value = 0 }; var greenSlider = new Slider { StyleId = "greenSlider", Minimum = 0, Maximum = 255, Value = 0 }; var blueSlider = new Slider { StyleId = "blueSlider", Minimum = 0, Maximum = 255, Value = 0 }; var push = new StyledButton { StyleId = "pushRGBvalueButton", Text = "PUSH TO PHOTON", BackgroundColor = AppColors.Blue, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, VerticalOptions = LayoutOptions.Fill }; var lightShow = new StyledButton { StyleId = "startLightShowButton", Text = "START A LIGHT SHOW", BackgroundColor = AppColors.Green, CssStyle = "button", BorderRadius = 0, HeightRequest = AppSettings.ButtonHeight, VerticalOptions = LayoutOptions.End }; var previewLabel = new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start }; var rLabel = new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start }; var gLabel = new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start }; var bLabel = new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start }; Func <RelativeLayout, View, double> layoutAfterPrevious = (p, v) => Device.OnPlatform( v.Y + v.Height + 5, v.Y + v.Height + 5, v.Y + v.Height + 2); RelativeLayout relativeLayout = new RelativeLayout(); relativeLayout.Children.Add(previewLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.Constant(10) ); relativeLayout.Children.Add(colorPreview, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(previewLabel, layoutAfterPrevious), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight * 2) ); relativeLayout.Children.Add(rLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(colorPreview, layoutAfterPrevious) ); relativeLayout.Children.Add(redSlider, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(rLabel, layoutAfterPrevious), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2) ); relativeLayout.Children.Add(gLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(redSlider, layoutAfterPrevious) ); relativeLayout.Children.Add(greenSlider, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(gLabel, layoutAfterPrevious), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2) ); relativeLayout.Children.Add(bLabel, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(greenSlider, layoutAfterPrevious) ); relativeLayout.Children.Add(blueSlider, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(bLabel, layoutAfterPrevious), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2) ); relativeLayout.Children.Add(indicator, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(blueSlider, layoutAfterPrevious), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(Device.OnPlatform(50, 50, 25)) ); relativeLayout.Children.Add(lightShow, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToParent(p => p.Height - AppSettings.Margin - AppSettings.ButtonHeight), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); relativeLayout.Children.Add(push, xConstraint: Constraint.Constant(AppSettings.Margin), yConstraint: Constraint.RelativeToView(lightShow, (p, v) => v.Y - AppSettings.ButtonHeight - 10), widthConstraint: Constraint.RelativeToParent(p => p.Width - AppSettings.Margin * 2), heightConstraint: Constraint.Constant(AppSettings.ButtonHeight) ); // StackLayout layout = new StackLayout //{ // VerticalOptions = LayoutOptions.CenterAndExpand, // Padding = new Thickness(AppSettings.Margin, 10, AppSettings.Margin, AppSettings.Margin), // Spacing = 10, // Children = { // new StyledLabel { CssStyle = "body", Text = "Color Preview:", HorizontalOptions = LayoutOptions.Start }, // colorPreview, // new StyledLabel { CssStyle = "body", Text = "R Value", HorizontalOptions = LayoutOptions.Start }, // redSlider, // new StyledLabel { CssStyle = "body", Text = "G Value", HorizontalOptions = LayoutOptions.Start }, // greenSlider, // new StyledLabel { CssStyle = "body", Text = "B Value", HorizontalOptions = LayoutOptions.Start }, // blueSlider, // indicator, // push, // lightShow // } //}; if (Device.OS == TargetPlatform.iOS) { push.FontFamily = "SegoeUI-Light"; push.FontSize = 16; push.TextColor = Color.FromHex("#ffffff"); lightShow.FontFamily = "SegoeUI-Light"; lightShow.FontSize = 16; lightShow.TextColor = Color.FromHex("#ffffff"); } var off = new ToolbarItem { Text = "LEDs Off" }; Content = relativeLayout; indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); if (Device.OS != TargetPlatform.iOS && Device.OS != TargetPlatform.Android) { indicator.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy"); } redSlider.SetBinding(Slider.ValueProperty, "R", BindingMode.TwoWay); greenSlider.SetBinding(Slider.ValueProperty, "G", BindingMode.TwoWay); blueSlider.SetBinding(Slider.ValueProperty, "B", BindingMode.TwoWay); colorPreview.SetBinding(BoxView.BackgroundColorProperty, "ColorBoxColor"); push.SetBinding(Button.CommandProperty, "PushColorCommand"); lightShow.SetBinding(Button.CommandProperty, "LightShowCommand"); off.SetBinding(ToolbarItem.CommandProperty, "LedsOffCommand"); ToolbarItems.Add(off); }
public LoginPage() { try { ViewModel.LoginFailed += HandleLoginFailed; ViewModel.LoginApproved += HandleLoginApproved; BackgroundColor = Color.FromHex("#3498db"); Padding = GetPagePadding(); _logo = new Image { Source = "xamarin_logo" }; _logoSlogan = new StyledLabel { Opacity = 0, Text = "ABSENSI", }; _usernameEntry = new StyledEntry { Placeholder = "Username", ReturnType = ReturnType.Next, ReturnCommand = new Command(() => _passwordEntry.Focus()) }; _usernameEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.UsernameEntryText)); _passwordEntry = new StyledEntry { Placeholder = "Password", IsPassword = true, ReturnType = ReturnType.Done }; _passwordEntry.SetBinding(Xamarin.Forms.Entry.TextProperty, nameof(ViewModel.PasswordEntryText)); _passwordEntry.SetBinding(Xamarin.Forms.Entry.ReturnCommandProperty, nameof(ViewModel.LoginButtonTappedCommand)); _loginButton = new StyledButton(Borders.Thin) { Text = "Login" }; _loginButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); _loginButton.SetBinding(Button.CommandProperty, nameof(ViewModel.LoginButtonTappedCommand)); _newUserSignUpButton = new StyledButton(Borders.None) { Text = "Sign-up" }; _newUserSignUpButton.Clicked += HandleNewUserSignUpButtonClicked; _newUserSignUpButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); _HomeAutomationButton = new StyledButton(Borders.None) { Text = "Home Automation" }; _HomeAutomationButton.Clicked += HandleHomeAutomationClicked; _HomeAutomationButton.SetBinding(IsEnabledProperty, nameof(ViewModel.IsInternetConnectionInactive)); var activityIndicator = new ActivityIndicator { Color = Color.White }; activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsInternetConnectionActive)); activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsInternetConnectionActive)); On <Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(true); Func <RelativeLayout, double> getNewUserButtonWidth = (p) => _newUserSignUpButton.Measure(p.Width, p.Height).Request.Width; Func <RelativeLayout, double> getLogoSloganWidth = (p) => _logoSlogan.Measure(p.Width, p.Height).Request.Width; Func <RelativeLayout, double> getActivityIndicatorHeight = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Height; Func <RelativeLayout, double> getActivityIndicatorWidth = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width; _relativeLayout = new RelativeLayout(); _relativeLayout.Children.Add( _logo, xConstraint: Constraint.Constant(100), yConstraint: Constraint.Constant(250), widthConstraint: Constraint.RelativeToParent(p => p.Width - 200) ); _relativeLayout.Children.Add( _logoSlogan, xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getLogoSloganWidth(p) / 2)), yConstraint: Constraint.Constant(125) ); _relativeLayout.Children.Add( _usernameEntry, xConstraint: Constraint.Constant(40), yConstraint: Constraint.RelativeToView(_logoSlogan, (p, v) => v.Y + v.Height + _relativeLayoutPadding), widthConstraint: Constraint.RelativeToParent(p => p.Width - 80) ); _relativeLayout.Children.Add( _passwordEntry, xConstraint: Constraint.Constant(40), yConstraint: Constraint.RelativeToView(_usernameEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding), widthConstraint: Constraint.RelativeToParent(p => p.Width - 80) ); _relativeLayout.Children.Add( _loginButton, xConstraint: Constraint.Constant(40), yConstraint: Constraint.RelativeToView(_passwordEntry, (p, v) => v.Y + v.Height + _relativeLayoutPadding), widthConstraint: Constraint.RelativeToParent(p => p.Width - 80) ); _relativeLayout.Children.Add( _newUserSignUpButton, xConstraint: Constraint.RelativeToParent(p => (p.Width / 2) - (getNewUserButtonWidth(p) / 2)), yConstraint: Constraint.RelativeToView(_loginButton, (p, v) => v.Y + _loginButton.Height + 15) ); _relativeLayout.Children.Add( _HomeAutomationButton, xConstraint: Constraint.Constant(40), yConstraint: Constraint.RelativeToView(_newUserSignUpButton, (p, v) => v.Y + v.Height + _relativeLayoutPadding), widthConstraint: Constraint.RelativeToParent(p => p.Width - 80) ); _relativeLayout.Children.Add(activityIndicator, xConstraint: Constraint.RelativeToParent(parent => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2), yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2 - getActivityIndicatorHeight(parent) / 2)); Content = new Xamarin.Forms.ScrollView { Content = _relativeLayout }; } catch (Exception ec) { DisplayAlert("Error", ec.ToString(), "Ok"); } }
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"); }