public void OnViewRemoved(BrushDrawingView brushDrawingView)
        {
            try
            {
                if (AddedViews.Count > 0)
                {
                    var item = AddedViews.LastOrDefault();
                    if (item != null)
                    {
                        AddedViews.Remove(item);
                        if (!(item.GetType() == typeof(BrushDrawingView)))
                        {
                            ParentView.RemoveView(item);
                        }
                        RedoViews.Add(item);
                    }
                }

                if (MOnNiceArtEditorListener != null)
                {
                    MOnNiceArtEditorListener?.OnRemoveViewListener(ViewType.BrushDrawing, AddedViews.Count);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
 public NiceArtEditor(Builder builder, ContentResolver resolver)
 {
     try
     {
         Context               = builder.context;
         ParentView            = builder.parentView;
         ImageView             = builder.imageView;
         DeleteView            = builder.deleteView;
         BrushDrawingView      = builder.brushDrawingView;
         IsTextPinchZoomable   = builder.isTextPinchZoomable;
         MDefaultTextTypeface  = builder.textTypeface;
         MDefaultEmojiTypeface = builder.emojiTypeface;
         MLayoutInflater       = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
         BrushDrawingView.SetBrushViewChangeListener(this);
         AddedViews = new List <View>();
         RedoViews  = new List <View>();
         Resolver   = resolver;
         //wael
         //ParentView.DrawingCacheEnabled = true;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 /// <summary>
 /// Building a NiceArtEditor which requires a Context and NiceArtEditorView
 /// which we have setup in our xml layout
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="NiceArtEditorView">NiceArtEditorView</param>
 public Builder(Context context, NiceArtEditorView NiceArtEditorView, ContentResolver resolver)
 {
     try
     {
         this.context     = context;
         parentView       = NiceArtEditorView;
         imageView        = NiceArtEditorView.GetSource();
         brushDrawingView = NiceArtEditorView.GetBrushDrawingView();
         resolverContent  = resolver;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 /// <summary>
 /// Building a NiceArtEditor which requires a Context and NiceArtEditorView
 /// which we have setup in our xml layout
 /// </summary>
 /// <param name="context">context</param>
 /// <param name="NiceArtEditorView">NiceArtEditorView</param>
 public Builder(Context context, NiceArtEditorView NiceArtEditorView, ContentResolver resolver)
 {
     try
     {
         this.context     = context;
         parentView       = NiceArtEditorView;
         imageView        = NiceArtEditorView.GetSource();
         brushDrawingView = NiceArtEditorView.GetBrushDrawingView();
         resolverContent  = resolver;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 public void OnViewAdd(BrushDrawingView brushDrawingView)
 {
     try
     {
         if (RedoViews.Count > 0)
         {
             var item = RedoViews.LastOrDefault();
             if (item != null)
             {
                 RedoViews.Remove(item);
             }
         }
         AddedViews.Add(brushDrawingView);
         MOnNiceArtEditorListener?.OnAddViewListener(ViewType.BrushDrawing, AddedViews.Count);
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 public void OnViewAdd(BrushDrawingView brushDrawingView)
 {
     try
     {
         if (RedoViews.Count > 0)
         {
             var item = RedoViews.LastOrDefault();
             if (item != null)
             {
                 RedoViews.Remove(item);
             }
         }
         AddedViews.Add(brushDrawingView);
         MOnNiceArtEditorListener?.OnAddViewListener(ViewType.BrushDrawing, AddedViews.Count);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }