Esempio n. 1
0
 private void ToolBarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
 {
     if (e.ToolbarItem.Text == "Crop")
     {
         editor.ToggleCropping(true, 3);
         e.Cancel = true;
     }
 }
Esempio n. 2
0
 void ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
 {
     if (e.ToolbarItem is ToolbarItem)
     {
         var toolitem = e.ToolbarItem as ToolbarItem;
         if (!(toolitem is HeaderToolbarItem))
         {
             CropSelectionMenu.Hidden = false;
         }
         if (toolitem is HeaderToolbarItem)
         {
             sfImageEditor.Save();
         }
         else if (toolitem.Text == "Facebook Post")
         {
             sfImageEditor.ToggleCropping(1200, 900);
         }
         else if (toolitem.Text == "Facebook Cover")
         {
             sfImageEditor.ToggleCropping(851, 315);
         }
         else if (toolitem.Text == "Twitter Cover")
         {
             sfImageEditor.ToggleCropping(1500, 500);
         }
         else if (toolitem.Text == "Twitter Post")
         {
             sfImageEditor.ToggleCropping(1024, 512);
         }
         else if (toolitem.Text == "YouTubeChannel Cover")
         {
             sfImageEditor.ToggleCropping(2560, 1440);
         }
         else if (toolitem.Text == "Banner Types")
         {
             sfImageEditor.ToggleCropping(1200, 900);
         }
     }
 }
Esempio n. 3
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);
            editor.Bitmap = BannerCreator.Image;
            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);
        }
Esempio n. 4
0
 void Cancel_Click(object sender, EventArgs e)
 {
     editor.ToggleCropping();
     visibilityLayout.Visibility = ViewStates.Gone;
 }
Esempio n. 5
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);
        }
Esempio n. 6
0
            private async void ImageEditor_ImageLoaded(object sender, ImageLoadedEventArgs e)
            {
                await System.Threading.Tasks.Task.Delay(25);

                imageEditor.ToggleCropping(true, 3);
            }