[longomatch] Do not allow duplicated links



commit a06d0dfa620e6b4257e4fa36ebd4eba2fabbb25c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Apr 22 12:07:14 2015 +0200

    Do not allow duplicated links

 .../CanvasObjects/Dashboard/ActionLinkObject.cs    |   18 ++++++++++++++++++
 LongoMatch.Drawing/Widgets/DashboardCanvas.cs      |    2 +-
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs 
b/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
index bca77ea..838741a 100644
--- a/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/Dashboard/ActionLinkObject.cs
@@ -97,6 +97,24 @@ namespace LongoMatch.Drawing.CanvasObjects.Dashboard
                        stop = line.Stop;
                }
 
+               public bool CanLink (LinkAnchorObject dest)
+               {
+                       /* Check if the link is possible between the 2 types of anchors */
+                       if (!Source.CanLink (dest)) {
+                               return false;
+                       }
+
+                       /* Check if this link will result into a duplicated link */
+                       foreach (ActionLink link in Source.Button.Button.ActionLinks) {
+                               if (link.DestinationButton == dest.Button.Button &&
+                                   link.SourceTags.SequenceEqualSafe (Source.Tags) &&
+                                   link.DestinationTags.SequenceEqualSafe (dest.Tags)) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+
                public override void Draw (IDrawingToolkit tk, Area area)
                {
                        Color lineColor;
diff --git a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
index f2beb63..4f043ff 100644
--- a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
+++ b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
@@ -241,7 +241,7 @@ namespace LongoMatch.Drawing.Widgets
                                                destAnchor.Highlighted = false;
                                        }
                                        /* Only highlight valid targets */
-                                       if (link.Source.CanLink (anchor)) {
+                                       if (link.CanLink (anchor)) {
                                                anchor.Highlighted = true;
                                                destAnchor = anchor;
                                        } else {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]