Custom Shape Resizing

4 posts, 2 answers
  1. Hilary
    Hilary avatar
    5 posts
    Member since:
    Oct 2014

    Posted 20 Nov 2014 Link to this post

    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.
  2. Answer
    Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 25 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Hilary
    Hilary avatar
    5 posts
    Member since:
    Oct 2014

    Posted 01 Dec 2014 in reply to Zarko Link to this post

    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? 
  5. Answer
    Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 01 Dec 2014 Link to this post

    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.

     
Back to Top