This is a migrated thread and some comments may be shown as answers.

Custom Shape Resizing

3 Answers 159 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Hilary
Top achievements
Rank 1
Hilary asked on 20 Nov 2014, 08:09 PM
Is there a way to prevent vertical resizing on a specific custom shape? 

The IsResizingEnabled property is specific to a shape, but disables all resizing. Creating a custom ResizingService appears to apply to the entire diagram and all the shapes. Basically we have a text shape and want to be able to size it horizontally and left/center/right align -> all working. But not allow vertical resizing – the text is vertically aligned to the top and does not wrap.

3 Answers, 1 is accepted

Sort by
0
Accepted
Zarko
Telerik team
answered on 25 Nov 2014, 01:28 PM
Hi Hilary,
The easiest way to do this will be to use a custom resizing service and just check if there's a TextShape in the currently resized shapes:
protected override Point CalculateNewDelta(Point newPoint)
{
    var newDelta = base.CalculateNewDelta(newPoint);
    var textShapes = this.resizingItems.Any(i => i is RadDiagramTextShape);
    return new Point(newDelta.X, textShapes ? 0 : newDelta.Y);
}
I've attached a sample project demonstrating this so you could test it and see if this is what you're looking for.

Regards,
Zarko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Hilary
Top achievements
Rank 1
answered on 01 Dec 2014, 02:03 PM
Thanks Zarko, that works. However prior to making a manual resize, if you change the text content or the font size the shape will resize horizontally and vertically as needed. A sort of Auto-fit. Once you manually resize the textbox that no-longer happens, so if you set a larger font the height won’t adjust to fit.

How do you recommend solving this? And is it possible to turn the auto-fit back on? 
0
Accepted
Zarko
Telerik team
answered on 01 Dec 2014, 04:04 PM
Hello Hilary,
Prior to a manual resize a shape's width (and height) is double.NaN and because of this the actual size comes from its content (a string in the default case). Once you resize a shape its width becomes a number and this "turns off" the auto-fit to turn it on again you'll have to change the size to double.NaN:
private void Button_Click(object sender, RoutedEventArgs e)
{
    this.shape.Width = double.NaN;
    this.shape.Height = double.NaN;
}
I hope I was able to help you.

Regards,
Zarko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Diagram
Asked by
Hilary
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Hilary
Top achievements
Rank 1
Share this question
or