Exemplo n.º 1
0
        private void InitVisualizers(JsonViewerTreeNode node)
        {
            if (!node.Initialized)
            {
                node.Initialized = true;
                JsonObject jsonObject = node.JsonObject;
                foreach (ICustomTextProvider textVis in _pluginsManager.TextVisualizers)
                {
                    if (textVis.CanVisualize(jsonObject))
                    {
                        node.TextVisualizers.Add(textVis);
                    }
                }

                node.RefreshText();

                foreach (IJsonVisualizer visualizer in _pluginsManager.Visualizers)
                {
                    if (visualizer.CanVisualize(jsonObject))
                    {
                        node.Visualizers.Add(visualizer);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void mnuCopy_Click(object sender, EventArgs e)
        {
            JsonViewerTreeNode node = GetSelectedTreeNode();

            if (node != null)
            {
                Clipboard.SetText(node.Text);
            }
        }
Exemplo n.º 3
0
        private void VisualizeJsonTree(JsonObjectTree tree)
        {
            AddNode(tvJson.Nodes, tree.Root);
            JsonViewerTreeNode node = GetRootNode();

            InitVisualizers(node);
            node.Expand();
            tvJson.SelectedNode = node;
        }
Exemplo n.º 4
0
        private void mnuCopyValue_Click(object sender, EventArgs e)
        {
            JsonViewerTreeNode node = GetSelectedTreeNode();

            if (node != null && node.Tag != null)
            {
                JsonObject obj = node.Tag as JsonObject;
                Clipboard.SetText(obj.Value.ToString());
            }
            else
            {
                Clipboard.SetText("null");
            }
        }
Exemplo n.º 5
0
        private void mnuCopyName_Click(object sender, EventArgs e)
        {
            JsonViewerTreeNode node = GetSelectedTreeNode();

            if (node != null && node.JsonObject.Id != null)
            {
                JsonObject obj = node.Tag as JsonObject;
                Clipboard.SetText(obj.Id);
            }
            else
            {
                Clipboard.SetText("");
            }
        }
Exemplo n.º 6
0
        private void AddNode(TreeNodeCollection nodes, JsonObject jsonObject)
        {
            JsonViewerTreeNode newNode = new JsonViewerTreeNode(jsonObject);

            nodes.Add(newNode);
            newNode.Text               = jsonObject.Text;
            newNode.Tag                = jsonObject;
            newNode.ImageIndex         = (int)jsonObject.JsonType;
            newNode.SelectedImageIndex = newNode.ImageIndex;

            foreach (JsonObject field in jsonObject.Fields)
            {
                AddNode(newNode.Nodes, field);
            }
        }
Exemplo n.º 7
0
        private void tvJson_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (_pluginsManager.DefaultVisualizer == null)
            {
                return;
            }

            cbVisualizers.BeginUpdate();
            _updating = true;
            try
            {
                JsonViewerTreeNode node       = (JsonViewerTreeNode)e.Node;
                IJsonVisualizer    lastActive = node.LastVisualizer;
                if (lastActive == null)
                {
                    lastActive = (IJsonVisualizer)cbVisualizers.SelectedItem;
                }
                if (lastActive == null)
                {
                    lastActive = _pluginsManager.DefaultVisualizer;
                }

                cbVisualizers.Items.Clear();
                cbVisualizers.Items.AddRange(node.Visualizers.ToArray());
                int index = cbVisualizers.Items.IndexOf(lastActive);
                if (index != -1)
                {
                    cbVisualizers.SelectedIndex = index;
                }
                else
                {
                    cbVisualizers.SelectedIndex = cbVisualizers.Items.IndexOf(_pluginsManager.DefaultVisualizer);
                }
            }
            finally
            {
                cbVisualizers.EndUpdate();
                _updating = false;
            }
            ActivateVisualizer();
        }