public SettingsPage(IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { Title = "Settings"; _fileRepository = fileRepository; _applicationEvents = applicationEvents; InitializeStorageSettings(fileRepository); InitializeDropboxSettings(externalBrowserService, applicationEvents); var autoSyncValue = new EntryCell { Label = "Interval in minutes", IsEnabled = PersistedState.SyncInterval > 0, Text = PersistedState.SyncInterval > 0 ? PersistedState.SyncInterval.ToString() : string.Empty }; var autoSyncSwitch = new SwitchCell { Text = "Auto sync", On = PersistedState.SyncInterval > 0 }; autoSyncSwitch.OnChanged += (sender, args) => { if (args.Value) { autoSyncValue.Text = "10"; autoSyncValue.IsEnabled = true; SetSyncInterval(10); } else { autoSyncValue.Text = string.Empty; autoSyncValue.IsEnabled = false; SetSyncInterval(0); } }; autoSyncValue.Completed += (sender, args) => { int value; SetSyncInterval(int.TryParse(autoSyncValue.Text, out value) ? value : 0); }; Content = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Storage") { _customStorageSwitch, _customStorageDirectoryEntry }, new TableSection("Cloud sync") { autoSyncSwitch, autoSyncValue, _dropboxSwitch } } }; }
public Settings () { Title = "Settings"; voiceCell=new SwitchCell(){Text="Voice files"}; voiceCell.On = voice; soundCell=new SwitchCell(){Text="Sound effects"}; soundCell.On = sound; TableView tableView = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection { voiceCell, soundCell } } }; voiceCell.OnChanged+= VoiceCell_OnChanged; soundCell.OnChanged+= SoundCell_OnChanged; this.Content = new StackLayout { Children = { tableView } }; }
public App() { ToggleIt = new Command (() => IsToggled = !IsToggled); SwitchCell mySwitch = new SwitchCell (); mySwitch.SetBinding (SwitchCell.OnProperty , "IsToggled", 0); var myButton = new Button(){ Text="CLICK IT! CLICK IT! CLICK IT! YOU KNOW YOU WANT TO", Command = ToggleIt}; MainPage = new ContentPage { BindingContext = this, Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { myButton, new TableView { Intent = TableIntent.Form, Root = new TableRoot { new TableSection { mySwitch } } } } } }; }
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} }, }, }; }
public FormIntentCode () { this.Title = "Form Intent"; var table = new TableView () { Intent = TableIntent.Form }; var root = new TableRoot (); var section1 = new TableSection () {Title = "First Section"}; var section2 = new TableSection () {Title = "Second Section"}; var text = new TextCell { Text = "TextCell", Detail = "TextCell Detail" }; var entry = new EntryCell { Text = "EntryCell Text", Label = "Entry Label" }; var switchc = new SwitchCell { Text = "SwitchCell Text" }; var image = new ImageCell { Text = "ImageCell Text", Detail = "ImageCell Detail", ImageSource = "XamarinLogo.png" }; section1.Add (text); section1.Add (entry); section1.Add (switchc); section1.Add (image); section2.Add (text); section2.Add (entry); section2.Add (switchc); section2.Add (image); table.Root = root; root.Add (section1); root.Add (section2); Content = table; }
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 SettingsNotificationspage() { ch = new ColorHandler(); Title = "Notifications"; var dailyRankSwitch = new SwitchCell { Text = "Daily Rank", On = false }; dailyRankSwitch.OnChanged += async (sender, e) => { if (dailyRankSwitch.On) { await App.dbWrapper.EnableRankingNotification(); } else { await App.dbWrapper.DisableRankingNotification(); } }; var usersNearYouSwitch = new SwitchCell { Text = "Users Near You" }; usersNearYouSwitch.OnChanged += async (sender, e) => { throw new NotImplementedException(); }; Content = new StackLayout { Children = { new TableView { BackgroundColor = ch.fromStringToColor("white"), Root = new TableRoot { new TableSection { dailyRankSwitch, usersNearYouSwitch } } } } }; }
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.PushAsync(sublayersPage); }
public SwitchCellDemoCode () { this.Title = "SwitchCell"; var table = new TableView (); var root = new TableRoot (); var section1 = new TableSection (); var switchOn = new SwitchCell { Text = "On", On = true }; var switchOff = new SwitchCell { Text = "Off", On = false }; section1.Add (switchOn); section1.Add (switchOff); Content = table; }
public SwitchPageCS() { SwitchPageViewModel vm = new SwitchPageViewModel(); BindingContext = vm; var sw0 = new SwitchCell { Text = "Toggle sw1 & sw2" }; sw0.SetBinding(SwitchCell.OnProperty, "SwAllValue", BindingMode.OneWayToSource); var sw1 = new SwitchCell { Text = "Toggle sw1" }; sw1.SetBinding(SwitchCell.OnProperty, "Sw1Value", BindingMode.TwoWay); var sw2 = new SwitchCell { Text = "Toggle sw2" }; sw2.SetBinding(SwitchCell.OnProperty, "Sw2Value", BindingMode.TwoWay); var tc1 = new TextCell { Text = "sw1 value" }; tc1.SetBinding(TextCell.DetailProperty, "Sw1Value"); var tc2 = new TextCell { Text = "sw2 value" }; tc2.SetBinding(TextCell.DetailProperty, "Sw2Value"); var tv = new TableView { Intent = TableIntent.Menu, Root = new TableRoot { new TableSection("Toggle all") { sw0, }, new TableSection("Toggle each") { sw1, sw2, }, new TableSection("Values of ViewModel") { tc1, tc2, } } }; Content = new StackLayout { Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0), Children = { tv, } }; }
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"; }
public TestPage() { this.BindingContext = new TestPageViewModel(); var ed = new Editor { Text = "BindingTo TextValue" }; ed.SetBinding(Editor.TextProperty, "TextValue", mode: BindingMode.OneWayToSource); var lb = new Label { Text = "" }; lb.SetBinding(Label.TextProperty, "TextValue"); var sw = new Switch(); sw.SetBinding(Switch.IsToggledProperty, "BoolValue", mode: BindingMode.TwoWay); var sc = new SwitchCell { Text = "BindingTo BoolValue" }; sc.SetBinding(SwitchCell.OnProperty, "BoolValue", mode: BindingMode.TwoWay); var tc = new TextCell { Text = "" }; tc.SetBinding(TextCell.TextProperty, "BoolValue", stringFormat:"Value: {0}"); var tv = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("TableView") { sc, tc, }, } }; Content = new StackLayout { Padding = 20, Children = { new Label { Text = "INotifyPropertyChanged Test", FontSize = 30, }, ed, lb, sw, tv, } }; }
public void buildUI(){ var section = new TableSection ("Assets"); foreach(FilterObject element in assetFilterData){ var cell = new SwitchCell { Text = element.Name, On = element.IsSelected, }; cell.OnChanged += switchedCellAsset; cell.Tapped += tappedCellAsset; section.Add (cell); switchList.Add (cell); } var dzSection = new TableSection ("Danger Zones"); foreach(FilterObject element in dzFilterData){ var cell = new SwitchCell { Text = element.Name, On = element.IsSelected, }; cell.OnChanged += switchedCellDZ; cell.Tapped += tappedCellDZ; dzSection.Add (cell); dzSwitchList.Add (cell); } TableRoot root = new TableRoot (); root.Add (section); root.Add (dzSection); TableView tableView = new TableView (root); Content = tableView; ToolbarItem allOnTBI; ToolbarItem allOffTBI; allOnTBI = new ToolbarItem ("All", "", allOn, 0, 0); allOffTBI = new ToolbarItem ("None", "", allOff, 0, 0); //Change map type ToolbarItems.Add (allOnTBI); ToolbarItems.Add (allOffTBI); }
public CheckDetailsPage(Check check) { EntryCell payee, amount; SwitchCell cleared; Title = "Details"; this.Content = new TableView { Intent = TableIntent.Form, Root = new TableRoot() { new TableSection("Check #" + check.Id) { new TextCell { Text = "Date", Detail = check.Date.ToString("D"), }, (payee = new EntryCell { Label = "Payee", Placeholder = "Enter Payee", Text = check.Payee, Keyboard = Keyboard.Default, }), (amount = new EntryCell { Label = "Amount", Placeholder = "Enter Dollar Amount", Text = check.Amount.ToString("N2"), Keyboard = Keyboard.Numeric, }), (cleared = new SwitchCell { Text = "Cleared?", On = check.Cleared, }), }, } }; // Push updates back to models. payee.Completed += (sender, e) => check.Payee = payee.Text; amount.Completed += (sender, e) => check.Amount = double.Parse(amount.Text, NumberStyles.Currency); cleared.OnChanged += (sender, e) => check.Cleared = cleared.On; }
public CloudsPage(List<Cloud> cloudList, List<string> savedClouds) { ch = new ColorHandler(); var tableSection = new TableSection(); for (int i = 0; i < savedClouds.Count; i++) { bool saved = false; for (int j = 0; j < cloudList.Count; j++) { if (savedClouds[i].Equals(cloudList[j].Title)) { saved = true; } } var s = new SwitchCell { Text = savedClouds[i], On = saved }; s.OnChanged += S_OnChanged; tableSection.Add(s); } var cloudSwitchTable = new TableView { Root = new TableRoot(), BackgroundColor = ch.fromStringToColor("white") }; cloudSwitchTable.Root.Add(tableSection); Content = cloudSwitchTable; }
private void InitializeStorageSettings(IFileRepository fileRepository) { bool hasCustomStorageDir = fileRepository.StorageDirectory != fileRepository.DefaultStorageDirectory; _customStorageSwitch = new SwitchCell { Text = "Custom storage directory", On = hasCustomStorageDir }; _customStorageDirectoryEntry = new EntryCell { Label = "Path", Text = fileRepository.StorageDirectory, IsEnabled = hasCustomStorageDir }; _customStorageSwitch.OnChanged += (sender, args) => { _customStorageDirectoryEntry.IsEnabled = args.Value; if (args.Value) { //reset to default _customStorageDirectoryEntry.Text = fileRepository.DefaultStorageDirectory; SetStorageDir(fileRepository.DefaultStorageDirectory); } }; _customStorageDirectoryEntry.Completed += (sender, args) => { SetStorageDir(_customStorageDirectoryEntry.Text); }; }
public SettingsPage(LanesViewModel viewModel) { BindingContext = viewModel; #region create the IsOpen Switch var isOpenSwitch = new SwitchCell { Text = "Is Open" }; isOpenSwitch.SetBinding(SwitchCell.OnProperty,"LaneTappedIsOpen"); #endregion #region Create the Needs Maintenance Switch var needsMaintenanceSwitch = new SwitchCell { Text = "Needs Maintenance" }; needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty,"LaneTappedNeedsMaintenance"); #endregion #region create the IP Address Entry var ipAddressText = new EntryCell { Label = "IP Address", HorizontalTextAlignment = TextAlignment.End }; ipAddressText.SetBinding(EntryCell.TextProperty, "LaneTappedIPAddress"); #endregion #region Create Image Cell var imageCell = new ImageCell(); imageCell.SetBinding(ImageCell.ImageSourceProperty, "ImageCellIcon"); #endregion #region Create the Icon Toggle Button var iconToggleButton = new Button(); iconToggleButton.SetBinding(Button.CommandProperty, "IconToggleButton"); iconToggleButton.SetBinding(Button.TextProperty, "ToggleButtonText"); #endregion #region create the TableView var tableView = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection{ isOpenSwitch, needsMaintenanceSwitch, ipAddressText, imageCell } } }; #endregion #region Create StackLayout to Include a Button var settingsStack = new StackLayout { Children ={ tableView, iconToggleButton } }; #endregion NavigationPage.SetTitleIcon(this,"cogwheel_navigation"); Title = $"Lane {viewModel.LanesList.IndexOf(viewModel.LaneTapped)+1} Settings"; Content = settingsStack; }
public SettingsView() { NavigationPage.SetHasNavigationBar (this, false); btnTmpFiles = new Button { HorizontalOptions = LayoutOptions.Start, TextColor = Color.Black, Command = new Command (() => { var deleteService = DependencyService.Get<IDeleteService> (); if (deleteService == null) return; deleteService.DeleteTempFiles ((bool completed) => { if (completed == true) { btnTmpFiles.Text = Translation.Localize("DeleteTempFiles"); DisplayAlert ("", Translation.Localize("TempFilesDeletedMessage"), Translation.Localize("Ok")); } else { DisplayAlert ("", "Error Occured.", Translation.Localize("Ok")); } }); }), }; btnMediaFiles = new Button { HorizontalOptions = LayoutOptions.Start, TextColor = Color.Black, Command = new Command (async () => { var confirm = await DisplayAlert ("", Translation.Localize("DeleteMediaMessage"), Translation.Localize("Yes"), Translation.Localize("No")); if (confirm) { var deleteService = DependencyService.Get<IDeleteService> (); if (deleteService == null) return; deleteService.DeleteAllMedia ((bool completed) => { if (completed == true) { db.DeleteAllDownloads (); btnMediaFiles.Text = Translation.Localize("DeleteMediaFiles"); DisplayAlert ("", Translation.Localize("MediaFilesDeletedMessage"), Translation.Localize("Ok")); } else { DisplayAlert ("", "Error Occured.", Translation.Localize("Ok")); } }); } }), }; var switchCell = new SwitchCell (); switchCell.Text = Translation.Localize("DownloadviaWifi"); switchCell.On = GlobalVariables.WifiDownloadOnly; switchCell.OnChanged += (sender, args) => { var selectedValue = (sender as SwitchCell).On; db.UpdateSettings ("WifiDownload", selectedValue == true ? "1" : "0"); }; TableView tableView = new TableView { BackgroundColor = Color.Transparent, Intent = TableIntent.Settings, Root = new TableRoot ("") { new TableSection (Translation.Localize("SettingsIcon")) { new ViewCell { View = btnTmpFiles, }, new ViewCell { View = btnMediaFiles }, switchCell, }, new TableSection ("Version 1.5 (03-September-2015)") { // new ViewCell { View = languagePicker }, // new ViewCell { // View = new Label { // HorizontalOptions = LayoutOptions.Start, // VerticalOptions = LayoutOptions.Center, // Text = "Version 1.1 (15-July-2015)" // }, // } }, }, }; // Build the page. this.Content = new StackLayout { Children = { ControlUtilities.GetAppHeader (), tableView } }; Device.OnPlatform ( iOS: () => { this.Content = new StackLayout { Children = { ControlUtilities.GetAppHeader (), tableView } }; }, Android: () => { this.Content = new StackLayout { Children = { //ControlUtilities.GetAppHeader (), tableView } }; }, WinPhone: () => { this.Content = new StackLayout { Children = { ControlUtilities.GetAppHeader (), tableView } }; } ); }
private void InitializeDropboxSettings(IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents) { _dropboxSwitch = new SwitchCell { Text = "Use Dropbox", On = PersistedState.UserLogin != null && !string.IsNullOrEmpty(PersistedState.UserLogin.Secret) }; _dropboxSwitch.OnChanged += (sender, args) => { if (args.Value) { applicationEvents.Resumed += ApplicationEventsOnResumed; _dropboxUserPermission = new DropboxUserPermission(); _dropboxUserPermission.AskUserForPermission(externalBrowserService); //(continue in ApplicationEventsOnResumed()) } else { PersistedState.UserLogin = null; } SyncBootstrapper.RefreshDropboxSync(_fileRepository); }; }
private void SetupActionCells(){ // Set up switch cells autoSessionManagementCell = new SwitchCell { Text = "Auto session management", On = true , }; autoSessionManagementCell.OnChanged += (sender, ea) => { ApplicationInsights.SetAutoSessionManagementDisabled(!autoSessionManagementCell.On); }; autoPageViewsCell = new SwitchCell { Text = "Auto page view tracking", On = true , }; autoPageViewsCell.OnChanged += (sender, ea) => { ApplicationInsights.SetAutoPageViewTrackingDisabled(!autoPageViewsCell.On); }; // TODO: also update ApplicationInsights config if input field lost focus serverURLCell = new EntryCell(){ Label = "Server URL", Placeholder = "Custom server URL" }; serverURLCell.Completed += (sender, ea) => { ApplicationInsights.SetServerUrl(serverURLCell.Text); }; userIDCell = new EntryCell(){ Label = "User ID", Placeholder = "Custom user ID" }; userIDCell.Completed += (sender, ea) => { ApplicationInsights.SetUserId(userIDCell.Text); }; }
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); }
public AboutView() { Title = "Settings"; var color = Color.FromHex("738182"); Content = new TableView { Intent = TableIntent.Form, Root = new TableRoot (Title) { (new TableSection ("Preferences") { (organizerMode = new SwitchCell { Text = "Show only groups I organize", On = Settings.OrganizerMode, StyleId="OragnizerMode" }), (showAll = new SwitchCell { Text = "Show all events", On = Settings.ShowAllEvents, StyleId = "ShowAll" }), (feedback = new SwitchCell { Text = "Automated Feedback", On = Settings.Insights, StyleId = "Feedback" }) }), new TableSection ("About Meetup Manager") { new TextCell { Text = "Created by", TextColor= color, Detail = "James Montemagno", Command = GoToSiteCommandExt, CommandParameter = "http://m.twitter.com/jamesmontemagno" }, new TextCell { Text = "Version 2.0", TextColor= color, Detail = "Copyright 2015 Refractored LLC", Command = GoToSiteCommandExt, CommandParameter = "http://refractored.com" }, new TextCell { Text = "Created with", TextColor= color, Detail = "C# and Xamarin", Command = GoToSiteCommandExt, CommandParameter = "http://xamarin.com" }, new TextCell { Text = "Support Forum", TextColor= color, Command = GoToSiteCommandExt, CommandParameter = "https://plus.google.com/u/1/communities/111605797436259290945" } }, new TableSection ("Technology Use") { new TextCell { Text = "Xamarin.Forms", TextColor= color, Detail ="By: Xamarin", Command = GoToSiteCommandExt, CommandParameter = "http://xamarin.com/forms" }, new TextCell { Text = "Modern HttpClient", TextColor= color, Detail ="By: Paul Betts", Command = GoToSiteCommandExt, CommandParameter = "https://components.xamarin.com/view/modernhttpclient" }, new TextCell { Text = "Json.NET", TextColor= color, Detail ="By: James Newton-King", Command = GoToSiteCommandExt, CommandParameter = "https://components.xamarin.com/view/json.net" }, new TextCell { Text = "Settings Plugin for Xamarin", TextColor= color, Detail ="By: James Montemagno", Command = GoToSiteCommandExt, CommandParameter = "https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Settings" }, new TextCell { Text = "Image Circle Plugin", TextColor= color, Detail ="By: James Montemagno", Command = GoToSiteCommandExt, CommandParameter = "https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/ImageCircle" }, new TextCell { Text = "SQLite-net PCL", TextColor= color, Detail ="By: Frank Krueger", Command = GoToSiteCommandExt, CommandParameter = "https://github.com/praeclarum/sqlite-net" }, }, } }; }
public ConfigView(ConfigViewModel configViewModel) { BindingContext = configViewModel; Title = "Configurações"; ToolbarItems.Add (new ToolbarItem { Text = "Sair", Order = ToolbarItemOrder.Primary, Command = new Command (ActionSair) }); datePickerInicio = new DatePicker { Format = "dd, MMM", VerticalOptions = LayoutOptions.CenterAndExpand, }; datePickerFim = new DatePicker { Format = "dd, MMM", VerticalOptions = LayoutOptions.CenterAndExpand, }; // Accomodate iPhone status bar. this.Padding = new Thickness (10, Device.OnPlatform (0, 0, 0), 1, 1); StackLayout stack = new StackLayout { Orientation = StackOrientation.Horizontal, Padding = new Thickness (10, 0, 10, 0), VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { new Label { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, Text = "Inicial", Style = Styles.DefaultCellText }, datePickerInicio } }, new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand, Children = { new Label { VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.StartAndExpand, Text = "Final", Style = Styles.DefaultCellText }, datePickerFim } } } }; SwitchCell EnableHolidaySwitch = new SwitchCell { Text = "Habilitar horário de verão", On = Settings.HolidayState }; ViewCell viewCell = new ViewCell { View = stack }; // EnableHolidaySwitch.SetBinding (IsVisibleProperty, "IsVisible"); // viewCell.SetBinding (IsVisibleProperty, "IsVisible"); TableSection firstSection = new TableSection ("Horario de verão") { viewCell, EnableHolidaySwitch }; ConfigTable = new TableView { Intent = TableIntent.Settings, BackgroundColor = Color.Transparent, Root = new TableRoot { firstSection, new TableSection () { new SwitchCell { Text = "Segurança" }, }, new TableSection ("Rede") { new SwitchCell { Text = "Sincronizar apenas via Wi-Fi" } }, } }; try { datePickerInicio.SetBinding (DatePicker.DateProperty, "MysafetyUser.IVerao", BindingMode.TwoWay, new StringDateConverter ()); datePickerInicio.DateSelected += datePickerInicio_DateSelected; datePickerFim.SetBinding (DatePicker.DateProperty, "MysafetyUser.FVerao", BindingMode.TwoWay, new StringDateConverter ()); datePickerFim.DateSelected += datePickerFim_DateSelected; } catch (Exception ex) { Debug.WriteLine ("Exception " + ex.Message); } ConfigTable.GetSwitchCell (1, 0).SetBinding (SwitchCell.OnProperty, "MysafetyUser.Stext", BindingMode.TwoWay, new NullBoolenConverter ()); ConfigTable.GetSwitchCell (1, 0).OnChanged += (object sender, ToggledEventArgs e) => { if (ConfigTable.GetSwitchCell (1, 0).On) Navigation.PushModalAsync (new LockScreen (new LockScreenViewModel (Navigation)), true); else Navigation.PushModalAsync (new LockScreen (new LockScreenViewModel (Navigation, LockScreenViewModel.Actions.DisablePassword)), true); ((ConfigViewModel)BindingContext).Save (); }; ConfigTable.GetSwitchCell (2, 0).SetBinding (SwitchCell.OnProperty, "MysafetyUser.SyncWiFi", BindingMode.TwoWay, new NullBoolenConverter ()); ConfigTable.GetSwitchCell (2, 0).OnChanged += (object sender, ToggledEventArgs e) => { ((ConfigViewModel)BindingContext).Save (); }; ConfigTable.GetSwitchCell (0, 1).OnChanged += (object sender, ToggledEventArgs e) => { if (ConfigTable.GetSwitchCell (0, 1).On) { datePickerInicio.IsEnabled = true; datePickerFim.IsEnabled = true; } else { datePickerInicio.IsEnabled = false; datePickerFim.IsEnabled = false; } Settings.HolidayState = ConfigTable.GetSwitchCell (0, 1).On; }; Content = ConfigTable; // if (App.Gates.Count > 0) // ConfigTable.Root.Insert (0, firstSection); // else // ConfigTable.Root.Remove (firstSection); }
/// <summary> /// Initializes the component. /// </summary> /// <param name="tshirt">Tshirt.</param> void InitializeComponent(TShirt tshirt) { var layout = new StackLayout { VerticalOptions = LayoutOptions.Center }; var image = new Image { HorizontalOptions = LayoutOptions.Center, Source = tshirt.Image }; var label = new Label { HorizontalOptions = LayoutOptions.Center, Text = tshirt.Name }; var genderCell = new SwitchCell { Text = "Women / Men" }; genderCell.SetBinding<OrderViewModel>(SwitchCell.OnProperty, vm => vm.IsMen); var sizeLabel = new Label { Text = "Size", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center }; var sizePicker = new Picker { Title = "Small", WidthRequest = 100.0, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center }; sizePicker.Items.Add("Small"); sizePicker.Items.Add("Medium"); sizePicker.Items.Add("Large"); sizePicker.Items.Add("X-Large"); sizePicker.SetBinding<OrderViewModel>(Picker.SelectedIndexProperty, vm => vm.SizeIndex); var sizeLayout = new StackLayout { Padding = new Thickness(15, 0), Spacing = 0, Orientation = StackOrientation.Horizontal, Children = { sizeLabel, sizePicker } }; var sizeCell = new ViewCell { View = sizeLayout }; var optionSection = new TableSection { Title = "Options" }; optionSection.Add(genderCell); optionSection.Add(sizeCell); var tableView = new TableView { Intent = TableIntent.Form, HeightRequest = 300.0, Root = new TableRoot { optionSection } }; var buttonCancel = new Button { HorizontalOptions = LayoutOptions.EndAndExpand, Text = "Cancel" }; buttonCancel.Clicked += async (sender, e) => await Navigation.PopModalAsync(); var buttonOrder = new Button { HorizontalOptions = LayoutOptions.StartAndExpand, Text = "Purchase" }; buttonOrder.SetBinding<OrderViewModel>(Button.CommandProperty, vm => vm.OrderCommand); var bottomLayout = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal, Children = { buttonCancel, new Label { HorizontalOptions = LayoutOptions.CenterAndExpand }, buttonOrder } }; layout.Children.Add(image); layout.Children.Add(label); layout.Children.Add(tableView); layout.Children.Add(bottomLayout); Content = layout; }
public SwitchCellEvents(SwitchCell This) : base(This) { this.This = This; }
public static SwitchCellEvents Events(this SwitchCell This) { return(new SwitchCellEvents(This)); }
public CodedPopupExample() { _closeOnAnyTap = new SwitchCell {Text = "Close on any tap", On = true}; _preventShowing = new SwitchCell { Text = "Prevent popup from showing" }; _displayTappedSection = new SwitchCell {Text = "Display the tapped section's name"}; _showingAnimation = new SwitchCell { Text = "Turn on 'Showing' animation" }; var showPopup = new Button {Text = "Show Popup"}; var closeButton = new Button { Text = "Close", TextColor = Color.FromHex("#D37E00"), BackgroundColor = Color.White, }; _popup1 = new Popup { XPositionRequest = 0.5, YPositionRequest = 0.5, ContentWidthRequest = 0.8, ContentHeightRequest = 0.5, Header = new ContentView { Padding = 10, BackgroundColor = Color.FromHex("#3399FF"), Content = new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Label)), TextColor = Color.White, Text = "Simple popup" } }, Body = new ContentView { Padding = 10, BackgroundColor = Color.White, Content = new Label { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof (Label)), TextColor = Color.Gray, Text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." } }, Footer = new ContentView { BackgroundColor = Color.White, Content = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.EndAndExpand, Children = { closeButton } } } }; Content = new StackLayout { Children = { new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Coded Popup Example") { _closeOnAnyTap, _preventShowing, _displayTappedSection, _showingAnimation } }, }, showPopup } }; // Required to be instantiated before the popup is added to ContentPage.Content new PopupPageInitializer(this) { _popup1 }; _popup1.Tapped += Popup1_Tapped; _popup1.Showing += Popup1_Showing; showPopup.Clicked += ShowPopup_Clicked; closeButton.Clicked += CloseButton_Clicked; }
public SettingsPage() { Title = Catalog.GetString("Settings"); BackgroundColor = App.Colors.Background; // Save for later use // Do this, because color could change while handling with settings :) textColor = App.Colors.Text; backgroundColor = App.Colors.Background; NavigationPage.SetTitleIcon(this, "HomeIcon.png"); NavigationPage.SetBackButtonTitle(this, string.Empty); var cellTheme = new MultiCell { Text = Catalog.GetString("Theme"), // Detail = Catalog.GetString("Theme of display"), Items = new string[] { Catalog.GetString("Light"), Catalog.GetString("Dark"), }, Key = Settings.DisplayThemeKey, DefaultValue = (int)0, }; var sectionTheme = new TableSection(Catalog.GetString("Appearance")) { cellTheme, }; var cellTextAlignment = new MultiCell { Text = Catalog.GetString("Alignment"), // Detail = Catalog.GetString("Alignment of text"), Items = new string[] { Catalog.GetString("Left"), Catalog.GetString("Center"), Catalog.GetString("Right"), }, Key = Settings.TextAlignmentKey, DefaultValue = (int)Settings.DefaultTextAlignment, }; var cellTextSize = new EntryCell { Label = Catalog.GetString("Size"), LabelColor = App.Colors.Text, Keyboard = Keyboard.Numeric, Text = Settings.Current.GetValueOrDefault<int>(Settings.TextSizeKey, Settings.DefaultFontSize).ToString(), XAlign = TextAlignment.End, }; cellTextSize.Completed += (object sender, EventArgs e) => { int value; if (int.TryParse(((EntryCell)sender).Text, out value)) { Settings.Current.AddOrUpdateValue<int>(Settings.TextSizeKey, value); } }; cellTextSize.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => { if (e.PropertyName == "Text") { int value; if (int.TryParse(((EntryCell)sender).Text, out value)) { Settings.Current.AddOrUpdateValue<int>(Settings.TextSizeKey, value); } } }; var sectionText = new TableSection(Catalog.GetString("Text")) { cellTextAlignment, cellTextSize, }; var cellImageAlignment = new MultiCell { Text = Catalog.GetString("Alignment"), // Detail = Catalog.GetString("Alignment of images"), Items = new string[] { Catalog.GetString("Left"), Catalog.GetString("Center"), Catalog.GetString("Right"), }, Key = Settings.ImageAlignmentKey, DefaultValue = (int)Settings.DefaultImageAlignment, }; var cellImageResize = new MultiCell { Text = Catalog.GetString("Resizing"), // Detail = Catalog.GetString("Resizing of images"), Items = new string[] { Catalog.GetString("Don't resize"), Catalog.GetString("Shrink only"), Catalog.GetString("Resize to screen width"), Catalog.GetString("Resize to max. half height"), }, ShortItems = new string[] { Catalog.GetString("Don't resize"), Catalog.GetString("Shrink only"), Catalog.GetString("Screen width"), Catalog.GetString("Max. half height"), }, Key = Settings.ImageResizeKey, DefaultValue = (int)Settings.DefaultImageResize, }; var sectionImages = new TableSection(Catalog.GetString("Images")) { cellImageAlignment, cellImageResize, }; var cellFeedbackSound = new SwitchCell { Text = Catalog.GetString("Sound"), On = Settings.Current.GetValueOrDefault<bool>(Settings.FeedbackSoundKey, false), }; cellFeedbackSound.OnChanged += (object sender, ToggledEventArgs e) => Settings.Current.AddOrUpdateValue<bool>(Settings.FeedbackSoundKey, e.Value); var cellFeedbackVibration = new SwitchCell { Text = Catalog.GetString("Vibration"), On = Settings.Current.GetValueOrDefault<bool>(Settings.FeedbackVibrationKey, false), }; cellFeedbackVibration.OnChanged += (object sender, ToggledEventArgs e) => Settings.Current.AddOrUpdateValue<bool>(Settings.FeedbackVibrationKey, e.Value); var sectionFeedback = new TableSection(Catalog.GetString("Feedback")) { cellFeedbackSound, cellFeedbackVibration, }; var cellUnitDegrees = new MultiCell { Text = Catalog.GetString("Degrees"), // Detail = Catalog.GetString("Resizing of images"), Items = new string[] { Catalog.GetString("Decimal degrees (9.07538°)"), Catalog.GetString("Decimal minutes (9° 04.523')"), Catalog.GetString("Decimal seconds (9° 04' 31.38\")"), }, ShortItems = new string[] { Catalog.GetString("Decimal degrees"), Catalog.GetString("Decimal minutes"), Catalog.GetString("Decimal seconds"), }, Key = Settings.FormatCoordinatesKey, DefaultValue = (int)Settings.DefaultFormatCoordinates, }; var cellUnitAltitude = new MultiCell { Text = Catalog.GetString("Altitude"), // Detail = Catalog.GetString("Resizing of images"), Items = new string[] { Catalog.GetString("Meter"), Catalog.GetString("Feet"), }, Key = Settings.UnitAltitudeKey, DefaultValue = (int)Settings.DefaultUnitAltitude, }; var cellUnitLength = new MultiCell { Text = Catalog.GetString("Length"), // Detail = Catalog.GetString("Resizing of images"), Items = new string[] { Catalog.GetString("Meter"), Catalog.GetString("Feet"), }, Key = Settings.UnitLengthKey, DefaultValue = (int)Settings.DefaultUnitLength, }; var sectionUnits = new TableSection(Catalog.GetString("Units")) { cellUnitDegrees, cellUnitAltitude, cellUnitLength, }; var languages = new string[] { string.Empty, "en", "fi", "fr", "de" }; var cellLanguage = new MultiCell { Text = Catalog.GetString("Language"), // Detail = Catalog.GetString("Resizing of images"), Items = new string[] { Catalog.GetString("Default"), Catalog.GetString("English"), Catalog.GetString("Finnish"), Catalog.GetString("French"), Catalog.GetString("German"), }, Values = languages, Key = Settings.LanguageKey, DefaultValue = Array.IndexOf(languages, Settings.LanguageKey) < 0 ? 0 : Array.IndexOf(languages, Settings.LanguageKey), }; var sectionLanguage = new TableSection(Catalog.GetString("Language")) { cellLanguage, }; #if __ANDROID__ cellPath = new TextCell { Text = Catalog.GetString("Path for cartridges"), TextColor = App.Colors.Text, Detail = Settings.Current.GetValueOrDefault<string>(Settings.CartridgePathKey, null), DetailColor = Color.Gray, }; cellPath.Command = new Command((sender) => App.Navigation.Navigation.PushAsync(new FolderSelectionPage(Settings.Current.GetValueOrDefault<string>(Settings.CartridgePathKey, null), () => { cellPath.Detail = Settings.Current.GetValueOrDefault<string>(Settings.CartridgePathKey, null); }, textColor, backgroundColor))); var sectionPath = new TableSection(Catalog.GetString("Path")) { cellPath, }; #endif var tableRoot = new TableRoot(Catalog.GetString("Settings")) { sectionTheme, sectionText, sectionImages, sectionFeedback, sectionUnits, sectionLanguage, #if __ANDROID__ sectionPath, #endif }; var tableView = new TableView() { BackgroundColor = App.Colors.Background, Intent = TableIntent.Settings, Root = tableRoot, HasUnevenRows = true, }; Content = tableView; }