/// <summary>
        /// Adds instances to the selection list.
        /// </summary>
        /// <param name="item">The item to select.</param>
        /// <param name="clearCurrentSelection">Determines if the current selection will be cleared.</param>
        /// <param name="pushToHistory">Determines if an action is pushed to the <see cref="HistoryService" /></param>
        public void Select(Instance item, bool clearCurrentSelection = false, bool pushToHistory = true)
        {
            if (clearCurrentSelection)
            {
                ClearSelection();
            }

            if (item == null || item.IsSelected)
            {
                return;
            }

            _selection.TryAdd(item);
            item.IsSelected = true;
            Selected.Fire(item);
            SelectionChanged.Fire();
            var element = item as GuiElement;

            if (element != null)
            {
                lock (Locker)
                {
                    SelectedGuiElements.Add(element);
                }
            }

            if (pushToHistory)
            {
                HistoryService.ExecuteAction(new SelectionAction(item, false));
            }
        }
        /// <summary>
        /// Removes instances from the selection list.
        /// </summary>
        /// <param name="item">The item to deselect.</param>
        /// <param name="pushToHistory">Determines if an action is pushed to the <see cref="HistoryService" /></param>
        public void Deselect(Instance item, bool pushToHistory = true)
        {
            if (item == null || !item.IsSelected)
            {
                return;
            }

            _selection.TryRemove(item);
            item.IsSelected = false;
            Deselected.Fire(item);
            SelectionChanged.Fire();

            var element = item as GuiElement;

            if (element != null)
            {
                lock (Locker)
                {
                    SelectedGuiElements.Add(element);
                }
            }

            if (pushToHistory)
            {
                HistoryService.ExecuteAction(new SelectionAction(item, true));
            }
        }