private void _handleButtonSaveClicked()
        {
            var    bmp     = Bitmap.CreateBitmap(dstBmp);
            Canvas canvas  = new Canvas(bmp);
            var    logoBmp = BitmapFactory.DecodeResource(Resources, Resource.Drawable.logo_horizon5);

            var compassView = new CompassView(ApplicationContext, null);

            compassView.Initialize(Context, false, new System.Drawing.Size(_photodata.PictureWidth, _photodata.PictureHeight));
            compassView.Layout(0, 0, _photodata.PictureWidth, _photodata.PictureHeight);
            compassView.InitializeViewDrawer(new System.Drawing.Size(dstBmp.Width, dstBmp.Height), new System.Drawing.Size(_photodata.PictureWidth, _photodata.PictureHeight));
            compassView.SetPoiViewItemList(Context.PoiData);
            compassView.SetElevationProfile(Context.ElevationProfileData);
            compassView.Draw(canvas);


            var logoWidth = Convert.ToInt32(0.2 * canvas.Width);

            canvas.DrawBitmap(logoBmp, new Rect(0, 0, logoBmp.Width, logoBmp.Height), new Rect(canvas.Width - logoWidth, canvas.Height - logoWidth * 2 / 3, canvas.Width, canvas.Height), null);
            var photoname = "export" +
                            "" + _photodata.PhotoFileName;
            var filename = System.IO.Path.Combine(ImageSaverUtils.GetPublicPhotosFileFolder(), photoname);

            if (File.Exists(filename))
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this).SetCancelable(false);
                alert.SetPositiveButton(Resources.GetText(Resource.String.Common_Yes), (senderAlert, args) =>
                {
                    File.Delete(filename);
                    var stream = new FileStream(filename, FileMode.CreateNew);
                    bmp.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                    Android.Media.MediaScannerConnection.ScanFile(Android.App.Application.Context, new string[] { filename }, null, null);
                    PopupHelper.Toast(this, Resource.String.PhotoShow_PhotoSaved);
                });
                alert.SetNegativeButton(Resources.GetText(Resource.String.Common_No), (senderAlert, args) => { });
                alert.SetMessage(Resources.GetText(Resource.String.PhotoShow_OverwriteQuestion));
                var answer = alert.Show();
            }
            else
            {
                var stream = new FileStream(filename, FileMode.CreateNew);
                bmp.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
                Android.Media.MediaScannerConnection.ScanFile(Android.App.Application.Context, new string[] { filename }, null, null);
                PopupHelper.Toast(this, Resource.String.PhotoShow_PhotoSaved);
            }
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Window.RequestFeature(WindowFeatures.NoTitle);

            SetContentView(sensorviz_xamarin.Resource.Layout.Main);

            //add camera texture view
            textureView = FindViewById <TextureView>(sensorviz_xamarin.Resource.Id.textureView1);
            textureView.SurfaceTextureListener = this;

            //add proximity layout
            LinearLayout lightLayout = FindViewById <LinearLayout>(sensorviz_xamarin.Resource.Id.light);

            light = new LightView(lightLayout);

            //add proximity layout
            LinearLayout proximityLayout = FindViewById <LinearLayout>(sensorviz_xamarin.Resource.Id.proximity);

            proximity = new ProximityView(proximityLayout);

            //add compass layout
            LinearLayout compassLayout = FindViewById <LinearLayout>(sensorviz_xamarin.Resource.Id.compass);

            compass = new CompassView(compassLayout);

            //add accelerometer layout
            LinearLayout accelerometerLayout = FindViewById <LinearLayout>(sensorviz_xamarin.Resource.Id.accelerometer);

            accelerometer = new AccelerometerView(accelerometerLayout);

            //get Sensor manager
            sensorService = (SensorManager)GetSystemService(Context.SensorService);

            proximitySensor = sensorService.GetDefaultSensor(SensorType.Proximity);
            lightSensor     = sensorService.GetDefaultSensor(SensorType.Light);         // Get a Light Sensor
            ori             = sensorService.GetDefaultSensor(SensorType.Orientation);   //Get orientation
            acc             = sensorService.GetDefaultSensor(SensorType.Accelerometer); //Get orientation

            // Register a listeners
            sensorService.RegisterListener(proximity, proximitySensor, Android.Hardware.SensorDelay.Normal);
            sensorService.RegisterListener(light, lightSensor, Android.Hardware.SensorDelay.Game);
            sensorService.RegisterListener(compass, ori, SensorDelay.Fastest);
            sensorService.RegisterListener(accelerometer, acc, SensorDelay.Fastest);
        }
Exemple #3
0
        public CompassRenderer(GlassMvxService service) : base(service)
        {
            try
            {
                _onChangedListener = new OnChangedListener(this);

                var inflater = LayoutInflater.From(service);
                _layout = (FrameLayout)inflater.Inflate(Resource.Layout.compass, null);
                _layout.SetWillNotDraw(false);

                _compassView = (CompassView)_layout.FindViewById(Resource.Id.compass);
                _tipsContainer = (RelativeLayout)_layout.FindViewById(Resource.Id.tips_container);

                _tipsView = (TextView) _layout.FindViewById(Resource.Id.tips_view);
            }
            catch (Exception e)
            {
                Log.Debug("Exception", e.Message);
                Log.Debug("Exception", e.InnerException.Message);
            }
        }
        private void _handleButtonShareClicked()
        {
            var    bmp     = Bitmap.CreateBitmap(dstBmp);
            Canvas canvas  = new Canvas(bmp);
            var    logoBmp = BitmapFactory.DecodeResource(Resources, Resource.Drawable.logo_horizon5);

            var compassView = new CompassView(ApplicationContext, null);

            compassView.Initialize(Context, false, new System.Drawing.Size(_photodata.PictureWidth, _photodata.PictureHeight));
            compassView.Layout(0, 0, _photodata.PictureWidth, _photodata.PictureHeight);
            compassView.InitializeViewDrawer(new System.Drawing.Size(dstBmp.Width, dstBmp.Height), new System.Drawing.Size(_photodata.PictureWidth, _photodata.PictureHeight));
            compassView.SetPoiViewItemList(Context.PoiData);
            compassView.SetElevationProfile(Context.ElevationProfileData);
            compassView.Draw(canvas);

            var logoWidth = Convert.ToInt32(0.2 * canvas.Width);

            canvas.DrawBitmap(logoBmp, new Rect(0, 0, logoBmp.Width, logoBmp.Height), new Rect(canvas.Width - logoWidth, canvas.Height - logoWidth * 2 / 3, canvas.Width, canvas.Height), null);
            //canvas.DrawBitmap(logoBmp, canvas.Width - logoBmp.Width - 40, canvas.Height - logoBmp.Height - 40, null);

            var filename = System.IO.Path.Combine(ImageSaverUtils.GetPhotosFileFolder(), "tmpHorizon.jpg");

            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            var stream = new FileStream(filename, FileMode.CreateNew);

            bmp.Compress(Bitmap.CompressFormat.Jpeg, 100, stream);
            Android.Media.MediaScannerConnection.ScanFile(Android.App.Application.Context, new string[] { filename }, null, null);

            var result = Share.RequestAsync(new ShareFileRequest
            {
                Title = Title,
                File  = new ShareFile(filename)
            });
        }
Exemple #5
0
        protected void InitializeBaseActivityUI()
        {
            AppContextLiveData.Instance.SetLocale(this);

            _gestureDetector = new GestureDetector(this);

            _textViewNotification = FindViewById <TextView>(Resource.Id.textViewNotification);

            _textViewStatusLine          = FindViewById <TextView>(Resource.Id.textViewStatusLine);
            _textViewStatusLine.Selected = true;

            _distanceSeekBar                  = FindViewById <DistanceSeekBar>(Resource.Id.seekBarDistance);
            _distanceSeekBar.Progress         = Context.Settings.MaxDistance;
            _distanceSeekBar.ProgressChanged += OnMaxDistanceChanged;

            _poiInfo = FindViewById <LinearLayout>(Resource.Id.mainActivityPoiInfo);
            _poiInfo.SetOnClickListener(this);
            _poiInfo.Visibility = ViewStates.Gone;

            _seekBars            = FindViewById <LinearLayout>(Resource.Id.mainActivitySeekBars);
            _seekBars.Visibility = ViewStates.Visible;

            _displayTerrainButton = FindViewById <ImageButton>(Resource.Id.buttonDisplayTerrain);
            _displayTerrainButton.SetOnClickListener(this);
            _displayTerrainButton.SetImageResource(Context.Settings.ShowElevationProfile ? Resource.Drawable.ic_terrain : Resource.Drawable.ic_terrain_off);

            var _selectCategoryButton = FindViewById <ImageButton>(Resource.Id.buttonCategorySelect);

            _selectCategoryButton.SetOnClickListener(this);

            FindViewById <Button>(Resource.Id.buttonWiki).SetOnClickListener(this);
            FindViewById <Button>(Resource.Id.buttonMap).SetOnClickListener(this);
            FindViewById <ImageView>(Resource.Id.buttonFavourite).SetOnClickListener(this);
            _compassView = FindViewById <CompassView>(Resource.Id.compassView1);
            _compassView.LayoutChange += OnLayoutChanged;
        }