Hello there,
I recently started using SfImageEditor for cropping, which after some support from this forum worked fine.
Now, I have two questions / problems:
1. I wanted all ToolbarItems except for a save button to be gone. This worked fine until recently, now when I start the editor I get a menu which looks as the image I have attached. Why is that?
The code is as follows:
public ImageEditor ()
{
InitializeComponent ();
CropEditor.ImageSaved += CropEditor_ImageSaved;
CropEditor.ImageLoaded += CropEditor_ImageLoaded;
CropEditor.ToolbarSettings.ToolbarItems.Add(new FooterToolbarItem() { Text = "Save" });
CropEditor.ToolbarSettings.ToolbarItemSelected += ToolbarSettings_ToolbarItemSelected;
}
private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
{
if (e.ToolbarItem.Text == "Save" || e.ToolbarItem.Name == "Ok")
{
try
{
CropEditor?.Crop();
Device.BeginInvokeOnMainThread(() =>
{
CropEditor.Save(".png", new Size(500, 500));
});
}
catch (Exception ex)
{
Logger.Error(ex.Message);
Logger.Error(ex.StackTrace);
}
}
}
private void CropEditor_ImageLoaded(object sender, Syncfusion.SfImageEditor.XForms.ImageLoadedEventArgs args)
{
Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
{
CropEditor.SetToolbarItemVisibility("text,path,shape,transform,reset,undo,redo,save", false);
CropEditor.ToggleCropping(1, 1);
return false;
});
}
2. When I call the Editor.Crop() method, an Exception is thrown.
2018-11-11 06:14:39.8734|ERROR|BaseViewModel|Object reference not set to an instance of an object.11-11 06:14:39.873 I/mono-stdout( 8023): 2018-11-11 06:14:39.8734|ERROR|BaseViewModel|Object reference not set to an instance of an object.
11-11 06:14:39.905 I/mono-stdout( 8023): 2018-11-11 06:14:39.9058|ERROR|BaseViewModel| at Syncfusion.SfImageEditor.Android.SfImageEditor.Crop (System.Drawing.Rectangle rectangle) [0x0009f] in <42f5eea3a286437b8ca2029ea16304bb>:0 2018-11-11 06:14:39.9058|ERROR|BaseViewModel| at Syncfusion.SfImageEditor.Android.SfImageEditor.Crop (System.Drawing.Rectangle rectangle) [0x0009f] in <42f5eea3a286437b8ca2029ea16304bb>:0
at Syncfusion.SfImageEditor.XForms.Droid.ImagEditorDependencyServiceMapping.Crop (System.Object obj, Xamarin.Forms.Rectangle rect) [0x0002e] in <42f5eea3a286437b8ca2029ea16304bb>:0
11-11 06:14:39.906 I/mono-stdout( 8023): at Syncfusion.SfImageEditor.XForms.Droid.ImagEditorDependencyServiceMapping.Crop (System.Object obj, Xamarin.Forms.Rectangle rect) [0x0002e] in <42f5eea3a286437b8ca2029ea16304bb>:0
11-11 06:14:39.906 I/mono-stdout( 8023): at Syncfusion.SfImageEditor.XForms.SfImageEditor.Crop (Xamarin.Forms.Rectangle rect) [0x00014] in <a44f15fc9a2149fc829989b3f3333a4a>:0
at Syncfusion.SfImageEditor.XForms.SfImageEditor.Crop (Xamarin.Forms.Rectangle rect) [0x00014] in <a44f15fc9a2149fc829989b3f3333a4a>:0
at App.View.Components.ImageEditor.ToolbarSettings_ToolbarItemSelected (System.Object sender, Syncfusion.SfImageEditor.XForms.ToolbarItemSelectedEventArgs e) [0x00036] in D:\Programmieren\MyProjects Xamarin\LifesHike\App\App\View\Components\ImageEditor.xaml.cs:46
Thanks in advance,
Wolf
Attachment:
Screenshot_1541916696_bc6b5d14.zip