コード例 #1
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            presentController = GetVisibleViewController();
            imageEditor       = new SfImageEditor(new CGRect(View.Frame.Location.X, 60, View.Frame.Size.Width, View.Frame.Size.Height - 60));
            imageEditor.SetToolbarItemVisibility("text,transform,shape,path,effects", false);

            CustomViewItems = new List <ToolbarItem>()
            {
                new CustomToolbarItem()
                {
                    CustomName = "Typogy1", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy1.png"), IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    CustomName = "Typogy2", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy2.png"), IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    CustomName = "Typogy3", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy3.png"), IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    CustomName = "Typogy4", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy4.png"), IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    CustomName = "Typogy5", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy5.png"), IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    CustomName = "Typogy6", Icon = UIImage.FromBundle("Images/ImageEditor/ITypogy6.png"), IconHeight = 70
                },
            };

            // Add the custom tool bar items
            var item1 = new FooterToolbarItem()
            {
                Text       = "Add",
                Icon       = UIImage.FromBundle("Images/ImageEditor/AddIcon.png"),
                SubItems   = CustomViewItems,
                TextHeight = 20,
            };

            var item2 = new FooterToolbarItem()
            {
                Text       = "Replace",
                Icon       = UIImage.FromBundle("Images/ImageEditor/ReplaceIcon.png"),
                SubItems   = CustomViewItems,
                TextHeight = 20
            };

            var item3 = new FooterToolbarItem()
            {
                Icon       = UIImage.FromBundle("Images/ImageEditor/BringFrontIcon"),
                Text       = "Bring Front",
                TextHeight = 20
            };

            var item4 = new FooterToolbarItem()
            {
                Icon       = UIImage.FromBundle("Images/ImageEditor/SendBack"),
                Text       = "Send Back",
                TextHeight = 20
            };

            imageEditor.ToolBarSettings.ToolbarItems.Add(item1);
            imageEditor.ToolBarSettings.ToolbarItems.Add(item2);
            imageEditor.ToolBarSettings.ToolbarItems.Add(item3);
            imageEditor.ToolBarSettings.ToolbarItems.Add(item4);
            imageEditor.ToolBarSettings.SubItemToolbarHeight = 70;
            imageEditor.ItemSelected += ImageEditor_ItemSelected;
            imageEditor.ToolBarSettings.ToolbarItemSelected += OnToolbarItemSelected;
            imageEditor.Image = image;
            this.View.AddSubview(imageEditor);
        }
コード例 #2
0
            protected override void OnCreate(Bundle savedInstanceState)
            {
                viewModel = new ViewModel();
                LayoutInflater layoutInflater = LayoutInflater.From(this);

                view = layoutInflater.Inflate(Resource.Layout.EditorSerializationMain, null);
                SetContentView(view);
                LinearLayout mainLayout = FindViewById <LinearLayout>
                                              (Resource.Id.ContentView);

                listView      = FindViewById <ListView>(Resource.Id.right_drawer);
                mDrawerLayout = (DrawerLayout)FindViewById(Resource.Id.drawer_layout);
                tableItems.Add(new TableItem()
                {
                    ImageResourceId = viewModel.ModelList[0].Name, ImageName = "Coffee"
                });
                tableItems.Add(new TableItem()
                {
                    ImageResourceId = viewModel.ModelList[1].Name, ImageName = "Food"
                });
                tableItems.Add(new TableItem()
                {
                    ImageResourceId = viewModel.ModelList[2].Name, ImageName = "Syncfusion"
                });

                listView.Adapter = new HomeScreenAdapter(this, tableItems);

                listView.ItemClick += OnListItemClick;
                editor              = new SfImageEditor(this);
                editor.ImageSaving += Editor_ImageSaving;

                editor.Bitmap = SerializedTemplate.Image;
                assets        = this.Assets;
                LoadStream();
                DelayActionAsync(500, LoadStreamToEditor);

                //Add ToolBar items

                HeaderToolBarItem item1 = new HeaderToolBarItem();

                item1.Text = "Settings";
                item1.Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.sett);
                HeaderToolBarItem item2 = new HeaderToolBarItem();

                item2.Text = "Share";
                item2.Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.share);
                HeaderToolBarItem item3 = new HeaderToolBarItem();

                item3.Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.info_24);

                editor.ToolbarSettings.ToolbarItems.Add(item1);
                editor.ToolbarSettings.ToolbarItems.Add(item2);
                editor.ToolbarSettings.ToolbarItems.Add(item3);

                editor.ToolbarSettings.ToolbarItemSelected += (sender, e) => {
                    if (e.Toolbar is HeaderToolBarItem)
                    {
                        var text = (e.Toolbar as HeaderToolBarItem).Text;
                        if (e.Toolbar is HeaderToolBarItem)
                        {
                            if ((e.Toolbar as HeaderToolBarItem).Text == "Share")
                            {
                                ShareImage();
                            }

                            if ((e.Toolbar as HeaderToolBarItem).Text == "Settings")
                            {
                                mDrawerLayout.OpenDrawer(listView);
                            }
                            if ((text != "Reset" && text != "undo" && text != "redo" && text != "Save" && text != "Settings" && text != "Share"))
                            {
                                string strin = "ImageEditor allows you to serialize and deserialize any custom edits(Shapes,Text,Path) over an image. In this sample we have deserialized some custom edits and loaded in to the editor.";
                                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                                alert.SetTitle("About this sample");
                                alert.SetMessage(strin.ToString());
                                alert.SetNegativeButton("Ok", (senderAlert, args) => {
                                });
                                Dialog dialog = alert.Create();
                                dialog.Show();
                            }
                        }
                    }
                };
                mainLayout.AddView(editor);
                base.OnCreate(savedInstanceState);
            }
コード例 #3
0
            protected override void OnCreate(Bundle savedInstanceState)
            {
                imageEditor = new SfImageEditor(this);
                var bitmap = BitmapFactory.DecodeResource(Resources, ImageEditorCustomView.Image);

                imageEditor.Bitmap        = bitmap;
                imageEditor.ItemSelected += ImageEditor_ItemSelected;
                SetContentView(imageEditor);
                base.OnCreate(savedInstanceState);

                imageEditor.SetToolbarItemVisibility("text,transform,shape,path,effects", false);

                CustomViewItems = new List <ToolbarItem>()
                {
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy1), CustomName = "ITypogy1", IconHeight = 70
                    },
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy2), CustomName = "ITypogy2", IconHeight = 70
                    },
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy3), CustomName = "ITypogy3", IconHeight = 70
                    },
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy4), CustomName = "ITypogy4", IconHeight = 70
                    },
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy5), CustomName = "ITypogy5", IconHeight = 70
                    },
                    new CustomToolbarItem()
                    {
                        Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ITypogy6), CustomName = "ITypogy6", IconHeight = 70
                    }
                };

                // Add the custom tool bar items
                var item = new FooterToolbarItem()
                {
                    Text       = "Add",
                    Icon       = BitmapFactory.DecodeResource(Resources, Resource.Drawable.AddIcon),
                    SubItems   = CustomViewItems,
                    TextHeight = 20,
                };

                imageEditor.ToolbarSettings.ToolbarItems.Add(item);

                item = new FooterToolbarItem()
                {
                    Text       = "Replace",
                    Icon       = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ReplaceIcon),
                    SubItems   = CustomViewItems,
                    TextHeight = 20
                };
                imageEditor.ToolbarSettings.ToolbarItems.Add(item);

                item = new FooterToolbarItem()
                {
                    Icon       = BitmapFactory.DecodeResource(Resources, Resource.Drawable.BringFrontIcon),
                    Text       = "Bring Front",
                    TextHeight = 20
                };
                imageEditor.ToolbarSettings.ToolbarItems.Add(item);

                item = new FooterToolbarItem()
                {
                    Icon       = BitmapFactory.DecodeResource(Resources, Resource.Drawable.SendBack),
                    Text       = "Send Back",
                    TextHeight = 20
                };
                imageEditor.ToolbarSettings.ToolbarItems.Add(item);
                imageEditor.ToolbarSettings.SubItemToolbarHeight = 70;
                imageEditor.ToolbarSettings.ToolbarItemSelected += OnToolbarItemSelected;
            }
コード例 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            viewModel = new ViewModel();
            assets    = this.Assets;
            LayoutInflater layoutInflater = LayoutInflater.From(this);

            view = layoutInflater.Inflate(Resource.Layout.EditorBannerMain, null);
            SetContentView(view);
            LinearLayout mainLayout = FindViewById <LinearLayout>
                                          (Resource.Id.editor_layout);

            visibilityLayout = FindViewById <LinearLayout>
                                   (Resource.Id.visibility_layout);
            visibilityLayout.Visibility = ViewStates.Gone;
            Button ok = FindViewById <Button>
                            (Resource.Id.button);
            Button cancel = FindViewById <Button>
                                (Resource.Id.button2);

            ok.Click     += Ok_Click;
            cancel.Click += Cancel_Click;
            editor        = new SfImageEditor(this);
            var bitmap = BitmapFactory.DecodeResource(Resources, BannerCreator.Image);

            editor.Bitmap = bitmap;
            mainLayout.AddView(editor);

            editor.ToolbarSettings.ToolbarItems.Clear();
            FooterToolbarItem banner = new FooterToolbarItem()
            {
                Text     = "Banner Types",
                SubItems = new List <ToolbarItem>()
                {
                    new ToolbarItem()
                    {
                        Text = "Facebook Post"
                    },
                    new ToolbarItem()
                    {
                        Text = "Facebook Cover"
                    },
                    new ToolbarItem()
                    {
                        Text = "Twitter Cover"
                    },
                    new ToolbarItem()
                    {
                        Text = "Twitter Post"
                    },
                    new ToolbarItem()
                    {
                        Text = "YouTubeChannel Cover"
                    },
                },
            };


            HeaderToolbarItem item2 = new HeaderToolbarItem();

            item2.Text = "Share";
            item2.Icon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.share);
            HeaderToolbarItem crop = new HeaderToolbarItem();

            crop.Text = "Banner Types";
            editor.ToolbarSettings.ToolbarItems.Add(item2);
            editor.ToolbarSettings.ToolbarItems.Add(banner);
            editor.ToolbarSettings.ToolbarItemSelected += (sender, e) =>
            {
                if (e.ToolbarItem is HeaderToolbarItem)
                {
                    if ((e.ToolbarItem as HeaderToolbarItem).Text == "Share")
                    {
                        ShareImage();
                    }
                }
                if (e.ToolbarItem is ToolbarItem)
                {
                    var toolitem = e.ToolbarItem as ToolbarItem;
                    if (toolitem.Text != "Banner Types" && toolitem.Text != "Share")
                    {
                        visibilityLayout.Visibility = ViewStates.Visible;
                    }
                    if (toolitem.Text == "Facebook Post")
                    {
                        editor.ToggleCropping(1200, 900);
                    }
                    else if (toolitem.Text == "Facebook Cover")
                    {
                        editor.ToggleCropping(851, 315);
                    }
                    else if (toolitem.Text == "Twitter Cover")
                    {
                        editor.ToggleCropping(1500, 500);
                    }
                    else if (toolitem.Text == "Twitter Post")
                    {
                        editor.ToggleCropping(1024, 512);
                    }
                    else if (toolitem.Text == "YouTubeChannel Cover")
                    {
                        editor.ToggleCropping(2560, 1440);
                    }
                }
            };



            base.OnCreate(savedInstanceState);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: Serialization.cs プロジェクト: zanesc/xamarin-demos
        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);
            RunTimer();
            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);
        }
コード例 #7
0
        public override void ViewDidAppear(bool animated)
        {
            base.ViewDidAppear(animated);

            presentController = GetVisibleViewController();
            sfImageEditor     = new SfImageEditor(new CGRect(View.Frame.Location.X, 60, View.Frame.Size.Width, View.Frame.Size.Height - 60));
            sfImageEditor.ToolBarSettings.ToolbarItems.Clear();
            sfImageEditor.ToolBarSettings.ToolbarItems.Add(new FooterToolbarItem()
            {
                Text = "Banner Types",

                SubItems = new System.Collections.Generic.List <ToolbarItem>()
                {
                    new ToolbarItem()
                    {
                        Text = "Facebook Post"
                    },
                    new ToolbarItem()
                    {
                        Text = "Facebook Cover"
                    },
                    new ToolbarItem()
                    {
                        Text = "Twitter Cover"
                    },
                    new ToolbarItem()
                    {
                        Text = "Twitter Post"
                    },
                    new ToolbarItem()
                    {
                        Text = "YouTubeChannel Cover"
                    }
                }
            });
            sfImageEditor.ToolBarSettings.ToolbarItems.Add(new CustomHeader()
            {
                HeaderName = "Share", Icon = UIImage.FromBundle("Images/ImageEditor/share.png")
            });
            sfImageEditor.ToolBarSettings.ToolbarItemSelected += ToolbarItemSelected;
            sfImageEditor.ImageSaved += ImageEditor_ImageSaved;
            sfImageEditor.Image       = _image;
            this.View.AddSubview(sfImageEditor);

            CropSelectionMenu = new UIView(new CGRect(0, 60, View.Frame.Width, 50));
            CropSelectionMenu.BackgroundColor = UIColor.White;
            UIButton okButton = new UIButton(new CGRect(0, 0, View.Frame.Width / 2, 50));

            okButton.SetTitle("OK", UIControlState.Normal);
            okButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            okButton.TouchDown += (sender, e) =>
            {
                sfImageEditor.Crop();
                CropSelectionMenu.Hidden = true;
            };
            CropSelectionMenu.AddSubview(okButton);


            UIButton cancelButton = new UIButton(new CGRect(View.Frame.Width / 2, 0, View.Frame.Width / 2, 50));

            cancelButton.SetTitle("Cancel", UIControlState.Normal);
            cancelButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            cancelButton.TouchDown += (sender, e) =>
            {
                sfImageEditor.ToggleCropping();
                CropSelectionMenu.Hidden = true;
            };

            CropSelectionMenu.Hidden = true;
            CropSelectionMenu.AddSubview(cancelButton);
            View.AddSubview(CropSelectionMenu);
        }
コード例 #8
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            presentController = GetVisibleViewController();
            UIView mainView = new UIView();

            mainView.Frame                          = new CGRect(0, 0, Frame.Width, Frame.Height);
            mainView.BackgroundColor                = UIColor.Clear;
            sfImageEditor                           = new SfImageEditor(new CGRect(mainView.Frame.X, mainView.Frame.Y, mainView.Frame.Width, mainView.Frame.Height));
            sfImageEditor.Image                     = UIImage.FromBundle("Images/ImageEditor/Customize.jpg");
            sfImageEditor.BackgroundColor           = UIColor.Black;
            sfImageEditor.ToolBarSettings.IsVisible = false;
            //settings = new Object();
            sfImageEditor.ItemSelected += (object sender, ItemSelectedEventArgs e) =>
            {
                RightView.Alpha = 1;
                settings        = e.Settings;
            };
            mainView.AddSubview(sfImageEditor);

            /*--------------------------------------------------*/
            //TopView

            topView       = new UIView();
            topView.Frame = new CGRect(0, 15, Frame.Width, 25);
            topView.Alpha = 0;

            UIButton reset = new UIButton(new CGRect(0, 0, Frame.Width / 6, 25));

            reset.BackgroundColor = UIColor.Clear;
            reset.SetImage(UIImage.FromBundle("Images/ImageEditor/reset_customization.png"), UIControlState.Normal);
            reset.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            reset.TouchUpInside        += Reset_TouchUpInside;
            topView.AddSubview(reset);

            UIButton redo = new UIButton(new CGRect(Frame.Width / 6, 0, Frame.Width / 6, 25));

            redo.BackgroundColor = UIColor.Clear;
            redo.SetImage(UIImage.FromBundle("Images/ImageEditor/redo_customization.png"), UIControlState.Normal);
            redo.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            redo.TouchUpInside        += Redo_TouchUpInside;
            redo.Alpha = 0;
            topView.AddSubview(redo);

            UIButton undo = new UIButton(new CGRect(2 * (Frame.Width / 6), 0, Frame.Width / 6, 25));

            undo.BackgroundColor = UIColor.Clear;
            undo.SetImage(UIImage.FromBundle("Images/ImageEditor/undo_customization.png"), UIControlState.Normal);
            undo.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            undo.TouchUpInside        += Undo_TouchUpInside;
            topView.AddSubview(undo);

            UIButton rect = new UIButton(new CGRect(3 * (Frame.Width / 6), 0, Frame.Width / 6, 25));

            rect.BackgroundColor = UIColor.Clear;
            rect.SetImage(UIImage.FromBundle("Images/ImageEditor/rect_customization.png"), UIControlState.Normal);
            rect.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            rect.TouchUpInside        += Rect_TouchUpInside;
            topView.AddSubview(rect);

            UIButton text = new UIButton(new CGRect(4 * (Frame.Width / 6), 0, Frame.Width / 6, 25));

            text.BackgroundColor = UIColor.Clear;
            text.SetImage(UIImage.FromBundle("Images/ImageEditor/text_customization.png"), UIControlState.Normal);
            text.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            text.TouchUpInside        += Text_TouchUpInside;
            topView.AddSubview(text);

            UIButton path = new UIButton(new CGRect(5 * (Frame.Width / 6), 0, Frame.Width / 6, 25));

            path.BackgroundColor = UIColor.Clear;
            path.SetImage(UIImage.FromBundle("Images/ImageEditor/pen_customization.png"), UIControlState.Normal);
            path.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            path.TouchUpInside        += Path_TouchUpInside;
            topView.AddSubview(path);

            mainView.AddSubview(topView);

            /*----------------------------------------------------------*/
            //BottomView

            UIView bottomView = new UIView();

            bottomView.Frame           = new CGRect(10, Frame.Height - 50, Frame.Width, 30);
            bottomView.BackgroundColor = UIColor.Clear;

            textView = new UITextField(new CGRect(20, 0, Frame.Width - 100, 30));
            textView.Layer.CornerRadius = 10.0f;
            textView.Layer.BorderColor  = UIColor.White.CGColor;
            textView.Layer.BorderWidth  = 2;

            textView.TextColor   = UIColor.White;
            textView.Placeholder = "Enter a Caption";
            textView.Enabled     = true;
            textView.ResignFirstResponder();
            textView.MultipleTouchEnabled = true;
            bottomView.AddSubview(textView);

            UIButton share = new UIButton(new CGRect(Frame.Width - 70, 0, 50, 30));

            share.BackgroundColor = UIColor.Clear;
            share.SetImage(UIImage.FromBundle("Images/ImageEditor/share_customization.png"), UIControlState.Normal);
            share.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            share.TouchUpInside        += Share_TouchUpInside;
            bottomView.AddSubview(share);
            mainView.AddSubview(bottomView);

            /*--------------------------------------------------*/

            //RightView
            RightView                 = new UIView();
            RightView.Frame           = new CGRect(Frame.Width - 50, 20, 30, Frame.Height);
            RightView.BackgroundColor = UIColor.Clear;

            //Color Collection
            UIColor[] array = new UIColor[10] {
                UIColor.FromRGB(68, 114, 196)
                , UIColor.FromRGB(237, 125, 49)
                , UIColor.FromRGB(255, 192, 0)
                , UIColor.FromRGB(112, 173, 71)
                , UIColor.FromRGB(91, 155, 213)
                , UIColor.FromRGB(193, 193, 193)
                , UIColor.FromRGB(111, 111, 226)
                , UIColor.FromRGB(226, 105, 174)
                , UIColor.FromRGB(158, 72, 14)
                , UIColor.FromRGB(153, 115, 0)
            };

            int y = (int)(this.Frame.Height / 2) - 175;

            for (int i = 0; i < 10; i++)
            {
                UIButton colorButton = new UIButton();
                colorButton.Frame = new CGRect(3, y + 5, 25, 25);
                colorButton.Layer.CornerRadius = 10;
                y = y + 30;
                colorButton.BackgroundColor = array[i];
                colorButton.TouchUpInside  += ColorButton_TouchUpInside;
                RightView.Add(colorButton);
            }

            mainView.AddSubview(RightView);
            RightView.Alpha = 0;

            overView                 = new UIView();
            overView.Frame           = new CGRect(0, 0, Frame.Width, Frame.Height);
            overView.BackgroundColor = UIColor.Clear;
            overView.Alpha           = 1f;
            UITapGestureRecognizer tapped = new UITapGestureRecognizer(TapCarrierLabel);

            overView.AddGestureRecognizer(tapped);

            AddSubview(mainView);
            AddSubview(overView);
        }