SpotPanel Issu

I created a Mydata object with : Spot=Spot.MiddleRight

In my class Mydata, I have :

private Spot _spot1 = Spot.None;

public Spot Spot
{
get { return _spot1; }
set
{
Spot old = _spot1;
if (old != value)
{
_spot1 = value;
RaisePropertyChanged(“Spot”, old, value);
}
}
}

Then I juste try to modify the position of my spot to middleleft instead of middleright with :

foreach (Node node in myDiagram.SelectedParts)
{
MyData data = node.Data as MyData;

            myDiagram.StartTransaction("Adding spots");
            Spot spot = Spot.MiddleLeft;
            data.Spot = spot;
            myDiagram.CommitTransaction("Adding spots");
        }

But my spot is still at MiddleRight on my diagram…
Could you tell me what am I doing wrong? :S

Thx again for your help

I have an other issu, I created several spot on my node but I can never attach my link on TopLeft Spot, TopRight Spot… Event MiddleTop…

Sometimes my link can’t be attach to the spot and sometimes I can but in this case, my link attach itselp to the middleBotom Spot…

Here is the code in my node :





I found why I had the second issu but if you could tell me what’s wrong in the first one I will be gratefull :)

You really ought to combine the transactions by surrounding the whole loop with the calls to StartTransaction and CommitTransaction, rather than having N separate transactions.

How did you data-bind to your MyData.Spot property?

Yes, it would be better but it should work, no?

I create this in my node :

            <Rectangle Fill="Violet" Width="4" Height="4"
             go:SpotPanel.Spot="{Binding Path=Data.Spot, Mode=TwoWay}" go:SpotPanel.Alignment="{Binding Path=Data.Spot, Mode=TwoWay}"
             go:Node.PortId="T" go:Node.LinkableFrom="True" go:Node.LinkableTo="True" Cursor="Hand"
             go:Node.FromSpot="{Binding Path=Data.Spot, Mode=TwoWay}" go:Node.ToSpot="{Binding Path=Data.Spot, Mode=TwoWay}" />

It isn’t clear to me what you want to do.

Probably you don’t need Mode=TwoWay, but that depends on whether you expect to change it in code and have it automatically update the bound MyData object.

Your links are actually connected to the node with a port parameter of “T”, yes?

I would like to be able to do that :

I want to create a spot and then bind his position with the position I
get with GetLinkPointFromPoint function in order to put the spot on my
shape borders.

I first start creating a spot on MiddleTop and I would like to change his position with this code :

foreach (Node node in myDiagram.SelectedParts)
{
MyData data = node.Data as MyData;

            myDiagram.StartTransaction("Adding spots");
            Spot spot = Spot.MiddleLeft;
            data.Spot = spot;
            myDiagram.CommitTransaction("Adding spots");
        }

But the spot is always on MiddleTop position…

I finally succeded but now I would like to set X and Y instead of Spot.MiddleLeft, Spot.MiddleTop…

I tried to do this :

MyData data = node.Data as MyData;

Point pointLocalisation = node.Location;
double localisation_x = pointLocalisation.X;
double localisation_y = pointLocalisation.Y;

CustomRoute route = new CustomRoute();

Point pointSpot = route.CustomGetLinkPointFromPoint(node,
node.Port,
new Point(localisation_x, localisation_y),
new Point(localisation_x + 100, localisation_y),
true);

Spot spot = data.Spot;
spot.X = pointSpot.X;
spot.Y = pointSpot.Y;
data.Spot = spot;

But I am not sure this is the way to set X and Y…
Should I do it like this?

I saw this in your  API Reference manuals, if I change 0.7, Y change and if I change -20, my spot change on the X axe. But I don't understand what 1 and 0 are... :$
            

I finally succeded, I have always one issu, my diagram doesn’t actualize itself… I have to click on my node to see the new spot… I don’t know how to solve this…

Thx again for your help

I was going to suggest reading about the Spot structure, which provides a way of computing a point in a rectangular area based on relative/fractional positioning plus absolute offsets.

I still don’t understand what you are trying to do, so it’s hard for me to provide useful suggestions. I don’t know if you are trying to modify the node by adding elements acting as ports at certain positions specified by Spot values, or if you just want to modify a link by setting its Route’s FromSpot or ToSpot so that it (and it alone) connects to a port at a particular position.

Here is what I wanted to do :

As you can see, after using my fonction, my spot are now on my figure borders :)

I create these in my xaml, then, in my MainPage.xaml.cs I create a function that set the position of my spots :




The only issu I still have is that I have to click on my node to see the new position of my spots… The new position is actualized after clicking on my node… It’s just a displaying issu but I can’t find how to solve it…

Are you performing all modifications to the model or to any of its data in a transaction?

I create a transaction as you can see here :

myDiagram.StartTransaction(“Adding spots”);
foreach (Node node in myDiagram.Nodes)
{

}
myDiagram.CommitTransaction(“Adding spots”)

Did I answer your question? :$

I haven’t had time to look into this, so I can’t explain why it’s not working for you. Maybe you can get around the problem by calling Part.Remeasure() on each Node that you have modified.

Thx a lot :)