Hi,
I want to save selections like shape border thickness as settings so when the user work with the tool again the last selected thickness should be selected instead of the default value.
How do I approach and solve this?
Best regards
3 Answers, 1 is accepted
0
Hello Frank,
What I can suggest to achieve the desired result would be to define your own custom ShapeTool and provide it with a custom ShapeToolSettings control.
You can the use this custom tool and set its StrokeSize manually.
You can then choose how to persist the StrokeSize property depending on your setup. A possible option would be the PersistenceFramework.
Please let me know whether this helps you in achieving your goal.
Regards,
Dilyan Traykov
Progress Telerik
What I can suggest to achieve the desired result would be to define your own custom ShapeTool and provide it with a custom ShapeToolSettings control.
public
class
CustomShapeToolSettings : ShapeToolSettings
{
public
CustomShapeToolSettings(
double
strokeSize) :
base
()
{
this
.StrokeSize = strokeSize;
}
}
public
class
CustomShapeTool : ShapeTool
{
private
double
strokeSize;
public
double
StrokeSize
{
get
{
return
this
.strokeSize; }
set
{
this
.strokeSize = value;
this
.settingsUI.StrokeSize = value;
}
}
private
readonly
CustomShapeToolSettings settingsUI;
public
CustomShapeTool()
{
this
.settingsUI =
new
CustomShapeToolSettings(
this
.StrokeSize);
}
public
override
UIElement GetSettingsUI()
{
return
this
.settingsUI;
}
}
You can the use this custom tool and set its StrokeSize manually.
<
telerik:ImageToolItem
ImageKey
=
"Shape"
telerik:LocalizationManager.ResourceKey
=
"ImageEditor_Shape"
Command
=
"commands:ImageEditorRoutedCommands.ExecuteTool"
>
<
telerik:ImageToolItem.CommandParameter
>
<
local:CustomShapeTool
StrokeSize
=
"5"
>
<
local:CustomShapeTool.Shapes
>
<
myShapes:TelerikLogo
/>
<
shapes:RectangleShape
/>
<
shapes:EllipseShape
/>
<
shapes:LineShape
/>
</
local:CustomShapeTool.Shapes
>
</
local:CustomShapeTool
>
</
telerik:ImageToolItem.CommandParameter
>
</
telerik:ImageToolItem
>
You can then choose how to persist the StrokeSize property depending on your setup. A possible option would be the PersistenceFramework.
Please let me know whether this helps you in achieving your goal.
Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Frank
Top achievements
Rank 1
answered on 28 Aug 2019, 05:09 AM
[quote]
<
telerik:ImageToolItem
ImageKey
=
"Shape"
telerik:LocalizationManager.ResourceKey
=
"ImageEditor_Shape"
Command
=
"commands:ImageEditorRoutedCommands.ExecuteTool"
>
<
telerik:ImageToolItem.CommandParameter
>
<
local:CustomShapeTool
StrokeSize
=
"5"
>
<
local:CustomShapeTool.Shapes
>
<
myShapes:TelerikLogo
/>
<
shapes:RectangleShape
/>
<
shapes:EllipseShape
/>
<
shapes:LineShape
/>
</
local:CustomShapeTool.Shapes
>
</
local:CustomShapeTool
>
</
telerik:ImageToolItem.CommandParameter
>
</
telerik:ImageToolItem
>
[/quote]
With this code it is possible for me to set the strokesize manually but the combobox with the shapes (rectangle, ellipse,...) is empty now. I can't select any shape.
This is my Code:
<
telerik:ImageToolItem
ImageKey
=
"Shape"
Command
=
"commands:ImageEditorRoutedCommands.ExecuteTool"
telerik:LocalizationManager.ResourceKey
=
"ImageEditor_Shape"
>
<
telerik:ImageToolItem.CommandParameter
>
<
CusShapes:MyShapeTool
x:Name
=
"shapeTool"
>
<
CusShapes:MyShapeTool.Shapes
>
<
shapes:RectangleShape
/>
<
shapes:EllipseShape
/>
<
shapes:LineShape
/>
</
CusShapes:MyShapeTool.Shapes
>
</
CusShapes:MyShapeTool
>
</
telerik:ImageToolItem.CommandParameter
>
</
telerik:ImageToolItem
>
0
Hi Frank,
Please excuse me for overlooking this.
You will need to add one more line to the CustomShapeTool constructor for everything to work as expected:
public CustomShapeTool()
{
this.settingsUI = new CustomShapeToolSettings(this.StrokeSize);
this.GetType().BaseType.GetField("settingsUI", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(this, this.settingsUI);
}
Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.