public SliderView(Context context, Slider slider, string path, ViewerScreen doc, RectF frame, float scale) : base(context) { _Slider = slider; _BasePath = path; _DocView = doc; _scale = scale; /*_Slider.PlayStopClick = true; * _Slider.Autoplay = true; * _Slider.Delay = 3000; * _Slider.TransitionDuration = 500;*/ //_Slider.Swipe = true; //autoplay if (_Slider.Autoplay) { _AutoplayTimer = new Timer(_Slider.Delay); _AutoplayTimer.Elapsed += (sender, e) => { _DocView.RunOnUiThread(() => { if (_isRunning) { this.NextState(); } }); }; } //gesture if (_Slider.Swipe || _Slider.PlayStopClick) { _gestureDetector = new GestureDetector(this.Context, new GestureListener(this)); } //scorrimento temporizzato _changeHandler = new Handler(Looper.MainLooper); _changeRunnable = new Runnable(() => { try { this.NextState(); } finally { _changeHandler.PostDelayed(_changeRunnable, _Slider.Delay); } }); LoadContent(); }
private void SetupMapIfNeeded() { if (Reachability.InternetConnectionStatus() == NetworkStatus.NotReachable) { return; } if (_googleMap == null) { _googleMap = _mapView.Map; if (_googleMap != null) { var client = new WebClient(); client.DownloadStringCompleted += (sender, e) => { if (e.Error != null) { return; } try { _xDoc = XDocument.Parse(e.Result); _docView.RunOnUiThread(() => LoadPlacemarks()); //RunOnUiThread(() => HideLoadingOverlay()); } catch (Exception ex) { Console.WriteLine(ex.Message); } }; client.DownloadStringAsync(new Uri(_mappa.Url)); ShowLoadingOverlay(); //_GoogleMap.SetInfoWindowAdapter(new CustomInfoWindowAdapter(this)); } } }
private void LoadContent() { //_DocView.PagingScrollView.ScrollEnabled = false; string fileName = ""; float ratio = _Scroller.Zoom > 0 ? _Scroller.Zoom : 1; if (_Scroller.TipoSfondo == SfondoType.PDF) { fileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(_Scroller.Sfondo), System.IO.Path.GetFileNameWithoutExtension(_Scroller.Sfondo) + ".png"); } else { fileName = _Scroller.Sfondo; } string imgPath = ImageUtility.GetBitmapPath(System.IO.Path.Combine(_BasePath, fileName), _DocView); //string imgPath = System.IO.Path.Combine(_BasePath, fileName); string name = System.IO.Path.GetFileNameWithoutExtension(imgPath).ToUpper(); //if(imgPath.ToUpper().Contains("_AND")) if (name.EndsWith("_AND")) { ratio = _Scroller.ZoomAndroid > 0 ? _Scroller.ZoomAndroid : 1;; } // get the size and mime type of the image System.Drawing.Size imgSize = ImageUtility.GetBitmapSize(imgPath); float imageHeight = imgSize.Height; float imageWidth = imgSize.Width; if (_Scroller.SfondoSize[0] > 0) { float xScale = _Scroller.SfondoSize[0] / imgSize.Width; float yScale = _Scroller.SfondoSize[1] / imgSize.Height; float imgScale = System.Math.Min(xScale, yScale); imageHeight *= imgScale; imageWidth *= imgScale; } ratio *= _scale; _ContentSize = new System.Drawing.SizeF(imageWidth * ratio, imageHeight * ratio); _contentView = new RelativeLayout(this.Context); _contentView.LayoutParameters = new RelativeLayout.LayoutParams((int)(imageWidth * ratio), (int)(imageHeight * ratio)); //_contentView.SetBackgroundColor(Android.Graphics.Color.Red); _DocView.RunOnUiThread(() => { if (_contentView != null) { _backgroundView = new ImgView(this.Context, imgPath); _backgroundView.LayoutParameters = new ViewGroup.LayoutParams((int)(imageWidth * ratio), (int)(imageHeight * ratio)); _contentView.AddView(_backgroundView, 0); } }); _objViews = Objects.CreateObjects(_Scroller.Oggetti, _BasePath, _DocView, ratio, this); foreach (View view in _objViews.Values) { _contentView.AddView(view); view.BringToFront(); } this.AddView(_contentView); _contentView.RequestFocus(); _contentX = _Scroller.ContentX * ratio; _contentY = _Scroller.ContentY * ratio; this.ScrollBy((int)_contentX, (int)_contentY); }
private void SetObjects() { int page = Page; var articolo = _documento.Articoli[page]; string artPath = System.IO.Path.Combine(_documento.Path, articolo.Path); float ratio = 1; float ratioW = MSize.X / articolo.Width; float ratioH = MSize.Y / articolo.Height; if (ratioW < ratioH) { ratio = ratioW; } else { ratio = ratioH; } if (_articleView == null) { _articleView = new RelativeLayout(MContext); this.AddView(_articleView, new RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)); //_articleView.SetClipToPadding(false); _articleView.BringToFront(); } Task.Factory .StartNew(() => { if (Looper.MyLooper() == null) { Looper.Prepare(); } _oggetti = Objects.CreateObjects(articolo.Oggetti, artPath, _docView, ratio); /*if(page % 10 == 0) * GC.Collect();*/ Log.Info(TAG, "Creazione oggetti pag " + page); }) .ContinueWith(task => { try { var oggetti = _oggetti.Values.ToArray(); for (int i = 0; i < oggetti.Length; i++) { View view = oggetti[i]; _docView.RunOnUiThread(() => { if (_articleView != null) { _articleView.AddView(view); mBusyIndicator.BringToFront(); } }); } oggetti = null; Log.Info(TAG, "Aggiunta oggetti pag " + page); Loaded = true; if (OnScreen) { _docView.RunOnUiThread(() => { Autoplay(); }); } } catch (Exception ex) { Utils.WriteLog(TAG + " -> SetObjects", ex.Message); } }); }