public SettingsViewModel(LaneModel laneModelTapped) { laneModel = laneModelTapped; _toggleButtonText = _iconToggleDisabled; _imageCellIcon = _aboutIconName; }
public static ObservableCollection <LaneModel> CreateLanes() { var rnd = new Random(); var IPAddress = "192.168.0."; var laneList = new ObservableCollection <LaneModel>(); for (int i = 0; i < 10; i++) { var lane = new LaneModel(); if (rnd.Next(9) < 1) { lane.IsOpen = false; } lane.Count = rnd.Next(1, 100); if (rnd.Next(5) == 1) { lane.NeedsMaintenance = true; } lane.IPAddress = $"{IPAddress}{i}"; laneList.Add(lane); } return(laneList); }
protected static List <LaneModel> CreateLanes() { var laneList = new List <LaneModel>(); for (int i = 0; i < 5; i++) { var laneModel = new LaneModel(i); laneList.Add(laneModel); } return(laneList); }
public SettingsPage(LaneModel laneModelTapped) { BindingContext = new SettingsViewModel(laneModelTapped); IconImageSource = "cogwheel_navigation"; Title = $"Lane {laneModelTapped.ID + 1} Settings"; Content = new StackLayout { Children = { new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection { new SwitchCell { Text = "Is Open" } .Bind(SwitchCell.OnProperty, nameof(SettingsViewModel.IsOpen)), new SwitchCell { Text = "Needs Maintenance" } .Bind(SwitchCell.OnProperty, nameof(SettingsViewModel.NeedsMaintenance)), new EntryCell { Label = "IP Address", HorizontalTextAlignment = TextAlignment.End } .Bind(EntryCell.TextProperty, nameof(SettingsViewModel.IPAddress)), new ImageCell() .Bind(ImageCell.ImageSourceProperty, nameof(SettingsViewModel.ImageCellIcon)) } } }, new Button() .Bind(Button.CommandProperty, nameof(SettingsViewModel.IconToggleButtonCommand)) .Bind(Button.TextProperty, nameof(SettingsViewModel.ToggleButtonText)) } }; }
public SettingsViewModel(LaneModel laneModelTapped) { laneModel = laneModelTapped; _toggleButtonText = _iconToggleDisabled; _imageCellIcon = _aboutIconName; IconToggleButtonTapped = new Command(async() => { _timerEnabled = !_timerEnabled; if (_timerEnabled) { ToggleButtonText = _iconToggleEnabled; } else { ToggleButtonText = _iconToggleDisabled; } await ToggleImage(); }); }
public SettingsPage(LaneModel laneModelTapped) { var viewModel = new SettingsViewModel(laneModelTapped); BindingContext = viewModel; #region create the IsOpen Switch var isOpenSwitch = new SwitchCell { Text = "Is Open" }; isOpenSwitch.SetBinding(SwitchCell.OnProperty, "IsOpen"); #endregion #region Create the Needs Maintenance Switch var needsMaintenanceSwitch = new SwitchCell { Text = "Needs Maintenance" }; needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty, "NeedsMaintenance"); #endregion #region create the IP Address Entry var ipAddressText = new EntryCell { Label = "IP Address", HorizontalTextAlignment = TextAlignment.End }; ipAddressText.SetBinding(EntryCell.TextProperty, "IPAddress"); #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, "IconToggleButtonTapped"); 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 {laneModelTapped.ID + 1} Settings"; Content = settingsStack; }
public SettingsPage(LaneModel laneModelTapped) { var viewModel = new SettingsViewModel(laneModelTapped); BindingContext = viewModel; var isOpenSwitch = new SwitchCell { Text = "Is Open" }; isOpenSwitch.SetBinding(SwitchCell.OnProperty, nameof(viewModel.IsOpen)); var needsMaintenanceSwitch = new SwitchCell { Text = "Needs Maintenance" }; needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty, nameof(viewModel.NeedsMaintenance)); var ipAddressText = new EntryCell { Label = "IP Address", HorizontalTextAlignment = TextAlignment.End }; ipAddressText.SetBinding(EntryCell.TextProperty, nameof(viewModel.IPAddress)); var imageCell = new ImageCell(); imageCell.SetBinding(ImageCell.ImageSourceProperty, nameof(viewModel.ImageCellIcon)); var iconToggleButton = new Button(); iconToggleButton.SetBinding(Button.CommandProperty, nameof(viewModel.IconToggleButtonCommand)); iconToggleButton.SetBinding(Button.TextProperty, nameof(viewModel.ToggleButtonText)); var tableView = new TableView { Intent = TableIntent.Settings, Root = new TableRoot { new TableSection { isOpenSwitch, needsMaintenanceSwitch, ipAddressText, imageCell } } }; var settingsStack = new StackLayout { Children = { tableView, iconToggleButton } }; NavigationPage.SetTitleIcon(this, "cogwheel_navigation"); Title = $"Lane {laneModelTapped.ID + 1} Settings"; Content = settingsStack; }