private async void comboBoxRooms_DropDownClosed(object sender, object e) { if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1) { progressRing.Visibility = Visibility.Visible; progressRing.IsActive = true; comboBox.SelectedIndex = -1; roomStart = databaseHelper.FindRoomByID(int.Parse((comboBox1.SelectedItem as ComboBoxItem).Name)); roomFinish = databaseHelper.FindRoomByID(int.Parse((comboBox2.SelectedItem as ComboBoxItem).Name)); object[] images = await drawer.DrawPath(roomStart, roomFinish); if (images.Length == 1) { scrollViewer.Visibility = Visibility.Visible; textBlock3.Visibility = Visibility.Collapsed; scrollViewer2.Visibility = Visibility.Collapsed; image.Source = images[0] as WriteableBitmap; float scale = (float)(GridContent.ActualWidth / 640); scrollViewer.ChangeView(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset, scale); scrollViewer.Height = GridContent.Height; } else { scrollViewer.Visibility = Visibility.Visible; scrollViewer2.Visibility = Visibility.Visible; image.Source = images[0] as WriteableBitmap; image2.Source = images[1] as WriteableBitmap; float scale = (float)(GridContent.ActualWidth / 640); scrollViewer.ChangeView(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset, scale); scrollViewer2.ChangeView(scrollViewer2.HorizontalOffset, scrollViewer2.VerticalOffset, scale); scrollViewer.Height = 260; int floorDifference = roomStart.Floor - roomFinish.Floor; if (floorDifference == -1) { textBlock3.Text = "↓ Piętro wyżej ↓"; } else if (floorDifference < 0) { textBlock3.Text = $"↓ {-floorDifference} piętra wyżej ↓"; } else if (floorDifference == 1) { textBlock3.Text = "↓ Piętro niżej ↓"; } else { textBlock3.Text = $"↓ {floorDifference} piętra niżej ↓"; } textBlock3.Visibility = Visibility.Visible; } progressRing.IsActive = false; progressRing.Visibility = Visibility.Collapsed; } }
private void spinnerRooms_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { using (Spinner spinnerFinish = FindViewById <Spinner>(Resource.Id.spinnerFinish)) { using (Spinner spinnerStart = FindViewById <Spinner>(Resource.Id.spinnerStart)) { if (spinnerFinish.SelectedItemPosition != 0 && spinnerStart.SelectedItemPosition != 0) { using (Spinner roomID = FindViewById <Spinner>(Resource.Id.spinnerRoomID)) { Room start = databaseHelper.FindRoomByID(int.Parse(roomID.GetItemAtPosition(spinnerStart.SelectedItemPosition).ToString())); Room finish = databaseHelper.FindRoomByID(int.Parse(roomID.GetItemAtPosition(spinnerFinish.SelectedItemPosition).ToString())); object[] maps = drawer.DrawPath(start, finish); if (maps.Length == 1) { using (ImageView image = FindViewById <ImageView>(Resource.Id.imageView1)) { image.Visibility = ViewStates.Visible; image.SetImageResource(Color.Transparent); image.SetImageBitmap(maps[0] as Bitmap); } using (ImageView image = FindViewById <ImageView>(Resource.Id.imageView2)) { image.Visibility = ViewStates.Gone; } using (TextView text = FindViewById <TextView>(Resource.Id.textView6)) { text.Visibility = ViewStates.Gone; } } else { using (ImageView image = FindViewById <ImageView>(Resource.Id.imageView1)) { image.Visibility = ViewStates.Visible; image.SetImageResource(Color.Transparent); image.SetImageBitmap(maps[0] as Bitmap); } using (ImageView image = FindViewById <ImageView>(Resource.Id.imageView2)) { image.Visibility = ViewStates.Visible; image.SetImageResource(Color.Transparent); image.SetImageBitmap(maps[1] as Bitmap); } using (TextView text = FindViewById <TextView>(Resource.Id.textView6)) { text.Visibility = ViewStates.Visible; int floorDifference = start.Floor - finish.Floor; if (floorDifference == -1) { text.Text = "↓ Piętro wyżej ↓"; } else if (floorDifference < 0) { text.Text = $"↓ {-floorDifference} piętra wyżej ↓"; } else if (floorDifference == 1) { text.Text = "↓ Piętro niżej ↓"; } else { text.Text = $"↓ {floorDifference} piętra niżej ↓"; } } } } } } } }