コード例 #1
0
        /// <summary>
        /// Carga el documento pasado durante la creación del control.
        /// </summary>
        public void LoadDocument(BsonValue document)
        {
            if (document is BsonDocument)
            {
                var doc = document as BsonDocument;

                //Insertar la línea de comienzo
                var start = new DocumentViewerLine(LineType.Opening, ++LineCounter);
                stpLinesContainer.Children.Add(start);

                foreach (var line in doc)
                {
                    if (line.Value is BsonDocument)
                    {
                        var childDoc = new DocumentViewerLineGroup(line, DocumentNestingLevel + 1, ++LineCounter);
                        LineCounter          = childDoc.LoadDocument();
                        childDoc.LinesAdded += ChildDoc_LinesAdded;
                        stpLinesContainer.Children.Add(childDoc);
                    }
                    else
                    {
                        //Insertar las líneas de datos
                        var docline = new DocumentViewerLine(line, ++LineCounter);
                        docline.AddNewLine      += Children_AddNewLine;
                        docline.UpdatedLineType += Children_UpdatedLineType;
                        stpLinesContainer.Children.Add(docline);
                    }
                }

                //Insertar la línea de cierre
                DocumentViewerLine dvl = new DocumentViewerLine(LineType.Closing, ++LineCounter);
                stpLinesContainer.Children.Add(dvl);
            }
        }
コード例 #2
0
        public int LoadDocument()
        {
            if (ChildDocument.Value is BsonDocument)
            {
                var doc         = ChildDocument.Value as BsonDocument;
                var tabLength   = DocumentViewerLine.DEFAULT_TAB_LENGTH;
                int bracketsTab = (DocumentNestingLevel - 1 > 0) ? (DocumentNestingLevel - 1) * tabLength : tabLength;

                isGroupFold = true;

                //Insertar la línea de comienzo
                var startLine = new DocumentViewerLine(ChildDocument, LineCounter, LineType.NestedObjectOpening, bracketsTab);
                startLine.IsGroupCollapsed     = true;
                startLine.FoldActionRequest   += FoldableStartLine_FoldActionRequest;
                startLine.InnerDocumentDelete += StartLine_InnerDocumentDelete;
                startLine.AddNewLine          += Children_AddNewLine;
                startLine.UpdatedLineType     += Children_UpdatedLineType;
                stpLinesContainer.Children.Add(startLine);

                foreach (var line in doc)
                {
                    if (line.Value is BsonDocument)
                    {
                        var childDoc = new DocumentViewerLineGroup(line, DocumentNestingLevel + 1, ++LineCounter);
                        LineCounter          = childDoc.LoadDocument();
                        childDoc.LinesAdded += ChildDoc_LinesAdded;
                        stpLinesContainer.Children.Add(childDoc);
                    }
                    else
                    {
                        //Insertar las líneas de datos
                        var docline = new DocumentViewerLine(line, ++LineCounter, DocumentNestingLevel * tabLength);
                        docline.AddNewLine      += Children_AddNewLine;
                        docline.UpdatedLineType += Children_UpdatedLineType;
                        docline.Visibility       = (DocumentNestingLevel > 1) ? Visibility.Collapsed : Visibility.Visible;
                        docline.IsGroupCollapsed = true;
                        stpLinesContainer.Children.Add(docline);
                    }
                }

                //Insertar la línea de cierre
                DocumentViewerLine dvl = new DocumentViewerLine(LineType.Closing, ++LineCounter, bracketsTab);
                dvl.Visibility       = (DocumentNestingLevel > 1) ? Visibility.Collapsed : Visibility.Visible;
                dvl.IsGroupCollapsed = true;
                stpLinesContainer.Children.Add(dvl);
            }

            return(LineCounter);
        }
コード例 #3
0
        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();
            }
        }