예제 #1
0
        public static View GetView(int position, CentralUnit centralUnit, View convertView)
        {
            var view = convertView ?? LayoutInflater.From(Application.Context).Inflate(Resource.Layout.HomeControlApiItem, null);

            view.FindViewById <TextView>(Resource.Id.tvName).Text    = centralUnit.Name;
            view.FindViewById <TextView>(Resource.Id.tvAddress).Text = centralUnit.Address;
            view.FindViewById <TextView>(Resource.Id.tvBrand).Text   = centralUnit.Brand.ToString();

            return(view);
        }
예제 #2
0
        public static View GetView(int position, CentralUnit centralUnit, View convertView)
        {
            var view = convertView ?? LayoutInflater.From(Application.Context).Inflate(Resource.Layout.HomeControlApiItem, null);

            view.FindViewById<TextView>(Resource.Id.tvName).Text = centralUnit.Name;
            view.FindViewById<TextView>(Resource.Id.tvAddress).Text = centralUnit.Address;
            view.FindViewById<TextView>(Resource.Id.tvBrand).Text = centralUnit.Brand.ToString();

            return view;
        }
예제 #3
0
        public async Task DeleteCentralUnitAsync(CentralUnit centralUnit)
        {
            // Delete central unit from list and configuration
            CentralUnits.Remove(centralUnit);
            _SettingsService.Settings.Configuration.CentralUnits.Remove(centralUnit);
            await _HomeControlService.InitAsync(_SettingsService.Settings.Configuration);

            // Save settings
            await _SettingsService.SaveSettingsAsync();
        }
예제 #4
0
        public async Task AddCentralUnitAsync(CentralUnit centralUnit)
        {
            // Add central unit to list and configuration
            CentralUnits.Add(centralUnit);

            _SettingsService.Settings.Configuration.CentralUnits.Add(centralUnit);
            await _HomeControlService.InitAsync(_SettingsService.Settings.Configuration);

            // Save settings
            await _SettingsService.SaveSettingsAsync();
        }
예제 #5
0
        private void ShowAddEditDialog(CentralUnit centralUnit)
        {
            var builder    = new Android.Support.V7.App.AlertDialog.Builder(this);
            var dialogView = LayoutInflater.Inflate(Resource.Layout.AddHomeControlSystemDialog, null);

            builder.SetView(dialogView);
            builder.SetNeutralButton(Android.Resource.String.Cancel, (sender, e) => { });
            builder.SetPositiveButton(Android.Resource.String.Ok, (e, s) => App.Bootstrapper.SettingsViewModel.AddCentralUnitCommand.Execute(null));

            // Bindings
            EtName             = dialogView.FindViewById <EditText>(Resource.Id.etName);
            EtNameBinding      = this.SetBinding(() => SettingsViewModel.NewCentralUnitName, () => EtName.Text, BindingMode.TwoWay);
            EtIpAddress        = dialogView.FindViewById <EditText>(Resource.Id.etIpAddress);
            EtIpAddressBinding = this.SetBinding(() => SettingsViewModel.NewCentralUnitAddress, () => EtIpAddress.Text, BindingMode.TwoWay);

            // Fill spinner
            var items          = Enum.GetValues(typeof(CentralUnitBrand)).OfType <object>().Select(s => s.ToString()).ToArray();
            var spinnerAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, items);

            spinnerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            dialogView.FindViewById <Spinner>(Resource.Id.spBrand).Adapter = spinnerAdapter;

            builder.Show();
        }
예제 #6
0
		private void ShowAddEditDialog(CentralUnit centralUnit)
		{
			var builder = new Android.Support.V7.App.AlertDialog.Builder(this);
			var dialogView = LayoutInflater.Inflate(Resource.Layout.AddHomeControlSystemDialog, null);
			builder.SetView(dialogView);
			builder.SetNeutralButton(Android.Resource.String.Cancel, (sender, e) => { });
			builder.SetPositiveButton(Android.Resource.String.Ok, (e, s) => App.Bootstrapper.SettingsViewModel.AddCentralUnitCommand.Execute(null));

			// Bindings
			EtName = dialogView.FindViewById<EditText>(Resource.Id.etName);
			EtNameBinding = this.SetBinding(() => SettingsViewModel.NewCentralUnitName, () => EtName.Text, BindingMode.TwoWay);
			EtIpAddress = dialogView.FindViewById<EditText>(Resource.Id.etIpAddress);
			EtIpAddressBinding = this.SetBinding(() => SettingsViewModel.NewCentralUnitAddress, () => EtIpAddress.Text, BindingMode.TwoWay);

			// Fill spinner
			var items = Enum.GetValues(typeof(CentralUnitBrand)).OfType<object>().Select(s => s.ToString()).ToArray();
			var spinnerAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, items);
			spinnerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
			dialogView.FindViewById<Spinner>(Resource.Id.spBrand).Adapter = spinnerAdapter;

			builder.Show();
		}