Beispiel #1
0
        protected override void StopMove(bool moved)
        {
            Selection sel = Selections.FirstOrDefault();

            if (movingLink != null)
            {
                if (destAnchor != null)
                {
                    ActionLink link = movingLink.Link;
                    link.DestinationButton = destAnchor.Button.Button;
                    link.DestinationTags   = destAnchor.Tags;
                    link.SourceButton.ActionLinks.Add(link);
                    movingLink.Destination = destAnchor;
                    destAnchor.Highlighted = false;
                    if (ActionLinkCreatedEvent != null)
                    {
                        ActionLinkCreatedEvent(link);
                    }
                    Edited = true;
                }
                else
                {
                    RemoveObject(movingLink);
                    widget.ReDraw();
                }
                ClearSelection();
                movingLink = null;
                destAnchor = null;
                return;
            }

            if (sel != null && moved)
            {
                if (sel.Drawable is DashboardButtonObject)
                {
                    /* Round the position of the button to match a corner in the grid */
                    int             i  = Constants.CATEGORY_TPL_GRID;
                    DashboardButton tb = (sel.Drawable as DashboardButtonObject).Button;
                    tb.Position.X = Utils.Round(tb.Position.X, i);
                    tb.Position.Y = Utils.Round(tb.Position.Y, i);
                    tb.Width      = (int)Utils.Round(tb.Width, i);
                    tb.Height     = (int)Utils.Round(tb.Height, i);
                    (sel.Drawable as DashboardButtonObject).ResetDrawArea();
                    widget.ReDraw();
                }
            }
            base.StopMove(moved);
        }
Beispiel #2
0
 protected override void StartMove(Selection sel)
 {
     if (sel != null && sel.Drawable is LinkAnchorObject)
     {
         LinkAnchorObject anchor = sel.Drawable as LinkAnchorObject;
         ActionLink       link   = new ActionLink {
             SourceButton = anchor.Button.Button,
             SourceTags   = anchor.Tags
         };
         movingLink = new ActionLinkObject(anchor, null, link);
         AddObject(movingLink);
         ClearSelection();
         UpdateSelection(new Selection(movingLink, SelectionPosition.LineStop, 0), false);
     }
     base.StartMove(sel);
 }
Beispiel #3
0
        protected override void SelectionMoved(Selection sel)
        {
            if (sel.Drawable is DashboardButtonObject)
            {
                SizeChanged();
                Edited = true;
            }
            else if (sel.Drawable is ActionLinkObject)
            {
                ActionLinkObject link   = sel.Drawable as ActionLinkObject;
                LinkAnchorObject anchor = null;
                Selection        destSel;

                destSel = GetSelection(MoveStart, true, true);
                if (destSel != null && destSel.Drawable is LinkAnchorObject)
                {
                    anchor = destSel.Drawable as LinkAnchorObject;
                }
                /* Toggled highlited state */
                if (anchor != destAnchor)
                {
                    if (destAnchor != null)
                    {
                        destAnchor.Highlighted = false;
                    }
                    /* Only highlight valid targets */
                    if (link.CanLink(anchor))
                    {
                        anchor.Highlighted = true;
                        destAnchor         = anchor;
                    }
                    else
                    {
                        destAnchor = null;
                    }
                }
            }
            base.SelectionMoved(sel);
        }
Beispiel #4
0
        void LoadTemplate()
        {
            ClearObjects();
            buttonsDict.Clear();

            foreach (TagButton tag in template.List.OfType <TagButton>())
            {
                TagObject to = new TagObject(tag);
                to.ClickedEvent += HandleTaggerClickedEvent;
                to.Mode          = Mode;
                AddButton(to);
            }

            foreach (AnalysisEventButton cat in template.List.OfType <AnalysisEventButton>())
            {
                CategoryObject co = new CategoryObject(cat);
                co.ClickedEvent        += HandleTaggerClickedEvent;
                co.EditButtonTagsEvent += (t) => EditButtonTagsEvent(t);
                co.Mode = Mode;
                AddButton(co);
            }
            foreach (PenaltyCardButton c in template.List.OfType <PenaltyCardButton>())
            {
                CardObject co = new CardObject(c);
                co.ClickedEvent += HandleTaggerClickedEvent;
                co.Mode          = Mode;
                AddButton(co);
            }
            foreach (ScoreButton s in template.List.OfType <ScoreButton>())
            {
                ScoreObject co = new ScoreObject(s);
                co.ClickedEvent += HandleTaggerClickedEvent;
                co.Mode          = Mode;
                AddButton(co);
            }

            foreach (TimerButton t in template.List.OfType <TimerButton>())
            {
                TimerObject to = new TimerObject(t);
                to.ClickedEvent += HandleTaggerClickedEvent;
                to.Mode          = Mode;
                if (Project != null && t.BackgroundImage == null)
                {
                    if (t.Timer.Team == TeamType.LOCAL)
                    {
                        to.TeamImage = Project.LocalTeamTemplate.Shield;
                    }
                    else if (t.Timer.Team == TeamType.VISITOR)
                    {
                        to.TeamImage = Project.VisitorTeamTemplate.Shield;
                    }
                }
                AddButton(to);
            }

            foreach (DashboardButtonObject buttonObject in buttonsDict.Values)
            {
                foreach (ActionLink link in buttonObject.Button.ActionLinks)
                {
                    LinkAnchorObject sourceAnchor, destAnchor;
                    ActionLinkObject linkObject;

                    sourceAnchor = buttonObject.GetAnchor(link.SourceTags);
                    try {
                        destAnchor = buttonsDict [link.DestinationButton].GetAnchor(link.DestinationTags);
                    } catch {
                        Log.Error("Skipping link with invalid destination tags");
                        continue;
                    }
                    linkObject         = new ActionLinkObject(sourceAnchor, destAnchor, link);
                    link.SourceButton  = buttonObject.Button;
                    linkObject.Visible = ShowLinks;
                    AddObject(linkObject);
                }
            }
            Edited = false;
            SizeChanged();
        }