// Overridden from UIViewController
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitNavigationBar("ic_nav_device_manager", true);
            View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("CarbonBackground"));
            NavigationItem.Title = Strings.Device.Manager.SELF.FromResources();

            labelEmpty.Text = Strings.Device.Manager.EMPTY;

            ion.deviceManager.onDeviceManagerEvent += OnDeviceManagerEvent;

            tableContent = new UITableView(new CGRect(.05 * View.Bounds.Width, 50, .9 * View.Bounds.Width, View.Bounds.Height - 50));
            tableContent.BackgroundColor    = UIColor.Clear;
            tableContent.SeparatorStyle     = UITableViewCellSeparatorStyle.None;
            tableContent.Source             = deviceSource = new RemoteDeviceManagerTableSource(ion, this, tableContent);
            deviceSource.sensorFilter       = displayFilter;
            deviceSource.onSensorAddClicked = (GaugeDeviceSensor sensor, NSIndexPath indexPath) => {
                if (onSensorReturnDelegate != null)
                {
                    onSensorReturnDelegate(sensor);
                    NavigationController.PopViewController(true);
                    return(true);
                }
                return(false);
            };
            View.AddSubview(tableContent);
        }
Ejemplo n.º 2
0
        // Overridden from UIViewController
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitNavigationBar("ic_nav_device_manager", true);
            View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("CarbonBackground"));
            NavigationItem.Title = Strings.Device.Manager.SELF.FromResources();
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(Strings.Device.Manager.SCAN.FromResources(), UIBarButtonItemStyle.Plain, delegate {
                if (!ion.deviceManager.connectionHelper.isEnabled)
                {
                    UIAlertView bluetoothWarning = new UIAlertView("Bluetooth Disconnected", "Bluetooth needs to be connected to discover peripherals", null, "Close", "Settings");
                    bluetoothWarning.Clicked    += (sender, e) => {
                        if (e.ButtonIndex.Equals(1))
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
                        }
                    };
                    bluetoothWarning.Show();
                }
                else
                {
                    if (ion.deviceManager.connectionHelper.isScanning)
                    {
                        ion.deviceManager.connectionHelper.StopScan();
                    }
                    else
                    {
                        if (!ion.deviceManager.connectionHelper.StartScan(TimeSpan.FromMilliseconds(DEFAULT_SCAN_TIME)))
                        {
                            Toast.New(View, Strings.Errors.SCAN_INIT_FAIL);
                        }
                    }
                }
            });
            labelEmpty.Text = Strings.Device.Manager.EMPTY;

            ion.deviceManager.onDeviceManagerEvent += OnDeviceManagerEvent;
            if (ion.deviceManager.connectionHelper.isEnabled)
            {
                UpdateScanState();
            }
            tableContent.Source             = deviceSource = new RemoteDeviceManagerTableSource(ion, this, tableContent);
            deviceSource.sensorFilter       = displayFilter;
            deviceSource.onSensorAddClicked = (GaugeDeviceSensor sensor, NSIndexPath indexPath) => {
                if (onSensorReturnDelegate != null)
                {
                    onSensorReturnDelegate(sensor);
                    NavigationController.PopViewController(true);
                    return(true);
                }
                return(false);
            };
        }