public override bool CanStartDrag(TreeViewItem targetItem, List<int> draggedItemIDs, Vector2 mouseDownPosition)
        {
            if (Event.current.modifiers != EventModifiers.None)
                return false;

            // Can only drag when starting in the track header area
            if (mouseDownPosition.x > m_Window.sequenceHeaderRect.xMax)
                return false;

            var trackBaseGUI = targetItem as TimelineTrackBaseGUI;

            if (trackBaseGUI == null || trackBaseGUI.track == null)
                return false;

            if (trackBaseGUI.track.lockedInHierarchy)
                return false;

            if (Event.current.type == EventType.MouseDrag && Mathf.Abs(Event.current.delta.y) < kDragSensitivity)
                return false;

            // Make sure dragged items are selected
            // TODO Use similar system than the SceneHierarchyWindow in order to handle selection between treeView and tracks.
            SelectionManager.Clear();
            var draggedTrackGUIs = m_Window.allTracks.Where(t => draggedItemIDs.Contains(t.id));
            foreach (var trackGUI in draggedTrackGUIs)
                SelectionManager.Add(trackGUI.track);

            return true;
        }
            public void AddMultipleItemsWithMultiSelectDisabledAndEmptyStart(string scope)
            {
                var addedItems   = new List <int>();
                var removedItems = new List <int>();

                var selectionManager = new SelectionManager <int>
                {
                    AllowMultiSelect = false
                };

                selectionManager.SelectionChanged += (sender, e) =>
                {
                    Assert.AreEqual(scope, e.Scope);

                    addedItems.AddRange(e.Added);
                    removedItems.AddRange(e.Removed);
                };

                selectionManager.Add(new[] { 1, 2, 3 }, scope);

                Assert.AreEqual(1, addedItems.Count);
                Assert.AreEqual(3, addedItems[0]);

                Assert.AreEqual(0, removedItems.Count);

                var selectedItems = selectionManager.GetSelectedItems(scope);

                Assert.AreEqual(1, selectedItems.Count);
                Assert.AreEqual(3, selectedItems[0]);

                var selectedItem = selectionManager.GetSelectedItem(scope);

                Assert.AreEqual(3, selectedItem);
            }
            public void ClearMultipleItemsWithMultiSelectEnabledAndFilledUpStart_ExistingItems(string scope)
            {
                var addedItems   = new List <int>();
                var removedItems = new List <int>();

                var selectionManager = new SelectionManager <int>
                {
                    AllowMultiSelect = true
                };

                selectionManager.Add(new[] { 4, 5, 6 }, scope);

                selectionManager.SelectionChanged += (sender, e) =>
                {
                    Assert.AreEqual(scope, e.Scope);

                    addedItems.AddRange(e.Added);
                    removedItems.AddRange(e.Removed);
                };

                selectionManager.Clear(scope);

                Assert.AreEqual(3, removedItems.Count);
                Assert.AreEqual(4, removedItems[0]);
                Assert.AreEqual(5, removedItems[1]);
                Assert.AreEqual(6, removedItems[2]);

                var selectedItems = selectionManager.GetSelectedItems(scope);

                Assert.AreEqual(0, selectedItems.Count);

                var selectedItem = selectionManager.GetSelectedItem(scope);

                Assert.AreEqual(0, selectedItem);
            }
        private void OnRequestedCharacters(AckResponseCode responseCode, BaseAckMessage message)
        {
            var castedMessage = (ResponseCharactersMessage)message;

            SelectionManager.Clear();
            // Unenabled buttons
            buttonStart.gameObject.SetActive(false);
            buttonDelete.gameObject.SetActive(false);
            // Remove all models
            characterModelContainer.RemoveChildren();
            CharacterModels.Clear();

            var selectableCharacters = new List <PlayerCharacterData>();

            switch (responseCode)
            {
            case AckResponseCode.Error:
                var errorMessage = string.Empty;
                switch (castedMessage.error)
                {
                case ResponseCharactersMessage.Error.NotLoggedin:
                    errorMessage = "User not logged in";
                    break;
                }
                UISceneGlobal.Singleton.ShowMessageDialog("Cannot Load Characters", errorMessage);
                break;

            case AckResponseCode.Timeout:
                UISceneGlobal.Singleton.ShowMessageDialog("Cannot Load Characters", "Connection timeout");
                break;

            default:
                selectableCharacters = castedMessage.characters;
                break;
            }

            // Show list of created characters
            for (var i = selectableCharacters.Count - 1; i >= 0; --i)
            {
                var selectableCharacter = selectableCharacters[i];
                if (selectableCharacter == null || !GameInstance.PlayerCharacters.ContainsKey(selectableCharacter.DataId))
                {
                    selectableCharacters.RemoveAt(i);
                }
            }
            selectableCharacters.Sort(new PlayerCharacterDataLastUpdateComparer().Desc());
            CacheList.Generate(selectableCharacters, (index, character, ui) =>
            {
                var uiCharacter  = ui.GetComponent <UICharacter>();
                uiCharacter.Data = character;
                // Select trigger when add first entry so deactivate all models is okay beacause first model will active
                var characterModel            = character.InstantiateModel(characterModelContainer);
                CharacterModels[character.Id] = characterModel;
                characterModel.gameObject.SetActive(false);
                characterModel.SetEquipWeapons(character.EquipWeapons);
                characterModel.SetEquipItems(character.EquipItems);
                SelectionManager.Add(uiCharacter);
            });
        }