Exemple #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            //toggle stuff
            ToggleKoffie = FindViewById <Button>(Resource.Id.ToggleKoffie);
            ToggleLicht  = FindViewById <Button>(Resource.Id.ToggleLicht);
            chooseMusic  = FindViewById <Button>(Resource.Id.goMusic);
            checkbox1    = FindViewById <CheckBox>(Resource.Id.checkBox1);
            checkbox2    = FindViewById <CheckBox>(Resource.Id.checkBox2);

            choice = new deviceChoice(true, true);

            //timer stuff

            btnset        = FindViewById <Button>(Resource.Id.set);
            txtCountdown  = FindViewById <TextView>(Resource.Id.txtCountdown);
            btnset.Click += Set_Click;
            tijd          = FindViewById <EditText>(Resource.Id.tijd);

            //snooze stuff
            snooze         = FindViewById <Button>(Resource.Id.snooze);
            snooze.Click  += snooze_Click;
            snooze.Enabled = false;

            Spinner selectMusic = FindViewById <Spinner>(Resource.Id.selectMusic);

            selectMusic.ItemSelected += SelectMusic_ItemSelected;
            var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.musicList, Android.Resource.Layout.SimpleSpinnerItem);

            selectMusic.Adapter = adapter;

            //autoconnect
            autoConnect           = FindViewById <Button>(Resource.Id.autoConnect);
            autoConnect.Click    += autoConnect_Click;
            textViewServerConnect = FindViewById <TextView>(Resource.Id.textViewServerConnect);

            UpdateConnectionState(4, "Disconnected");

            //koffie keuze aan of uit
            if (checkbox1.Checked == true)
            {
                choice.koffieAan = true;
            }
            else
            {
                choice.koffieAan = false;
            }

            //licht keuze aan of uit
            if (checkbox2.Checked == true)
            {
                choice.lichtAan = true;
            }
            else
            {
                choice.lichtAan = false;
            }

            //koffie aan
            if (ToggleKoffie != null)  // if koffie button exists
            {
                ToggleKoffie.Click += (sender, e) =>
                {
                    socket.Send(System.Text.Encoding.ASCII.GetBytes("$k---------#")); //send k
                };
            }

            //licht aan
            if (ToggleLicht != null)  // if licht button exists
            {
                ToggleLicht.Click += (sender, e) =>
                {
                    socket.Send(System.Text.Encoding.ASCII.GetBytes("$l---------#")); //send l
                };
            }


            chooseMusic.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(musicActivity));
                StartActivity(intent);
            };
        }
Exemple #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            music = MediaPlayer.Create(this, Resource.Raw.Life);
            AlarmScreenActivity.musicFinal = MediaPlayer.Create(this, Resource.Raw.Life);

            //toggle stuff
            ToggleKoffie    = FindViewById <Button>(Resource.Id.ToggleKoffie);
            ToggleLicht     = FindViewById <Button>(Resource.Id.ToggleLicht);
            chooseMusic     = FindViewById <Button>(Resource.Id.goMusic);
            checkbox1       = FindViewById <CheckBox>(Resource.Id.checkBox1);
            checkbox2       = FindViewById <CheckBox>(Resource.Id.checkBox2);
            WekkerInstellen = FindViewById <Button>(Resource.Id.WekkerInstellen);

            choice = new deviceChoice(true, true);

            //timer stuff

            btnset        = FindViewById <Button>(Resource.Id.set);
            txtCountdown  = FindViewById <TextView>(Resource.Id.txtCountdown);
            btnset.Click += Set_Click;
            tijd          = FindViewById <EditText>(Resource.Id.tijd);

            //autoconnect
            autoConnect           = FindViewById <Button>(Resource.Id.autoConnect);
            autoConnect.Click    += autoConnect_Click;
            textViewServerConnect = FindViewById <TextView>(Resource.Id.textViewServerConnect);

            //Enabled
            ToggleKoffie.Enabled = false;
            ToggleLicht.Enabled  = false;

            UpdateConnectionState(4, "Disconnected");

            //koffie keuze aan of uit
            if (checkbox1.Checked)
            {
                choice.koffieAan = true;
            }
            else
            {
                choice.koffieAan = false;
            }

            //licht keuze aan of uit
            checkbox2.Click += (o, e) =>
            {
                if (checkbox2.Checked)
                {
                    licht = true;
                }
                else
                {
                    licht = false;
                }
            };

            //koffie aan
            if (ToggleKoffie != null)  // if koffie button exists
            {
                ToggleKoffie.Click += (sender, e) =>
                {
                    socket.Send(System.Text.Encoding.ASCII.GetBytes("$k---------#")); //send k
                };
            }

            //licht aan
            if (ToggleLicht != null)  // if licht button exists
            {
                ToggleLicht.Click += (sender, e) =>
                {
                    socket.Send(System.Text.Encoding.ASCII.GetBytes("$l---------#")); //send l
                };
            }

            chooseMusic.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(musicActivity));
                StartActivity(intent);
            };

            WekkerInstellen.Click += (sender, e) =>
            {
                Intent intent = new Intent(this, typeof(Alarmcontroller));
                StartActivity(intent);
            };
        }