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

How to change shape bounds's minheight when resizeing

5 Answers 92 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
rui
Top achievements
Rank 1
rui asked on 12 Jun 2018, 01:45 AM

The shape's minheight is 60, The name of the object displays on the bottom of the shape, when  zoom out the  shape,  the name string may word wrap,  so the shape's minheight  is increase by a new line's height,   but when resizeing, the minheight of the bounds is not change,

how to solve this problem?

thanks!

5 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Jun 2018, 12:22 PM
Hello rui,

Thank you for the provided picture.

I am not familiar with your application set-up but I am assuming that you are changing the MinHeight of the shape in ZoomChanged event. Correct me if I am wrong. What I can suggest you is to subscribe to the SizeChangedEvent and change the MinHeight of the shapes. Check the following code snippets.
public MainWindow()
{
    InitializeComponent();
    EventManager.RegisterClassHandler(typeof(RadDiagramShape), RadDiagramShape.SizeChangedEvent,new RoutedEventHandler(OnSizeChanged));
}
 
private void OnSizeChanged(object sender, RoutedEventArgs e)
{
    var diagramShape = sender as RadDiagramShape;
    diagramShape.MinHeight = 90;
}

Hope this approach will work in your main application.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
rui
Top achievements
Rank 1
answered on 15 Jun 2018, 01:59 AM

Hi Dinko,

Thanks for your reply, I think I didn't describe it clearly

The shape's MinHeight changed correct,but the MinHeight  of  resizeing bounds(the dotted rectangle in the attached second picture) is not change, the MinHeight of the bounds seems fixed at the beginning of resize,  the related code  as follows:

<Style x:Key="SquidShapeStyle"
           TargetType="telerik:RadDiagramShape">
        ...
        <Setter Property="MinHeight"
                Value="{Binding MinHeight}" />
        <Setter Property="MinWidth"
                Value="{Binding MinWidth}" />
      ...
    </Style>

this.diagram.ServiceLocator.Register<IResizingService>( new CustomResizingService(this.diagram));

public class CustomResizingService : ResizingService
    {
        List<IDiagramItem> _selectedItems;
        public CustomResizingService(RadDiagram owner)
            : base(owner as IGraphInternal)
        {
            Resizing += CustomResizingService_Resizing;
        }
        public override void InitializeResize(IEnumerable<IDiagramItem> newSelectedItems, double adornerAngle, Rect adornerBounds, ResizeDirection resizingDirection, Point startPoint)
        {
            _selectedItems = newSelectedItems.ToList();
            base.InitializeResize(newSelectedItems, adornerAngle, adornerBounds, resizingDirection, startPoint);
        }
        }

        void CustomResizingService_Resizing(object sender, ResizingEventArgs e)
        {
            foreach (var item in _selectedItems)
            {
                var shape = item as RadDiagramShape;
                if (shape == null) continue;
                var squidNode = shape.DataContext as SquidNode;
                squidNode.Squid.Location_x = (int)item.Bounds.X;
                squidNode.Squid.Location_y = (int)item.Bounds.Y;
                squidNode.Squid.Squid_width = item.Bounds.Width;
                squidNode.Squid.Squid_height = Math.Max(item.Bounds.Height, squidNode.MinHeight);
                
            }
        }
    }

0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Jun 2018, 01:36 PM
Hello rui,

Thank you for the provided code snippet. Can you try setting the mode of the MinHeight and MinWidth binding to TwoWay? 
<Style x:Key="SquidShapeStyle" TargetType="telerik:RadDiagramShape">
    <Setter Property="MinHeight" Value="{Binding MinHeight,Mode=TwoWay}" />
    <Setter Property="MinWidth" Value="{Binding MinWidth,Mode=TwoWay}" />
</Style>

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
rui
Top achievements
Rank 1
answered on 20 Jun 2018, 01:32 AM
Hi Dinko,
Thanks for your reply, The problem still exists.
0
Dinko | Tech Support Engineer
Telerik team
answered on 22 Jun 2018, 12:30 PM
Hi rui,

I think I will need additional information in order to better understand your scenario. From the attached pictures in your first reply, I can see that you had use custom shape or you have a custom style for that shape. Can you send me the template of the custom shape or any custom style which you have applied to the shape? This way I could try to reproduce this visuazalition on my side. Also, can you confirm that you are using the latest version of our controls? 

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Diagram
Asked by
rui
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
rui
Top achievements
Rank 1
Share this question
or