public SettingsScreen () { Intent = TableIntent.Settings; var cell = new TextCell { Text = "Coverflow", Detail = "Value 1" }; var boolCell = new SwitchCell { Text = "Off" }; boolCell.OnChanged += (sender, arg) => boolCell.Text = boolCell.On ? "On" : "Off"; var root = new TableRoot () { new TableSection () { cell, new TextCell { Text = "Cell 2", Detail = "Value 2" }, new EntryCell { Label = "Label", Placeholder = "Placeholder 1", HorizontalTextAlignment = TextAlignment.Center, Keyboard = Keyboard.Numeric }, new ImageCell { Text = "Hello", Detail = "World", ImageSource = "cover1.jpg" } }, new TableSection ("Styles") { boolCell, new EntryCell { Label = "Label2", Placeholder = "Placeholder 2", HorizontalTextAlignment = TextAlignment.Center, Keyboard = Keyboard.Chat }, }, new TableSection ("Custom Cells") { new ViewCell { View = new Button (){ Text = "Hi" } }, } }; Root = root; }
void UpdateIsEnabled(SwitchCellView cell, SwitchCell switchCell) { cell.Enabled = switchCell.IsEnabled; var aSwitch = cell.AccessoryView as ASwitch; if (aSwitch != null) aSwitch.Enabled = switchCell.IsEnabled; }
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; }
protected override void Init () { var listView = new ListView (); var selection = new Selection (); listView.SetBinding (ListView.ItemsSourceProperty, "Items"); listView.ItemTemplate = new DataTemplate (() => { var cell = new SwitchCell (); cell.SetBinding (SwitchCell.TextProperty, "Name"); cell.SetBinding (SwitchCell.OnProperty, "IsSelected", BindingMode.TwoWay); return cell; }); var instructions = new Label { FontSize = 16, Text = "The label at the bottom should equal the number of switches which are in the 'on' position. Flip some of the switches. If the number at the bottom does not equal the number of 'on' switches, the test has failed." }; var label = new Label { FontSize = 24 }; label.SetBinding (Label.TextProperty, "SelectedCount"); Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, Children = { instructions, listView, label } }; BindingContext = selection; }
void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { cell.UserInteractionEnabled = switchCell.IsEnabled; cell.TextLabel.Enabled = switchCell.IsEnabled; cell.DetailTextLabel.Enabled = switchCell.IsEnabled; var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) uiSwitch.Enabled = switchCell.IsEnabled; }
static void UpdateIsEnabled(CellNSView cell, SwitchCell switchCell) { cell.TextLabel.Enabled = switchCell.IsEnabled; var uiSwitch = cell.AccessoryView.Subviews[0] as NSButton; if (uiSwitch != null) { uiSwitch.Enabled = switchCell.IsEnabled; } }
private static object CellGenerate() { var sc = new SwitchCell { }; sc.SetBinding(SwitchCell.TextProperty, "Description"); // sc.SetBinding(SwitchCell.OnProperty, "Content", BindingMode.TwoWay, new Options.Setting.ContentConverter()); //*/ return(sc); }
internal static Cell BoolCell(PropertyInfo property, IContact context, Page parent = null) { var label = CreateLabel(property); var switchCell = new SwitchCell(); switchCell.SetValue(SwitchCell.TextProperty, label); switchCell.SetBinding(SwitchCell.OnProperty, new Binding(property.Name, BindingMode.TwoWay)); switchCell.BindingContext = context; return(switchCell); }
public void On() { var template = new DataTemplate(typeof(SwitchCell)); template.SetValue(SwitchCell.OnProperty, true); SwitchCell cell = (SwitchCell)template.CreateContent(); Assert.That(cell.On, Is.EqualTo(true)); }
void UpdateIsEnabled(SwitchCellView cell, SwitchCell switchCell) { cell.Enabled = switchCell.IsEnabled; var aSwitch = cell.AccessoryView as ASwitch; if (aSwitch != null) { aSwitch.Enabled = switchCell.IsEnabled; } }
public void Text() { var template = new DataTemplate(typeof(SwitchCell)); template.SetValue(SwitchCell.TextProperty, "text"); SwitchCell cell = (SwitchCell)template.CreateContent(); Assert.That(cell.Text, Is.EqualTo("text")); }
private void OnCellOnOffChanged(object sender, ToggledEventArgs e) { SwitchCell cell = (SwitchCell)sender; // Find the layer from the image layer ArcGISSublayer sublayer = _imageLayer.Sublayers.First(x => x.Name == cell.Text); // Change sublayers visibility sublayer.IsVisible = e.Value; }
public SettingsPage() { var svm = new SettingsViewModel { AirplaneMode = true }; BindingContext = svm; var airplaneModeCell = new SwitchCell { Text = "Airplane Mode" }; airplaneModeCell.SetBinding(SwitchCell.OnProperty, "AirplaneMode"); Title = "Settings"; Content = new TableView { Root = new TableRoot { new TableSection(" ") { airplaneModeCell, new SwitchCell { Text = "Notifications" } }, new TableSection(" ") { new EntryCell { Label = "Login", Placeholder = "username" } , new EntryCell { Label = "Password", Placeholder = "password" } }, new TableSection("Silent") { new SwitchCell { Text = "Vibrate", }, new ViewCell { View = new Slider() } }, new TableSection("Ring") { new SwitchCell { Text = "New Voice Mail" }, new SwitchCell { Text = "New Mail", On = true } }, }, }; }
// Adds a new switch (two in case the symbology has an inverse) to SymbologySection void addSymbologySwitches(String settingString, int offset) { // DPM Mode switch will be created alongside with the DataMatrix one, // as DPM Mode availability depends on DataMatrix being enabled if (Settings.isDpmMode(settingString)) { return; } // add switch for regular symbology SwitchCell cell = new SwitchCell { Text = Convert.settingToDisplay[settingString] }; initializeSwitch(cell, settingString); SymbologySection.Insert(SymbologySection.Count - offset, cell); if (Settings.hasInvertedSymbology(settingString)) { string invString = Settings.getInvertedSymbology(settingString); // add switch for inverse symbology SwitchCell invCell = new SwitchCell { Text = Convert.settingToDisplay[invString] }; initializeSwitch(invCell, invString); SymbologySection.Insert(SymbologySection.Count - offset, invCell); // Gray out the inverse symbology switch if the regular symbology is disabled invCell.IsEnabled = Settings.getBoolSetting(settingString); cell.OnChanged += (object sender, ToggledEventArgs e) => { invCell.IsEnabled = e.Value; }; } if (Settings.isDataMatrix(settingString)) { string dpmString = Settings.DpmModeString; // add switch for DPM Mode SwitchCell dpmCell = new SwitchCell { Text = Convert.settingToDisplay[dpmString] }; initializeSwitch(dpmCell, dpmString); SymbologySection.Insert(SymbologySection.Count - offset, dpmCell); // Gray out the DPM Mode switch if the DataMatrix symbology is disabled dpmCell.IsEnabled = Settings.getBoolSetting(settingString); cell.OnChanged += (object sender, ToggledEventArgs e) => { dpmCell.IsEnabled = e.Value; }; } }
public SettingsScreen() { Intent = TableIntent.Settings; var cell = new TextCell { Text = "Coverflow", Detail = "Value 1" }; var boolCell = new SwitchCell { Text = "Off" }; boolCell.OnChanged += (sender, arg) => boolCell.Text = boolCell.On ? "On" : "Off"; var root = new TableRoot() { new TableSection() { cell, new TextCell { Text = "Cell 2", Detail = "Value 2" }, new EntryCell { Label = "Label", Placeholder = "Placeholder 1", HorizontalTextAlignment = TextAlignment.Center, Keyboard = Keyboard.Numeric }, new ImageCell { Text = "Hello", Detail = "World", ImageSource = "cover1.jpg" } }, new TableSection("Styles") { boolCell, new EntryCell { Label = "Label2", Placeholder = "Placeholder 2", HorizontalTextAlignment = TextAlignment.Center, Keyboard = Keyboard.Chat }, }, new TableSection("Custom Cells") { new ViewCell { View = new Button() { Text = "Hi" } }, } }; Root = root; }
// Bind an existing switch cell to the permanent storage // and the currently active settings private void initializeSwitch(SwitchCell cell, string setting) { cell.On = Settings.getBoolSetting(setting); cell.OnChanged += (object sender, ToggledEventArgs e) => { Settings.setBoolSetting(setting, e.Value); updateScanOverlay(); updateScanSettings(); }; }
private void CreateComponent(CreateTrainingDayViewModel viewModel) { if (viewModel != null && viewModel.EditMode == BodyReport.Message.TEditMode.Edit) { SwitchCell convertionSwitchCell = new SwitchCell(); convertionSwitchCell.BindingContext = viewModel; convertionSwitchCell.SetBinding(SwitchCell.TextProperty, (CreateTrainingDayViewModel source) => source.AutomaticalUnitConvertionLabel, mode: BindingMode.OneWay); convertionSwitchCell.SetBinding(SwitchCell.OnProperty, (CreateTrainingDayViewModel source) => source.BindingTrainingDay.AutomaticalUnitConvertion, mode: BindingMode.TwoWay); tableSection.Add(convertionSwitchCell); } }
private void AddBooleanParam(OrderParameterType paramType, OrderParameter param) { SwitchCell switchCell = new SwitchCell { Text = paramType.Name, On = param.Value == "True" }; switchCell.OnChanged += (sender, e) => { param.Value = switchCell.On ? "True" : "False"; }; LastSection.Add(switchCell); }
private void LoadSettings() { settings = App.SettingsDatabase.GetSettings(); //currentUser = App.UserDatabase.getUser(); TableView table; kwhPricing = new Entry //Setup keyboard for KwH pricing { Placeholder = "Price of KwH: $", PlaceholderColor = Color.Gray, Keyboard = Keyboard.Numeric }; switchCell1 = new SwitchCell //Setup first switch button in settings { Text = "SwitchCell 1", On = settings.switch1 }; switchCell1.OnChanged += (object sender, ToggledEventArgs e) => //Causes an event to occur when value changes { switchCell1Switched(sender, e); }; switchCell2 = new SwitchCell //Setup second switch buton in settings { Text = "SwitchCell 2", On = settings.switch2 }; switchCell2.OnChanged += (object sender, ToggledEventArgs e) => //Causes an event to occur when value changes { switchCell2Switched(sender, e); }; table = new TableView //Setup the table which holds the settings { Root = new TableRoot { new TableSection { switchCell1, switchCell2, } } }; table.VerticalOptions = LayoutOptions.FillAndExpand; MainLayout.Children.Add(kwhPricing); MainLayout.Children.Add(table); //Adds the table to the frontend under the mainlayout section }
public ConfigPage() { //InitializeComponent(); if (Device.OS == TargetPlatform.Android) { BackgroundColor = Color.FromHex("#2A2A2A"); NavigationPage.SetTitleIcon(this, "opac.png"); } SwitchCell adminSwitch = new SwitchCell { Text = "I am Manager", On = App.isAdmin(), }; adminSwitch.OnChanged += (o, s) => { App.setAdmin(adminSwitch.On); }; SwitchCell courseSwitch = new SwitchCell { Text = "Get all courses", On = App.isUsingAllCourses(), }; courseSwitch.OnChanged += async(o, s) => { App.setUsingAllCourses(courseSwitch.On); RefreshNavbar(courseSwitch.On); }; Content = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Manager or Student?") { adminSwitch }, new TableSection("All Courses/Semester Courses") { courseSwitch } } }; // In case of iOS the padding is done automatically by the table representation if (Device.OS != TargetPlatform.iOS) { Padding = new Thickness(15, 10, 15, 10); } Title = "Settings"; }
private void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { /* * cell.UserInteractionEnabled = switchCell.IsEnabled; * cell.TextLabel.Enabled = switchCell.IsEnabled; * cell.DetailTextLabel.Enabled = switchCell.IsEnabled; * UISwitch uiSwitch = cell.AccessoryView as UISwitch; * if (uiSwitch == null) * return; * uiSwitch.Enabled = switchCell.IsEnabled; */ }
void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { cell.UserInteractionEnabled = switchCell.IsEnabled; cell.TextLabel.Enabled = switchCell.IsEnabled; cell.DetailTextLabel.Enabled = switchCell.IsEnabled; var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) { uiSwitch.Enabled = switchCell.IsEnabled; } }
public SettingsPage() { BindingContext = new SettingsModel(); var cameraSwitch = new SwitchCell { Text = "Rear Camera" }; cameraSwitch.SetBinding(SwitchCell.OnProperty, new Binding("DefaultCameraRear")); var timerEntry = new EntryCell { Label = "Seconds", Keyboard = Keyboard.Numeric }; timerEntry.SetBinding(EntryCell.TextProperty, new Binding("TimerInterval", BindingMode.TwoWay)); var clearDataLabel = new TextCell { Text = "Clear All Data" }; clearDataLabel.Tapped += async(s, e) => { var result = await DisplayAlert("Delete All Data", "Are you sure you wish to clear all stored data online?", "YES", "Cancel"); if (result) { var response = await(BindingContext as SettingsModel).ResetData(); DisplayAlert(response, "", "Ok"); } }; Title = "Settings"; Content = new TableView { Root = new TableRoot { new TableSection("Default Camera") { cameraSwitch }, new TableSection("Data") { clearDataLabel }, new TableSection("Identify Interval") { timerEntry } } }; // }
void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { cell.UserInteractionEnabled = switchCell.IsEnabled; #pragma warning disable CA1416 // TODO: 'UITableViewCell.TextLabel', DetailTextLabel is unsupported on: 'ios' 14.0 and later cell.TextLabel.Enabled = switchCell.IsEnabled; cell.DetailTextLabel.Enabled = switchCell.IsEnabled; #pragma warning restore CA1416 var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) { uiSwitch.Enabled = switchCell.IsEnabled; } }
private async void OnItemToggled(object sender, ToggledEventArgs e) { try { serviceActivityIndicator.IsRunning = true; SwitchCell toggledSwitch = (SwitchCell)sender; string stationID = toggledSwitch.Text.Substring(0, toggledSwitch.Text.IndexOf(" ")); WateringStationViewModel wsvm = new WateringStationViewModel(int.Parse(stationID)); bool stationActive = await App.restService.GetSwitchStateAsync(stationID); bool switchOn = toggledSwitch.On; if (!stationActive && switchOn) { stationActive = await App.restService.ActivateSwitchAsync(stationID); Device.StartTimer(new TimeSpan(0, 0, 0, 0, wsvm.WateringTime * 60 * 100), () => { Device.BeginInvokeOnMainThread(async() => { await wateringProgressBar.ProgressTo(wateringProgressBar.Progress + 0.1, 1000, Easing.SinOut); }); if (wateringProgressBar.Progress == 1) { toggledSwitch.On = false; return(false); } else { return(true); } }); await DisplayAlert("Info", string.Concat("Station ", stationID, " activated"), "OK"); } else if (stationActive && !switchOn) { stationActive = await App.restService.ActivateSwitchAsync(stationID); wateringProgressBar.Progress = 0.0; await DisplayAlert("Info", string.Concat("Station ", stationID, " deactivated"), "OK"); } serviceActivityIndicator.IsRunning = false; } catch (Exception ex) { await DisplayAlert("Error", String.Concat("Failed to connect to Relay Panel - ", ex.Message), "Ok"); } finally { serviceActivityIndicator.IsRunning = false; } }
public FilterPage() { var restaurantTypes = new[] { "Pizza", "China", "German" }; // Database.RestaurantTypes ListView types = new ListView(); types.ItemTemplate = new DataTemplate(() => { var cell = new SwitchCell(); cell.SetBinding(SwitchCell.TextProperty, "."); return(cell); }); types.ItemsSource = restaurantTypes; Content = types; }
public FilterSelection(Planning handle) { Title = "Filtres"; ToolbarItems.Add(new ToolbarItem("OK", null, new Action(delegate { handle.DisplayContent(handle.Data); Navigation.PopModalAsync(true); }))); SwitchCell subscribed = new SwitchCell { Text = "Inscrit à l'évènement", }; subscribed.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayRegisteredEvent", BindingMode.TwoWay, null, null)); SwitchCell tosubscribe = new SwitchCell { Text = "Inscription possible", }; tosubscribe.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayEventToRegister", BindingMode.TwoWay, null, null)); SwitchCell registeredmodule = new SwitchCell { Text = "Inscrit au module", }; registeredmodule.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayEventFromRegisteredModule", BindingMode.TwoWay, null, null)); SwitchCell pastevent = new SwitchCell { Text = "Afficher évènement passés", }; pastevent.SetBinding(SwitchCell.OnProperty, new Binding("DisplayPastEvent", BindingMode.TwoWay, null, null)); TableView tableView = new TableView { Intent = TableIntent.Form, Root = new TableRoot { new TableSection("Filtres") { subscribed, tosubscribe, registeredmodule, pastevent } } }; Content = new StackLayout { Children = { tableView } }; }
private async void OnSublayersClicked(object sender, EventArgs e) { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); // Create layout for sublayers page // Create root layout var layout = new StackLayout(); // Create list for layers var sublayersTableView = new TableView(); // Create section for basemaps sublayers var sublayersSection = new TableSection(_imageLayer.Name); // Create cells for each of the sublayers foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { // Using switch cells that provides on/off functionality SwitchCell cell = new SwitchCell() { Text = sublayer.Name, On = sublayer.IsVisible }; // Hook into the On/Off changed event cell.OnChanged += OnCellOnOffChanged; // Add cell into the table view sublayersSection.Add(cell); } // Add section to the table view sublayersTableView.Root.Add(sublayersSection); // Add table to the root layout layout.Children.Add(sublayersTableView); // Create internal page for the navigation page var sublayersPage = new ContentPage() { Content = layout, Title = "Sublayers" }; // Navigate to the sublayers page await Navigation.PushModalAsync(sublayersPage); }
private void SwitchCell_OnChanged(object sender, ToggledEventArgs e) { SwitchCell switchCell = (SwitchCell)sender; bool switchCellState = switchCell.On; if (switchCellState) { txtEmail.IsVisible = true; } else { txtEmail.IsVisible = false; txtEmail.Text = string.Empty; } }
async void SwitchCell_Clicked(object sender, EventArgs a) { SwitchCell s = (sender as SwitchCell); string id = s.ClassId; try { string url = "http://starc.azurewebsites.net/Componente/AlteraStatusMobile/" + id; HttpResponseMessage result = await App.http.GetAsync(url); }catch (Exception e) { await DisplayAlert("Erro", "Não foi possivel conectar ao servidor para alterar o status da sua lâmpada", "Cancelar"); } }
private void AceitarSwitchCell(object sender, ToggledEventArgs e) { SwitchCell sc = (SwitchCell)sender; bool switchCellState = sc.On; if (switchCellState) { EmailEntry.IsVisible = true; } else { EmailEntry.IsVisible = false; EmailEntry.Text = string.Empty; } }
public FilterGenderLanguagePage(TherapistFilter filter) { InitializeComponent(); BindingContext = filter; foreach (var filterLanguage in filter.Languages) { var switchCell = new SwitchCell { BindingContext = filterLanguage }; switchCell.SetBinding(SwitchCell.TextProperty, "DisplayName"); switchCell.SetBinding(SwitchCell.OnProperty, "Set"); LanguageTableSection.Add(switchCell); } }
private void DisplaySettings() { _sc = new SwitchCell() { Text = "Remember user?", On = _user.Save }; _ec = new EntryCell() { Label = "Connect to:", Text = _user.Url }; HeaderLabel.Text = _user.Name + " Settings"; Section.Add(_sc); Section.Add(_ec); }
protected override void OnAppearing() { base.OnAppearing(); ViewModel.GetExpenseStatus(); //counter variable for the collection int counter = 0; //creates a switchcell obj var cell = new SwitchCell(); //iterates all of the state objes and then assigns a binding to each iteration foreach (var item in ViewModel.ExpensesStates) { //Assigns the 'text' property //to the observable collection 'Name' property cell = new SwitchCell() { Text = item.Name }; //creates a binding object Binding bindingSWcell = new Binding(); //Assigns the binding and fills the properties bindingSWcell.Source = ViewModel.ExpensesStates[counter]; //the source of the data in the cell bindingSWcell.Path = "Status"; // what the cell binds to in xaml bindingSWcell.Mode = BindingMode.TwoWay; //creates a two way data binding //Adds the binding to the cell obj cell.SetBinding(SwitchCell.OnProperty, bindingSWcell); //changes the height? cell.Height = 25d; //adds the bindable object (cell) to the section object //-->var section = new TableSection() { cell }; var section = new TableSection() { cell }; //section.Add(cell); //adds the cell with its binding to the element in the view tbvDisplayExpenses.Root.Add(section); //increments the count before the next iteration counter++; } }
void UpdateOnColor(CellTableViewCell cell, SwitchCell switchCell) { var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) { if (switchCell.OnColor == Color.Default) { uiSwitch.OnTintColor = _defaultOnColor; } else { uiSwitch.OnTintColor = switchCell.OnColor.ToUIColor(); } } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell(ReuseIdentifier) as SwitchCell; if (cell == null) { cell = new SwitchCell(); cell.SwitchValueChanged += HandleItemSwitchValueChanged; } int index = indexPath.Row; cell.Index = index; cell.Title = GetItemTitle(index); cell.SwitchValue = GetItemSelected(index); return cell; }