Пример #1
0
        public void Init(Context context, IAttributeSet attrs)
        {
            try
            {
                //Setup image attributes
                MImgSource    = new FilterImageView(context);
                MImgSource.Id = ImgSrcId;
                MImgSource.SetAdjustViewBounds(true);
                LayoutParams imgSrcParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                imgSrcParam.AddRule(LayoutRules.CenterInParent, ImgSrcId);
                if (attrs != null)
                {
                    //TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.NiceArtEditorView);
                    //Drawable imgSrcDrawable = a.GetDrawable(Resource.Styleable.NiceArtEditorView_photo_src);
                    //if (imgSrcDrawable != null)
                    //{
                    //    MImgSource.SetImageDrawable(imgSrcDrawable);
                    //}
                }

                //Setup brush view
                MBrushDrawingView            = new BrushDrawingView(context);
                MBrushDrawingView.Visibility = ViewStates.Gone;
                MBrushDrawingView.Id         = BrushSrcId;

                //Align brush to the size of image view
                LayoutParams brushParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                brushParam.AddRule(LayoutRules.CenterInParent, ImgSrcId);
                brushParam.AddRule(LayoutRules.AlignTop, ImgSrcId);
                brushParam.AddRule(LayoutRules.AlignBottom, ImgSrcId);

                //Setup GLSurface attributes
                MImageFilterView = new ImageFilterView(context)
                {
                    Id         = GlFilterId,
                    Visibility = ViewStates.Gone
                };

                //Align brush to the size of image view
                LayoutParams imgFilterParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                imgFilterParam.AddRule(LayoutRules.CenterInParent, ImgSrcId);
                imgFilterParam.AddRule(LayoutRules.AlignTop, ImgSrcId);
                imgFilterParam.AddRule(LayoutRules.AlignBottom, ImgSrcId);

                OnBitmapLoaded(MImgSource.GetBitmap());

                //Add image source
                AddView(MImgSource, imgSrcParam);

                //Add Gl FilterView
                AddView(MImageFilterView, imgFilterParam);

                //Add brush view
                AddView(MBrushDrawingView, brushParam);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }