public MainPage() { this.InitializeComponent(); // Initialize ConnectTheDots Helper CTD = new ConnectTheDots(); // Restore local settings if (localSettings.Values.ContainsKey("DisplayName")) { CTD.DisplayName = (string)localSettings.Values["DisplayName"]; this.TBDeviceName.Text = CTD.DisplayName; } if (localSettings.Values.ContainsKey("ConnectionString")) { CTD.ConnectionString = (string)localSettings.Values["ConnectionString"]; this.TBConnectionString.Text = CTD.ConnectionString; } // Check configuration settings ConnectToggle.IsEnabled = checkConfig(); CTD.DisplayName = this.TBDeviceName.Text; CTD.ConnectionString = this.TBConnectionString.Text; CTD.Organization = "My Company"; CTD.Location = "Unknown"; // Get user consent for accessing location Task.Run(async() => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { this.LocationAccess = await Geolocator.RequestAccessAsync(); }); }); // Connect to MS Band connectToBand(); // Start task that will send telemetry data to Azure // Hook up a callback to display message received from Azure CTD.ReceivedMessage += (object sender, EventArgs e) => { // Received a new message, display it CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var dialogbox = new MessageDialog("Received message from Azure IoT Hub: \nName: " + ((ConnectTheDots.ReceivedMessageEventArgs)e).Message.name + "\nMessage: " + ((ConnectTheDots.ReceivedMessageEventArgs)e).Message.message); await dialogbox.ShowAsync(); }); }; }
public MainPage() { this.InitializeComponent(); // Initialize QRCode Scanner Scanner = new MobileBarcodeScanner(Dispatcher); Scanner.Dispatcher = Dispatcher; // Initialize ConnectTheDots Helper CTD = new ConnectTheDots(); // Hook up a callback to display message received from Azure CTD.ReceivedMessage += CTD_ReceivedMessage; // Restore local settings if (localSettings.Values.ContainsKey("ConnectionString")) { CTD.ConnectionString = (string)localSettings.Values["ConnectionString"]; this.TBConnectionString.Text = CTD.ConnectionString; } if (localSettings.Values.ContainsKey("DisplayName")) { CTD.DisplayName = (string)localSettings.Values["DisplayName"]; this.TBDeviceName.Text = CTD.DisplayName; } // Check configuration settings ConnectToggle.IsEnabled = checkConfig(); CTD.ConnectionString = this.TBConnectionString.Text; CTD.DisplayName = this.TBDeviceName.Text; CTD.Organization = "My Company"; CTD.Location = "Unknown"; // Get user consent for accessing location Task.Run(async() => { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { this.LocationAccess = await Geolocator.RequestAccessAsync(); // Get device location await updateLocation(); }); }); // Add sensors to the ConnectTheDots object CTD.AddSensor("Temperature", "C"); CTD.AddSensor("Humidity", "%"); }
public MainPage() { this.InitializeComponent(); // Initialize ConnectTheDots Helper CTD = new ConnectTheDots(); // Restore local settings if (localSettings.Values.ContainsKey("DisplayName")) { CTD.DisplayName = (string)localSettings.Values["DisplayName"]; this.TBDeviceName.Text = CTD.DisplayName; } if (localSettings.Values.ContainsKey("ConnectionString")) { CTD.ConnectionString = (string)localSettings.Values["ConnectionString"]; this.TBConnectionString.Text = CTD.ConnectionString; } // Check configuration settings ConnectToggle.IsEnabled = checkConfig(); CTD.DisplayName = this.TBDeviceName.Text; CTD.ConnectionString = this.TBConnectionString.Text; CTD.Organization = "My Company"; CTD.Location = "Unknown"; // Hook up a callback to display message received from Azure CTD.ReceivedMessage += CTD_ReceivedMessage; // Get user consent for accessing location Task.Run(async() => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { this.LocationAccess = await Geolocator.RequestAccessAsync(); // Get device location await updateLocation(); }); }); // Connect to MS Band Task.Run(async() => { await connectToBand(); }); }