private void btnDeleteLine_Click(object sender, RoutedEventArgs e)
        {
            if (LineType == LineType.NestedObjectOpening || (LineType == LineType.DeletedLine && typeBeforeDelete == LineType.NestedObjectOpening))
            {
                var args = new LineEventArgs();
                args.LineNumber       = LineNumber;
                args.OriginalLineType = LineType;

                InnerDocumentDelete?.Invoke(this, args);
            }
            else
            {
                if (!LineKey.Equals("_id"))
                {
                    SetLineAsDeleted();
                }
            }
        }
        private void StartLine_InnerDocumentDelete(object sender, LineEventArgs e)
        {
            //var line = sender as DocumentViewerLine;
            //var group = FoldingGroups[line.FoldingGroup];
            //var groupElements = stpLinesContainer.Children;
            //int i = group.LineStart - 1;
            //int end = i + group.LinesCount;

            //for (; i <= end; i++)
            //{
            //    if (i < groupElements.Count)
            //    {
            //        var element = groupElements[i] as DocumentViewerLine;

            //        element.SetAsDeleted();
            //    }
            //}
        }
        private void Children_UpdatedLineType(object sender, LineEventArgs e)
        {
            var index = stpLinesContainer.Children.IndexOf(sender as UIElement);

            if (index > -1)
            {
                var newDoc = new BsonDocument();
                var value  = new BsonValue("");
                newDoc.Add("newValue", value);
                var newLine  = new KeyValuePair <string, BsonValue>("newDocument", newDoc);
                var childDoc = new DocumentViewerLineGroup(newLine, DocumentNestingLevel + 1, ++LineCounter);
                LineCounter          = childDoc.LoadDocument();
                childDoc.LinesAdded += ChildDoc_LinesAdded;
                ((DocumentEditorComponent)childDoc).ActivateEdition();
                stpLinesContainer.Children.Remove(sender as UIElement);
                stpLinesContainer.Children.Insert(index, childDoc);

                UpdateLineNumbers();
            }
        }
        private void Children_AddNewLine(object sender, LineEventArgs e)
        {
            var line = sender as DocumentViewerLine;

            if (line != null)
            {
                var index = stpLinesContainer.Children.IndexOf(line);

                if (index > -1)
                {
                    BsonValue          value   = new BsonValue("");
                    DocumentViewerLine newLine = new DocumentViewerLine("newVariable", value, e.LineNumber + 1, DocumentNestingLevel * DocumentViewerLine.DEFAULT_TAB_LENGTH);
                    newLine.UpdatedLineType += Children_UpdatedLineType;
                    newLine.AddNewLine      += Children_AddNewLine;
                    ((DocumentEditorComponent)newLine).ActivateEdition();

                    stpLinesContainer.Children.Insert(index + 1, newLine);

                    UpdateLineNumbers();
                }
            }
        }
 private void StartLine_InnerDocumentDelete(object sender, LineEventArgs e)
 {
     DeleteGroup();
 }