コード例 #1
0
 /// <summary>
 /// Set the location of where screen output will be buffered to
 /// </summary>
 /// <param name="location"></param>
 /// <param name="index"></param>
 public void SetLogHistoryContainer(RowLocation location, int index, Color foregroundColor, Color backgroundColor)
 {
     LogHistoryContainer.Location        = location;
     LogHistoryContainer.Index           = index;
     LogHistoryContainer.ForegroundColor = foregroundColor;
     LogHistoryContainer.BackgroundColor = backgroundColor;
 }
コード例 #2
0
        static IEnumerator <object> DragTask()
        {
            var             roll         = Timeline.Instance.Roll;
            RowLocation?    dragLocation = new RowLocation(Document.Current.RowTree, 0);
            Action <Widget> a            = _ => {
                if (dragLocation != null)
                {
                    RenderDragCursor(dragLocation.Value);
                }
            };

            roll.OnRenderOverlay += a;
            var input = roll.RootWidget.Input;

            while (input.IsMousePressed())
            {
                dragLocation = MouseToRowLocation(input.MousePosition);
                CommonWindow.Current.Invalidate();
                yield return(null);
            }
            roll.OnRenderOverlay -= a;
            CommonWindow.Current.Invalidate();
            if (dragLocation != null)
            {
                DragRows(dragLocation.Value);
            }
        }
コード例 #3
0
 /// <summary>
 /// Set the location of where screen output will be buffered to
 /// </summary>
 /// <param name="location"></param>
 /// <param name="index"></param>
 public void SetLogHistoryContainer(RowLocation location, int index, Enum foregroundColor, Enum backgroundColor)
 {
     LogHistoryContainer.Location = location;
     LogHistoryContainer.Index    = index;
     LogHistoryContainer.ForegroundColorPalette = foregroundColor;
     LogHistoryContainer.BackgroundColorPalette = backgroundColor;
 }
コード例 #4
0
        static void DragRows(RowLocation dragLocation)
        {
            var rows = Document.Current.TopLevelSelectedRows().ToList();

            foreach (var elem in rows)
            {
                Probers.Any(p => p.Probe(elem, dragLocation));
                dragLocation.Index++;
            }
        }
コード例 #5
0
 protected override bool ProbeInternal(FolderRow component, Row row, RowLocation location)
 {
     if (!location.ParentRow.Components.Contains <FolderRow>() || row == location.ParentRow || row.Rows.Contains(location.ParentRow))
     {
         return(false);
     }
     try {
         MoveFolderItemTo(component.Folder, location);
     } catch (InvalidOperationException e) {
         AlertDialog.Show(e.Message);
         return(false);
     }
     return(true);
 }
コード例 #6
0
            protected static void MoveFolderItemTo(IFolderItem item, RowLocation newLocation)
            {
                FolderItemLocation targetLoc;
                var folder = newLocation.ParentRow.Components.Get <FolderRow>().Folder;

                if (newLocation.ParentRow.Rows.Count <= newLocation.Index)
                {
                    targetLoc = new FolderItemLocation(folder, folder.Items.Count);
                }
                else
                {
                    targetLoc = Row.GetFolderItemLocation(newLocation.ParentRow.Rows[newLocation.Index]);
                }
                MoveNodes.Perform(item, targetLoc);
            }
コード例 #7
0
        static void RenderDragCursor(RowLocation rowLocation)
        {
            float y  = 1;
            var   pr = rowLocation.ParentRow;

            if (rowLocation.Index < pr.Rows.Count)
            {
                y = pr.Rows[rowLocation.Index].GridWidget().Top();
            }
            else if (pr.Rows.Count > 0)
            {
                var lastRow = pr.Rows[rowLocation.Index - 1];
                y = lastRow.GridWidget().Bottom() + CalcSubtreeHeight(lastRow) + TimelineMetrics.RowSpacing;
            }
            else if (pr != Document.Current.RowTree)
            {
                y = pr.GridWidget().Bottom() + TimelineMetrics.RowSpacing;
            }

            if (ShouldSkipDragCursorRendering(y, CalcIndentation(pr)))
            {
                return;
            }

            Timeline.Instance.Roll.ContentWidget.PrepareRendererState();
            Renderer.DrawRect(
                new Vector2(TimelineMetrics.RollIndentation * CalcIndentation(pr), y - 1),
                new Vector2(Timeline.Instance.Roll.ContentWidget.Width, y + 1), ColorTheme.Current.TimelineRoll.DragCursor);

            for (var p = pr; p != null; p = p.Parent)
            {
                var parentWidget = p.GridWidget();
                if (parentWidget == null)
                {
                    continue;
                }

                Renderer.DrawRect(
                    parentWidget.Left(),
                    parentWidget.Top(),
                    parentWidget.Right(),
                    parentWidget.Bottom(),
                    ColorTheme.Current.TimelineRoll.DragTarget
                    );
            }
        }
コード例 #8
0
        private int GetYPosition(RowLocation loc, int index, int currentOffset)
        {
            var height = Console.WindowHeight;
            var y      = 0;

            switch (loc)
            {
            case RowLocation.Top:
                y = currentOffset + index;
                break;

            case RowLocation.Bottom:
                y = height - index - currentOffset - 1;
                break;

            case RowLocation.Middle:
                break;
            }
            return(y);
        }
コード例 #9
0
ファイル: Modification.cs プロジェクト: aologos/Citrus
        public static void Perform(RowLocation newLocation)
        {
            var i            = newLocation.Index;
            var nodes        = Document.Current.SelectedNodes().ToList();
            var targetFolder = newLocation.ParentRow.Components.Get <FolderRow>()?.Folder;

            if (targetFolder == null)
            {
                throw new Lime.Exception("Cant put nodes in a non folder row");
            }
            foreach (var node in nodes)
            {
                DocumentHistory.Current.Perform(
                    new MoveNodes(
                        Document.Current.Container,
                        new FolderItemLocation(targetFolder, i++),
                        GetParentFolder(node),
                        node));
            }
        }
コード例 #10
0
ファイル: CopyPaste.cs プロジェクト: kutselabskii/Citrus
        private static void PasteAnimationTracks(string data, RowLocation loc)
        {
            try {
                var stream    = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(data));
                var animation = TangerinePersistence.Instance.ReadObject <Animation>(string.Empty, stream);
                ClearRowSelection.Perform();
                var tracks = animation.Tracks.ToList();
                animation.Tracks.Clear();
                int i = Document.Current.Animation.Tracks.Count == 0 ? 0 : loc.Index + 1;
                foreach (var t in tracks)
                {
                    InsertIntoList <AnimationTrackList, AnimationTrack> .Perform(Document.Current.Animation.Tracks, i ++, t);

                    SelectRow.Perform(Document.Current.GetRowForObject(t));
                }
            } catch (System.Exception e) {
                Debug.Write(e);
                return;
            }
        }
コード例 #11
0
        static void DragRows(RowLocation dragLocation)
        {
            List <Row> parentRowRows = dragLocation.ParentRow.Rows;

            IEnumerable <KeyValuePair <Row, int> > enumeratedSelectedRows = Document.Current.TopLevelSelectedRows()
                                                                            .Select(row => new KeyValuePair <Row, int>(row, parentRowRows.IndexOf(row)));

            var rows = enumeratedSelectedRows.ToList();

            Document.Current.History.DoTransaction(() => {
                foreach (var elem in rows)
                {
                    Probers.Any(p => p.Probe(elem.Key, dragLocation));
                    if (elem.Value == -1 || elem.Value >= dragLocation.Index)
                    {
                        ++dragLocation.Index;
                    }
                }
            });
        }
コード例 #12
0
            protected override bool ProbeInternal(BoneRow node, Row row, RowLocation location)
            {
                if (!(location.ParentRow.Components.Contains <BoneRow>() || location.ParentRow.Components.Contains <FolderRow>()))
                {
                    return(false);
                }
                var targetParent = location.ParentRow.Components.Get <BoneRow>()?.Bone;

                try {
                    var bone = row.Components.Get <BoneRow>().Bone;
                    // Check if bone target parent is bone descendant
                    if (IsDescendant(bone, targetParent))
                    {
                        return(false);
                    }
                    if (bone.BaseIndex == 0 && !location.ParentRow.Components.Contains <BoneRow>())
                    {
                        MoveFolderItemTo(bone, location);
                    }
                    else
                    {
                        SetProperty.Perform(bone, nameof(Bone.Position), Vector2.Zero);
                    }

                    SetProperty.Perform(bone, nameof(Bone.BaseIndex), targetParent?.Index ?? 0);
                    SortBonesInChain.Perform(bone);
                    var nodes      = Document.Current.Container.Nodes;
                    var parentBone = nodes.GetBone(bone.BaseIndex);
                    while (parentBone != null && !parentBone.EditorState().ChildrenExpanded)
                    {
                        SetProperty.Perform(parentBone.EditorState(), nameof(NodeEditorState.ChildrenExpanded), true);
                        bone = nodes.GetBone(bone.BaseIndex);
                    }
                } catch (InvalidOperationException e) {
                    AlertDialog.Show(e.Message);
                    return(false);
                }
                return(true);
            }
コード例 #13
0
        static void RenderDragCursor(RowLocation rowLocation)
        {
            float y  = 1;
            var   pr = rowLocation.ParentRow;

            if (rowLocation.Index < pr.Rows.Count)
            {
                y = pr.Rows[rowLocation.Index].GridWidget().Top();
            }
            else if (pr.Rows.Count > 0)
            {
                var lastRow = pr.Rows[rowLocation.Index - 1];
                y = lastRow.GridWidget().Bottom() + CalcSubtreeHeight(lastRow) + TimelineMetrics.RowSpacing;
            }
            else if (pr != Document.Current.RowTree)
            {
                y = pr.GridWidget().Bottom() + TimelineMetrics.RowSpacing;
            }
            Timeline.Instance.Roll.ContentWidget.PrepareRendererState();
            Renderer.DrawRect(
                new Vector2(TimelineMetrics.RollIndentation * CalcIndentation(pr), y - 1),
                new Vector2(Timeline.Instance.Roll.ContentWidget.Width, y + 1), ColorTheme.Current.TimelineRoll.DragCursor);
        }
コード例 #14
0
 /// <summary>
 /// Set a static console row
 /// </summary>
 /// <param name="name">The name for the row</param>
 /// <param name="location">The location to snap to</param>
 /// <param name="index">The 0-based row index to offset from the location</param>
 /// <param name="foregroundColor">The row's default foreground color</param>
 /// <param name="backgroundColor">The row's default background color</param>
 public void SetStaticRow(string name, RowLocation location, int index, Enum foregroundColor, Enum backgroundColor)
 {
     StaticRows.Add(new StaticRowConfig {
         Name = name, Location = location, Index = index, ForegroundColorPalette = foregroundColor, BackgroundColorPalette = backgroundColor
     });
 }
コード例 #15
0
 /// <summary>
 /// Set a static console row
 /// </summary>
 /// <param name="name">The name for the row</param>
 /// <param name="location">The location to snap to</param>
 /// <param name="foregroundColor">The row's default foreground color</param>
 /// <param name="backgroundColor">The row's default background color</param>
 public void SetStaticRow(string name, RowLocation location, Enum foregroundColor, Enum backgroundColor)
 {
     SetStaticRow(name, location, 0, foregroundColor, backgroundColor);
 }
コード例 #16
0
 /// <summary>
 /// Set a static console row
 /// </summary>
 /// <param name="name">The name for the row</param>
 /// <param name="location">The location to snap to</param>
 /// <param name="foregroundColor">Foreground color to use</param>
 public void SetStaticRow(string name, RowLocation location, Color?foregroundColor)
 {
     SetStaticRow(name, location, 0, foregroundColor, null);
 }
コード例 #17
0
 /// <summary>
 /// Set a static console row
 /// </summary>
 /// <param name="name">The name for the row</param>
 /// <param name="location">The location to snap to</param>
 public void SetStaticRow(string name, RowLocation location)
 {
     SetStaticRow(name, location, 0, default(Color?), default(Color?));
 }
コード例 #18
0
            protected override bool ProbeInternal(BoneRow node, Row row, RowLocation location)
            {
                if (!(location.ParentRow.Components.Contains <BoneRow>() || location.ParentRow.Components.Contains <FolderRow>()))
                {
                    return(false);
                }
                var targetParent = location.ParentRow.Components.Get <BoneRow>()?.Bone;

                try {
                    var bone = row.Components.Get <BoneRow>().Bone;
                    // Check if bone target parent is bone descendant
                    if (IsDescendant(bone, targetParent))
                    {
                        return(false);
                    }
                    if (bone.BaseIndex == 0 && !location.ParentRow.Components.Contains <BoneRow>())
                    {
                        MoveFolderItemTo(bone, location);
                    }
                    else if (!location.ParentRow.Components.Contains <BoneRow>())
                    {
                        SetAnimableProperty.Perform(
                            bone, nameof(Bone.Position),
                            bone.Position * bone.CalcLocalToParentWidgetTransform(),
                            CoreUserPreferences.Instance.AutoKeyframes);
                        var   boneEntry = bone.Parent.AsWidget.BoneArray[bone.Index];
                        float angle     = (boneEntry.Tip - boneEntry.Joint).Atan2Deg;
                        SetAnimableProperty.Perform(
                            bone, nameof(Bone.Rotation),
                            angle, CoreUserPreferences.Instance.AutoKeyframes);
                    }
                    else
                    {
                        SetAnimableProperty.Perform(
                            bone, nameof(Bone.Position),
                            Vector2.Zero, CoreUserPreferences.Instance.AutoKeyframes);
                        var   newParent   = location.ParentRow.Components.Get <BoneRow>().Bone;
                        var   parentEntry = newParent.Parent.AsWidget.BoneArray[newParent.Index];
                        float parentAngle = (parentEntry.Tip - parentEntry.Joint).Atan2Deg;
                        var   boneEntry   = bone.Parent.AsWidget.BoneArray[bone.Index];
                        float angle       = (boneEntry.Tip - boneEntry.Joint).Atan2Deg;
                        SetAnimableProperty.Perform(
                            bone, nameof(Bone.Rotation),
                            angle - parentAngle, CoreUserPreferences.Instance.AutoKeyframes);
                    }

                    SetProperty.Perform(bone, nameof(Bone.BaseIndex), targetParent?.Index ?? 0);
                    SortBonesInChain.Perform(bone);
                    var nodes      = Document.Current.Container.Nodes;
                    var parentBone = nodes.GetBone(bone.BaseIndex);
                    while (parentBone != null && !parentBone.EditorState().ChildrenExpanded)
                    {
                        SetProperty.Perform(parentBone.EditorState(), nameof(NodeEditorState.ChildrenExpanded), true);
                        bone = nodes.GetBone(bone.BaseIndex);
                    }
                } catch (InvalidOperationException e) {
                    AlertDialog.Show(e.Message);
                    return(false);
                }
                return(true);
            }
コード例 #19
0
 public DataGridRowBuilder <TItem> HasLocation(RowLocation location)
 {
     AddAction(rowInfo => rowInfo.RowLocation = location);
     return(this);
 }
コード例 #20
0
            protected override bool ProbeInternal(AnimationTrackRow component, Row row, RowLocation location)
            {
                var newIndex = location.Index > row.Index ? location.Index - 1 : location.Index;
                var track    = component.Track;

                RemoveFromList <AnimationTrackList, AnimationTrack> .Perform(Document.Current.Animation.Tracks, row.Index);

                InsertIntoList <AnimationTrackList, AnimationTrack> .Perform(Document.Current.Animation.Tracks, newIndex, track);

                return(true);
            }
コード例 #21
0
 public static bool CanPaste(string data, RowLocation location)
 {
     // We are support only paste into folders for now.
     return(location.ParentRow.Components.Contains <FolderRow>() ||
            location.ParentRow.Components.Contains <BoneRow>());
 }
コード例 #22
0
ファイル: CopyPaste.cs プロジェクト: kutselabskii/Citrus
        public static bool PasteNodes(string data, RowLocation location, Vector2?mousePosition)
        {
            bool CanPaste()
            {
                // We are support only paste into folders for now.
                return(location.ParentRow.Components.Contains <FolderRow>() ||
                       location.ParentRow.Components.Contains <BoneRow>());
            }

            if (!CanPaste())
            {
                return(false);
            }
            Frame frame;

            try {
                var stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(data));
                frame = TangerinePersistence.Instance.ReadObject <Frame>(Document.Current.Path, stream);
            } catch (System.Exception e) {
                Debug.Write(e);
                return(false);
            }
            var animators = frame.Animators;
            var items     = frame.RootFolder().Items.Where(item => NodeCompositionValidator.IsCopyPasteAllowed(item.GetType())).ToList();

            if (items.Count == 0)
            {
                if (animators.Count != 0)
                {
                    foreach (var row in Document.Current.TopLevelSelectedRows().ToList())
                    {
                        if (!(row.Components.Get <NodeRow>()?.Node is IAnimationHost animable))
                        {
                            continue;
                        }
                        Document.Current.History.DoTransaction(() => {
                            foreach (var animator in animators)
                            {
                                if (animable.GetType().GetProperty(animator.TargetPropertyPath) == null)
                                {
                                    continue;
                                }
                                foreach (var keyframe in animator.Keys)
                                {
                                    SetKeyframe.Perform(animable, animator.TargetPropertyPath, animator.AnimationId, keyframe);
                                }
                            }
                        });
                    }
                }
                return(true);
            }
            var folderLocation = location.ParentRow.Rows.Count > 0 ?
                                 Row.GetFolderItemLocation(location.ParentRow.Rows[location.Index]) :
                                 new FolderItemLocation {
                Index = 0, Folder = location.ParentRow.Components.Get <FolderRow>().Folder
            };

            if (!folderLocation.Folder.Expanded)
            {
                SetProperty.Perform(folderLocation.Folder, nameof(Folder.Expanded), true);
            }
            mousePosition *= Document.Current.Container.AsWidget?.LocalToWorldTransform.CalcInversed();
            var shift = mousePosition - items.OfType <Widget>().FirstOrDefault()?.Position;

            foreach (var n in items.OfType <Node>())
            {
                Document.Current.Decorate(n);
            }
            if (shift.HasValue)
            {
                foreach (var w in items.OfType <Widget>())
                {
                    w.Position += shift.Value;
                }
            }
            frame.RootFolder().Items.Clear();
            frame.RootFolder().SyncDescriptorsAndNodes(frame);
            ClearRowSelection.Perform();
            while (items.Count > 0)
            {
                var item = items.First();
                if (item is Bone bone)
                {
                    if (bone.BaseIndex != 0)
                    {
                        continue;
                    }
                    var newIndex = 1;
                    var bones    = Document.Current.Container.Nodes.OfType <Bone>();
                    if (bones.Any())
                    {
                        newIndex = bones.Max(b => b.Index) + 1;
                    }
                    var children = BoneUtils.FindBoneDescendats(bone, items.OfType <Bone>()).ToList();
                    var map      = new Dictionary <int, int> {
                        { bone.Index, newIndex }
                    };
                    bone.BaseIndex = location.ParentRow.Components.Get <BoneRow>()?.Bone.Index ?? 0;
                    bone.Index     = newIndex;
                    InsertFolderItem.Perform(
                        Document.Current.Container,
                        folderLocation, bone);
                    folderLocation.Index++;
                    foreach (var b in children)
                    {
                        b.BaseIndex = map[b.BaseIndex];
                        map.Add(b.Index, b.Index = ++newIndex);
                        InsertFolderItem.Perform(
                            Document.Current.Container,
                            folderLocation, b);
                        folderLocation.Index++;
                        items.Remove(b);
                    }
                    Document.Current.Container.RootFolder().SyncDescriptorsAndNodes(Document.Current.Container);
                    SortBonesInChain.Perform(bone);
                    SelectRow.Perform(Document.Current.GetRowForObject(item));
                }
                else
                {
                    if (!location.ParentRow.Components.Contains <BoneRow>())
                    {
                        InsertFolderItem.Perform(
                            Document.Current.Container,
                            folderLocation, item);
                        folderLocation.Index++;
                        SelectRow.Perform(Document.Current.GetRowForObject(item));
                    }
                }
                items.Remove(item);
            }
            return(true);
        }
コード例 #23
0
 protected abstract bool ProbeInternal(T component, Row row, RowLocation location);
コード例 #24
0
 public bool Probe(Row row, RowLocation location) => row.Components.Contains <T>() && ProbeInternal(row.Components.Get <T>(), row, location);
コード例 #25
0
 public LogHistoryContainer(RowLocation location, int index)
 {
     Location = location;
     Index    = index;
 }
コード例 #26
0
 /// <summary>
 /// Set the location of where screen output will be buffered to
 /// </summary>
 /// <param name="location"></param>
 /// <param name="index"></param>
 public void SetLogHistoryContainer(RowLocation location, int index)
 {
     LogHistoryContainer.Location = location;
     LogHistoryContainer.Index    = index;
 }
コード例 #27
0
        public Cell GetCellForDetailTable(string text, TextAlignment alignment, RowLocation rowLocation = RowLocation.MIDDLE_ROW, CellLocation cellLocation = CellLocation.MIDDLE_CELL, int rowspan = 1, int colspan = 1)
        {
            PdfFont baseFont = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H);

            Cell cell = new Cell(rowspan, colspan);

            cell.SetFontSize(8f);
            cell.SetPadding(0);
            cell.SetTextAlignment(alignment);
            cell.SetVerticalAlignment(VerticalAlignment.MIDDLE);
            cell.SetBorder(new SolidBorder(ColorConstants.LIGHT_GRAY, 0.5f));

            if (rowLocation == RowLocation.TITLE)
            {
                Paragraph p    = new Paragraph();
                Text      bold = new Text(text).SetFont(baseFont).SetTextRenderingMode(PdfCanvasConstants.TextRenderingMode.FILL_STROKE).SetStrokeWidth(0.5f).SetStrokeColor(DeviceGray.BLACK);
                p = new Paragraph(bold);
                p.SetFontSize(9.5f);
                cell.Add(p);
                cell.SetBorderTop(new SolidBorder(ColorConstants.BLACK, 0.5f));
                cell.SetBorderLeft(Border.NO_BORDER);
                cell.SetBorderRight(Border.NO_BORDER);
            }
            else
            {
                cell.Add(new Paragraph(text));

                // 테이블의 시작 셀
                if (cellLocation == CellLocation.FIRST_CELL)
                {
                    cell.SetBorderLeft(Border.NO_BORDER);
                }
                else if (cellLocation == CellLocation.LAST_CELL)
                {
                    // 테이블의 마지막 셀
                    cell.SetBorderRight(Border.NO_BORDER);
                }

                if (rowLocation != RowLocation.HEADER)
                {
                    cell.SetPaddingTop(2f);
                    cell.SetPaddingBottom(2f);
                }

                if (rowLocation == RowLocation.LAST_ROW)
                {
                    cell.SetBorderBottom(new SolidBorder(ColorConstants.BLACK, 0.5f));
                }

                if (alignment == TextAlignment.RIGHT)
                {
                    cell.SetPaddingRight(4f);
                }

                if (alignment == TextAlignment.LEFT)
                {
                    cell.SetPaddingLeft(4f);
                }
            }

            return(cell);
        }
コード例 #28
0
        public static bool Perform(string data, RowLocation location)
        {
            if (!CanPaste(data, location))
            {
                return(false);
            }
            Frame frame;

            try {
                var stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(data));
                frame = Serialization.ReadObject <Frame>(Document.Current.Path, stream);
            } catch (System.Exception e) {
                Debug.Write(e);
                return(false);
            }
            FolderItemLocation folderLocation;

            if (location.ParentRow.Rows.Count > 0)
            {
                folderLocation = Row.GetFolderItemLocation(location.ParentRow.Rows[location.Index]);
                folderLocation.Index++;
            }
            else
            {
                folderLocation = new FolderItemLocation {
                    Index = 0, Folder = location.ParentRow.Components.Get <FolderRow>().Folder
                };
            }
            if (!folderLocation.Folder.Expanded)
            {
                SetProperty.Perform(folderLocation.Folder, nameof(Folder.Expanded), true);
            }
            var items = frame.RootFolder().Items.ToList();

            foreach (var n in items.OfType <Node>())
            {
                Document.Current.Decorate(n);
            }
            frame.RootFolder().Items.Clear();
            frame.RootFolder().SyncDescriptorsAndNodes(frame);
            ClearRowSelection.Perform();
            while (items.Count > 0)
            {
                var item = items.First();
                var bone = item as Bone;
                if (bone != null)
                {
                    if (bone.BaseIndex != 0)
                    {
                        continue;
                    }
                    var newIndex = Document.Current.Container.Nodes.OfType <Bone>().Max(b => b.Index) + 1;
                    var children = BoneUtils.FindBoneDescendats(bone, items.OfType <Bone>()).ToList();
                    var map      = new Dictionary <int, int>();
                    map.Add(bone.Index, newIndex);
                    bone.BaseIndex = location.ParentRow.Components.Get <BoneRow>()?.Bone.Index ?? 0;
                    bone.Index     = newIndex;
                    InsertFolderItem.Perform(
                        Document.Current.Container,
                        folderLocation, bone);
                    folderLocation.Index++;
                    foreach (var b in children)
                    {
                        b.BaseIndex = map[b.BaseIndex];
                        map.Add(b.Index, b.Index = ++newIndex);
                        InsertFolderItem.Perform(
                            Document.Current.Container,
                            folderLocation, b);
                        folderLocation.Index++;
                        items.Remove(b);
                    }
                    Document.Current.Container.RootFolder().SyncDescriptorsAndNodes(Document.Current.Container);
                    SortBonesInChain.Perform(bone);
                    SelectRow.Perform(Document.Current.GetRowForObject(item));
                }
                else
                {
                    if (!location.ParentRow.Components.Contains <BoneRow>())
                    {
                        InsertFolderItem.Perform(
                            Document.Current.Container,
                            folderLocation, item);
                        folderLocation.Index++;
                        SelectRow.Perform(Document.Current.GetRowForObject(item));
                    }
                }
                items.Remove(item);
            }
            return(true);
        }