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

Rotation ancor-points problem for RadDiagramShape

3 Answers 12 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Tatiana
Top achievements
Rank 1
Tatiana asked on 24 Oct 2018, 11:06 PM

Hello again!

I am creating custom RadDiagramShape as it is written in Telerik documentation: https://docs.telerik.com/devtools/wpf/controls/raddiagram/howto/create-custom-shape . It contains 2 borders and an image inside of them. When I am doing it according to the documentation, rotation and zoom after rotation works weird with ancor-points of this CustomControl. When I am doing 2 borders and an image inside RadDiagramShape inside xaml without any CustomControl it works as it should.

The picture of weird behaviour is attached (after rotating of both figures).

Would you be so kind to tell me how I can fix this weird behaviour of my CustomControl?

This is my .cs code

public class RasterObject : RadDiagramShapeBase
{
    static RasterObject()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(RasterObject), new FrameworkPropertyMetadata(typeof(RasterObject)));
    }
 
    public static readonly DependencyProperty ContrastyBorderBrushProperty =
         DependencyProperty.Register("ContrastyBorderBrush", typeof(Brush),
         typeof(RasterObject), new FrameworkPropertyMetadata(Brushes.Transparent));
 
    // .NET Property wrapper
    public Brush ContrastyBorderBrush
    {
        get { return (Brush)GetValue(ContrastyBorderBrushProperty); }
        set { SetValue(ContrastyBorderBrushProperty, value); }
    }
 
    public static readonly DependencyProperty SourceProperty =
         DependencyProperty.Register("Source", typeof(ImageSource),
         typeof(RasterObject));
 
    // .NET Property wrapper
    public ImageSource Source
    {
        get { return (ImageSource)GetValue(SourceProperty); }
        set { SetValue(SourceProperty, value); }
    }
 
 
}

This is my style code:

<Style TargetType="{x:Type local:RasterObject}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:RasterObject}">
                <Border BorderBrush="{TemplateBinding ContrastyBorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Image Source="{TemplateBinding Source}" Stretch="Fill"/>
                    </Border>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

This is my Xaml code:

<telerik:RadDiagram  IsBackgroundSurfaceVisible="True">
                                     
                                    <telerik:RadDiagramShape Position="50, 50" Background="Transparent" BorderBrush="Transparent">
                                        <Border BorderBrush="Red" BorderThickness="13" >
                                            <Border BorderBrush="Blue" BorderThickness="23" >
                                                <Image Source="/Images/MainToolbar/Arc.png" Stretch="Fill"/>
                                            </Border>
                                        </Border>
                                    </telerik:RadDiagramShape>
                                    <imageeditor:RasterObject BorderBrush="Gray" BorderThickness="10"
                                                               ContrastyBorderBrush="White"
                                                              Source="/Images/MainToolbar/Arc.png"/>
                                     
 
                                </telerik:RadDiagram>

 

Best regards,
Tatiana

3 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 29 Oct 2018, 11:36 AM
Hello Tatiana,

Thank you for the provided code snippets. Actually, this is a known issue and it is logged in our feedback portal. You can track its status there. 

As a workaround, use RadDiagramShape instead of RadDiagramShapeBase as a base class.
public class RasterObject : RadDiagramShape

Regards,
Martin Ivanov
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
Tatiana
Top achievements
Rank 1
answered on 06 Nov 2018, 08:15 AM

Hello Martin,

Thank you for your answer, but it did not help. There is still a problem with rotation.

0
Martin Ivanov
Telerik team
answered on 06 Nov 2018, 09:21 AM
Hello Tatiana,

I've tested your code with the replace shape base type and the issues it not presented on my side. Can you please give the attached project a try and let me know if I am missing something?

Regards,
Martin Ivanov
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.
Tags
Diagram
Asked by
Tatiana
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Tatiana
Top achievements
Rank 1
Share this question
or