示例#1
0
        public DevicesView(DevicesViewModel viewModel) : base(viewModel, "display all sensors")
        {
            ViewBuilder.Create()
            .SetHorizontalMargin(2)
            .Add(statusLabel, width: Dim.Fill())
            .Below(new Label("-------------------------"))
            .Below(_devicesList = new ListView()
            {
                LayoutStyle = LayoutStyle.Absolute,
            })
            .Below(new Label("-------------------------"))
            .Below(new Label(" "))
            .Below(AddNewDeviceButton("add new sensor"))
            .Build(this);

            ViewModel.OnError.Subscribe(err =>
            {
                MessageBox.ErrorQuery(40, 15, err.Message.Length > 40 ? err.Message.Substring(0, 40) : err.Message, err.Message + "\n" + err.StackTrace, "ok");
            }).DisposeWith(_disposable);

            Observable.FromEvent <ListViewItemEventArgs>(h => _devicesList.OpenSelectedItem += h, h => _devicesList.OpenSelectedItem -= h)
            .Select(evt => evt.Value as ThingsDeviceModel)
            .Subscribe(device => ViewModel.ShowDevice(device))
            .DisposeWith(_disposable);

            LoadDevices(statusLabel);
        }
示例#2
0
        public static TableViewCell TableViewCell(this ViewBuilder builder, Type cellType, int type)
        {
#if __IOS__
            var cell = Activator.CreateInstance(cellType, type.ToString());
#endif
#if __ANDROID__
            var cell = builder.Create(cellType);
#endif
            return(new TableViewCell(cell));
        }
        public AddSensorView(AddSensorViewModel viewModel) : base(viewModel, "set in constructor")
        {
            Title = viewModel.IsReadOnly ? "viewing sensor" : "adding sensor";

            var builder = ViewBuilder.Create()
                          // .SetHorizontalMargin(2)
                          .Add(new Label(" "))
                          .Add(InputField("-Device ID", vm => vm.DeviceID))
                          .Add(InputField("-Description", vm => vm.Description))
                          .Add(InputField("-Device EUI", vm => vm.DeviceEUI))
                          // .Add(InputField("-App Key", vm => vm.AppKey))
                          .Add(InputField("-App EUI", vm => vm.AppEUI, "70B3D57ED0035458"))
                          .Below(new Label("  "))
                          .Below(StatusLabel())
                          .Below(new Label("  "));

            if (!ViewModel.IsReadOnly)
            {
                builder.ToTheRight(AddDeviceButton("add"))
                .ToTheRight(new Label("  "))
                .ToTheRight(ClearButton("clear"))
                .Below(new Label("  "));
            }

            else
            {
                builder.ToTheRight(DeleteButton("delete"))
                .ToTheRight(new Label("  "));
            }

            builder
            .ToTheRight(CancelButton("cancel"))
            .Build(this);

            ViewModel.OnError.Subscribe(err =>
            {
                MessageBox.ErrorQuery(40, 15, err.Message, err.Message + "\n" + err.StackTrace, "ok");
            }).DisposeWith(_disposable);
        }