Exemplo n.º 1
0
        public override bool Merge(BaseCommand other)
        {
            if (!m_DupeInPlace)
            {
                return(false);
            }

            // If we duplicated a selection in place (the stamp feature), subsequent movements of
            // the selection should get bundled up with this command as a child.
            MoveWidgetCommand move = other as MoveWidgetCommand;

            if (move != null)
            {
                if (m_Children.Count == 0)
                {
                    m_Children.Add(other);
                }
                else
                {
                    MoveWidgetCommand childMove = m_Children[0] as MoveWidgetCommand;
                    Debug.Assert(childMove != null);
                    return(childMove.Merge(other));
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        public override bool Merge(BaseCommand other)
        {
            if (base.Merge(other))
            {
                return(true);
            }
            if (m_Final)
            {
                return(false);
            }
            MoveWidgetCommand move = other as MoveWidgetCommand;

            if (move != null && m_Widget == move.m_Widget)
            {
                m_EndTransform             = move.m_EndTransform;
                m_CustomDimension.endState = move.m_CustomDimension.endState;
                // Not used if (m_Type != Type.Selection)
                m_EndSelectionTransform = move.m_EndSelectionTransform;
                m_Final = move.m_Final;
                return(true);
            }
            HideWidgetCommand hide = other as HideWidgetCommand;

            if (hide != null && m_Widget == hide.Widget)
            {
                m_Children.Add(hide);
                m_Final = true;
                return(true);
            }
            PinWidgetCommand pin = other as PinWidgetCommand;

            if (pin != null && m_Widget == pin.Widget)
            {
                m_Children.Add(pin);
                if (pin.IsPinning)
                {
                    m_Final = true;
                }
                return(true);
            }
            // Strokes are deleted right after a move if the SelectionWidget is tossed.
            DeleteSelectionCommand delete = other as DeleteSelectionCommand;

            if (delete != null && m_Type == Type.Selection)
            {
                m_Children.Add(delete);
                m_Final = true;
                return(true);
            }
            // If a widget has been tossed but the animation is not yet complete, finish it here.
            if (m_Widget.IsTossed() || m_Widget.IsHiding())
            {
                if (m_Type == Type.Selection)
                {
                    // Additional "hide now" logic if the there is a selection that needs to be deleted
                    // when the selection widget hides.
                    DeleteSelectionCommand del = SelectionManager.m_Instance.CurrentDeleteSelectionCommand();
                    del.Redo();
                    m_Children.Add(del);
                    SelectionManager.m_Instance.ResolveChanges();
                }

                m_Widget.HideNow();
                HideWidgetCommand hideComm = new HideWidgetCommand(m_Widget);
                hideComm.Redo();
                m_Children.Add(hideComm);

                if (m_Type == Type.Selection)
                {
                    // If a selection is made while the selection widget is animating out, the transform
                    // passed into the SelectCommand constructor is incorrect. It should always be the identity
                    // because it is the transform of a new selection since the previous selection was deleted.
                    SelectCommand select = other as SelectCommand;
                    if (select != null)
                    {
                        select.ResetInitialTransform();
                    }
                }
            }
            // Mark as final if a merge is failed, because a non-compatible command was pushed on top.
            // This will prevent future move commands from merging if the non-compatible command is undone.
            m_Final = true;
            return(false);
        }