예제 #1
0
        /// <summary>
        /// Initializes and modifies the members
        /// </summary>
        public void Init()
        {
            // Initializing objects
            m_ViewName     = FindViewById <TextView>(Resource.Id.DeviceName);
            m_ViewAddress  = FindViewById <TextView>(Resource.Id.DeviceAdresse);
            m_BtControl    = FindViewById <Button>(Resource.Id.btSteueren);
            m_BtDisconnect = FindViewById <Button>(Resource.Id.btDisconnect);
            m_Linear       = FindViewById <LinearLayout>(Resource.Id.linear4);

            // Setting text color of buttons
            m_BtControl.SetBackgroundColor(Android.Graphics.Color.DeepSkyBlue);
            m_BtDisconnect.SetBackgroundColor(Android.Graphics.Color.DeepSkyBlue);
            m_BtControl.SetTextColor(Android.Graphics.Color.White);
            m_BtDisconnect.SetTextColor(Android.Graphics.Color.White);

            // Setting activity background
            m_Linear.SetBackgroundColor(Android.Graphics.Color.White);

            // Receiving data from other activities
            IList <String> text = Intent.GetStringArrayListExtra("MyData");

            m_ViewName.Text    = text.ElementAt(0);
            m_ViewAddress.Text = text.ElementAt(1);

            // Setting text color of textviews
            m_ViewName.SetTextColor(Android.Graphics.Color.Black);
            m_ViewAddress.SetTextColor(Android.Graphics.Color.Black);

            // Handling button contact
            m_BtControl.Click += delegate
            {
                if (ConnectedThread.m_Socket.IsConnected)
                {
                    StartActivity(typeof(ControllerActivity));
                }
            };

            m_BtDisconnect.Click += delegate
            {
                ConnectedThread.Cancel();
                StartActivity(typeof(MainActivity));
            };
        }
 protected override void OnDestroy()
 {
     base.OnDestroy();
     ConnectedThread.Cancel();
 }
 protected override void OnStop()
 {
     base.OnStop();
     ConnectedThread.Cancel();
 }