Exemplo n.º 1
0
        public void DrawItemLabel(Rect rect, DragListEntry entry)
        {
            Assert.Throw("TODO");
            //DrawListItem(rect, entry.Name);

            //switch (entry.ListOwner.ListType)
            //{
            //case DragListTypes.Release:
            //{
            //var info = (ReleaseInfo)(entry.Tag);

            //var labelStr = info.Name;

            //if (_model.IsReleaseInstalled(info))
            //{
            //labelStr = ImguiUtil.WrapWithColor(labelStr, _settings.Theme.DraggableItemAlreadyAddedColor);
            //}

            //DrawItemLabelWithVersion(rect, labelStr, info.Version);
            //break;
            //}
            //case DragListTypes.Package:
            //{
            //}
            //case DragListTypes.AssetItem:
            //case DragListTypes.PluginItem:
            //{
            //}
            //default:
            //{
            //Assert.Throw();
            //break;
            //}
            //}
        }
Exemplo n.º 2
0
        public void SetItems(List <ItemDescriptor> newItems)
        {
            var oldEntries = _entries.ToDictionary(x => x.Model, x => x);

            _entries.Clear();

            for (int i = 0; i < newItems.Count; i++)
            {
                var item = newItems[i];

                var entry = new DragListEntry()
                {
                    Name      = item.Caption,
                    Model     = item.Model,
                    ListOwner = this,
                    ListType  = _listType,
                    Index     = i,
                };

                var oldEntry = oldEntries.TryGetValue(item.Model);

                if (oldEntry != null)
                {
                    entry.IsSelected = oldEntry.IsSelected;
                }

                _entries.Add(entry);
            }
        }
Exemplo n.º 3
0
        void ClickSelect(DragListEntry newEntry)
        {
            if (newEntry.IsSelected)
            {
                if (Event.current.control)
                {
                    newEntry.IsSelected = false;
                }

                return;
            }

            if (!Event.current.control && !Event.current.shift)
            {
                _manager.ClearSelected();
            }

            // The selection entry list should all be from the same list
            _manager.ClearOtherListSelected(_listType);

            var selected = GetSelected();

            if (Event.current.shift && !selected.IsEmpty())
            {
                var closestEntry = selected
                                   .Select(x => new { Distance = Mathf.Abs(x.Index - newEntry.Index), Entry = x })
                                   .OrderBy(x => x.Distance)
                                   .Select(x => x.Entry).First();

                int startIndex;
                int endIndex;

                if (closestEntry.Index > newEntry.Index)
                {
                    startIndex = newEntry.Index + 1;
                    endIndex   = closestEntry.Index - 1;
                }
                else
                {
                    startIndex = closestEntry.Index + 1;
                    endIndex   = newEntry.Index - 1;
                }

                for (int i = startIndex; i <= endIndex; i++)
                {
                    var inBetweenEntry = closestEntry.ListOwner.GetAtIndex(i);

                    inBetweenEntry.IsSelected = true;
                }
            }

            newEntry.IsSelected = true;
        }
Exemplo n.º 4
0
 public void Remove(DragListEntry entry)
 {
     _entries.RemoveWithConfirm(entry);
     UpdateIndices();
 }
Exemplo n.º 5
0
        void ClickSelect(DragListEntry newEntry)
        {
            if (newEntry.IsSelected)
            {
                if (Event.current.control)
                {
                    newEntry.IsSelected = false;
                }

                return;
            }

            if (!Event.current.control && !Event.current.shift)
            {
                _manager.ClearSelected();
            }

            // The selection entry list should all be from the same list
            _manager.ClearOtherListSelected(_listType);

            var selected = GetSelected();

            if (Event.current.shift && !selected.IsEmpty())
            {
                var closestEntry = selected
                    .Select(x => new { Distance = Mathf.Abs(x.Index - newEntry.Index), Entry = x })
                    .OrderBy(x => x.Distance)
                    .Select(x => x.Entry).First();

                int startIndex;
                int endIndex;

                if (closestEntry.Index > newEntry.Index)
                {
                    startIndex = newEntry.Index + 1;
                    endIndex = closestEntry.Index - 1;
                }
                else
                {
                    startIndex = closestEntry.Index + 1;
                    endIndex = newEntry.Index - 1;
                }

                for (int i = startIndex; i <= endIndex; i++)
                {
                    var inBetweenEntry = closestEntry.ListOwner.GetAtIndex(i);

                    inBetweenEntry.IsSelected = true;
                }
            }

            newEntry.IsSelected = true;
        }
Exemplo n.º 6
0
        public void SetItems(List<ItemDescriptor> newItems)
        {
            var oldEntries = _entries.ToDictionary(x => x.Model, x => x);

            _entries.Clear();

            for (int i = 0; i < newItems.Count; i++)
            {
                var item = newItems[i];

                var entry = new DragListEntry()
                {
                    Name = item.Caption,
                    Model = item.Model,
                    ListOwner = this,
                    ListType = _listType,
                    Index = i,
                };

                var oldEntry = oldEntries.TryGetValue(item.Model);

                if (oldEntry != null)
                {
                    entry.IsSelected = oldEntry.IsSelected;
                }

                _entries.Add(entry);
            }
        }
Exemplo n.º 7
0
 public void Remove(DragListEntry entry)
 {
     _entries.RemoveWithConfirm(entry);
     UpdateIndices();
 }
Exemplo n.º 8
0
        public void DrawItemLabel(Rect rect, DragListEntry entry)
        {
            Assert.Throw("TODO");
            //DrawListItem(rect, entry.Name);

            //switch (entry.ListOwner.ListType)
            //{
                //case DragListTypes.Release:
                //{
                    //var info = (ReleaseInfo)(entry.Tag);

                    //var labelStr = info.Name;

                    //if (_model.IsReleaseInstalled(info))
                    //{
                        //labelStr = ImguiUtil.WrapWithColor(labelStr, _settings.Theme.DraggableItemAlreadyAddedColor);
                    //}

                    //DrawItemLabelWithVersion(rect, labelStr, info.Version);
                    //break;
                //}
                //case DragListTypes.Package:
                //{
                //}
                //case DragListTypes.AssetItem:
                //case DragListTypes.PluginItem:
                //{
                //}
                //default:
                //{
                    //Assert.Throw();
                    //break;
                //}
            //}
        }