Example #1
0
        public RegisterCommonMethods(ProfilePage context)
        {
            this.context = context;

            context.CheckUsername.Click += CheckUsername_Click;
            context.Images.Click        += Images_Click;

            context.Description.Touch += Description_Touch;

            context.UseLocationSwitch.Click   += UseLocationSwitch_Click;
            context.LocationShareAll.Click    += LocationShareAll_Click;
            context.LocationShareLike.Click   += LocationShareLike_Click;
            context.LocationShareMatch.Click  += LocationShareMatch_Click;
            context.LocationShareFriend.Click += LocationShareFriend_Click;
            context.LocationShareNone.Click   += LocationShareNone_Click;

            context.DistanceShareAll.Click    += DistanceShareAll_Click;
            context.DistanceShareLike.Click   += DistanceShareLike_Click;
            context.DistanceShareMatch.Click  += DistanceShareMatch_Click;
            context.DistanceShareFriend.Click += DistanceShareFriend_Click;
            context.DistanceShareNone.Click   += DistanceShareNone_Click;

            context.ImageEditorCancel.Click += ImageEditorCancel_Click;
            context.ImageEditorOK.Click     += ImageEditorOK_Click;

            /*client = new WebClient();
             * client.UploadProgressChanged += Client_UploadProgressChanged;
             * client.UploadFileCompleted += Client_UploadFileCompleted;
             * client.Headers.Add("Content-Type", "image/jpeg");*/
        }
        private void Initialize(Context context)
        {
            this.context = (ProfilePage)context;

            drawOrder = new List <int>();
            //Width is 0 even in OnMeasure, even though I set the attribute to match_parent in the layout file.
        }
Example #3
0
 private void Initialize(Context context)
 {
     this.context = (ProfilePage)context;
 }
 public void Initialize(Context context)
 {
     this.context = (ProfilePage)context;
 }
        protected override async void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            try
            {
                //context.c.CW("OnDraw canvas + " + canvas + "scaleFactor " + scaleFactor + " Width " + Width + " Height " + Height + " bmWidth " + bm.Width + " bmHeight " + bm.Height + " intrinsicWidth " + intrinsicWidth + " intrinsicHeight " + intrinsicHeight);

                canvas.Save();
                canvas.Translate(-(scaleFactor - 1) * canvas.Width / 2, -(scaleFactor - 1) * canvas.Height / 2);
                canvas.Scale(scaleFactor, scaleFactor);

                Rect  frameToDraw = new Rect(0, 0, bm.Width, bm.Height);
                RectF whereToDraw = new RectF((float)Width / 2 - intrinsicWidth / 2 + xDist, (float)Height / 2 - intrinsicHeight / 2 + yDist, (float)Width / 2 - intrinsicWidth / 2 + xDist + intrinsicWidth, (float)Height / 2 - intrinsicHeight / 2 + yDist + intrinsicHeight);

                //context.c.CW("Where to x " + ((float)Width / 2 - intrinsicWidth / 2 + xDist) + " y " + ((float)Height / 2 - intrinsicHeight / 2 + yDist) + " right " + ((float)Width / 2 - intrinsicWidth / 2 + xDist + intrinsicWidth) + " bottom " + ((float)Height / 2 - intrinsicHeight / 2 + yDist + intrinsicHeight) + " BorderY " + (context.ImageEditorFrameBorder.GetY() - context.ImageEditor.GetY()) + " BorderH " + context.ImageEditorFrameBorder.Height + " scaleFactor " + scaleFactor);

                Paint paint = new Paint
                {
                    AntiAlias = true
                };
                canvas.DrawBitmap(bm, frameToDraw, whereToDraw, paint);
                canvas.Restore();

                //context.c.CW("OnDraw scaleFactor " + scaleFactor + " Width " + Width + " Height " + Height + " bmWidth " + bm.Width + " bmHeight " + bm.Height + " intrinsicWidth " + intrinsicWidth + " intrinsicHeight " + intrinsicHeight);
            }
            catch (Exception ex)
            {
                //Java.Lang.RuntimeException: Canvas: trying to draw too large(127844352bytes) bitmap.
                if (ex is Java.Lang.RuntimeException)
                {
                    context.c.Log("OnDraw bitmap too large");
                    if (bm is null)                     //bm may be null now, but it was okay up until canvas.DrawBitmap();
                    {
                        context.c.Log("Bitmap is null, ProfilePage.bm: " + ProfilePage.bm);
                        bm = await ProfilePage.GetBitmap(context);

                        if (bm is null)                         //should not happen, because the file was loaded successfully before
                        {
                            context.rc.CloseEditor();           //error is displayed in the function
                            return;
                        }
                    }

                    //will be halved at each error until the image is of manageable size. Hope that there are no other RuntimeException types here, but just in that case, we will exit if width falls below 1000;

                    ProfilePage.bmWidth  /= 2;
                    ProfilePage.bmHeight /= 2;

                    if (ProfilePage.bmWidth < 1000 && ProfilePage.bmHeight < 1000)
                    {
                        context.c.Log("New dimensions under threshold: " + ProfilePage.bmWidth + " x " + ProfilePage.bmHeight);
                        context.rc.CloseEditor();
                        await context.c.ErrorAlert(context.res.GetString(Resource.String.OtherBitmapError).Replace("[error]", ex.Message));

                        context.c.ReportErrorSilent("OnDraw error " + ex.Message + " " + ex.StackTrace);
                        return;
                    }

                    context.c.Log("Scaling bitmap to half: " + ProfilePage.bmWidth + " x " + ProfilePage.bmHeight);
                    SetContent(Bitmap.CreateScaledBitmap(bm, ProfilePage.bmWidth, ProfilePage.bmHeight, false));
                }
                else
                {
                    context.rc.CloseEditor();
                    await context.c.ErrorAlert(context.res.GetString(Resource.String.OtherBitmapError).Replace("[error]", ex.Message));

                    context.c.ReportErrorSilent("OnDraw error " + ex.Message + " " + ex.StackTrace);
                }
            }
        }
 public FrameBorder(Context context, IAttributeSet attrs, int defStyle) :
     base(context, attrs, defStyle)
 {
     this.context = (ProfilePage)context;
 }
 public FrameBorder(Context context, IAttributeSet attrs) :
     base(context, attrs)
 {
     this.context = (ProfilePage)context;
 }