public CustomViewSample()
 {
     viewModel           = new CustomViewViewModel();
     model               = new CustomViewModel();
     this.BindingContext = new ImageListModel(viewModel);
     InitializeComponent();
 }
 void LoadFromStream(ImageSource source, CustomViewViewModel viewModel, CustomViewModel model)
 {
     if (Device.RuntimePlatform.ToLower() == "ios")
     {
         Navigation.PushAsync(new NavigationPage(new CustomViewHomePage(source, viewModel)));
     }
     else if (Device.RuntimePlatform.ToLower() == "uwp")
     {
         Navigation.PushAsync(new CustomViewHomePage(source, viewModel));
     }
     else
     {
         Navigation.PushModalAsync(new CustomViewHomePage(source, viewModel));
     }
 }
 void LoadFromStream(ImageSource source, CustomViewViewModel viewModel, CustomViewModel model)
 {
     if (Device.OS == TargetPlatform.iOS)
     {
         Navigation.PushAsync(new NavigationPage(new CustomViewHomePage(source, viewModel)));
     }
     else if (Device.OS == TargetPlatform.Windows)
     {
         Navigation.PushAsync(new CustomViewHomePage(source, viewModel));
     }
     else
     {
         Navigation.PushModalAsync(new CustomViewHomePage(source, viewModel));
     }
 }
 public ImageListModel(CustomViewViewModel viewmodel)
 {
     Image1 = viewmodel.ImageList[0].Image;
     Image2 = viewmodel.ImageList[1].Image;
     Image3 = viewmodel.ImageList[2].Image;
 }
Esempio n. 5
0
        public CustomViewHomePage(ImageSource source, CustomViewViewModel viewModel)
        {
            InitializeComponent();
            this.BindingContext = viewModel;

            // Set source to the SfImageEditor
            imageEditor.Source            = source;
            imageEditor.RotatableElements = ImageEditorElements.CustomView;
            imageEditor.SetToolbarItemVisibility("text,transform,shape,path", false);


            CustomViewItems = new ObservableCollection <Syncfusion.SfImageEditor.XForms.ToolbarItem>()
            {
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy1.png", assembly), CustomName = "ITypogy1", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy2.png", assembly), CustomName = "ITypogy2", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy3.png", assembly), CustomName = "ITypogy3", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy4.png", assembly), CustomName = "ITypogy4", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy5.png", assembly), CustomName = "ITypogy5", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy6.png", assembly), CustomName = "ITypogy6", IconHeight = 70
                }
            };

            // Add the custom tool bar items
            var item = new FooterToolbarItem()
            {
                Text       = "Add",
                Icon       = ImageSource.FromResource(samplePath + "AddIcon.png", assembly),
                SubItems   = CustomViewItems,
                TextHeight = 20,
            };

            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Text       = "Replace",
                Icon       = ImageSource.FromResource(samplePath + "ReplaceIcon.png", assembly),
                SubItems   = CustomViewItems,
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Icon       = ImageSource.FromResource(samplePath + "BringFrontIcon.png", assembly),
                Text       = "Bring Front",
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Icon       = ImageSource.FromResource(samplePath + "SendBack.png", assembly),
                Text       = "Send Back",
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);
            imageEditor.ToolbarSettings.SubItemToolbarHeight = 70;
            imageEditor.ItemSelected += ImageEditor_ItemSelected;
            imageEditor.ToolbarSettings.ToolbarItemSelected += OnToolbarItemSelected;
        }
        public CustomViewHomePage(ImageSource source, CustomViewViewModel viewModel)
        {
            InitializeComponent();
            this.BindingContext = viewModel;

            // Set source to the SfImageEditor
            imageEditor.Source            = source;
            imageEditor.RotatableElements = ImageEditorElements.CustomView;
            imageEditor.SetToolbarItemVisibility("text,transform,shape,path,effects", false);


            CustomViewItems = new ObservableCollection <Syncfusion.SfImageEditor.XForms.ToolbarItem>()
            {
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy1.png", assembly), CustomName = "ITypogy1", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy2.png", assembly), CustomName = "ITypogy2", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy3.png", assembly), CustomName = "ITypogy3", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy4.png", assembly), CustomName = "ITypogy4", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy5.png", assembly), CustomName = "ITypogy5", IconHeight = 70
                },
                new CustomToolbarItem()
                {
                    Icon = ImageSource.FromResource(samplePath + "ITypogy6.png", assembly), CustomName = "ITypogy6", IconHeight = 70
                }
            };

            // Add the custom tool bar items
            var item = new FooterToolbarItem()
            {
                Text = "Add",
                Icon = new FontImageSource()
                {
                    Glyph      = "\ue70a",
                    FontFamily = Device.RuntimePlatform == Device.iOS ? "Sync FontIcons" : Device.RuntimePlatform == Device.Android ? "Sync FontIcons.ttf#" : "Sync FontIcons.ttf#Sync FontIcons",
                    Color      = Color.Black
                },
                SubItems   = CustomViewItems,
                TextHeight = 20,
            };

            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Text       = "Replace",
                IconHeight = Device.RuntimePlatform == Device.Android ? 27 : double.NaN,
                Icon       = new FontImageSource()
                {
                    Glyph      = "\ue740",
                    FontFamily = Device.RuntimePlatform == Device.iOS ? "SB Icons" : Device.RuntimePlatform == Device.Android ? "SB Icons.ttf#" : "SB Icons.ttf#SB Icons",
                    Color      = Color.Black
                },
                SubItems   = CustomViewItems,
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Icon = new FontImageSource()
                {
                    Glyph      = "\ue764",
                    FontFamily = Device.RuntimePlatform == Device.iOS ? "Sync FontIcons" : Device.RuntimePlatform == Device.Android ? "Sync FontIcons.ttf#" : "Sync FontIcons.ttf#Sync FontIcons",
                    Color      = Color.Black
                },
                Text       = "Bring Front",
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);

            item = new FooterToolbarItem()
            {
                Icon = new FontImageSource()
                {
                    Glyph      = "\ue70e",
                    FontFamily = Device.RuntimePlatform == Device.iOS ? "Sync FontIcons" : Device.RuntimePlatform == Device.Android ? "Sync FontIcons.ttf#" : "Sync FontIcons.ttf#Sync FontIcons",
                    Color      = Color.Black
                },
                Text       = "Send Back",
                TextHeight = 20
            };
            imageEditor.ToolbarSettings.ToolbarItems.Add(item);
            imageEditor.ToolbarSettings.SubItemToolbarHeight = 70;
            imageEditor.ItemSelected += ImageEditor_ItemSelected;
            imageEditor.ToolbarSettings.ToolbarItemSelected += OnToolbarItemSelected;
        }