Пример #1
0
        /// <summary>
        /// Set the provided target as the current target.
        /// </summary>
        /// <param name="target">Reference to the new target.</param>
        /// <param name="startTimer">Should a timer be started for handling sub menu showing.</param>
        public void SetTarget(IContextMenuTarget target, bool startTimer)
        {
            // Only interested in a change of target
            if (_target != target)
            {
                // Tell current target to reset drawing
                if (_target != null)
                {
                    _itemDelayTimer.Stop();
                    _target.ClearTarget();
                    _target = null;
                }

                // Shift the active view to the new target
                ActiveView = target?.GetActiveView();

                _target = target;

                // Tell new target to draw as highlighted and start delay timer
                if (_target != null)
                {
                    _itemDelayTimer.Stop();

                    if (startTimer)
                    {
                        _itemDelayTimer.Start();
                    }

                    _target.ShowTarget();
                }
            }
        }