public SerializationContentPage(SerializationModel selectedItem, Syncfusion.ListView.XForms.SfListView listView, SerializationViewModel model)
        {
            InitializeComponent();
            mainModel    = model;
            SelectedItem = selectedItem;
            imageEditor.SetToolbarItemVisibility("save", false);
            HeaderToolbarItem item1 = new HeaderToolbarItem();

            item1.Text = "Save Edits";
            item1.Name = "CustomSave";
            imageEditor.ImageSaving += ImageEditor_ImageSaving;
            imageEditor.ImageSaved  += ImageEditor_ImageSaved;
            imageEditor.ToolbarSettings.ToolbarItems.Add(item1);

            imageEditor.ToolbarSettings.ToolbarItemSelected += (sender, e) =>
            {
                if (e.ToolbarItem is HeaderToolbarItem)
                {
                    var text = e.ToolbarItem.Name;
                    if (text == "CustomSave")
                    {
                        if (SelectedItem.ImageName == "CreateNew")
                        {
                            popup.IsVisible = true;
                            grid.IsVisible  = true;
                        }
                        else
                        {
                            imageEditor.Save();
                        }
                    }
                }
            };
            if (Device.RuntimePlatform == Device.UWP && SelectedItem.ImageName == "CreateNew")
            {
#if COMMONSB
                imageEditor.Source = ImageSource.FromResource("SampleBrowser.Icons.Plain.png", assembly);
#else
                imageEditor.Source = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.Plain.png", assembly);
#endif
            }
            LoadStream();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        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);
        }
        public ImageEditorToolbarPage(ImageSource imagesource, ViewModel viewModel, Model model)
        {
            data                = model;
            ViewModelMain       = viewModel;
            this.BindingContext = ViewModelMain;
            scr = imagesource;
            InitializeComponent();
            imageEditor.Source = imagesource;
            // imageEditor.SetToolbarItemVisibility("Cancel,Ok", false);
            imageEditor.ToolbarSettings.ToolbarItems.Clear();
            imageEditor.EnableZooming = false;
            Assembly          assembly = typeof(ImageSerializeModel).GetTypeInfo().Assembly;
            FooterToolbarItem banner   = new FooterToolbarItem()
            {
                Text     = "Banner Types",
                SubItems = new System.Collections.ObjectModel.ObservableCollection <Syncfusion.SfImageEditor.XForms.ToolbarItem>()
                {
                    #if COMMONSB
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Facebook Post", Icon = ImageSource.FromResource("SampleBrowser.Icons.fivetofour.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Facebook Cover", Icon = ImageSource.FromResource("SampleBrowser.Icons.fourtothree.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Twitter Cover", Icon = ImageSource.FromResource("SampleBrowser.Icons.fivetofour.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Twitter Post", Icon = ImageSource.FromResource("SampleBrowser.Icons.fourtothree.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "YouTubeChannel Cover", Icon = ImageSource.FromResource("SampleBrowser.Icons.fivetofour.png", assembly)
                    },
                    #else
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Facebook Post", Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.fivetofour.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Facebook Cover", Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.fourtothree.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Twitter Cover", Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.fivetofour.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "Twitter Post", Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.fourtothree.png", assembly)
                    },
                    new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                    {
                        Text = "YouTubeChannel Cover", Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.fivetofour.png", assembly)
                    },
                    #endif
                },
            };


            HeaderToolbarItem item2 = new HeaderToolbarItem();

            item2.Name = "Share";
            #if COMMONSB
            item2.Icon = ImageSource.FromResource("SampleBrowser.Icons.share.png", assembly);
            #else
            item2.Icon = ImageSource.FromResource("SampleBrowser.SfImageEditor.Icons.share.png", assembly);
            #endif
            imageEditor.ToolbarSettings.ToolbarItems.Add(item2);
            imageEditor.ToolbarSettings.ToolbarItems.Add(banner);
            imageEditor.ToolbarSettings.ToolbarItemSelected += (sender, e) =>
            {
                var selected = (e.ToolbarItem as Syncfusion.SfImageEditor.XForms.ToolbarItem);
                if (selected != null)
                {
                    if (selected.Name == "Share")
                    {
                        Share();
                    }
                    else if (selected.Text == "Facebook Post" || selected.Text == "Banner Types")
                    {
                        imageEditor.ToggleCropping(1200, 900);
                    }
                    else if (selected.Text == "Facebook Cover")
                    {
                        imageEditor.ToggleCropping(851, 315);
                    }
                    else if (selected.Text == "Twitter Cover")
                    {
                        imageEditor.ToggleCropping(1500, 500);
                    }
                    else if (selected.Text == "Twitter Post")
                    {
                        imageEditor.ToggleCropping(1024, 512);
                    }
                    else if (selected.Text == "YouTubeChannel Cover")
                    {
                        imageEditor.ToggleCropping(2560, 1440);
                    }
                }
            };
        }