Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            int poss = positionImg;

            if (container == null)
            {
                return(null);
            }

            LinearLayout l = (LinearLayout)inflater.Inflate(Resource.Layout.mf, container, false);


            //string p = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "photo1.jpg");

            //Bitmap bitmap = BitmapFactory.DecodeFile(p);
            //ResizeImage("p");


            int pos = this.Arguments.GetInt("pos");

            LinearLayout root = (LinearLayout)l.FindViewById(Resource.Id.root);
            ImageView    img  = (ImageView)l.FindViewById(Resource.Id.content);

            // seul la premiere image a une taille normale. les autres sont à l'échele 0.7
            if (pos != MainActivity.FIRST_PAGE)
            {
                ViewHelper.SetScaleX(root, MainActivity.SMALL_SCALE);
                ViewHelper.SetScaleY(root, MainActivity.SMALL_SCALE);
            }
            else
            {
                ViewHelper.SetScaleX(root, MainActivity.BIG_SCALE);
                ViewHelper.SetScaleY(root, MainActivity.BIG_SCALE);
            }

            img.Click += img_Click;


            int resourceId = (int)typeof(Resource.Drawable).GetField("photo" + pos).GetVa‌​lue(null);

            img.SetImageResource(resourceId);

            float scale    = this.Arguments.GetFloat("scale");
            bool  isBlured = this.Arguments.GetBoolean("IsBlured");

            if (isBlured)
            {
                ViewHelper.SetAlpha(root, MyPagerAdapter.getMinAlpha());
                ViewHelper.SetRotationY(root, MyPagerAdapter.getMinDegree());
            }
            return(l);
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            pager         = FindViewById <ViewPager>(Resource.Id.myviewpager);
            adapter       = new MyPagerAdapter(this, this.SupportFragmentManager);
            pager.Adapter = adapter;
            pager.SetOnPageChangeListener(adapter);

            pager.SetCurrentItem(FIRST_PAGE, true);

            // nombre d'images chargées hors de l'écran
            pager.OffscreenPageLimit = 5;

            // recupération de l'orientation du téléphone
            var surfaceOrientation = WindowManager.DefaultDisplay.Rotation;

            if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180)
            {
                // règle l'espacement entre deux images et l'angle en mode portrait
                int i = (int)(Convert.ToInt32(GetString(Resource.String.pagermargin)));
                pager.PageMargin = Convert.ToInt32(GetString(Resource.String.pagermargin));
                float f = (float)Convert.ToDouble(GetString(Resource.String.anglePortrait));
                MyPagerAdapter.setminDegree(f);
            }
            else
            {
                // règle l'espacement entre deux images et l'angle en mode paysage
                int i = (int)(Convert.ToInt32(GetString(Resource.String.pagermargin)));
                pager.PageMargin = (int)(Convert.ToInt32(GetString(Resource.String.pagermargin)) * 2.5);
                float f = (float)Convert.ToDouble(GetString(Resource.String.angleLandscape));
                MyPagerAdapter.setminDegree(f);
            }
            //https://developer.xamarin.com/api/member/Android.Views.View.BringToFront()/
        }