Esempio 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);
            }
        }
Esempio n. 2
0
 protected override void OnEndDrag()
 {
     base.OnEndDrag();
     if (CandidateLayerIcon != null)
     {
         CandidateLayerIcon.MembershipAction = LayerIcon.MembershipActions.None;
         CandidateLayerIcon = null;
     }
 }
Esempio n. 3
0
        public override void Drag(Point mousePosition, Point offset)
        {
            base.Drag(mousePosition, offset);
            if (CandidateLayerIcon != null)
            {
                CandidateLayerIcon.MembershipAction = LayerIcon.MembershipActions.None;
                CandidateLayerIcon = null;
            }

            // If the mouse is over a layer icon, let the user know

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

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

                if (layer.Members.Contains(ReferencedObject))
                {
                    if (layer.IsDefaultLayer)
                    {
                        layerIcon.MembershipAction = LayerIcon.MembershipActions.Forbidden;
                    }
                    else
                    {
                        if ((ReferencedObject as LayeredPositionableObject).CurrentLayerPosition.Layer == layer &&
                            (ReferencedObject as LayeredPositionableObject).CurrentLayerPosition.GroupStatus == LayerPosition.GroupStatuses.Implicit)
                        {
                            layerIcon.MembershipAction = LayerIcon.MembershipActions.Forbidden;
                        }
                        else
                        {
                            layerIcon.MembershipAction = LayerIcon.MembershipActions.Remove;
                        }
                    }
                }
                else
                {
                    layerIcon.MembershipAction = LayerIcon.MembershipActions.Add;
                }
                CandidateLayerIcon = layerIcon;
            }
        }