private async Task <MenuFlyout> Show_Experiment_Devices() { Device[] c = Exp.Devices; List <Device> b = await CacheManagement.GetConnectedDevices(); MenuFlyout m = new MenuFlyout(); bool available = false; for (int i = 0; i < c.Length; i++) { c[i].Connected = false; for (int j = 0; j < b.Count; j++) { if (c[i] == b[j]) { c[i].Connected = true; } } } if (c.Length > 0) { foreach (Device d in c) { available = available || d.Connected; MenuFlyoutItem mi = new MenuFlyoutItem() { Text = d.Name, IsEnabled = d.Connected, Tag = d }; mi.Click += delegate { Play_Experiment((Device)this.Tag); }; m.Items.Add(mi); } if (!available) { MenuFlyoutItem mi = new MenuFlyoutItem() { Text = "Experiment Manually" }; mi.Click += delegate { Run_Manual(); }; m.Items.Add(mi); } } else { MenuFlyoutItem placeholder = new MenuFlyoutItem() { Text = "Run Manually" }; m.Items.Add(placeholder); } return(m); }
public async void GetConnectedDevices(object sender, RoutedEventArgs e) { List <Device> c = new List <Device>(); c = await CacheManagement.GetConnectedDevices(); MenuFlyout m = new MenuFlyout(); Device[] already = Exp.Devices; if (already != null && c.Count > 0) { foreach (Device d in already) { for (int i = 0; i < c.Count; i++) { if (d == c[i]) { c.Remove(c[i]); } } } } if (c.Count > 0) { for (int i = 0; i < c.Count; i++) { MenuFlyoutItem mi = new MenuFlyoutItem() { Text = c[i].Name, FontSize = 16, Tag = c[i] }; mi.Click += Connect_Device_To_Experiment_Click; m.Items.Add(mi); } } else { MenuFlyoutItem mi = new MenuFlyoutItem() { Text = "No Connected Devices", FontSize = 16, IsEnabled = false }; m.Items.Add(mi); } m.ShowAt((Button)sender); }
public MainPage() { this.InitializeComponent(); if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { Color mBlue = Color.FromArgb(0xFF, 0x00, 0x71, 0xC1); titleBar.ButtonBackgroundColor = mBlue; titleBar.ButtonForegroundColor = Colors.White; titleBar.BackgroundColor = mBlue; titleBar.ForegroundColor = Colors.White; } } CacheManagement.CheckLocalConnections(true); NavPanel.ExpandClick += new RoutedEventHandler(this.NavControl_Expand); }
private async Task <List <Device> > ConnectedDevices() { return(await CacheManagement.GetConnectedDevices()); }
public async Task Connect() { CacheManagement.ConnectDevice(SelectedDevice); await Task.Delay(2000); }