I am running into an odd behavior that I have been able to reproduce in a simple example.
This example draws 2 squares and a circle and has 3 buttons.
Clicking button1 I create a connection between the circle and square1 and smartRefreshView.
Clicking button2 I modify the connection between the circle and square1 so it connects to square2 instead, and smartRefreshView.
Clicking button3 I perform an HistoryService Undo and smartRefreshView.
The expected behavior was that after clicking button3 the connector would be back to square1. At first it doesn't appear to have worked. The connector is still showing connected to square2.
However, if you select the circle and move it a pixel or 2, the connector will suddenly redraw to show connected to square1 as it should.
It appears the SmartRefresh did not succeed. At the model level it appears the Undo succeeded but the NLineShape failed to redraw.
Is there something I am missing here? Is there a work around?
(See example code below....)
Thanks in advance for your time.
Jason Irby
using
System;using
System.Windows.Forms;using
Nevron.Diagram;using
Nevron.Diagram.Shapes;using
Nevron.GraphicsCore;namespace
ConnectorExample{
public partial class Form1 : Form{
NDrawingDocument drawingDoc = new NDrawingDocument();private NShape square1;private NShape square2;private NShape circle;private NLineShape edge; public Form1(){
InitializeComponent();
this.nDrawingView1.Document = this.drawingDoc;}
private void Form1_Load(object sender, EventArgs e){
NBasicShapesFactory f = new NBasicShapesFactory(drawingDoc);f.DefaultSize =
new NSizeF(100, 100);square1 = f.CreateShape(
BasicShapes.Rectangle);square1.Location =
new NPointF(50, 50);drawingDoc.ActiveLayer.AddChild(square1);
square2 = f.CreateShape(
BasicShapes.Rectangle);square2.Location =
new NPointF(250, 50);drawingDoc.ActiveLayer.AddChild(square2);
circle = f.CreateShape(
BasicShapes.Circle);drawingDoc.ActiveLayer.AddChild(circle);
circle.Location =
new NPointF(200, 200);}
private void button1_Click(object sender, EventArgs e){
this.drawingDoc.HistoryService.StartTransaction("connectSq1");this.edge = new NLineShape();this.drawingDoc.ActiveLayer.AddChild(edge);this.edge.ToShape = this.circle;this.edge.FromShape = this.square1;this.drawingDoc.HistoryService.Commit();this.drawingDoc.SmartRefreshAllViews();}
private void button2_Click(object sender, EventArgs e){
this.drawingDoc.HistoryService.StartTransaction("connectSq2");this.edge.FromShape = this.square2;this.drawingDoc.HistoryService.Commit();this.drawingDoc.SmartRefreshAllViews();}
private void button3_Click(object sender, EventArgs e){
this.drawingDoc.HistoryService.Undo();this.drawingDoc.SmartRefreshAllViews();}
}
}