Beispiel #1
0
        public void CancelTool()
        {
            if (CurrentTool is null)
            {
                return;
            }

            CurrentTool.Cancel();

            CurrentTool = null;
        }
        //--------------------------------------------------------------------------------------------------

        public bool CancelTool(Tool tool, bool force)
        {
            var isCancelled = true;

            Debug.Assert(tool != null);
            if (CurrentTool != tool)
            {
                return(false);
            }

            if (CurrentTool != null)
            {
                if (!CurrentTool.Cancel(force))
                {
                    Debug.WriteLine("CancelTool -> CurrentTool.Cancel() denied.");
                    isCancelled = false;
                }
            }

            if (isCancelled)
            {
                _CurrentTool = null;
                while (CurrentToolAction?.Owner == tool)
                {
                    if (!(CurrentToolAction.IsFinished || CurrentToolAction.Cancel(force)))
                    {
                        Debug.WriteLine("CancelTool -> CurrentToolAction.Cancel() denied.");
                        isCancelled = false;
                    }
                }
                HudManager?.RemoveElements(e => e.Owner == tool);
                RaisePropertyChanged(nameof(CurrentTool));
            }

            Invalidate();
            UpdateSelection();
            return(isCancelled);
        }