Image customImage = new Image() { HeightRequest = 200, WidthRequest = 200 };
Assembly assembly = Assembly.GetAssembly(typeof(GettingStarted));
customImage.Source = ImageSource.FromResource("IESample.ITypogy1.png", assembly);
editor.AddCustomView(customImage, new CustomViewSettings());
I wish customImage to be prevented when moved to exit specific boundaries inside the editor.
How to do that ?
That's render the whole idea just into a drawbox without much of a serious applications usage.
Please change it by exposing the elements as a list or something.
even if it had to be with a big warning that some thing in this way may or may not work properly.
SfImageEditor designerEditor;
...
object view = null;
Image image = new Image();
image.HeightRequest = 150;
image.WidthRequest = 150;
image.Aspect = Aspect.AspectFill;
image.PropertyChanging += onSVGImagePropertyChanged;
string filePath = samplePath + name + ".png";
image.Source = ImageSource.FromResource( filePath, assembly );
view = image;
CustomViewSettings settings = new CustomViewSettings();
designerEditor.AddCustomView( view, settings );
I need to have control over these "
image" objects which I am creating.
When I drag them and move around inside
SfImageEditor I must prevent them to exit specific bounds inside the
SfImageEditor.
This should be easily achieved if they are exposed after adding.
Aside of the - having control over the elements inside
SfImageEditor is the thing which is giving it more than just a drawbox features, so the developers can really use it for different more professional things.
Hmm.. I wasn't playing with that one until I saw this post.
To not have access to the important for a developer properties of the participating objects really render the whole idea to not very useful, but just a pile of pictures.
I am double voting to review the whole idea and expose the important properties of the participating into the collage objects, since they are the important things for the developers here.
They always return -1 or 0 for the bounds.
Please do a small example project which is showing the bounds of the selected or unselected item (CustomviewSettings), since maybe I am missing something else.
<xforms:SfImageEditor x:Name="editor"
Source="{Binding Image}"
ItemSelected="editor_ItemSelected" /> |
private void editor_ItemSelected(object sender, ItemSelectedEventArgs args)
{
Rectangle bounds = GetBounds(args.Settings);
}
private Rectangle GetBounds(object settings)
{
Rectangle bounds;
PenSettings penSettings = settings as PenSettings;
TextSettings textSettings = settings as TextSettings;
CustomViewSettings customViewSettings = settings as CustomViewSettings;
if (penSettings != null)
{
bounds = penSettings.Bounds;
}
else if (textSettings != null)
{
bounds = textSettings.Bounds;
}
else
{
bounds = customViewSettings.Bounds;
}
return bounds;
} |
Hey Vignesh Ramesh!
You are really a life saver.
It's more complex than I expected, quite not intuitive, anyway You've did the job well done !
Thanks man !
As we get the bound - is there a way to set them as well ?
public MainPage()
{
InitializeComponent();
editor.ToolbarSettings.ToolbarItems.Add(new FooterToolbarItem()
{
Name = "AddViews",
Text = "Add Views"
});
editor.ToolbarSettings.ToolbarItemSelected += this.ToolbarSettings_ToolbarItemSelected;
}
private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
{
if (e.ToolbarItem.Name == "AddViews")
{
Image customImage = new Image() { HeightRequest = 50, WidthRequest = 50 };
Assembly assembly = Assembly.GetAssembly(typeof(MainPage));
customImage.Source = ImageSource.FromResource("XFImageEditor.EditorPerson1.png", assembly);
editor.AddCustomView(customImage, new CustomViewSettings
{
Bounds = new Rectangle(0, 0, 50, 50)
});
editor.AddShape(ShapeType.Circle, new PenSettings
{
Bounds = new Rectangle(50, 0, 20, 20)
});
editor.AddText("Test", new TextSettings
{
Bounds = new Rectangle(0, 50, 20, 10)
});
}
} |
I see, but why ?
Why something which is so trivial can not be done ?
What is the reason behind this weird limitation ?
Maybe as a work-around we could get a function added?
.ResizeCustomView(int shapeId, Rectangle newBounds)
I currently do all my manipulating by using .SaveEdits/LoadEdits but as has been discussed, custom views are not present.
... actually I'd like a function to .ResizeEntity that would work with any type, honestly. Save a .SaveEdits/.LoadEdits and all the serialization/de-serialization.