Completed
Last Updated: 09 Nov 2016 13:50 by ADMIN
ADMIN
Hristo
Created on: 14 Oct 2016 11:11
Category: Diagram, DiagramRibbonBar, DiagramToolBox
Type: Bug Report
1
FIX. RadDiagram - scrollbars are not updated correctly after calling the BringIntoView method for an item outside of the viewport
How to reproduce: 

 public partial class Form1 : Form
 {
     public Form1()
     {
         InitializeComponent();

         RadDiagramShape shape1 = new RadDiagramShape()
         {
             Text = "Second Level Domain",
             ElementShape = new RoundRectShape(4),
             BackColor = Color.LimeGreen
         };
         shape1.Position = new Telerik.Windows.Diagrams.Core.Point(100, 100);
         radDiagram1.Items.Add(shape1);

         var res = radDiagram1.Items[0];
         ((Telerik.WinControls.UI.Diagrams.RadDiagramItem)shape1).EndEdit += item_EndEdit;

         RadDiagramShape shape2 = new RadDiagramShape()
         {
             Text = "Top Level Domain",
             ElementShape = new RoundRectShape(50),
             BackColor = Color.Cyan
         };
         shape2.Position = new Telerik.Windows.Diagrams.Core.Point(1600, 100);

         radDiagram1.Items.Add(shape2);

         RadDiagramShape shape3 = new RadDiagramShape()
         {
             Text = "Organization Domain",
             ElementShape = new RoundRectShape(20),
             BackColor = Color.Yellow
         };
         shape3.Position = new Telerik.Windows.Diagrams.Core.Point(2400, 100);
         radDiagram1.Items.Add(shape3);

         RadDiagramConnection connection1 = new RadDiagramConnection() { Name = "connection1" };
         connection1.Source = shape1;
         connection1.Target = shape2;
         radDiagram1.Items.Add(connection1);

         RadDiagramConnection connection2 = new RadDiagramConnection()
         {
             Name = "connection2"
         };
         connection2.Source = shape2;
         connection2.Target = shape3;
         radDiagram1.Items.Add(connection2);
     }

     private void item_EndEdit(object sender, Telerik.WinControls.UI.Diagrams.RadRoutedEditEventArgs e)
     {
         RadDiagramShape shape = ((RadDiagramShape)sender);
         string txt = shape.Text;
         Size size = TextRenderer.MeasureText(txt, shape.Font, new System.Drawing.Size( (int)shape.Width, int.MaxValue ), ~TextFormatFlags.SingleLine);

         shape.Height = size.Height;
     }

     private void radButton1_Click(object sender, EventArgs e)
     {
         this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[0], this.radDiagram1.Zoom, false);
     }

     private void radButton2_Click(object sender, EventArgs e)
     {
         this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[1], this.radDiagram1.Zoom, false);
     }

     private void radButton3_Click(object sender, EventArgs e)
     {
         this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[2], this.radDiagram1.Zoom, false);
     }
 }

Workaround:  manually update the view
private void radButton1_Click(object sender, EventArgs e)
{
    this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[0], this.radDiagram1.Zoom, false);
    this.radDiagram1.DiagramElement.Controller.OnViewportChanged();
}

private void radButton2_Click(object sender, EventArgs e)
{
    this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[1], this.radDiagram1.Zoom, false);
    this.radDiagram1.DiagramElement.Controller.OnViewportChanged();
}

private void radButton3_Click(object sender, EventArgs e)
{
    this.radDiagram1.DiagramElement.BringIntoView(radDiagram1.Items[2], this.radDiagram1.Zoom, false);
    this.radDiagram1.DiagramElement.Controller.OnViewportChanged();
}

0 comments