Esempio n. 1
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if (requestCode == CAPTURE_PHOTO)
     {
         if (resultCode == Result.Ok)
         {
             //display saved image
             Bitmap poiImage = POIData.GetImageFile(_poi.Id.Value);
             _poiImageView.SetImageBitmap(poiImage);
             if (poiImage != null)
             {
                 _poiImageView.Visibility = ViewStates.Visible;
                 poiImage.Dispose();
             }
         }
         else
         {
             //Let the user know that the photo was cancelled
             Toast toast = Toast.MakeText(this, "未擷取任何影像!", ToastLength.Short);
             toast.Show();
         }
     }
     else
     {
         base.OnActivityResult(requestCode, resultCode, data);
     }
 }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            SetContentView(Resource.Layout.POIDetail);
            _locMgr = GetSystemService(Context.LocationService) as LocationManager;

            _nameEditText        = FindViewById <EditText> (Resource.Id.nameEditText);
            _descrEditText       = FindViewById <EditText> (Resource.Id.descrEditText);
            _addrEditText        = FindViewById <EditText> (Resource.Id.addrEditText);
            _latEditText         = FindViewById <EditText> (Resource.Id.latEditText);
            _longEditText        = FindViewById <EditText> (Resource.Id.longEditText);
            _poiImageView        = FindViewById <ImageView> (Resource.Id.poiImageView);
            _locationImageButton = FindViewById <ImageButton> (Resource.Id.locationImageButton);
            _mapImageButton      = FindViewById <ImageButton> (Resource.Id.mapImageButton);
            _photoImageButton    = FindViewById <ImageButton> (Resource.Id.photoImageButton);

            _locationImageButton.Click += GetLocationClicked;
            _addrEditText.FocusChange  += GetLocationFromAddress;
            _mapImageButton.Click      += MapClicked;
            _photoImageButton.Click    += NewPhotoClicked;

            if (Intent.HasExtra("poiId"))
            {
                int poiId = Intent.GetIntExtra("poiId", -1);
                _poi = POIData.Service.GetPOI(poiId);
                Bitmap poiImage = POIData.GetImageFile(_poi.Id.Value);
                _poiImageView.SetImageBitmap(poiImage);
                if (poiImage != null)
                {
                    _poiImageView.Visibility = ViewStates.Visible;
                    poiImage.Dispose();
                }
                //Console.WriteLine ("_poiImageView's visibility is " + _poiImageView.Visibility.ToString());
            }
            else
            {
                //Tom: 使用者按了新增鍵
                _poi = new PointOfInterest();
                //Console.WriteLine ("in else");
                this.Title = "新增景點";

                AlertDialog.Builder alertConfirm = new AlertDialog.Builder(this);
                alertConfirm.SetCancelable(false);
                alertConfirm.SetPositiveButton("是", GetLocationClicked);
                alertConfirm.SetNegativeButton("否", delegate {});
                alertConfirm.SetTitle("自動定位?");
                alertConfirm.SetMessage(String.Format("若欲以自動定位目前所在位置及地址,請按[是],或按[否]手動輸入地址。"));
                alertConfirm.Show();
            }

            UpdateUI();
        }
Esempio n. 3
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = _context.LayoutInflater.Inflate(Resource.Layout.POIListItem, null);
            }

            PointOfInterest poi = POIData.Service.POIs [position];

            //load image into image view
            Bitmap poiImage = POIData.GetImageFile(poi.Id.Value);

            view.FindViewById <ImageView> (Resource.Id.poiImageView).SetImageBitmap(poiImage);
            if (poiImage != null)
            {
                poiImage.Dispose();
            }
            view.FindViewById <TextView> (Resource.Id.nameTextView).Text = poi.Name;

            if (string.IsNullOrEmpty(poi.Address))
            {
                view.FindViewById <TextView> (Resource.Id.addrTextView).Visibility = ViewStates.Gone;
            }
            else
            {
                view.FindViewById <TextView> (Resource.Id.addrTextView).Text = poi.Address;
            }

            if ((CurrentLocation != null) && (poi.Latitude.HasValue) && (poi.Longitude.HasValue))
            {
                Location poiLocation = new Location("");
                poiLocation.Latitude  = poi.Latitude.Value;
                poiLocation.Longitude = poi.Longitude.Value;
                float distance = CurrentLocation.DistanceTo(poiLocation) / 1000;                  //原單位為公尺;若乘以 0.000621371F表以英哩顯示;
                view.FindViewById <TextView> (Resource.Id.distanceTextView).Text =
                    String.Format("{0:0,0.00} 公里", distance);
            }
            else
            {
                view.FindViewById <TextView> (Resource.Id.distanceTextView).Text = "??";
            }

            return(view);
        }