Page Index Toggle Pages: 1 2 3 [4] 5  Send TopicPrint
Very Hot Topic (More than 25 Replies) Starting with a Default Node (Read 28480 times)
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #45 - Aug 19th, 2011 at 12:15pm
Print Post  
The link's end points and the node's position's stay exactly the same. It may look like there are differences but that comes from the choosing a slightly different cut-out in the Paint program.

The diagonal segments vanish when I call diagram.RouteAllLinks().
The diagonal segments appear when I call
diagram.LinkRouter.RouteLinks(CollectionOfRecreatedLinks).

When I move a second unconnected DiagramNode to a position where some DiagrammLinks are already the DiagrammLinks must find new Routes. Then sometimes LinkCrossings reside or do not appear where they should.

I also have a problem when there are more than one DiagramLinks leaving an AnchorPoint. Sometimes I get ugly arcs sometimes not.

This is how I would like to see it (watch the two DiagramLinks with the left lower AnchorPoint on the side as origin):


When I add another DiagramLink it leaves the other one with an arc (hard to see in this resolution):


Whenever DiagramLinks have the same AnchorPoint as origin I would like them to interact without arcs.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #46 - Aug 19th, 2011 at 3:22pm
Print Post  
Are you sure you are not setting ControlPoints before or after calling Route? If you are setting it before Route() and still getting diagonal lines, make sure you also call UpdateFromPoints.

Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #47 - Aug 19th, 2011 at 3:45pm
Print Post  
No, I am not setting ControlPoints.

Imagine I have MyTableNodes on the left and on the right side (like in the pictures above). I have a user interaction that adds or removes Rows from MyTableNode. So some AnchorPoints are not there anymore others may have changed their position.

1. I collect the existing DiagramLinks by saving GUIDs that I always have stored in the AnchorPoint.Tag of the MyTableNode.Row.AnchorPatterns and the MyTemplatedNodes.AnchorPatterns.
2. I remove the DiagramLinks.
3. I reorganize the MyTableNodes which now may consist of old Rows and new Rows respectivly. This is done due to a user interaction. I remove all Rows and Add Rows again with the same GUIDs in the AnchorPoint.Tag.
4. I recreate the old DiagramLinks whenever I find the two AnchorPoints defined by the two GUIDs I have saved.

It does not make sense for me to save ControlPoints because everything may be mixed up. The DiagramLinks must be reroutet from scratch.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #48 - Aug 22nd, 2011 at 6:23am
Print Post  
The only way I could reproduce diagonal lines is by adding or removing new table rows *after* routing the links. That shifts the link end points up or down, but not the next-to-last ones when using polyline links, so you get diagonal segments. If you think it's a different problem, email a test project that reproduces it to support@mindfusion.eu and we'll investigate.

Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #49 - Aug 22nd, 2011 at 4:10pm
Print Post  
Hi Stoyan,

I will work out a sample for you to see the diagonal links. But that may take some time. Hopefully I can do it this week.

I have a problem with my TemplatedNode:


You can see the node with three AnchorPoints as circles and the text "Plus".
I set the TextBrush to black but I always get the text in white color instead.

What do I do wrong?

Code
Select All
            Brush = System.Windows.Media.Brushes.Green;

            FontSize = 12.0;
            FontStyle = FontStyles.Normal;
            FontFamily = new FontFamily("Arial");

            TextAlignment = System.Windows.TextAlignment.Center;
            TextVerticalAlignment = AlignmentY.Center;

            Text = "Plus";
            TextBrush = System.Windows.Media.Brushes.Black;

            Stroke = System.Windows.Media.Brushes.Black;
            StrokeThickness = 1.0;
 



Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #50 - Aug 22nd, 2011 at 6:14pm
Print Post  
Hi,

What does your node template look like?

Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #51 - Aug 23rd, 2011 at 7:24am
Print Post  
Hi,

curently I am not using any TemplatedNode.Template.
So the diagrams NodeTemplate should be in effect.
Since I also do not have any diagram.NodeTemplate the default should be a TextBlock inside a border.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #52 - Aug 23rd, 2011 at 8:01am
Print Post  
Hi,

The default template is a TextBlock with binding only to the Text property; it's just a placeholder and not intended to use it directly. When you create your template, you can add Foreground="{Binding TextBrush}" to textblocks to draw their text content using TextBrush.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #53 - Aug 29th, 2011 at 2:38pm
Print Post  
Hi Stoyo,

maybe I was a little simple-hearted regarding the Template.

So I worked out an own DataTemplate for testing purpose that is related to MyTemplatedNode:

Code
Select All
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:MindFusionProject">

    <Style TargetType="local:MyTemplatedNode">
        <Setter Property="Template">
            <Setter.Value>
                <DataTemplate DataType="local:MyTemplatedNode">
                    <Border
                        BorderBrush="{Binding Stroke}"
                        BorderThickness="{Binding StrokeThickness}"
                        Background="{Binding Brush}">
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary> 



The corresponding class looks like:
Code
Select All
namespace MindFusionProject
{
    public class MyTemplatedNode: TemplatedNode
    {

        static MyTemplatedNode()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(MyTemplatedNode), new FrameworkPropertyMetadata(typeof(MyTemplatedNode)));
        }

        public MyTemplatedNode(MyTemplatedNode prototype)
            : base(prototype)
        {
        }

        public Brush BorderBrush
        {
            get { return (Brush)GetValue(BorderBrushProperty); }
            set { SetValue(BorderBrushProperty, value); }
        }

        public static readonly DependencyProperty BorderBrushProperty = DependencyProperty.Register(
            "BorderBrush",
            typeof(Brush),
            typeof(MyTemplatedNode),
            new FrameworkPropertyMetadata(Brushes.Green, FrameworkPropertyMetadataOptions.AffectsRender));

        public double BorderThickness
        {
            get { return (double)GetValue(BorderThicknessProperty); }
            set { SetValue(BorderThicknessProperty, value); }
        }

        public static readonly DependencyProperty BorderThicknessProperty = DependencyProperty.Register(
            "BorderThickness",
            typeof(double),
            typeof(MyTemplatedNode),
            new PropertyMetadata(1.0));

        public Brush Background
        {
            get { return (Brush)GetValue(BackgroundProperty); }
            set { SetValue(BackgroundProperty, value); }
        }

        public static readonly DependencyProperty BackgroundProperty = DependencyProperty.Register(
            "Background",
            typeof(Brush),
            typeof(MyTemplatedNode),
            new FrameworkPropertyMetadata(Brushes.Green, FrameworkPropertyMetadataOptions.AffectsRender));

        public MyTemplatedNode()
        {
            //Stroke = System.Windows.Media.Brushes.Red;
            //StrokeThickness = 5.0;
            //Brush = System.Windows.Media.Brushes.Green;

            BorderBrush = Brushes.Red;
            BorderThickness = 5.0;
            Background = Brushes.Green;
        }
    }

        private void diagram_Loaded(object sender, RoutedEventArgs e)
        {
                var node = new MyTemplatedNode
                {
                    Bounds= new Rect (200,200,200,200),

                    BorderBrush = Brushes.Red,
                    BorderThickness = 5.0,
                    Background = Brushes.Green,

                    //Stroke = Brushes.Red,
                    //StrokeThickness = 5.0,
                    //Brush = Brushes.Green,
                };

                diagram.Nodes.Add(node);
        }
}
 



Just for testing I want to see a green Rect with a red border of 5.0 thickness.

But I always get a white Rect with a black border of 1.0 thickness unless I uncomment the
three lines in the diagram_Loaded where I set the properties directly instead of using the bounded methods.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #54 - Aug 29th, 2011 at 2:55pm
Print Post  
Hi Pontius,

I think this happens because the node already has local values for these properties, and local values have higher priority than what's defined as default in the property metadata. You could call the ClearStyleableProperties method from your constructor to remove local values for all Stroke, Brush, Text and Font properties, and kind of start with a clean canvas. Then they will derive values from your dependency property declarations or from styles. Alternatively, you can call the ClearValue method to remove individual local values.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #55 - Aug 29th, 2011 at 3:28pm
Print Post  
Hi Stoyo,

changing my constructor to
Code
Select All
       public MyTemplatedNode()
        {
            ClearStyleableProperties();
        }
 



and implementing
Code
Select All
        private void diagram_Loaded(object sender, RoutedEventArgs e)
        {
                var node = new MyTemplatedNode
                {
                    Bounds= new Rect (200,200,200,200),
                };


               node.BorderBrush = Brushes.Red,
               node.BorderThickness = 5.0,
               node.Background = Brushes.Green,

               diagram.Nodes.Add(node);
        }
 



doesn't have any effect.
The node ist still white with a black border.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #56 - Aug 29th, 2011 at 4:33pm
Print Post  
Sorry, I haven't noticed you are trying to show custom properties. I think the probelm is that the template does not bind to your own properties, but to the standard ones derived from DiagramNode:

BorderBrush="{Binding Stroke}"
BorderThickness="{Binding StrokeThickness}"
Background="{Binding Brush}"

You must change the Binding expressions to

BorderBrush="{Binding BorderBrush}"
BorderThickness="{Binding BorderThickness}"
Background="{Binding Background}"

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #57 - Aug 30th, 2011 at 8:34am
Print Post  
Hi Stoyo,

isn't there something missing like
           Template = new DataTemplate("local:MyTemplatedNode");
in the contructor of MyTemplatedNode?
I didn't find that in the tutorial 3 but I wonder how the MyTemplatedNode knows which XAML file it corresponds to.

Regarding your last hint, in my first shot I just want to use a simple XAML description where I use different properties like "Fill" instead of "Brush" (like in the tutorial3):
                            Fill="{Binding Brush}"

After this works the next step might be to create new selfdefined properties.

Regards,
Pontius
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Starting with a Default Node
Reply #58 - Aug 30th, 2011 at 8:50am
Print Post  
Hi Pontius,

The DefaultStyleKeyProperty.OverrideMetadata sets the default style for all MyTemplatedNode instances. You can also assign distinct styles to the Style property of individual nodes.

Such rows in the Xaml define that a property of a visual element from the template, specified on the left side, is bound to a property of the node, which is on the right side:

Fill="{Binding Brush}"

So the visual element must have a Fill property, and I think only the Rectangle and other classes derived from Shape have it. Most of the other WPF framework elements have a Background property. And then your node class must define the property on the right side, or inherit it (in this case Brush is derived from DiagramItem).

In your older example, setting node.BorderBrush = Brushes.Red did not work because the binding Expression created binding to the Brush property instead of BorderBrush.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Pontius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 51
Joined: May 13th, 2011
Re: Starting with a Default Node
Reply #59 - Aug 30th, 2011 at 10:41am
Print Post  
Hi Stoyo,

I'm sorry for asking that elementary questions...

Yes I just copied from the tutorial3.
There is the Rectangle in the DataTemplate:
Code
Select All
                        <Rectangle
                            Stroke="{Binding Stroke}"
                            Fill="{Binding Brush}" /> 



When writing the DataTemplate myself how can I find out what properties this Rectangle has? From your tutorial3 I can see that it must have a Fill property but without that tutorial? I do not see a Rectangle in the MindFusion reference. I only see some similiar things like ImageRectangle in the Shape class. In the tutorial3 there are descriptions of both a Rectangle and an Image.

How can I write my own DataTemplate with knowing and not only guessing whats right and whats wrong?

Regards,
Pontius
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 2 3 [4] 5 
Send TopicPrint