Ejemplo n.º 1
0
        public override void CommitDrag(Point dragTerminationPoint, Point offset)
        {
            //  This is really messy. This ought to be generalized somehow.

            //  If the drag ended over a layer icon, then perform a layer membership operation

            IEnumerable <LayerIcon> occludedLayerIcons = Utility.DrawingAids.FindOccludedIcons <LayerIcon>(Designer.LayerIconsListBox,
                                                                                                           Utility.DrawingAids.NormalizePoint(Designer.LayerIconsListBox, Designer.IconSurface, dragTerminationPoint));

            if (occludedLayerIcons.Count() > 0)
            {
                CancelDrag();
                LayerIcon       layerIcon = occludedLayerIcons.First();
                ViewModel.Layer layer     = layerIcon.ReferencedObject as ViewModel.Layer;

                if (layer.Members.Contains(ReferencedObject))
                {
                    if (layer != Designer.DefaultLayer)
                    {
                        Designer.RemoveLayerMember(layer, ReferencedObject as ObjectModel.ITransitionEndpoint);
                    }
                }
                else
                {
                    Designer.AddLayerMember(layer, ReferencedObject as ObjectModel.ITransitionEndpoint, layer.DefaultGroupStatus, (ReferencedObject as ObjectModel.ITransitionEndpoint).LeftTopPosition);
                }
            }
            else
            {
                base.CommitDrag(dragTerminationPoint, offset);
            }
        }