/// <summary> /// Initializes a new instance of the <see cref="SensusUI.ProbesPage"/> class. /// </summary> /// <param name="protocol">Protocol to display probes for.</param> public ProbesPage(Protocol protocol) { _protocol = protocol; Title = "Probes"; _probesList = new ListView { IsPullToRefreshEnabled = true }; _probesList.ItemTemplate = new DataTemplate(typeof(TextCell)); _probesList.ItemTemplate.SetBinding(TextCell.TextProperty, new Binding(".", converter: new ProbeTextValueConverter())); _probesList.ItemTemplate.SetBinding(TextCell.TextColorProperty, new Binding(".", converter: new ProbeTextColorValueConverter())); _probesList.ItemTemplate.SetBinding(TextCell.DetailProperty, new Binding(".", converter: new ProbeDetailValueConverter())); _probesList.ItemTapped += async (o, e) => { ProbePage probePage = new ProbePage(e.Item as Probe); probePage.Disappearing += (oo, ee) => { Bind(); }; // rebind the probes page to pick up changes in the probe await Navigation.PushAsync(probePage); _probesList.SelectedItem = null; }; _probesList.Refreshing += (o, e) => { Bind(); _probesList.IsRefreshing = false; }; Bind(); ToolbarItems.Add(new ToolbarItem("All", null, async () => { if(await DisplayAlert("Enable All Probes", "Are you sure you want to enable all probes?", "Yes", "No")) { foreach(Probe probe in _protocol.Probes) if(UiBoundSensusServiceHelper.Get(true).EnableProbeWhenEnablingAll(probe)) probe.Enabled = true; Bind(); } })); ToolbarItems.Add(new ToolbarItem("None", null, async () => { if(await DisplayAlert("Disable All Probes", "Are you sure you want to disable all probes?", "Yes", "No")) { foreach(Probe probe in _protocol.Probes) probe.Enabled = false; Bind(); } })); Content = _probesList; }
public ProbesPage(Protocol protocol) { _protocol = protocol; Title = "Probes"; _probesList = new ListView(); _probesList.ItemTemplate = new DataTemplate(typeof(TextCell)); _probesList.ItemTemplate.SetBinding(TextCell.TextProperty, new Binding(".", converter: new ProbeTextValueConverter())); _probesList.ItemTemplate.SetBinding(TextCell.TextColorProperty, new Binding(".", converter: new ProbeTextColorValueConverter())); _probesList.ItemTemplate.SetBinding(TextCell.DetailProperty, new Binding(".", converter: new ProbeDetailValueConverter())); _probesList.ItemTapped += async(o, e) => { ProbePage probePage = new ProbePage(e.Item as Probe); probePage.Disappearing += (oo, ee) => { Bind(); }; // rebind the probes page to pick up changes in the probe await Navigation.PushAsync(probePage); _probesList.SelectedItem = null; }; Bind(); ToolbarItems.Add(new ToolbarItem("All", null, async() => { if (await DisplayAlert("Enable All Probes", "Are you sure you want to enable all probes?", "Yes", "No")) { foreach (Probe probe in _protocol.Probes) { probe.Enabled = true; } Bind(); } })); ToolbarItems.Add(new ToolbarItem("None", null, async() => { if (await DisplayAlert("Disable All Probes", "Are you sure you want to disable all probes?", "Yes", "No")) { foreach (Probe probe in _protocol.Probes) { probe.Enabled = false; } Bind(); } })); ToolbarItems.Add(new ToolbarItem("Refresh", null, () => { Bind(); })); Content = _probesList; }