public SerializationContentPage(SerializationModel selectedItem, Syncfusion.ListView.XForms.SfListView listView, SerializationViewModel model)
        {
            InitializeComponent();
            mainModel = model;
            SelectedItem = selectedItem;
            imageEditor.SetToolbarItemVisibility("save", false);
            CustomHeader item1 = new CustomHeader();
            item1.Text = "Save Edits";
            item1.HeaderName = "Save";
            imageEditor.ImageSaving += ImageEditor_ImageSaving;
            imageEditor.ToolbarSettings.ToolbarItems.Add(item1);

            imageEditor.ToolbarSettings.ToolbarItemSelected += (sender, e) =>
            {

                if (e.ToolbarItem is CustomHeader)
                {

                    var text = (e.ToolbarItem as CustomHeader).HeaderName;
                    if (text == "Save")
                    {
                        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

            }
            DelayActionAsync(1500, Action);
        }
Esempio n. 2
0
        public ImageEditorToolbarPage(ImageSource imagesource, ViewModel viewModel, Model model)
        {
            data                = model;
            ViewModelMain       = viewModel;
            this.BindingContext = ViewModelMain;
            scr = imagesource;
            InitializeComponent();
            imageEditor.Source = imagesource;
            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
                },
            };


            CustomHeader item2 = new CustomHeader();

            item2.HeaderName = "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) =>
            {
                // cancelToolBar.IsVisible = false;
                if (e.ToolbarItem is CustomHeader)
                {
                    if ((e.ToolbarItem as CustomHeader).HeaderName == "Share")
                    {
                        Share();
                    }
                }
                if (e.ToolbarItem is Syncfusion.SfImageEditor.XForms.ToolbarItem)
                {
                    var toolitem = e.ToolbarItem as Syncfusion.SfImageEditor.XForms.ToolbarItem;
                    if (cancelToolBar.IsVisible == true && toolitem.Text == "Banner Types")
                    {
                        imageEditor.ToggleCropping();
                    }
                    cancelToolBar.IsVisible = false;
                    if (toolitem is CustomHeader)
                    {
                        var item = toolitem as CustomHeader;
                        if (item.HeaderName == "Banner Types" && item.HeaderName == "Share")
                        {
                            cancelToolBar.IsVisible = false;
                        }
                    }
                    else if (toolitem.Text != "Banner Types")
                    {
                        cancelToolBar.IsVisible = true;
                        isCropped = true;
                    }

                    if (toolitem.Text == "Facebook Post")
                    {
                        imageEditor.ToggleCropping(1200, 900);
                    }
                    else if (toolitem.Text == "Facebook Cover")
                    {
                        imageEditor.ToggleCropping(851, 315);
                    }
                    else if (toolitem.Text == "Twitter Cover")
                    {
                        imageEditor.ToggleCropping(1500, 500);
                    }
                    else if (toolitem.Text == "Twitter Post")
                    {
                        imageEditor.ToggleCropping(1024, 512);
                    }
                    else if (toolitem.Text == "YouTubeChannel Cover")
                    {
                        imageEditor.ToggleCropping(2560, 1440);
                    }
                }
            };
        }