protected override void OnBindingContextChanged () { base.OnBindingContextChanged (); if (BindingContext == null) return; if ((BindingContext as MapCardViewModel).Context != MapCardViewModel.MapCardContext.Search) { var doneButton = new ToolbarItem (); doneButton.SetBinding<MapCardViewModel> (ToolbarItem.TextProperty, vm => vm.DoneLabel); doneButton.SetBinding<MapCardViewModel> (ToolbarItem.CommandProperty, vm => vm.DoneCommand); ToolbarItems.Add (doneButton); } }
ToolbarItem CreateClearButton () { var clearButton = new ToolbarItem { Name = "Clear" }; clearButton.SetBinding (ToolbarItem.CommandProperty, "ClearTrackFilters"); return clearButton; }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); // Fixed in next version of Xamarin.Forms. BindingContext is not properly set on ToolbarItem. var aboutItem = new ToolbarItem { Name = "About", BindingContext = BindingContext }; aboutItem.SetBinding(ToolbarItem.CommandProperty, new Binding("ShowAboutPageCommand")); ToolbarItems.Add(aboutItem); }
static ToolbarItem CreateFiltersItem () { var filters = new ToolbarItem { Icon = "filter.png", Name = "Filter" }; filters.SetBinding (ToolbarItem.CommandProperty, "ShowFilters"); return filters; }
public FruitsPage() { var toolbarItem = new ToolbarItem { Text = "Add fruit", }; toolbarItem.SetBinding(ToolbarItem.CommandProperty, FruitsViewModel.AddFruitCommandProperty); ToolbarItems.Add(toolbarItem); Content = FruitsListView(); }
public NewEntryPage () { Title = "New Entry"; // Form fields var title = new EntryCell { Label = "Titel" }; title.SetBinding (EntryCell.TextProperty, "Title", BindingMode.TwoWay); var latitude = new EntryCell { Label = "Latitude", Keyboard = Keyboard.Numeric }; latitude.SetBinding (EntryCell.TextProperty, "Latitude", BindingMode.TwoWay); var longitude = new EntryCell {Label = "Longitude", Keyboard = Keyboard.Numeric }; longitude.SetBinding (EntryCell.TextProperty, "Longitude", BindingMode.TwoWay); var date = new DatePickerEntryCell {Label = "Date"}; date.SetBinding (DatePickerEntryCell.DateProperty, "Date",BindingMode.TwoWay); var rating = new EntryCell { Label = "Rating", Keyboard = Keyboard.Numeric }; rating.SetBinding (EntryCell.TextProperty, "Rating", BindingMode.TwoWay); var notes = new EntryCell { Label = "Notes" }; notes.SetBinding (EntryCell.TextProperty, "Notes", BindingMode.TwoWay); // Form var entryForm = new TableView { Intent = TableIntent.Form, Root = new TableRoot { new TableSection () { title, latitude, longitude, date, rating, notes } } }; Content = entryForm; var save = new ToolbarItem { Text = "Save" }; save.SetBinding (ToolbarItem.CommandProperty, "SaveCommand"); ToolbarItems.Add (save); }
public ContactsView () { BaseViewModel.CreateAndBind<ContactsViewModel> (this); SetBinding (ContactsView.NavigationProperty, new Binding("Navigation")); SetBinding(AlertProperty, new Binding("AlertMessage")); Title = "Contacts"; NavigationPage.SetBackButtonTitle (this, ""); var addContactButton = new ToolbarItem { Icon = "plus.png", Name = "Add Contact", }; addContactButton.SetBinding<ContactsViewModel> (ToolbarItem.CommandProperty, vm => vm.AddContactCommand); this.ToolbarItems.Add(addContactButton); var relativeLayout = new RelativeLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; var searchBar = CreateSearchBar (); relativeLayout.Children.Add (searchBar, Constraint.RelativeToParent ((parent) => { return parent.X; }), Constraint.RelativeToParent ((parent) => { return parent.Y; }), Constraint.RelativeToParent ((parent) => { return parent.Width; }) ); _listView = CreateList (); relativeLayout.Children.Add (_listView, Constraint.RelativeToParent ((parent) => { return parent.X; }), Constraint.RelativeToView (searchBar, (parent,sibling) => { return sibling.Height; }), Constraint.RelativeToParent ((parent) => { return parent.Width; }), Constraint.RelativeToView (searchBar, (parent,sibling) => { return parent.Height - sibling.Height; }) ); var gettingStarted = CreateGettingStartedView (); relativeLayout.Children.Add (gettingStarted, Constraint.RelativeToParent ((parent) => { return parent.X; }), Constraint.RelativeToParent ((parent) => { return (parent.Height / 2) - 100; }), Constraint.RelativeToParent ((parent) => { return parent.Width; }), Constraint.RelativeToParent ((parent) => { return parent.Height - 175; }) ); Content = relativeLayout; }
public MainPage () { Title = "TripLog"; var itemTemplate = new DataTemplate (typeof(TextCell)); itemTemplate.SetBinding (TextCell.TextProperty, "Title"); itemTemplate.SetBinding (TextCell.DetailProperty, "Notes"); var entries = new ListView { ItemTemplate = itemTemplate }; entries.SetBinding (ListView.ItemsSourceProperty, "LogEntries"); entries.SetBinding (ListView.IsVisibleProperty, "IsBusy", converter: new ReverseBooleanConverter()); entries.ItemTapped += (sender, e) => { var item = (TripLogEntry) e.Item; vm.ViewCommand.Execute (item); }; var newButton = new ToolbarItem { Text = "New" }; newButton.SetBinding (ToolbarItem.CommandProperty, "NewCommand"); ToolbarItems.Add (newButton); var loading = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Children = { new ActivityIndicator { IsRunning = true }, new Label { Text = "Loading Entries..." } } }; loading.SetBinding (StackLayout.IsVisibleProperty, "IsBusy"); var mainLayout = new Grid { Children = { entries, loading } }; Content = mainLayout; }
public ProfileView () { BaseViewModel.CreateAndBind<ProfileViewModel> (this); SetBinding (ProfileView.NavigationProperty, new Binding("Navigation")); Title = "Profile"; NavigationPage.SetBackButtonTitle (this, ""); var edit = new ToolbarItem (); edit.Name = "Edit"; edit.SetBinding<ProfileViewModel> (ToolbarItem.CommandProperty, vm => vm.EditProfileCommand); this.ToolbarItems.Add(edit); Content = CreateStack (); }
/* * * * * * * * * * * * * * * * */ public RateSessionView (string sessionId) { BaseViewModel.CreateAndBind<RateSessionViewModel> (this, sessionId); Title = "Rate Session"; NavigationPage.SetBackButtonTitle (this, ""); SetBinding (NavigationProperty, new Binding ("Navigation")); var doneButton = new ToolbarItem { Name = "Done" }; doneButton.SetBinding (ToolbarItem.CommandProperty, "SaveRating"); this.ToolbarItems.Add(doneButton); SetBinding (AlertProperty, new Binding("AlertMessage")); Content = CreateStack (); }
public SplashscreenPage() { Title = ""; Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new SquawkLabel { Text = "Connecting...", HorizontalOptions = LayoutOptions.CenterAndExpand, FontSize = 24, }, new ActivityIndicator { IsRunning = true, } } }; //NOTE: this button is a workaround, adding button on HomePage doesn't work so it will be presented always //but will work only in Chat var sendImageItem = new ToolbarItem("send photo", Device.OnPlatform(null, null, "appbar.image.beach.png"), () => { var homeVm = ViewModelBase.CurrentViewModel as HomeViewModel; if (homeVm != null) { //homeVm.SendImageCommand.Execute(null); } else if (ViewModelBase.CurrentViewModel != null) { ViewModelBase.CurrentViewModel.Notify(";(", "You can send images only in chat. I just don't know how to show it only on specific pages - ToolbarItems.Add doesn't work on HomePage ;("); } }); sendImageItem.SetBinding(ToolbarItem.CommandProperty, new Binding("SendImageCommand")); Device.OnPlatform(WinPhone: () => ToolbarItems.Add(sendImageItem)); // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); }
// public string Success { // get { // return (string)GetValue (SuccessProperty); // } // set { // SetValue (SuccessProperty, value); // } // } // // public static readonly BindableProperty SuccessProperty = // BindableProperty.Create<EditProfileView, string>(b => b.Success, null, // propertyChanged: async (bindable, oldValue, newValue) => { // if(newValue == null) // return; // var view = (EditProfileView)bindable; // await view.DisplayAlert ("Success", newValue, null, "Okay"); // ((EditProfileViewModel)view.BindingContext).SuccessMessage = null; // }); public EditProfileView () { BaseViewModel.CreateAndBind<EditProfileViewModel> (this); SetBinding (EditProfileView.NavigationProperty, new Binding("Navigation")); SetBinding(AlertProperty, new Binding("AlertMessage")); // SetBinding(SuccessProperty, new Binding("SuccessMessage")); Title = "Profile"; NavigationPage.SetBackButtonTitle (this, ""); var save = new ToolbarItem (); save.Name = "Save"; save.SetBinding<EditProfileViewModel> (ToolbarItem.CommandProperty, vm => vm.SaveProfileCommand); this.ToolbarItems.Add(save); Content = CreateStack (); }
public AddReviewView () { viewModel = new AddReviewsViewModel (Navigation); BindingContext = viewModel; Title = "Add New Review"; var email = new Entry () { Placeholder = "Email Address" }; email.SetBinding (Entry.TextProperty, "Email"); var cheeseType = new Entry () { Placeholder = "Cheese Type" }; cheeseType.SetBinding (Entry.TextProperty, "CheeseType"); var dairy = new Entry () { Placeholder = "Dairy" }; dairy.SetBinding (Entry.TextProperty, "DairyName"); var comments = new Editor (); comments.BackgroundColor = Color.FromRgb (255, 255, 229); comments.VerticalOptions = LayoutOptions.FillAndExpand; comments.SetBinding (Editor.TextProperty, "Comments"); var saveButton = new ToolbarItem () { Text = "Save" }; saveButton.SetBinding (ToolbarItem.CommandProperty, "AddCommand"); ToolbarItems.Add (saveButton); Content = new StackLayout { Padding= new Thickness(10,10,10,10), Children = { email, cheeseType, dairy, new Label{ Text = "Comments:" }, comments } }; }
public ToDoListPage() { BindingContext = new ToDoListViewModel(); var listView = new ListView(); listView.ItemTemplate = new DataTemplate(typeof(TextCell)); // Bindings para los items de la vista listView.SetBinding(ListView.ItemsSourceProperty, "ToDoItems"); listView.SetBinding(ListView.SelectedItemProperty, "SelectedToDoItem"); listView.ItemSelected += (s, a) => { (BindingContext as ToDoListViewModel).ViewDetailCommand.Execute(null); }; // Binding para los items de la lista BindingContext = new ToDoListViewModel(); // Bindings para definir la información que se muestra por cada fila listView.ItemTemplate.SetBinding(TextCell.TextProperty, "Name"); listView.ItemTemplate.SetBinding(TextCell.DetailProperty, "Description"); var saveButton = new ToolbarItem { Text = "Save" }; saveButton.SetBinding(ToolbarItem.CommandProperty, "SaveToDosCommand"); var addButton = new ToolbarItem { Text = "Add" }; addButton.SetBinding(ToolbarItem.CommandProperty, "AddToDoCommad"); Content = new StackLayout { Children = { listView } }; ToolbarItems.Add(saveButton); ToolbarItems.Add(addButton); }
private void Init() { var addTile = new ToolbarItem { Text = "Add", Icon = OnPlatform( iOS: (FileImageSource)FileImageSource.FromFile("Icons/Done.png"), Android: (FileImageSource)FileImageSource.FromFile("Done.png"), Windows: (FileImageSource)FileImageSource.FromFile("Assets/Icons/Done.png")) }; addTile.SetBinding(ToolbarItem.CommandProperty, new Binding("AddTileCommand")); ToolbarItems.Add(addTile); var removeTile = new ToolbarItem { Text = "Remove", Icon = OnPlatform( iOS: (FileImageSource)FileImageSource.FromFile("Icons/Remove.png"), Android: (FileImageSource)FileImageSource.FromFile("Remove.png"), Windows: (FileImageSource)FileImageSource.FromFile("Assets/Icons/Remove.png")) }; removeTile.SetBinding(ToolbarItem.CommandProperty, new Binding("RemoveTileCommand")); ToolbarItems.Add(removeTile); }
public ChatPage(ViewModelBase viewModel) : base(viewModel) { SetBinding (ContentPage.TitleProperty, new Binding("RoomName")); Icon = Styling.ChatIcon; var toolbarItem = new ToolbarItem { Text = "Actions", Icon = Styling.ToolbarIcon, Order = ToolbarItemOrder.Primary }; toolbarItem.SetBinding(ToolbarItem.CommandProperty, new Binding("ContextOptionsCommand")); ToolbarItems.Add(toolbarItem); var headerLabel = new SquawkLabel(); headerLabel.FontSize = Styling.Sized(24); headerLabel.TextColor = Device.OnPlatform(Color.Green, Color.Yellow, Color.Yellow); headerLabel.SetBinding(Label.TextProperty, new Binding("Subject", stringFormat:" {0}")); var sendButton = new Button(); sendButton.Text = " Send "; sendButton.VerticalOptions = LayoutOptions.EndAndExpand; sendButton.SetBinding(Button.CommandProperty, new Binding("SendMessageCommand")); sendButton.SetBinding(Button.IsEnabledProperty, new Binding("IsInConnectedMode", BindingMode.OneWay)); if (Device.OS == TargetPlatform.WinPhone) { sendButton.BackgroundColor = Color.Green; sendButton.BorderColor = Color.Green; sendButton.TextColor = Color.White; } var inputBox = new SquawkEntry(); inputBox.HorizontalOptions = LayoutOptions.FillAndExpand; inputBox.Keyboard = Keyboard.Chat; inputBox.Placeholder = "Type a message..."; inputBox.HeightRequest = 30; inputBox.SetBinding(Entry.TextProperty, new Binding("InputText", BindingMode.TwoWay)); inputBox.SetBinding(Entry.IsEnabledProperty, new Binding("IsInConnectedMode", BindingMode.OneWay)); _messageList = new ChatListView(); _messageList.VerticalOptions = LayoutOptions.FillAndExpand; _messageList.SetBinding(ChatListView.ItemsSourceProperty, new Binding("MessageEvents")); _messageList.ItemTemplate = new DataTemplate(CreateMessageCell); _messageList.ItemTapped += ItemTapped; _messageList.HasUnevenRows = true; _messageList.SeparatorVisibility = SeparatorVisibility.None; _messageList.SetBinding(Entry.IsEnabledProperty, new Binding("IsInRequestMode", BindingMode.OneWay, converter: new InverterConverter())); var typingLabel = new SquawkLabel(); typingLabel.FontSize = Styling.Sized(11); typingLabel.TextColor = Color.Gray; typingLabel.SetBinding(Label.TextProperty, new Binding("TypingEventsString", stringFormat:" {0}")); //typingLabel.SetBinding(Label.IsVisibleProperty, new Binding("AreTypingEvents")); #region Error Message UI var chatStatusLabel = new SquawkLabel { HorizontalOptions = LayoutOptions.Center, FontSize = 16, TextColor = Color.Gray }; chatStatusLabel.SetBinding(Label.TextProperty, new Binding("StatusText", BindingMode.OneWay)); var chatStatusLayout = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { chatStatusLabel } }; chatStatusLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("IsInMessageMode", BindingMode.OneWay)); #endregion #region Request UI var requestLabel = new SquawkLabel { HorizontalOptions = LayoutOptions.Center, FontSize = Styling.Sized(16), Text = "This user wants to chat! What would you like to do?" }; var acceptButton = new Button(){ FontSize = Styling.Sized(14) }; acceptButton.Text = "Accept"; acceptButton.SetBinding(Button.CommandProperty, new Binding("AcceptChatCommand")); if (Device.OS == TargetPlatform.WinPhone) { acceptButton.BackgroundColor = Color.Green; acceptButton.BorderColor = Color.Green; acceptButton.TextColor = Color.White; } var declineButton = new Button(){ FontSize = Styling.Sized(14) }; declineButton.Text = "Decline"; declineButton.SetBinding(Button.CommandProperty, new Binding("DeclineChatCommand")); if (Device.OS == TargetPlatform.WinPhone) { declineButton.BackgroundColor = Color.Green; declineButton.BorderColor = Color.Green; declineButton.TextColor = Color.White; } var ignoreButton = new Button(); { ignoreButton.FontSize = Styling.Sized(14); ignoreButton.Text = "Ignore"; ignoreButton.SetBinding(Button.CommandProperty, new Binding("LeaveRoomCommand")); if (Device.OS == TargetPlatform.WinPhone) { ignoreButton.BackgroundColor = Color.Green; ignoreButton.BorderColor = Color.Green; ignoreButton.TextColor = Color.White; } } var requestLayout = new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 15, Children = { requestLabel, acceptButton, declineButton, ignoreButton } }; requestLayout.SetBinding(StackLayout.IsVisibleProperty, new Binding("IsInRequestMode", BindingMode.OneWay)); #endregion Content = new StackLayout { Padding = Device.OnPlatform(new Thickness(6,6,6,6), new Thickness(0), new Thickness(0)), Children = { _messageList, chatStatusLayout, requestLayout, typingLabel, new StackLayout { Children = {inputBox, sendButton}, Orientation = StackOrientation.Horizontal, Padding = new Thickness(0, Device.OnPlatform(0, 20, 0),0,0), //VerticalOptions = LayoutOptions.End } } }; }
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); }; }
ToolbarItem CreateSelectButton () { var selectButton = new ToolbarItem { Name = "Select" }; selectButton.SetBinding (ToolbarItem.CommandProperty, "ToggleSessionSelection"); return selectButton; }
ToolbarItem CreateSubmitButton () { var submitButton = new ToolbarItem { Name = "Submit" }; submitButton.SetBinding (ToolbarItem.CommandProperty, "SubmitSurvey"); return submitButton; }
public AddOpportunityPage() { var viewModel = new AddOpportunityViewModel(this); BindingContext = viewModel; #region Create Topic Entry var topicText = new EntryCell { Label = "Topic" }; topicText.SetBinding(EntryCell.TextProperty, "Topic"); #endregion #region Create Company Entry var companyText = new EntryCell { Label = "Company" }; companyText.SetBinding(EntryCell.TextProperty, "Company"); #endregion #region Create DBA Entry var dbaText = new EntryCell { Label = "DBA" }; dbaText.SetBinding(EntryCell.TextProperty, "DBA"); #endregion #region Create LeaseAmount Entry var leaseAmountNumber = new EntryCell { Label = "Lease Amount", Keyboard = Keyboard.Numeric }; leaseAmountNumber.SetBinding(EntryCell.TextProperty, "LeaseAmount"); #endregion #region Create Owner Entry var ownerText = new EntryCell { Label = "Owner", }; ownerText.SetBinding(EntryCell.TextProperty, "Owner"); #endregion #region create the TableView var tableView = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection{ topicText, companyText, leaseAmountNumber, ownerText, dbaText, } } }; #endregion #region Create Save Button var saveButtonToolBar = new ToolbarItem(); saveButtonToolBar.Text = "Save"; saveButtonToolBar.SetBinding(ToolbarItem.CommandProperty, "SaveButtonTapped"); saveButtonToolBar.Priority = 0; ToolbarItems.Add(saveButtonToolBar); #endregion #region Create Cancel Button var cancelButtonToolBar = new ToolbarItem(); cancelButtonToolBar.Text = "Cancel"; cancelButtonToolBar.Command = new Command (async ()=> await PopModalAsync(true)); cancelButtonToolBar.Priority = 1; ToolbarItems.Add(cancelButtonToolBar); #endregion Title = "Add Opportunity"; Content = tableView; viewModel.SaveError += HandleSaveError; SaveToDatabaseCompleted += async (sender, e) => await PopModalAsync(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); }