protected override void OnCreate(Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(bundle); apphandler = new AppHandler(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); btnUp = FindViewById <Button> (Resource.Id.buttonUP); btnDown = FindViewById <Button> (Resource.Id.buttonDown); btnVUp = FindViewById <Button> (Resource.Id.buttonVUp); btnVDown = FindViewById <Button> (Resource.Id.buttonVDown); btnVMute = FindViewById <Button> (Resource.Id.buttonVMute); btnClose = FindViewById <Button> (Resource.Id.buttonClose); btnShutdown = FindViewById <Button> (Resource.Id.buttonS); EventHandler eventhandler = new EventHandler(this); //CheckConnection apphandler.CheckConnection(this); }
public EventHandler(MainActivity main) { AppHandler apphandler = new AppHandler(); // Get our button from the layout resource, // and attach an event to it main.btnUp.Click += delegate { apphandler.SendRequest("U"); }; main.btnDown.Click += delegate { apphandler.SendRequest("D"); }; main.btnVUp.Click += delegate { apphandler.SendRequest("Y"); }; main.btnVDown.Click += delegate { apphandler.SendRequest("X"); }; main.btnVMute.Click += delegate { apphandler.SendRequest("M"); }; main.btnClose.Click += delegate { new AlertDialog.Builder(main) .SetPositiveButton("Yes", (sender, EventArgs) => { apphandler.SendRequest("C"); }) .SetNegativeButton("No", (sender, EventArgs) => { }) .SetMessage("Close Wilmaa?") .Show(); }; main.btnShutdown.Click += delegate { new AlertDialog.Builder(main) .SetPositiveButton("Yes", (sender, EventArgs) => { apphandler.SendRequest("S"); }) .SetNegativeButton("No", (sender, EventArgs) => { }) .SetMessage("Computer shutdown?") .Show(); }; }