protected override void OnCreate(Bundle savedInstanceState)
        {
            LayoutInflater layoutInflater = LayoutInflater.From(this);

            view      = layoutInflater.Inflate(Resource.Layout.editorSavePopup, null);
            popipView = view.FindViewById <LinearLayout>(Resource.Id.editorPopUp);

            var deviceDensity = (int)this.Resources.DisplayMetrics.Density;


            popipView.Visibility = ViewStates.Invisible;
            var SaveButton   = view.FindViewById <Button>(Resource.Id.Savebutton);
            var CancelButton = view.FindViewById <Button>(Resource.Id.Cancelbutton);

            entry               = view.FindViewById <EditText>(Resource.Id.editTextDialogUserInput);
            SaveButton.Click   += SaveButton_Click;
            CancelButton.Click += CancelButton_Click;

            imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
            if (IsTabletDevice(this))
            {
                height = 150;
            }
            else
            {
                height = 200 * deviceDensity;
            }
            var Params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent - 100, height, GravityFlags.CenterHorizontal);

            Params.SetMargins(0, 300, 0, 0);
            popipView.LayoutParameters = Params;
            FrameLayout mainLayout = new FrameLayout(this);
            var         tParams    = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent, GravityFlags.Fill);

            mainLayout.SetBackgroundColor(Color.Transparent);
            editor = new SfImageEditor(this);

            DelayActionAsync(500, LoadStreamToEditor);
            editor.ImageSaving += Editor_ImageSaving;
            base.OnCreate(savedInstanceState);

            editor.SetToolbarItemVisibility("save", false);
            HeaderToolbarItem item1 = new HeaderToolbarItem();

            item1.Text = "Save";
            editor.SetBackgroundColor(Color.White);
            editor.ToolbarSettings.ToolbarItems.Add(item1);

            editor.ToolbarSettings.ToolbarItemSelected += (sender, e) =>
            {
                if (e.ToolbarItem is HeaderToolbarItem)
                {
                    var text = (e.ToolbarItem as HeaderToolbarItem).Text;
                    if (text == "Save")
                    {
                        if (Serialization.SelectedItem.Name == "CreateNew")
                        {
                            overView.Visibility  = ViewStates.Visible;
                            popipView.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            editor.Save();
                        }
                    }
                }
            };

            overView = new FrameLayout(this);
            var overViewParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, FrameLayout.LayoutParams.MatchParent, GravityFlags.Fill);

            overView.LayoutParameters = overViewParams;
            overView.Alpha            = 0.5f;
            overView.Visibility       = ViewStates.Invisible;
            overView.SetBackgroundColor(Color.Black);

            mainLayout.AddView(editor);
            mainLayout.AddView(overView);
            mainLayout.AddView(popipView);
            SetContentView(mainLayout);
        }
Example #2
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            var deviceDensity = (int)context.Resources.DisplayMetrics.Density;
            // Set our view from the "main" layout resource
            var layoutInflater = LayoutInflater.From(context);

            view = layoutInflater.Inflate(Resource.Layout.EditorCustomization, null);


            FrameLayout mainLayout = view.FindViewById <FrameLayout>
                                         (Resource.Id.CustomizationMain);

            editor               = new SfImageEditor(context);
            editor.Bitmap        = BitmapFactory.DecodeResource(context.Resources, Resource.Drawable.Customize);
            editor.ItemSelected += Editor_ItemSelected;
            editor.ToolbarSettings.IsVisible = false;
            editor.SetBackgroundColor(Color.Black);
            editor.ToolbarSettings.SubItemToolbarHeight = 0;


            var bottomview = layoutInflater.Inflate(Resource.Layout.BottomView, mainLayout, true);
            var topview    = layoutInflater.Inflate(Resource.Layout.TopView, mainLayout, true);
            var rightview  = layoutInflater.Inflate(Resource.Layout.RightView, mainLayout, true);


            //Bottom View------------------------------------
            var bottomView = bottomview.FindViewById <LinearLayout>(Resource.Id.bottomView);

            bottomView.SetGravity(GravityFlags.Bottom);
            var bParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, 50 * deviceDensity, GravityFlags.Bottom);

            bottomView.SetBackgroundColor(Color.Transparent);
            bParams.SetMargins(0, 0, 0, 10 * deviceDensity);
            bottomView.LayoutParameters = bParams;


            //Top View------------------------------------
            var topView = topview.FindViewById <LinearLayout>(Resource.Id.topView);
            var tParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MatchParent, 50 * deviceDensity, GravityFlags.Top);

            tParams.SetMargins(0, 10 * deviceDensity, 0, 0);
            topView.LayoutParameters = tParams;


            //Right View------------------------------------

            var rightView = rightview.FindViewById <LinearLayout>(Resource.Id.rightView);
            var rParams   = new FrameLayout.LayoutParams(65 * deviceDensity, FrameLayout.LayoutParams.MatchParent, GravityFlags.Right);

            rParams.SetMargins(0, 250, 0, 250);
            rightView.SetBackgroundColor(Color.Transparent);
            rightView.SetPadding(0, 0, 15 * deviceDensity, 15 * deviceDensity);
            rightView.LayoutParameters = rParams;
            rightView.Visibility       = ViewStates.Invisible;
            topView.Visibility         = ViewStates.Invisible;
            mainLayout.RemoveAllViews();
            (mainLayout.Parent as ViewGroup)?.RemoveAllViews();


            mainLayout.AddView(editor);
            mainLayout.AddView(topView);
            mainLayout.AddView(bottomView);
            mainLayout.AddView(rightView);

            Button dummyLayout = new Button(context);

            dummyLayout.SetBackgroundColor(Color.Transparent);
            dummyLayout.Alpha = 0.5F;
            mainLayout.AddView(dummyLayout);
            dummyLayout.Click += (sender, e) =>
            {
                topView.Visibility     = ViewStates.Visible;
                dummyLayout.Visibility = ViewStates.Invisible;
            };


            //Top view

            var reset = topView.FindViewById <ImageButton>(Resource.Id.resetButton);
            var undo  = topView.FindViewById <ImageButton>(Resource.Id.undoButton);
            var rect  = topView.FindViewById <ImageButton>(Resource.Id.rectButton);
            var text  = topView.FindViewById <ImageButton>(Resource.Id.textButton);
            var path  = topView.FindViewById <ImageButton>(Resource.Id.pathButton);

            reset.Click += (sender, e) =>
            {
                if (editor.IsImageEdited)
                {
                    editor.Reset();
                }
                rightView.Visibility   = ViewStates.Invisible;
                topView.Visibility     = ViewStates.Invisible;
                dummyLayout.Visibility = ViewStates.Visible;
                isPath = false;
                isText = false;
                isRect = false;
            };
            undo.Click += (sender, e) =>
            {
                if (editor.IsImageEdited)
                {
                    editor.Undo();
                }
            };
            rect.Click += (sender, e) =>
            {
                isPath = false;
                isText = false;
                isRect = true;
                AddShapes();
                rightView.Visibility = ViewStates.Visible;
            };
            text.Click += (sender, e) =>
            {
                isPath = false;
                isRect = false;
                isText = true;
                AddShapes();
                rightView.Visibility = ViewStates.Visible;
            };
            path.Click += (sender, e) =>
            {
                isPath = true;
                isRect = false;
                isText = false;
                rightView.Visibility = ViewStates.Visible;
                editor.AddShape();
            };



            // colorLayout
            var firstBut   = rightview.FindViewById <Button>(Resource.Id.firstButton);
            var secondBut  = rightview.FindViewById <Button>(Resource.Id.secondButton);
            var thirdBut   = rightview.FindViewById <Button>(Resource.Id.thirdButton);
            var fourthBut  = rightview.FindViewById <Button>(Resource.Id.fourthButton);
            var fifthBut   = rightview.FindViewById <Button>(Resource.Id.fifthButton);
            var sixthBut   = rightview.FindViewById <Button>(Resource.Id.sixthButton);
            var seventhBut = rightview.FindViewById <Button>(Resource.Id.seventhButton);
            var eightBut   = rightview.FindViewById <Button>(Resource.Id.eightButton);
            var ninthBut   = rightview.FindViewById <Button>(Resource.Id.ninthButton);
            var tenthBut   = rightview.FindViewById <Button>(Resource.Id.tenthButton);

            firstBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#4472c4");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            secondBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#ed7d31");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            thirdBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#ffc000");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            fourthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#70ad47");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            fifthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#5b9bd5");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            sixthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#c1c1c1");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            seventhBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#6f6fe2");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            eightBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#e269ae");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            ninthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#9e480e");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };
            tenthBut.Click += (sender, e) =>
            {
                var color = Color.ParseColor("#997300");
                setting(Settings, color);
                if (isPath)
                {
                    editor.AddShape(Syncfusion.SfImageEditor.Android.ShapeType.Path, new PenSettings()
                    {
                        Color = color
                    });
                }
            };


            //Share

            var share = bottomView.FindViewById <ImageButton>(Resource.Id.sharecustomization);

            editText     = bottomView.FindViewById <EditText>(Resource.Id.captionText);
            share.Click += async(sender, e) =>
            {
                await ShareImageAsync();
            };
            return(mainLayout);
        }