protected override void StopMove(bool moved) { Selection sel = Selections.FirstOrDefault(); if (movingLink != null) { if (destAnchor != null) { ActionLinkVM link = movingLink.Link; link.DestinationButton = destAnchor.Button.ButtonVM; link.DestinationTags.ViewModels.AddRange(destAnchor.Tags); link.SourceButton.ActionLinks.ViewModels.Add(link); movingLink.Destination = destAnchor; destAnchor.Highlighted = false; if (ActionLinkCreatedEvent != null) { ActionLinkCreatedEvent(link); } linksDict.Add(link, movingLink); } else { RemoveObject(movingLink); widget.ReDraw(); } ClearSelection(); movingLink = null; destAnchor = null; return; } if (sel != null && moved) { if (sel.Drawable is DashboardButtonView) { /* Round the position of the button to match a corner in the grid */ int i = VASDrawing.Constants.CATEGORY_TPL_GRID; DashboardButton tb = (sel.Drawable as DashboardButtonView).Button; tb.Position.X = VASDrawing.Utils.Round(tb.Position.X, i); tb.Position.Y = VASDrawing.Utils.Round(tb.Position.Y, i); tb.Width = (int)VASDrawing.Utils.Round(tb.Width, i); tb.Height = (int)VASDrawing.Utils.Round(tb.Height, i); (sel.Drawable as DashboardButtonView).ResetDrawArea(); widget.ReDraw(); } } base.StopMove(moved); }
protected override void StartMove(Selection sel) { if (sel != null && sel.Drawable is LinkAnchorView) { LinkAnchorView anchor = sel.Drawable as LinkAnchorView; ActionLinkVM link = new ActionLinkVM { Model = new ActionLink { SourceTags = new RangeObservableCollection <Tag> (anchor.Tags.Select(t => t.Model)) }, SourceButton = anchor.Button.ButtonVM }; movingLink = new ActionLinkView(anchor, null, link); AddObject(movingLink); ClearSelection(); UpdateSelection(new Selection(movingLink, SelectionPosition.LineStop, 0), false); } base.StartMove(sel); }
void AddActionLinks(DashboardButtonView buttonObject) { foreach (ActionLinkVM link in buttonObject.ButtonVM.ActionLinks) { LinkAnchorView sourceAnchor, destAnchor; ActionLinkView linkObject; sourceAnchor = buttonObject.GetAnchor(link.SourceTags.ViewModels); try { var but = buttonsDict [link.DestinationButton]; destAnchor = buttonsDict [link.DestinationButton].GetAnchor(link.DestinationTags.ViewModels); } catch { Log.Error("Skipping link with invalid destination tags"); continue; } linkObject = new ActionLinkView(sourceAnchor, destAnchor, link); link.SourceButton = buttonObject.ButtonVM; linkObject.Visible = ViewModel.ShowLinks; AddObject(linkObject); linksDict.Add(link, linkObject); } }
protected override void SelectionMoved(Selection sel) { if (sel.Drawable is DashboardButtonView) { HandleSizeChangedEvent(); } else if (sel.Drawable is ActionLinkView) { ActionLinkView link = sel.Drawable as ActionLinkView; LinkAnchorView anchor = null; Selection destSel; destSel = GetSelection(MoveStart, true, true); if (destSel != null && destSel.Drawable is LinkAnchorView) { anchor = destSel.Drawable as LinkAnchorView; } /* 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); }