예제 #1
0
 private void AddPlugin(IJsonViewerPlugin plugin)
 {
     plugins.Add(plugin);
     if (plugin is ICustomTextProvider)
         textVisualizers.Add((ICustomTextProvider)plugin);
     if (plugin is IJsonVisualizer)
     {
         if (_defaultVisualizer == null)
             _defaultVisualizer = (IJsonVisualizer)plugin;
         visualizers.Add((IJsonVisualizer)plugin);
     }
 }
예제 #2
0
 private void AddPlugin(IJsonViewerPlugin plugin)
 {
     plugins.Add(plugin);
     if (plugin is ICustomTextProvider)
     {
         textVisualizers.Add((ICustomTextProvider)plugin);
     }
     if (plugin is IJsonVisualizer)
     {
         if (_defaultVisualizer == null)
         {
             _defaultVisualizer = (IJsonVisualizer)plugin;
         }
         visualizers.Add((IJsonVisualizer)plugin);
     }
 }
예제 #3
0
 private void AddPlugin(IJsonViewerPlugin plugin)
 {
     //_plugins.Add(plugin);
     if (plugin is ICustomTextProvider provider)
     {
         TextVisualizers.Add(provider);
     }
     if (plugin is IJsonVisualizer visualizer)
     {
         if (DefaultVisualizer == null)
         {
             DefaultVisualizer = visualizer;
         }
         Visualizers.Add(visualizer);
     }
 }
예제 #4
0
        private void ActivateVisualizer()
        {
            IJsonVisualizer visualizer = (IJsonVisualizer)cbVisualizers.SelectedItem;

            if (visualizer != null)
            {
                JsonObject jsonObject     = GetSelectedTreeNode().JsonObject;
                Control    visualizerCtrl = visualizer.GetControl(jsonObject);
                if (_lastVisualizerControl != visualizerCtrl)
                {
                    pnlVisualizer.Controls.Remove(_lastVisualizerControl);
                    pnlVisualizer.Controls.Add(visualizerCtrl);
                    visualizerCtrl.Dock    = DockStyle.Fill;
                    _lastVisualizerControl = visualizerCtrl;
                }
                visualizer.Visualize(jsonObject);
            }
        }
예제 #5
0
        private void AddPlugin(IJsonViewerPlugin plugin)
        {
            _plugins.Add(plugin);
            switch (plugin)
            {
            case ICustomTextProvider provider:
                _textVisualizers.Add(provider);
                break;

            case IJsonVisualizer visualizer:
                if (_defaultVisualizer == null)
                {
                    _defaultVisualizer = visualizer;
                }
                _visualizers.Add(visualizer);
                break;
            }
        }
예제 #6
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();
        }