public static void Measure (Activity context) { Resources resources = context.Resources; ScreenWidth = resources.DisplayMetrics.WidthPixels; RealSize = new Android.Graphics.Point (); context.Window.WindowManager.DefaultDisplay.GetRealSize (RealSize); ScreenHeight = resources.DisplayMetrics.HeightPixels; int navBarId = resources.GetIdentifier("navigation_bar_height", "dimen", "android"); int statusbarId = resources.GetIdentifier("status_bar_height", "dimen", "android"); NavigationBarHeight = resources.GetDimensionPixelSize(navBarId); StatusBarHeight = resources.GetDimensionPixelSize(statusbarId); TrueScreenHeight = ScreenHeight - NavigationBarHeight - StatusBarHeight; Density = resources.DisplayMetrics.Density; // memory const string ActivityService = global::Android.Content.Context.ActivityService; ActivityManager manager = (ActivityManager)context.GetSystemService(ActivityService); ActivityManager.MemoryInfo outInfo = new ActivityManager.MemoryInfo(); manager.GetMemoryInfo(outInfo); Memory = outInfo.TotalMem; RuntimeMemory = Java.Lang.Runtime.GetRuntime().MaxMemory(); }
/// <summary> /// OverrayするViewの描写範囲設定とフォントサイズを設定し描写 /// </summary> public void OverrayViewReSet() { // カスタムViewにアダプターをセット(フォントの大きさ変更のため) customMemoAdapter = new CustomMemoAdapter(this, customViewItem, getFontSize()); listView.Adapter = customMemoAdapter; // 描写位置決定のため画面サイズを取得 var psize = new Android.Graphics.Point(); WindowManager.DefaultDisplay.GetSize(psize); // 重ね合わせる画面を指定 param = new WindowManagerLayoutParams( (int)(psize.X * 0.8), (int)(psize.Y * 0.9), WindowManagerTypes.ApplicationOverlay, // タッチ操作ありのため WindowManagerFlags.Fullscreen, //フルスクリーン表示 Android.Graphics.Format.Translucent //半透明 ) { Gravity = GravityFlags.Top }; // Viewを画面上に重ね合わせする WindowManager.AddView(view, param); // オーバーレイViewの存在フラグを立てる _isViewPresenceCheck = true; }
private void updateVideoSize() { int videoWidth = 960; int videoHeight = 720; if (Tello.picMode == 1)//pic mode is also aspect ratio. { videoWidth = 1280; } float videoProportion = (float)videoWidth / (float)videoHeight; var size = new Android.Graphics.Point(); WindowManager.DefaultDisplay.GetSize(size); int screenWidth = size.X; int screenHeight = size.Y; float screenProportion = (float)screenWidth / (float)screenHeight; var surfaceView = FindViewById <SurfaceView>(Resource.Id.surfaceView); var lp = surfaceView.LayoutParameters; if (videoProportion > screenProportion) { lp.Width = screenWidth; lp.Height = (int)((float)screenWidth / videoProportion); } else { lp.Width = (int)(videoProportion * (float)screenHeight); lp.Height = screenHeight; } surfaceView.LayoutParameters = lp; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); PrepareActionBar(); var id = Intent.Extras.GetInt(KEY_ID); var newsService = new NewsService(); var news = newsService.GetNewsById(id); var newsTitle = FindViewById <TextView>(Resource.Id.newsTitle); var newsBody = FindViewById <TextView>(Resource.Id.newsBody); var newsImage = FindViewById <ImageView>(Resource.Id.newsImage); var display = WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); var imageURL = string.Concat(ValuesService.ImagesBaseURL, news.ImageName); Picasso.With(ApplicationContext) .Load(imageURL) .Resize(point.X, 0) .Into(newsImage); newsTitle.Text = news.Title; newsBody.Text = news.Body; }
public void SurfaceCreated(ISurfaceHolder holder) { try { mCamera.SetPreviewDisplay(holder); } catch (Exception e) { Console.WriteLine(e.Message); } FrameLayout.LayoutParams lp = this.LayoutParameters as FrameLayout.LayoutParams; Display display = mContext.GetSystemService(Context.WindowService).JavaCast <IWindowManager>().DefaultDisplay; Android.Graphics.Point rect = new Android.Graphics.Point(); display.GetRealSize(rect); display.GetRealSize(rect); lp.Gravity = GravityFlags.CenterVertical; lp.Width = rect.X; // required width lp.Height = (int)(rect.X * (9 / 16f)); // required height this.LayoutParameters = lp; }
internal int IndexForPoint(Android.Graphics.Point p) { var line = Layout.GetLineForVertical(p.Y); var offset = Layout.GetOffsetForHorizontal(line, p.X); return(offset); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental", "FastRenderers_Experimental"); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Instance = this; CrossCurrentActivity.Current.Init(this, savedInstanceState); Display display = WindowManager.DefaultDisplay; Android.Graphics.Point size = new Android.Graphics.Point(); display.GetSize(size); width = size.X; height = size.Y; Android.Gms.Ads.MobileAds.Initialize(ApplicationContext, Ads.AdConstant.AppId); LoadApplication(new App()); }
public static void ApplyWindowChanges( IntPtr window, int clientWidth, int clientHeight, bool wantsFullscreen, string screenDeviceName, ref string resultDeviceName ) { object[] args = { window, clientWidth, clientHeight, wantsFullscreen, screenDeviceName, resultDeviceName }; if (MainActivity.SDL2DCS_Fullscreen) { // Real display size Android.Graphics.Point size = new Android.Graphics.Point(); MainActivity.SDL2DCS_Instance.WindowManager.DefaultDisplay.GetRealSize(size); args[1] = size.X; args[2] = size.Y; GraphicsDeviceManager gdm = Game?.Services.GetService(typeof(IGraphicsDeviceManager)) as GraphicsDeviceManager; if (gdm != null) { gdm.PreferredBackBufferWidth = size.X; gdm.PreferredBackBufferHeight = size.Y; } } fna_ApplyWindowChanges.DynamicInvoke(args); resultDeviceName = (string)args[5]; }
public ColorPickerView(Context context, int minWidth, int minHeight) : base(context) { SelectedColor = Color.Black.ToAndroid(); SetMinimumHeight(minHeight); SetMinimumWidth(minWidth); imageViewPallete = new ImageView(context); imageViewPallete.DrawingCacheEnabled = true; imageViewPallete.Background = new Droid.Graphics.Drawables.GradientDrawable(Droid.Graphics.Drawables.GradientDrawable.Orientation.LeftRight, COLORS); imageViewPallete.Touch += (object sender, TouchEventArgs e) => { if (e.Event.Action == MotionEventActions.Down || e.Event.Action == MotionEventActions.Move) { currentPoint = new Droid.Graphics.Point((int)e.Event.GetX(), (int)e.Event.GetY()); previewColor = GetCurrentColor(imageViewPallete.GetDrawingCache(false), (int)e.Event.GetX(), (int)e.Event.GetY()); } if (e.Event.Action == MotionEventActions.Up) { SelectedColor = previewColor; } }; imageViewSelectedColor = new ImageView(context); colorPointer = new ColorPointer(context); AddView(imageViewPallete); AddView(imageViewSelectedColor); AddView(colorPointer); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.Dic_MusicMainLayout); Display display = WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); MusicRecyclerView = FindViewById <RecyclerView>(Resource.Id.MusicDicRecyclerView); MainLayoutManager = new GridLayoutManager(this, point.X / 200); MusicRecyclerView.SetLayoutManager(MainLayoutManager); SearchResetButton = FindViewById <ImageButton>(Resource.Id.MusicSearchResetButton); SearchText = FindViewById <EditText>(Resource.Id.MusicSearchText); SearchText.TextChanged += SearchText_TextChanged; FindViewById <LinearLayout>(Resource.Id.MusicDicLineUpSelector_Name).Click += LineUpSelector_Click; FindViewById <LinearLayout>(Resource.Id.MusicDicLineUpSelector_Update).Click += LineUpSelector_Click; FindViewById <LinearLayout>(Resource.Id.MusicDicMusicTypeSelector_Vocal).Click += MusicTypeSelector_Click; FindViewById <LinearLayout>(Resource.Id.MusicDicMusicTypeSelector_Dance).Click += MusicTypeSelector_Click; FindViewById <LinearLayout>(Resource.Id.MusicDicMusicTypeSelector_Session).Click += MusicTypeSelector_Click; InitLoad(); ListMusic(""); }
/// <param name="context"> used to get system services </param> /// <returns> screenWidth in pixels </returns> public static int getScreenWidth(Context context) { IWindowManager wm = context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); Point size = new Point(); wm.DefaultDisplay.GetSize(size); return(size.X); }
public override AssetFileDescriptor OpenDocumentThumbnail(string documentId, Android.Graphics.Point sizeHint, CancellationSignal signal) { Log.Verbose(TAG, "openDocumentThumbnail"); File file = GetFileForDocId(documentId); var pfd = ParcelFileDescriptor.Open(file, ParcelFileMode.ReadOnly); return(new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UnknownLength)); }
// public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Intent _intent = new Intent(Settings.ActionUsageAccessSettings); StartActivity(_intent); // ViewがすでにあるならRemoveする if (_isOverlayViewPresenceCheck) { _windowManager.RemoveView(_overlayView); _isOverlayViewPresenceCheck = false; } // UsageStatsManager usageStatsManager1 = (UsageStatsManager)_context.GetSystemService(USAGE_STATS_SERVICE); currentYear1 = DateTime.Now.Year; // Calendar.GetInstance().Get(Calendar.Year); queryUsageStats1 = usageStatsManager1.QueryUsageStats(UsageStatsInterval.Yearly, currentYear1 - 1, currentYear1); queryUsageStats2 = usageStatsManager1.QueryEvents(currentYear1 - 1, currentYear1); // _windowManager = _context.GetSystemService(WindowService).JavaCast <IWindowManager>(); var layoutInflater = LayoutInflater.From(_context); _overlayView = layoutInflater.Inflate(Resource.Layout.overlay_test_layout, null); // 画面サイズを取得 var psize = new Android.Graphics.Point(); _windowManager.DefaultDisplay.GetSize(psize); // オーバーレイ範囲指定 & オーバーレイ設定 var param = new WindowManagerLayoutParams( (int)(psize.X * 0.9), (int)(psize.Y * 0.4), // なんかいい感じに範囲を指定 WindowManagerTypes.SystemAlert, WindowManagerFlags.Fullscreen, // なんかいい感じに属性を追加 Android.Graphics.Format.Translucent // 半透明とか ) { Gravity = GravityFlags.Top }; // OverlayViewのクリックイベントを登録 var closeButton = _overlayView.FindViewById <Button>(Resource.Id.closeButton); closeButton.Click += CloseButton_Click; var testButton = _overlayView.FindViewById <Button>(Resource.Id.testButton); testButton.Click += (sender, args) => TestMethod(); // Viewを画面上に重ね合わせする _windowManager.AddView(_overlayView, param); _isOverlayViewPresenceCheck = true; return(StartCommandResult.NotSticky); }
public static Rectangle GetSize() { Display display = (Forms.Context as Activity).WindowManager.DefaultDisplay; var size = new Android.Graphics.Point(); display.GetSize(size); int width = (int)Forms.Context.FromPixels(size.X); int height = (int)Forms.Context.FromPixels(size.Y); return new Rectangle(0, 0, width, height); }
public void UpdatePoint(Droid.Graphics.Point p) { if (p == null) return; if (currentPoint == null) currentPoint = nextPoint; nextPoint = p; }
private void Init() { if (sps.Length == 14) decoderWidth = 1280; else decoderWidth = 960; MediaFormat videoFormat = MediaFormat.CreateVideoFormat("video/avc", decoderWidth, decoderHeight); videoFormat.SetByteBuffer("csd-0", ByteBuffer.Wrap(sps)); videoFormat.SetByteBuffer("csd-1", ByteBuffer.Wrap(pps)); string str = videoFormat.GetString("mime"); try { var cdx = MediaCodec.CreateDecoderByType(str); cdx.Configure(videoFormat, Holder.Surface, (MediaCrypto)null, 0); cdx.SetVideoScalingMode(VideoScalingMode.ScaleToFit); cdx.Start(); codec = cdx; } catch (Exception ex) { //handle } bConfigured = true; //set surface aspect ratio MainActivity.getActivity().RunOnUiThread(() => { float videoProportion = (float)decoderWidth / (float)decoderHeight; var size = new Android.Graphics.Point(); MainActivity.getActivity().WindowManager.DefaultDisplay.GetSize(size); int screenWidth = size.X; int screenHeight = size.Y; float screenProportion = (float)screenWidth / (float)screenHeight; var lp = this.LayoutParameters; if (videoProportion > screenProportion) { lp.Width = screenWidth; lp.Height = (int)((float)screenWidth / videoProportion); } else { lp.Width = (int)(videoProportion * (float)screenHeight); lp.Height = screenHeight; } this.LayoutParameters = lp; }); }
public static Rectangle GetSize() { var display = (Forms.Context as Activity).WindowManager.DefaultDisplay; var size = new Point(); display.GetSize(size); var width = (int)Forms.Context.FromPixels(size.X); var height = (int)Forms.Context.FromPixels(size.Y); return(new Rectangle(0, 0, width, height)); }
public PhotoEditing() { screenResolution = Utils.GetScreenResolution(Activity); graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = true; graphics.PreferredBackBufferWidth = screenResolution.X; graphics.PreferredBackBufferHeight = screenResolution.Y; graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft; Content.RootDirectory = "Content"; }
public void PlatformToSystemException(float x, float y) { #if __IOS__ var platform = new CoreGraphics.CGPoint(x, y); Assert.Throws <ArgumentOutOfRangeException>(() => platform.ToSystemPoint()); #elif __ANDROID__ var platform = new Android.Graphics.Point((int)x, (int)y); Assert.Throws <ArgumentOutOfRangeException>(() => platform.ToSystemPoint()); #elif WINDOWS_UWP var platform = new Windows.Foundation.Point(x, y); Assert.Throws <ArgumentOutOfRangeException>(() => platform.ToSystemPoint()); #endif }
// This gets called when the drawing surface is ready protected override void OnLoad(EventArgs e) { base.OnLoad(e); Android.Graphics.Point sc_size = new Android.Graphics.Point(); Display.GetSize(sc_size); this.view_width = sc_size.X; this.view_height = sc_size.Y; SetupGL(); // Run the render loop Run(); }
public void PlatformToSystem() { #if __IOS__ var platform = new CoreGraphics.CGPoint(x, y); #elif __ANDROID__ var platform = new Android.Graphics.Point(x, y); #else var platform = new Windows.Foundation.Point(x, y); #endif var system = platform.ToSystemPoint(); Assert.Equal(x, system.X); Assert.Equal(y, system.Y); }
public bool IsPortreitScreenOreientation() { var windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); var sizePoint = new Point(); windowManager.DefaultDisplay.GetSize(sizePoint); if (sizePoint.Y > sizePoint.X) { return(true); } return(false); }
public void UpdatePoint(Android.Graphics.Point p) { if (p == null) { return; } if (currentPoint == null) { currentPoint = nextPoint; } nextPoint = p; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Android.Graphics.Point displaySize = new Android.Graphics.Point(); this.WindowManager.DefaultDisplay.GetSize(displaySize); string content_dir = Intent.GetStringExtra("CONTENT_DIR"); int duration = Intent.GetIntExtra("duration", 500) * 60; float difficulty = Intent.GetFloatExtra("difficulty", 1.0f); //Normalized [0, 1] var g = new TrafficGame(displaySize.X, displaySize.Y, content_dir, duration, difficulty); SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { PokeDexHolder poke = holder as PokeDexHolder; poke.TxtName.Text = this._pokemons[position].Name; //poke.TxtId.Text = this._pokemons[position].Id.ToString(); var display = (this._context as Android.Support.V7.App.AppCompatActivity).WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); Picasso.Get() .Load(this._pokemons[position].UrlImagePrincipal) .Error(this._context.GetDrawable(Resource.Drawable.whypoke)) .Resize(point.X, 0) .Into(poke.ImgPrincipal); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.menu_editor_activity); Android.Graphics.Point point = new Android.Graphics.Point(); this.WindowManager.DefaultDisplay.GetSize(point); foodList = new List <Util.BabyFood>(); recycler = FindViewById <RecyclerView>(Resource.Id.MenuListHolder); var adapter = new MenuEditorAdapter(foodList); var manager_ = new LinearLayoutManager(this); recycler.HasFixedSize = false; recycler.SetLayoutManager(manager_); recycler.LayoutParameters.Height = (int)(point.Y * 0.66667); recycler.SetAdapter(adapter); addButton = FindViewById <Button>(Resource.Id.addElement); addButton.Click += (sender, e) => { foodList.Add(new Util.BabyFood(Util.BabyFood.Kind.EVENING, DateTime.Now, "", "", 0)); adapter.NotifyDataSetChanged(); }; var itemTouchHelperCallback = new MenuEditorItemTouchHelper(); itemTouchHelperCallback.onSwipe += (sender, e) => { var archive = new KeyValuePair <int, Util.BabyFood>(((RecyclerView.ViewHolder)sender).AdapterPosition, foodList[((RecyclerView.ViewHolder)sender).AdapterPosition]); foodList.RemoveAt(((RecyclerView.ViewHolder)sender).AdapterPosition); adapter.NotifyItemRemoved(((RecyclerView.ViewHolder)sender).AdapterPosition); Snackbar.Make(addButton, "qfewf", Snackbar.LengthLong).SetAction("元に戻す", (v) => { Android.Util.Log.Debug("afwefwaef", "asfweageaorighnpeogrerogjnerpigkm"); foodList.Insert(archive.Key, archive.Value); adapter.NotifyItemInserted(archive.Key); }).Show(); }; var itemTouchHelper = new ItemTouchHelper(itemTouchHelperCallback); itemTouchHelper.AttachToRecyclerView(recycler); // Create your application here }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); PrepareActionBar(); var id = Intent.Extras.GetInt(Key_Id); if (savedInstanceState == null) { var noticiaServicio = new NoticiaServicio(); _noticia = noticiaServicio.GetNoticiaById(id); } else { _noticia = new Noticia(); _noticia.Id = savedInstanceState.GetInt(Key_Id); _noticia.Cuerpo = savedInstanceState.GetString(KEY_BODY); _noticia.NombreImagen = savedInstanceState.GetString(KEY_IMAGE_NAME); _noticia.Titulo = savedInstanceState.GetString(KEY_TITLE); } var noticiaTitulo = FindViewById <TextView>(Resource.Id.tituloNoticia); var noticiaCuerpo = FindViewById <TextView>(Resource.Id.textView2); var noticiaImagen = FindViewById <ImageView>(Resource.Id.imagenNoticia); var display = WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); var imageUrl = string.Concat(ValuesService.ImageBaseUrl, _noticia.NombreImagen); Picasso.With(ApplicationContext) .Load(imageUrl) .Resize(point.X, 0) .Into(noticiaImagen); noticiaTitulo.Text = _noticia.Titulo; noticiaCuerpo.Text = _noticia.Cuerpo; }
public override View GetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = new ImageView(ContextProp); convertView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); // set size initially to fill whole screen. otherwise because of no height PdfPageGenerationTask will attempt to load all pages IWindowManager windowManager = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>(); Display disp = windowManager?.DefaultDisplay; if (disp != null) { Android.Graphics.Point screenSize = new Android.Graphics.Point(); disp.GetSize(screenSize); Android.Graphics.Bitmap pdfPageStartBitmap = Android.Graphics.Bitmap.CreateBitmap((int)(screenSize.X - HorizontalMarginsForView), (int)(screenSize.Y - VerticalMarginsForView), Android.Graphics.Bitmap.Config.Argb4444); ((ImageView)convertView).SetImageDrawable(new BitmapDrawable(ContextProp.Resources, pdfPageStartBitmap)); } } // on zoom do not cancel previous tasks so zooming is visible and performed on all visible views // on scrolling lets just focus on newest task bool isZooming = false; int tasksHistoryRelevant = 1; if (parent is PdfListView) { isZooming = ((PdfListView)parent).ScalingStatus != PdfListView.ScalingStatusValues.Idle; tasksHistoryRelevant = ((PdfListView)parent).VisibleItemCount; } // on scrolling hide reused views untill shown again so they do not show old content if (!isZooming) { ((ImageView)convertView).Visibility = ViewStates.Invisible; } PdfPageGenerationTask newPdfViewTask = new PdfPageGenerationTask((ImageView)convertView, this); newPdfViewTask.TaskIndex = position; SetPageGenerationTaskMngr(newPdfViewTask, tasksHistoryRelevant); newPdfViewTask.Execute(_url, position.ToString(), _zoom.ToString()); return(convertView); }
private static Android.Views.View ConvertFormsToNative(Xamarin.Forms.View view, Display display) { Android.Graphics.Point size = new Android.Graphics.Point(); display.GetRealSize(size); var rectSize = new Rectangle(0, 0, size.X / 1.5, size.Y / 1.5); var renderer = Platform.CreateRendererWithContext(view, Android.App.Application.Context); var nativeView = renderer.View; renderer.Tracker.UpdateLayout(); var layoutParams = new ViewGroup.LayoutParams((int)rectSize.Width, (int)rectSize.Height); nativeView.LayoutParameters = layoutParams; view.Layout(rectSize); nativeView.Layout(0, 0, (int)view.WidthRequest, (int)view.HeightRequest); return(nativeView); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); PrepareActionBar(); var id = Intent.Extras.GetInt(KEY_ID); if (savedInstanceState == null) { var newsService = new NewsService(); _news = newsService.GetNewsById(id); } else { _news = new News(); _news.Id = savedInstanceState.GetInt(KEY_ID); _news.Body = savedInstanceState.GetString(KEY_BODY); _news.ImageName = savedInstanceState.GetString(KEY_IMAGE_NAME); _news.Title = savedInstanceState.GetString(KEY_TITLE); } var newsTitle = FindViewById <TextView>(Resource.Id.newsTitle); var newsBody = FindViewById <TextView>(Resource.Id.newsBody); var newsImage = FindViewById <ImageView>(Resource.Id.newsImage); var display = WindowManager.DefaultDisplay; Android.Graphics.Point point = new Android.Graphics.Point(); display.GetSize(point); var imageURL = string.Concat(ValuesService.ImagesBaseURL, _news.ImageName); Picasso.With(ApplicationContext) .Load(imageURL) .Resize(point.X, 0) .Into(newsImage); newsTitle.Text = _news.Title; newsBody.Text = _news.Body; }
internal Position GetMapCenterLocation() { //METHOD 1 FORM CameraPosition var centerPosition = (Control as global::Android.Gms.Maps.MapView).Map.CameraPosition.Target; //METHOD 2 CALCULATE PROJECTION var visibleRegion = (Control as global::Android.Gms.Maps.MapView).Map.Projection.VisibleRegion; var x = (Control as global::Android.Gms.Maps.MapView).Map.Projection.ToScreenLocation( visibleRegion.FarRight); var y = (Control as global::Android.Gms.Maps.MapView).Map.Projection.ToScreenLocation( visibleRegion.NearLeft); var centerPoint = new Android.Graphics.Point(x.X / 2, y.Y / 2); var centerFromPoint = (Control as global::Android.Gms.Maps.MapView).Map.Projection.FromScreenLocation( centerPoint); //BOTH RETURNS THE SAME RESULT return new Position (centerPosition.Latitude, centerPosition.Longitude); }
internal Position GetMapCenterLocation() { //METHOD 1 FORM CameraPosition var centerPosition = (Control as global::Android.Gms.Maps.MapView).Map.CameraPosition.Target; //METHOD 2 CALCULATE PROJECTION var visibleRegion = (Control as global::Android.Gms.Maps.MapView).Map.Projection.VisibleRegion; var x = (Control as global::Android.Gms.Maps.MapView).Map.Projection.ToScreenLocation( visibleRegion.FarRight); var y = (Control as global::Android.Gms.Maps.MapView).Map.Projection.ToScreenLocation( visibleRegion.NearLeft); var centerPoint = new Android.Graphics.Point(x.X / 2, y.Y / 2); var centerFromPoint = (Control as global::Android.Gms.Maps.MapView).Map.Projection.FromScreenLocation( centerPoint); //BOTH RETURNS THE SAME RESULT return(new Position(centerPosition.Latitude, centerPosition.Longitude)); }
private static Size GetSplashScreenSize(Activity activity) { var physicalDisplaySize = new Android.Graphics.Point(); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { // The windowBackground takes the size of the screen (only when using Theme.AppCompat.*) activity.WindowManager.DefaultDisplay.GetRealSize(physicalDisplaySize); } else { // The windowBackground takes the size of the screen minus the bottom navigation bar activity.WindowManager.DefaultDisplay.GetSize(physicalDisplaySize); } return(new Size( ViewHelper.PhysicalToLogicalPixels(physicalDisplaySize.X), ViewHelper.PhysicalToLogicalPixels(physicalDisplaySize.Y) )); }
public void UpdateUI() { if (CurrentRun != null && !CurrentRun.Active) { mRunLocations = mRunManager.GetLocationsForRun(CurrentRun.Id); if (mRunLocations.Count >0) { mStartedTextView.Text = CurrentRun.StartDate.ToLocalTime().ToString(); mLatitudeTextView.Text = mRunLocations[0].Latitude.ToString(); mLongitudeTextView.Text = mRunLocations[0].Longitude.ToString(); mAltitudeTextView.Text = mRunLocations[0].Altitude.ToString(); int durationSeconds = (int)Math.Ceiling((mRunLocations[mRunLocations.Count -1].Time - CurrentRun.StartDate).TotalSeconds); mDurationTextView.Text = Run.FormatDuration(durationSeconds); // var location = new LatLng(mRunLocations[mRunLocations.Count -1].Latitude, mRunLocations[mRunLocations.Count -1].Longitude); // var cu = CameraUpdateFactory.NewLatLngZoom (location, 20); // mGoogleMap.MoveCamera (cu); DrawRunTrack(false); } else { var toast = Toast.MakeText(Activity, Resource.String.empty_run_message, ToastLength.Long); Display display = Activity.WindowManager.DefaultDisplay; var size = new Android.Graphics.Point(); display.GetSize(size); toast.SetGravity(GravityFlags.Top, 0, size.Y/6); toast.Show(); } if (mRunManager.IsTrackingRun()) { mStartButton.Enabled = false; mStartButton.Visibility = ViewStates.Invisible; mStopButton.Enabled = false; mStopButton.Visibility = ViewStates.Invisible; } else { mStartButton.Enabled = true; mStopButton.Enabled = false; } } else { bool started = mRunManager.IsTrackingRun(); if (CurrentRun != null) { mRunLocations = mRunManager.GetLocationsForRun(CurrentRun.Id); mStartedTextView.Text = CurrentRun.StartDate.ToLocalTime().ToString(); } int durationSeconds = 0; if (CurrentRun != null && LastLocation != null) { DateTime lastLocTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(LastLocation.Time); durationSeconds = CurrentRun.GetDurationSeconds(lastLocTime); mLatitudeTextView.Text = LastLocation.Latitude.ToString(); mLongitudeTextView.Text = LastLocation.Longitude.ToString(); mAltitudeTextView.Text = LastLocation.Altitude.ToString(); mDurationTextView.Text = Run.FormatDuration(durationSeconds); CurrentRun.Duration = durationSeconds; mRunManager.UpdateItem<Run>(CurrentRun); // var location = new LatLng(LastLocation.Latitude, LastLocation.Longitude); // var cu = CameraUpdateFactory.NewLatLngZoom (location, 20); // mGoogleMap.MoveCamera (cu); DrawRunTrack(true); } mStartButton.Enabled = !started; mStopButton.Enabled = started; } }
public Boolean OnTouch(View v, MotionEvent ev) { if (_box != null) { v.SetLayerType(LayerType.Software, null); switch (ev.Action) { case MotionEventActions.Down: if (_touchState != TouchState.Result) { _touchState = TouchState.None; } int x = (int)ev.GetX(); int y = (int)ev.GetY(); Android.Graphics.Point cursor = new Android.Graphics.Point(x, y); Android.Graphics.Point leftBot = new Android.Graphics.Point((int)(_box.MidX - _box.Width / 2), (int)(_box.MidY + _box.Height / 2)); Android.Graphics.Point rightBot = new Android.Graphics.Point((int)(_box.MidX + _box.Width / 2), (int)(_box.MidY + _box.Height / 2)); Android.Graphics.Point rightTop = new Android.Graphics.Point((int)(_box.MidX + _box.Width / 2), (int)(_box.MidY - _box.Height / 2)); double botLine = BitmapHelpers.LineToCursorDistance(cursor, leftBot, rightBot); double rightLine = BitmapHelpers.LineToCursorDistance(cursor, rightTop, rightBot); //Choose an binarized image and start OCR if (_touchState == TouchState.Result) { if (x <= screenWidth / 2 && y <= screenHeight / 3) { threshhold = threshholds[0]; } else if (x > screenWidth / 2 && y <= screenHeight / 3) { threshhold = threshholds[1]; } else if (x <= screenWidth / 2 && y <= screenHeight * 2 / 3) { threshhold = threshholds[2]; } else if (x > screenWidth / 2 && y <= screenHeight * 2 / 3) { threshhold = threshholds[3]; } else if (x <= screenWidth / 2 && y <= screenHeight) { threshhold = threshholds[4]; } else if (x > screenWidth / 2 && y <= screenHeight) { threshhold = threshholds[5]; } _surfaceBox.SetOnTouchListener(null); if (!_processDialog.IsShowing) { _processDialog.SetMessage("Waiting for character recognition..."); _processDialog.Show(); } PerformResult(); } //Move box over camera else if (botLine <= lineDistance && rightLine <= lineDistance) { _touchState = TouchState.Mixed; } else if (botLine <= lineDistance) { _touchState = TouchState.Horizontal; } else if (rightLine <= lineDistance) { _touchState = TouchState.Vertical; } else if (x >= _box.MidX - _box.Width / 2 && x <= _box.MidX + _box.Width / 2 && y >= _box.MidY - _box.Height / 2 && y <= _box.MidY + _box.Height / 2) { _touchState = TouchState.Moving; } touchStartX = x; touchStartY = y; break; case MotionEventActions.Move: if (_touchState == TouchState.Moving) { _box.MidX += ev.GetX() - touchStartX; _box.MidY += ev.GetY() - touchStartY; } else if (_touchState == TouchState.Horizontal) { _box.Height += ev.GetY() - touchStartY; } else if (_touchState == TouchState.Vertical) { _box.Width += ev.GetX() - touchStartX; } else if (_touchState == TouchState.Mixed) { _box.Width += ev.GetX() - touchStartX; _box.Height += ev.GetY() - touchStartY; } touchStartX = ev.GetX(); touchStartY = ev.GetY(); break; case MotionEventActions.Up: if (_touchState == TouchState.Moving) { if (hasAutoFocus && focusReady) { _camera.AutoFocus(this); } } _touchState = TouchState.None; break; } } return false; }