Esempio n. 1
0
 private void Redraw()
 {
     try
     {
         tvJson.BeginUpdate();
         try
         {
             Reset();
             if (!String.IsNullOrEmpty(_json))
             {
                 JsonObjectTree tree = JsonObjectTree.Parse(_json);
                 VisualizeJsonTree(tree);
             }
         }
         finally
         {
             tvJson.EndUpdate();
         }
     }
     catch (JsonParseError e)
     {
         GetParseErrorDetails(e);
     }
     catch (Exception e)
     {
         ShowException(e);
     }
 }
Esempio n. 2
0
        private void VisualizeJsonTree(JsonObjectTree tree)
        {
            AddNode(tvJson.Nodes, tree.Root);
            JsonViewerTreeNode node = GetRootNode();

            InitVisualizers(node);
            node.Expand();
            tvJson.SelectedNode = node;
        }
Esempio n. 3
0
        private void Redraw()
        {
            if (_pirateXPackage == null)
            {
                return;
            }

            var response = _pirateXPackage;
            var text     = _pirateXPackage.ContentBytes == null?string.Empty: Encoding.UTF8.GetString(_pirateXPackage.ContentBytes);


            var viewitem = listViewIn.Items.Add(DateTime.Now.ToString());

            viewitem.SubItems.Add($"{string.Join("&", response.Headers.AllKeys.Select(a=>a+"="+ response.Headers[a]))}");

            if (string.IsNullOrEmpty(text))
            {
                if (response.Headers.AllKeys.Contains("errorCode") && response.Headers.AllKeys.Contains("errorMsg"))
                {
                    text = $@"
                        {"{"}""errorCode"":""{response.Headers["errorCode"]}"",
                             ""errorMsg"":""{response.Headers["errorMsg"]}""{"}"}";
                }
            }
            viewitem.SubItems.Add(text);
            _json        = text;
            txtJson.Text = text;

            try
            {
                tvJson.BeginUpdate();
                try
                {
                    Reset();
                    if (!String.IsNullOrEmpty(_json))
                    {
                        JsonObjectTree tree = JsonObjectTree.Parse(_json);
                        VisualizeJsonTree(tree);
                    }
                }
                finally
                {
                    tvJson.EndUpdate();
                }
            }
            catch (JsonParseError e)
            {
                GetParseErrorDetails(e);
            }
            catch (Exception e)
            {
                ShowException(e);
            }
        }
Esempio n. 4
0
 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     switch ((sender as TabControl).SelectedIndex)
     {
     case 0:
         if (_tree != null && _tree != _oldTree)
         {
             VisualizeJsonTree(_tree);
             _oldTree = _tree;
         }
         break;
     }
 }
Esempio n. 5
0
        private void VisualizeJsonTree(JsonObjectTree tree)
        {
            if (tree == null)
            {
                return;
            }
            tvJson.Nodes.Clear();
            AddNode(tvJson.Nodes, tree.Root);
            JsonViewerTreeNode node = GetRootNode();

            InitVisualizers(node);
            node.Expand();
            tvJson.SelectedNode = node;
            GC.Collect();
        }
 //对比功能
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     CheckedListBox.CheckedIndexCollection checkeds = hisListBox1.CheckedIndices;
     if (checkeds.Count == 2)
     {
         JsonObjectTree tree1 = hisJsonMap[hisStringList[checkeds[0]]];
         JsonObjectTree tree2 = hisJsonMap[hisStringList[checkeds[1]]];
         CheckedListBox.CheckedItemCollection    items = hisListBox1.CheckedItems;
         KeyValuePair <string, JsonObjectTree>[] data  = new KeyValuePair <string, JsonObjectTree>[] {
             new KeyValuePair <string, JsonObjectTree>((string)items[0], tree1), new KeyValuePair <string, JsonObjectTree>((string)items[1], tree2)
         };
         new CompareWindow(data).Show();
     }
     else
     {
         MessageBox.Show("请选择两条记录");
     }
 }
        private void VisualizeJsonTree(JsonObjectTree tree)
        {
            levelNodesCount = new int[20];
            AddNode(tvJson.Nodes, tree.Root);
            JsonViewerTreeNode node = GetRootNode();
            int total = 0;
            int index = 0;

            for (int i = 0; i < 20; i++)
            {
                total += levelNodesCount[i];
                if (total * 18 > tvJson.Bounds.Height * 1)
                {
                    break;
                }
                else
                {
                    index = i;
                }
            }
            expandSubNodes(node, index - 1 < 0?0:index - 1);
            tvJson.SelectedNode = node;
        }
Esempio n. 8
0
 private void VisualizeJsonTree(JsonObjectTree tree)
 {
     AddNode(tvJson.Nodes, tree.Root);
     JsonViewerTreeNode node = GetRootNode();
     InitVisualizers(node);
     node.Expand();
     tvJson.SelectedNode = node;
 }
        private void Redraw()
        {
            if (_json == prevText)
            {
                return;
            }
            try
            {
                tvJson.BeginUpdate();
                try
                {
                    Reset();
                    if (!String.IsNullOrEmpty(_json))
                    {
                        JsonObjectTree tree = null;
                        if (hisJsonMap.ContainsKey(_json))
                        {
                            tree = hisJsonMap[_json];
                            int index = hisStringList.BinarySearch(_json);
                            if (index >= 0)
                            {
                                hisListBox1.SetSelected(index, true);
                                lastSelectHisItem = (string)hisListBox1.Items[index];
                            }
                        }
                        else
                        {
                            tree = JsonObjectTree.Parse(_json);
                            hisJsonMap.Add(_json, tree);
                            hisStringList.Add(_json);
                            string title = DateTime.Now.ToLongTimeString() + "→";
                            if (tree.Root.Fields.Count > 0)
                            {
                                title += tree.Root.Fields[0].Text.Replace("\n", " ");
                            }
                            hisListBox1.Items.Add(title, CheckState.Unchecked);
                            hisListBox1.SetSelected(hisListBox1.Items.Count - 1, true);
                            lastSelectHisItem = title;
                            if (hisListBox1.Items.Count > 40)
                            {//超过40条历史记录每多一条删除第一条
                                hisJsonMap.Remove(hisStringList[0]);
                                hisStringList.RemoveAt(0);
                                hisListBox1.Items.RemoveAt(0);
                            }
                        }

                        VisualizeJsonTree(tree);
                    }
                }
                finally
                {
                    tvJson.EndUpdate();
                }
            }
            catch (JsonParseError e)
            {
                GetParseErrorDetails(e);
            }
            catch (Exception e)
            {
                ShowException(e);
            }
            prevText = _json;
        }