Exemple #1
0
 private void ShowError(string message)
 {
     var activity = this.GetService<IMvxAndroidCurrentTopActivity>().Activity as IMvxBindingActivity;
     var alertDialog = new AlertDialog.Builder((Activity)activity).Create();
     alertDialog.SetTitle("Sorry!");
     alertDialog.SetMessage(message);
     alertDialog.SetButton("OK", (sender, args) => {});
     alertDialog.Show();
 }
 protected void ShowErrorDialog(Exception ex)
 {
     RunOnUiThread(() =>
     {
         AlertDialog ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false);
         ad.SetMessage(string.Format("An error has occured: {0}", ex));
         ad.SetButton("OK", (sender, args) => ad.Dismiss());
         ad.Show();
     });
 }
        public static void ShowMsgBox_OK(Activity currentActivity, string title, string msg)
        {
            AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).Create();

            alertDialog.SetTitle(title);
            alertDialog.SetMessage(msg);

            alertDialog.SetButton((int)DialogButtonType.Neutral, "OK",
                (object sender, DialogClickEventArgs e) => {
                    alertDialog.Dismiss();
                });
            alertDialog.Show();
        }
 private void ShowError(ErrorMessage message)
 {
     var activity = Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity as IMvxBindingContextOwner;
     if (activity == null)
     {
         return;
     }
     var alertDialog = new AlertDialog.Builder((Activity)activity).Create();
     alertDialog.SetTitle("Sorry!");
     alertDialog.SetMessage(message.Message);
     alertDialog.SetButton("OK", (sender, args) => {});
     alertDialog.Show();
 }
Exemple #5
0
        public Task ShowAlertAsync(string title, string message)
        {
            var tcs = new TaskCompletionSource<bool> ();

            var alert = new AlertDialog.Builder(Forms.Context).Create();
            alert.SetTitle(title);
            alert.SetMessage(message);
            alert.SetButton("OK", (sender, e) => {
                tcs.TrySetResult(true);
            });

            alert.Show ();

            return tcs.Task;
        }
 void ConnectToServer()
 {
     AlertDialog ad = null;
     try
     {
         Sockets.client = new TcpClient(SERVER_IP, PORT);
     }
     catch (SocketException e)
     {
         ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false); // This blocks the 'BACK' button
         ad.SetMessage("Nie można połączyć się z serwerem. Sprawdź połączenie z internetem.");
         ad.SetButton("OK", delegate
         {
             Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
         });
         ad.Show();
     }
 }
Exemple #7
0
        public static void ShowAlertDialog(Context context, string title, string message,
                                    bool isSuccessStatus)
        {
            var alertDialog = new AlertDialog.Builder(context).Create();

            // Setting Dialog Title
            alertDialog.SetTitle(title);

            // Setting Dialog Message
            alertDialog.SetMessage(message);

            // Setting alert dialog icon
            alertDialog.SetIcon(isSuccessStatus ? Resource.Drawable.success : Resource.Drawable.fail);

            // Setting OK Button
            alertDialog.SetButton("OK", (sender, args) => { });

            // Showing Alert Message
            alertDialog.Show();
        }
 void Delegat()
 {
     Intent intent = null;
     EditText edittext = FindViewById<EditText>(Resource.Id.loginArea);
     byte[] buffer = new byte[MAX_LENGTH];
     AlertDialog ad = null;
     buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Hello), edittext.Text));
     Sockets.client.GetStream().Write(buffer, 0, buffer.Length);
     buffer = new byte[MAX_LENGTH];
     Sockets.client.GetStream().Read(buffer, 0, buffer.Length);
     string[] parse = MessageParser.Split(buffer);
     switch (MessageParser.ToMessageType(parse[0]))
     {
         case MessageTypes.WelcomeClient:
             intent = new Intent(this, typeof(GameManager));
             intent.PutExtra("Nickname", edittext.Text);
             //strbuff = System.Text.Encoding.ASCII.GetString(buffer).Split(';')[1];
             intent.PutExtra("PlayerList", parse[1]);
             StartActivity(intent);
             break;
         case MessageTypes.PlayerExist:
             ad = new AlertDialog.Builder(this).Create();
             ad.SetCancelable(false); // This blocks the 'BACK' button
             ad.SetMessage("Gracz o takim nicku istnieje! Wpisz inny login");
             ad.SetButton("OK", delegate {
                 Sockets.client.Close();
                 ConnectToServer();
             });
             ad.Show();
             break;
         default:
             ad = new AlertDialog.Builder(this).Create();
             ad.SetCancelable(false); // This blocks the 'BACK' button
             ad.SetMessage("Nieoczekiwany błąd. Aplikacja zostanie zamknięta.");
             ad.SetButton("OK", delegate {
                 Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
             });
             ad.Show();
             break;
      }
 }
 private void RenderResults(List<Product> products)
 {
     if (products == null || products.Count == 0)
     {
         _progressDialog.Dismiss ();
         var alertDialog = new AlertDialog.Builder(this).Create();
         alertDialog.SetTitle("Search Results");
         alertDialog.SetMessage("We were unable to find any matches in the catalog.");
         alertDialog.SetIcon(Resource.Drawable.icon);
         alertDialog.SetButton("OK", (o, e) =>
         {
             alertDialog.Dismiss();
             Finish();
         });
         alertDialog.Show();
     }
     else
     {
         SetContentView (Resource.Layout.SearchResults);
         ListView.SetBackgroundColor (G.Color.Transparent);
         ListAdapter = new ProductListAdapter(this, products);
         _progressDialog.Dismiss ();
     }
 }
		void InternalSetPage(Page page)
		{
			if (!Forms.IsInitialized)
				throw new InvalidOperationException("Call Forms.Init (Activity, Bundle) before this");

			if (_canvas != null)
			{
				_canvas.SetPage(page);
				return;
			}

			var busyCount = 0;
			MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) =>
			{
				busyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1);

				if (!Forms.SupportsProgress)
					return;

				SetProgressBarIndeterminate(true);
				UpdateProgressBarVisibility(busyCount > 0);
			});

			UpdateProgressBarVisibility(busyCount > 0);

			MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>
			{
				AlertDialog alert = new AlertDialog.Builder(this).Create();
				alert.SetTitle(arguments.Title);
				alert.SetMessage(arguments.Message);
				if (arguments.Accept != null)
					alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true));
				alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false));
				alert.CancelEvent += (o, args) => { arguments.SetResult(false); };
				alert.Show();
			});

			MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) =>
			{
				var builder = new AlertDialog.Builder(this);
				builder.SetTitle(arguments.Title);
				string[] items = arguments.Buttons.ToArray();
				builder.SetItems(items, (sender2, args) => { arguments.Result.TrySetResult(items[args.Which]); });

				if (arguments.Cancel != null)
					builder.SetPositiveButton(arguments.Cancel, delegate { arguments.Result.TrySetResult(arguments.Cancel); });

				if (arguments.Destruction != null)
					builder.SetNegativeButton(arguments.Destruction, delegate { arguments.Result.TrySetResult(arguments.Destruction); });

				AlertDialog dialog = builder.Create();
				builder.Dispose();
				//to match current functionality of renderer we set cancelable on outside
				//and return null
				dialog.SetCanceledOnTouchOutside(true);
				dialog.CancelEvent += (sender3, e) => { arguments.SetResult(null); };
				dialog.Show();
			});

			_canvas = new Platform(this);
			if (_application != null)
				_application.Platform = _canvas;
			_canvas.SetPage(page);
			_layout.AddView(_canvas.GetViewGroup());
		}
 public override void OnBackPressed()
 {
     AlertDialog ad = new AlertDialog.Builder(this).Create();
     ad.SetCancelable(false); // This blocks the 'BACK' button
     ad.SetMessage("Czy chcesz opuœciæ grê (oddasz walkowerem)?");
     ad.SetButton("Nie", delegate { dialogLive = false; });
     ad.SetButton2("Tak", delegate
     {
         byte[] buffer = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Left), nickname));
         Sockets.client.GetStream().Write(buffer, 0, buffer.Length);
         dialogLive = false;
     });
     dialogLive = true;
     ad.Show();
 }
        void GameThreadProc()
        {
            NetworkStream stream = Sockets.client.GetStream();
            byte[] buffer;
            AlertDialog ad = null;

            while (Sockets.client.Connected)
            {
                try
                {
                    buffer = new byte[MainActivity.MAX_LENGTH];
                    stream.Read(buffer, 0, buffer.Length);
                    string[] data = MessageParser.Split(buffer);
                    if (data.Length == 1)
                    {
                        Sockets.client.Close();
                        RunOnUiThread(delegate
                        {
                            ad = new AlertDialog.Builder(this).Create();
                            ad.SetCancelable(false); // This blocks the 'BACK' button
                            ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
                            ad.SetButton("OK", delegate
                            {
                                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                            });
                            ad.Show();
                        });
                    }
                    switch (MessageParser.ToMessageType(data[0]))
                    {
                        case MessageTypes.TurnClient:
                            RunOnUiThread(delegate { ParseCanvas(data[1]); });
                            isMyTurn = true;
                            break;
                        case MessageTypes.WinClient:
                            RunOnUiThread(delegate
                            {
                                ad = new AlertDialog.Builder(this).Create();
                                ad.SetCancelable(false); // This blocks the 'BACK' button
                                if (data[1].Contains(nickname))
                                    ad.SetMessage("Gratulacje! Wygra³eœ!");
                                else
                                    ad.SetMessage("Niestety przegra³eœ!");
                                ad.SetButton("WyjdŸ", delegate
                                {
                                    GameManager.thLock = false;
                                    Finish();
                                });
                                ad.Show();
                            });
                            return;
                            break;
                        case MessageTypes.LeftClient:
                            RunOnUiThread(delegate
                            {
                                ad = new AlertDialog.Builder(this).Create();
                                ad.SetCancelable(false); // This blocks the 'BACK' button
                                ad.SetMessage("Twój przeciwnik opuœci³ grê!");
                                ad.SetButton("WyjdŸ", delegate
                                {
                                    //th.Abort();
                                    GameManager.thLock = false;
                                    Finish();
                                });
                                ad.Show();
                            });
                            return;
                            break;
                    }
                }
                catch (System.Threading.ThreadAbortException e)
                {
                    return;
                }
                catch (Exception e)
                {

                    Sockets.client.Close();
                    RunOnUiThread(delegate
                    {
                        ad = new AlertDialog.Builder(this).Create();
                        ad.SetCancelable(false); // This blocks the 'BACK' button
                        ad.SetMessage("Nie mo¿na po³¹czyæ siê z serwerem. SprawdŸ po³¹czenie z internetem.");
                        ad.SetButton("OK", delegate
                        {
                            Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                        });
                        ad.Show();
                    });
                }
            }
        }
Exemple #13
0
		private void EnableWriteMode()
		{
			_inWriteMode = true;

			// Create an intent filter for when an NFC tag is discovered.  When
			// the NFC tag is discovered, Android will u
			var tagDetected = new IntentFilter(NfcAdapter.ActionTagDiscovered);
			var filters = new[] { tagDetected };

			// When an NFC tag is detected, Android will use the PendingIntent to come back to this activity.
			// The OnNewIntent method will invoked by Android.
			var intent = new Intent(this, GetType()).AddFlags(ActivityFlags.SingleTop);
			var pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0);

			if (_nfcAdapter == null) {
				var alert = new AlertDialog.Builder (this).Create ();
				alert.SetMessage ("NFC is not supported on this device.");
				alert.SetTitle ("NFC Unavailable");
				alert.SetButton ("OK", delegate {
					_button.Enabled = false;
					_alertMessage.Text = "NFC is not supported on this device.";
				});
				alert.Show ();
			} else
				_nfcAdapter.EnableForegroundDispatch(this, pendingIntent, filters, null);
		}
		protected void OnStartClicked(object sender, EventArgs e){

			if(tunnel.IsRunning){
				ProgressDialog progress = null;
				RunOnUiThread(delegate() {
					progress = ProgressDialog.Show(this,"Disconnecting From Brick...","Closing connection...       ");
				});
				System.Threading.Thread t =  new System.Threading.Thread( delegate(object obj){
					tunnel.Stop();
					RunOnUiThread(delegate() {
						progress.Dismiss();
						ShowToast("Tunnel stoped");
					});
				});
				t.IsBackground = true;
				t.Priority = System.Threading.ThreadPriority.Normal;
				t.Start();
			}
			else{
				ProgressDialog progress = null;
				System.Threading.Thread t = new System.Threading.Thread(delegate(object obj){
					UpdateSettings();
					if(bluetoothDeviceName == ""){
						RunOnUiThread(delegate() {
							AlertDialog dialog = new AlertDialog.Builder(this).Create();
							dialog.SetTitle("Select Bluetooth Device");
							dialog.SetMessage("No Bluetooth Device has been selected. Please go to settings and select a Bluetooth device");
							dialog.SetButton("OK", delegate(object sen, DialogClickEventArgs eventArgs) {
							});
							dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
							dialog.Show();
						});
						return;
					}
					RunOnUiThread(delegate() {
						progress =	ProgressDialog.Show(this,"Connecting To Brick...","Opening connection...       ",true,false);
					});
					connection = new MonoBrick.Bluetooth<MonoBrick.NXT.Command, MonoBrick.NXT.Reply>(bluetoothDeviceName);
					//connection = new Loopback();
					if(tunnel.Start(tunnelSettings, connection)){
						RunOnUiThread(delegate() {
							progress.Dismiss();
							ShowToast("Tunnel started");
						});
					}
					else{
						RunOnUiThread(delegate() {
							progress.Dismiss();
							ShowToast("Failed to start tunnel");
						});
					}
				});
				t.IsBackground = true;
				t.Priority = System.Threading.ThreadPriority.Normal;
				t.Start();
			}
		}
 private void ButtonClickEvent(int numerek)
 {
     if (isMyTurn)
     {
         if (canvas[numerek] != '-')
         {
             AlertDialog ad = new AlertDialog.Builder(this).Create();
             ad.SetCancelable(false); // This blocks the 'BACK' button
             ad.SetMessage("Te pole jest ju¿ zajête!");
             ad.SetButton("OK", delegate { });
             ad.Show();
             return;
         }
         canvas[numerek] = mySign;
         byte[] buffbuff = System.Text.Encoding.ASCII.GetBytes(string.Format("{0};{1}", Convert.ToInt32(MessageTypes.Turn), new string(canvas)));
         pole[numerek].Text = Char.ToString(mySign);
         Sockets.client.GetStream().Write(buffbuff, 0, buffbuff.Length);
         isMyTurn = false;
     }
     else
     {
         AlertDialog ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false); // This blocks the 'BACK' button
         ad.SetMessage("Poczekaj na swoj¹ kolej!");
         ad.SetButton("OK", delegate {});
         ad.Show();
     }
 }
Exemple #16
0
 public void SyncEmptyError(Exception ex)
 {
     RunOnUiThread(() => {
         AlertDialog ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false);
         ad.SetTitle("Error");
         ad.SetMessage(ex.Message);
         ad.SetButton("OK", (sender, args) => ad.Dismiss());
         ad.Show();
     });
 }
 public override void OnBackPressed()
 {
     AlertDialog ad = new AlertDialog.Builder(this).Create();
     ad.SetCancelable(false); // This blocks the 'BACK' button
     ad.SetMessage("Czy chcesz wyjϾ z gry?");
     ad.SetButton("Nie", delegate { /*dialogLive = false;*/ });
     ad.SetButton2("Tak", delegate
     {
         Sockets.client.Close();
         Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
         //dialogLive = false;
     });
     //dialogLive = true;
     ad.Show();
 }
        public void SaveCode()
        {
            int getLastID = codeDatabase.SelectAll<Code>().Count + 1;

            LinearLayout layout = new LinearLayout(this);
            layout.Orientation = Orientation.Vertical;

            EditText inputFileName = new EditText(this);
            inputFileName.Hint = "FileName";
            layout.AddView (inputFileName);

            EditText inputAuthor = new EditText(this);
            inputAuthor.Hint = "Author";
            layout.AddView (inputAuthor);

            inputAuthor.Text = GlobalSupport.LastNameInput;
            AlertDialog ad = new AlertDialog.Builder (this).Create();
            ad.SetTitle ("Enter name");
            ad.SetMessage ("Please enter a file name and your name.");
            ad.SetView (layout);
            ad.SetButton ("Save",(senderAlert, args) => {
                //Save File
                GlobalSupport.LastNameInput = inputAuthor.Text;
                Code code = new Code();
                code.CodeString = txtCodeField.Text;
                code.Author = inputAuthor.Text;
                code.FileName = inputFileName.Text;
                code.Date = DateTime.Now;
                code.LevelName = GlobalSupport.GameLevel.Substring(0,GlobalSupport.GameLevel.LastIndexOf('.'));
                code.Language = GlobalSupport.GameLanguage;

                codeDatabase.Insert(code);
            });

            ad.SetButton2 ("Cancel", (senderAlert, args) => {
                // cancels (Do nothing)
            });

            ad.Show ();
        }
        private void ShowScorePopup(int score)
        {
            EditText input = new EditText(this);
            input.Text = GlobalSupport.LastNameInput;
            AlertDialog ad = new AlertDialog.Builder (this).Create();
            ad.SetTitle ("Enter name");
            ad.SetMessage ("You have passed the level with a score of " + score + "! Please enter your name.");
            ad.SetView (input);
            ad.SetButton ("Save",(senderAlert, args) => {
                //Save Highscore
                robot.SaveHighscore(score,input.Text);
                GlobalSupport.LastNameInput = input.Text;

            });

            ad.SetButton2 ("Cancel", (senderAlert, args) => {
                // cancels (Do nothing)
            });

            ad.Show ();
        }
 public void ShowMessage(string title, string message)
 {
     RunOnUiThread(() => {
         AlertDialog ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false);
         ad.SetTitle(title);
         ad.SetMessage(message);
         ad.SetButton("OK", (sender, args) => ad.Dismiss());
         ad.Show();
     });
 }
Exemple #21
0
 protected void ShowMessage(String title, String message)
 {
     AlertDialog error = new AlertDialog.Builder(this).Create();
     error.SetTitle(title);
     error.SetIcon(Android.Resource.Drawable.IcDialogAlert);
     error.SetMessage(message);
     error.SetButton("OK", (s, ev) => {});
     error.Show();
 }
Exemple #22
0
 public void SyncCompleted()
 {
     RunOnUiThread(() => {
         _lblTitle.Text = "Sync completed";
         AlertDialog ad = new AlertDialog.Builder(this).Create();
         ad.SetCancelable(false);
         ad.SetMessage("Sync has completed successfully.");
         ad.SetButton("OK", (sender, args) => {
             ad.Dismiss();
             Finish();
         });
         ad.Show();
     });
 }
			public override bool OnOptionsItemSelected (IMenuItem item)
			{
				switch (item.ItemId) {
					case Resource.Id.menuConnection:
						if(brickController.NXT.Connection.IsConnected){
							ProgressDialog progress = null;
							RunOnUiThread(delegate() {
								progress = ProgressDialog.Show(this,"Disconnecting From Brick...","Closing connection...       ");
							});
							System.Threading.Thread t =  new System.Threading.Thread( delegate(object obj){
								try{
									brickController.NXT.Connection.Close(); 
								}
								catch{
								
								}
								RunOnUiThread(delegate() {
									progress.Dismiss();
									ShowToast(this,"Disconnected from brick");
								});
							});
							t.IsBackground = true;
							t.Priority = System.Threading.ThreadPriority.Normal;
							t.Start();
						}
						else{
							ProgressDialog progress = null;
							System.Threading.Thread t = new System.Threading.Thread(delegate(object obj) {
								if(settings.DeviceName == ""){
									RunOnUiThread(delegate() {
										AlertDialog dialog = new AlertDialog.Builder(this).Create();
										dialog.SetTitle("Select Bluetooth Device");
										dialog.SetMessage("No Bluetooth Device has been selected. Please go to settings and select a Bluetooth device");
										dialog.SetButton("OK", delegate(object sen, DialogClickEventArgs eventArgs) {
										});
										dialog.SetIcon(Android.Resource.Drawable.IcDialogInfo);
										dialog.Show();
									});
									return;
								}
								RunOnUiThread(delegate() {
									progress =	ProgressDialog.Show(this,"Connecting To Brick...","Opening connection...       ",true,false);
								});
								try{
									if(settings.Type == BrickType.NXT){
									brickController.NXT = new MonoBrick.NXT.Brick<MonoBrick.NXT.Sensor, MonoBrick.NXT.Sensor, MonoBrick.NXT.Sensor, MonoBrick.NXT.Sensor>(
												//new MonoBrick.Loopback()
												new MonoBrick.Bluetooth<MonoBrick.NXT.Command,MonoBrick.NXT.Reply>(MonoBrick.Bluetooth<MonoBrick.NXT.Command,MonoBrick.NXT.Reply>.GetBondDevice(settings.DeviceName))
												);
									}	
								
									brickController.NXT.Connection.Open();
								}
								catch(Exception ex){
									RunOnUiThread(delegate() {
										progress.Dismiss();
										ShowToast(this,"Error connecting: " + ex.Message, ToastLength.Long);
									});
									return;
								}
								Dictionary<string,MonoBrick.NXT.Sensor> sensorDictionary = MonoBrick.NXT.Sensor.SensorDictionary;
								string[] sensorName = new string[]{settings.Sensor1, settings.Sensor2, settings.Sensor3, settings.Sensor4};
								MonoBrick.NXT.Sensor sensorType = new MonoBrick.NXT.NoSensor();
								try{
									SetSensor[] setSensor = new SetSensor[]{
										delegate(MonoBrick.NXT.Sensor sensor){brickController.NXT.Sensor1 = sensor; brickController.NXT.Sensor1.Initialize();},
										delegate(MonoBrick.NXT.Sensor sensor){brickController.NXT.Sensor2 = sensor; brickController.NXT.Sensor2.Initialize();},
										delegate(MonoBrick.NXT.Sensor sensor){brickController.NXT.Sensor3 = sensor; brickController.NXT.Sensor3.Initialize();},
										delegate(MonoBrick.NXT.Sensor sensor){brickController.NXT.Sensor4 = sensor; brickController.NXT.Sensor4.Initialize();},
									};
									//Check if sensors should be initialized with something other than none
									
									for(int i = 0; i < 4; i++){ 
										try{
											if(!sensorDictionary.TryGetValue(sensorName[i], out sensorType)){
												//could not load a value
												sensorName[i] = "None"; 
												sensorType = new MonoBrick.NXT.NoSensor();
											}
											RunOnUiThread(delegate() {
													progress.SetMessage("initialize sensor " + (i+1) + " as " + sensorName[i]);
											});
											setSensor[i](sensorType);
										}
										catch(MonoBrickException nxtEx){
											if(nxtEx is MonoBrick.NXT.BrickException){
												RunOnUiThread(delegate() {
													progress.SetMessage("Sensor " + (i+1) + " initialized as \"no-sensor\"");
												});
												sensorName[i] = "None";
												setSensor[i](new MonoBrick.NXT.Sensor(MonoBrick.NXT.SensorType.NoSensor,MonoBrick.NXT.SensorMode.Raw));
											}
											else{
												RunOnUiThread(delegate() {
													progress.Dismiss();
													ShowToast(this,"Failed to initialize sensors.\n" + nxtEx.Message);
													OnDisconnected();
												});
												brickController.NXT.Connection.Close();
												return;
											}
										}
									}
								}
								catch(MonoBrick.NXT.BrickException ex){
									RunOnUiThread(delegate() {
											progress.Dismiss();
											ShowToast(this,"Failed to initialize sensors.\n" + ex.Message);
									});
									brickController.NXT.Connection.Close();
									return;
								}
								RunOnUiThread(delegate() {
									progress.Dismiss();
									ShowToast(this,"Connected successfully to brick");
								});
							});
							t.IsBackground = true;
							t.Priority = System.Threading.ThreadPriority.Normal;
							t.Start();
						}
					break;
					case Resource.Id.menuSettings:
						StartActivity(new Intent(this,typeof(SettingsActivity)));
					break;
					case Resource.Id.menuRefresh:
						fileFragment.ReloadFileList();
					break;
					case Resource.Id.menuUpload:
						fileFragment.UploadFile();
					break;
					case Resource.Id.menuFormat:
						fileFragment.Format();
					break;
					
					default:
						return base.OnOptionsItemSelected (item);
			
				}
				return true;
			}