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 LoadContent() { if (_Slider.Stati == null || _Slider.Stati.Count == 0) { return; } _StatiView = new List <RelativeLayout>(); _StatiViewObj = new List <Dictionary <string, RelativeLayout> >(); int count = 0; foreach (StatoSlider stato in _Slider.Stati) { RelativeLayout statoView = new RelativeLayout(_DocView); statoView.LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent); string fileName = ""; if (stato.TipoSfondo == SfondoType.PDF) { fileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(stato.Sfondo), System.IO.Path.GetFileNameWithoutExtension(stato.Sfondo) + ".png"); } else { fileName = stato.Sfondo; } string imgPath = ImageUtility.GetBitmapPath(System.IO.Path.Combine(_BasePath, fileName), _DocView); _DocView.RunOnUiThread(() => { ImgView imgView = new ImgView(Context, imgPath); imgView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); //imgView.LayoutParameters = new ViewGroup.LayoutParams(200, 100); statoView.AddView(imgView, 0); }); Dictionary <string, RelativeLayout> objViews = Objects.CreateObjects(stato.Oggetti, _BasePath, _DocView, _scale); foreach (var video in stato.VideoViews) { if (objViews.ContainsKey(video)) { var view = objViews[video]; for (int i = 0; i < view.ChildCount; i++) { if (view.GetChildAt(i).GetType() == typeof(VideoView)) { VideoView av = view.GetChildAt(i) as VideoView; if (_Slider.Autoplay) { av.OnStart += () => { this.Stop(); _stoppedForContent = true; }; av.OnFinish += () => { this.Start(true); av.Stop(); }; } //impedisco al video di partire subito perché lo faccio partire io quando entra la slide av.Stop(); //av.StopAutoplay = false; break; } } } } _DocView.RunOnUiThread(() => { foreach (View view in objViews.Values) { statoView.AddView(view); view.BringToFront(); } this.AddView(statoView); }); _StatiView.Add(statoView); _StatiViewObj.Add(objViews); count++; } //se è in autoplay la funzione viene chiamata quando entro nella pagina, altrimenti la chiamo subito if (!_Slider.Autoplay) { this.Initialize(); } }