Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic highlight effect for custom node (not container node) (Read 1440 times)
Vincent
Junior Member
**
Offline


I Love MindFusion!

Posts: 62
Joined: Oct 3rd, 2013
highlight effect for custom node (not container node)
Nov 7th, 2013 at 2:28pm
Print Post  
Hi,

I want to show a highlighted part of a node when another node is being dragged close to it.

So far, I've done that by adding the following method to UpdateModify and CompleteModify of the node
Code
Select All
protected virtual void HighlightConnectionPointOfClosestNode(Point current, InteractionState ist)
        {
            if (ist.AdjustmentHandle == 8)
            {
                var nearbyNode = Parent.GetNearestNode(current, 25, this);
                if (nearbyNode != null && nearbyNode is BR_Shape)
                {
                    BR_Shape nearby_Node = nearbyNode as BR_Shape;
                    nearby_Node.highlightConnectionPoint();
                }
                else
                {
                    doNotHighlightConnectionPoint();
                }
            }
        }
 



The other methods needed are
Code
Select All
bool shouldHighlight = false;

private void highlightConnectionPoint()
        {
            shouldHighlight = true;
            Repaint();
        }

        private void doNotHighlightConnectionPoint()
        {
            shouldHighlight = false;
            Repaint();
        }
 



In the override of Draw I have
Code
Select All
double highlightmargin = 2;
            bottomFittingCorner = new PathFigure(new Point(width, height + highlightmargin), new[]
                {
                    new LineSegment(new Point(15, height + highlightmargin), true),
                    new LineSegment(new Point(10, height-7 + highlightmargin), true),
                    new LineSegment(new Point(5, height + highlightmargin), true),
                    new LineSegment(new Point(0, height + highlightmargin), true),
                    new LineSegment(new Point(10, height-7 + highlightmargin), false),
                    new LineSegment(new Point(15, height + highlightmargin), false)
                }, false);

            if (shouldHighlight)
            {
                graphics.DrawGeometry(Brush, drawingPen, shape);
                drawingPen = new Pen(Brushes.White, StrokeThickness * 3);
                var highlightedShape = new PathGeometry();
                highlightedShape.Figures.Add(bottomFittingCorner);
                graphics.DrawGeometry(Brushes.Transparent, drawingPen, highlightedShape);
            }
            else
            {
                graphics.DrawGeometry(Brush, drawingPen, shape);
            }
 



When I drag a node close, the highlighted part is shown but when I drag the node away, the other node does not go back to the default shape (without highlighting). Any ideas why this is happening?

Thanks in advance!

Vincent
  
Back to top
 
IP Logged
 
Vincent
Junior Member
**
Offline


I Love MindFusion!

Posts: 62
Joined: Oct 3rd, 2013
Re: highlight effect for custom node (not container node)
Reply #1 - Nov 7th, 2013 at 2:38pm
Print Post  
Never mind, I saw that I wasn't calling doNotHighlightConnectionPoint() on the nearbyNode. xD

I changed the method to
Code
Select All
protected virtual void HighlightConnectionPointOfClosestNode(Point current, InteractionState ist)
        {
            if (ist.AdjustmentHandle == 8)
            {
                var nearbyNode = Parent.GetNearestNode(current, 25, this);
                if (nearbyNode != null && nearbyNode is BR_Shape)
                {
                    BR_Shape nearby_Node = nearbyNode as BR_Shape;
                    nearby_Node.highlightConnectionPoint();
                }
                else
                {
                    UIElement parent = this.Parent as UIElement;
                    MC_Diagram parentDiag = null;
                    if (parent != null)
                        parentDiag = parent as MC_Diagram;

                    if (parentDiag != null)
                    {
                        foreach (BR_Shape s in parentDiag.Content)
                        {
                            s.doNotHighlightConnectionPoint();
                        }
                    }
                }
            }
        }
 



Greets,

Vincent
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint