Skip to content

Commit

Permalink
Refactor Json Viewer fix #1614
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Feb 4, 2023
1 parent f9e2bd6 commit bf49636
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 24 deletions.
109 changes: 107 additions & 2 deletions Analogy.CommonControls/Tools/JsonTreeUC.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Analogy.CommonControls/Tools/JsonTreeUC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ private void JsonTreeUC_Load(object sender, EventArgs e)
_jsonTreeView.ShowJson(JsonData);
}


bbiCopyMessage.ItemClick += (_, _) =>
{
Clipboard.SetText(_jsonTreeView.Message);
};
}

public void ShowJson(string json)
Expand Down
3 changes: 3 additions & 0 deletions Analogy.CommonControls/Tools/JsonTreeUC.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="barManager1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
40 changes: 19 additions & 21 deletions Analogy.CommonControls/Tools/JsonTreeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class JsonTreeView : TreeView
private StatusStrip statusStrip1;
private string previouslySelectedNodeText;
public event EventHandler<string> OnNodeChanged;
public string Message { get; set; }
public JsonTreeView()
{
InitializeComponent();
Expand Down Expand Up @@ -111,23 +112,6 @@ private void LoadImageList()
ImageList = treeImages;
}

public void ClearList()
{
Nodes.Clear();
}
public void ShowJson(string jsonString)
{
try
{
object json = JsonConvert.DeserializeObject(jsonString);
LoadTree(json);
}
catch (Exception e)
{
}

}

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
private void LoadTree(object jsonData)
{
Expand Down Expand Up @@ -296,9 +280,7 @@ private void InitializeComponent()
get => base.SelectedNode as JsonTreeNode;
set => base.SelectedNode = value;
}

#region UI events


private void this_AfterSelect(object sender, TreeViewEventArgs e)
{
// restore previous seelcted node text and store the next
Expand Down Expand Up @@ -344,6 +326,22 @@ private void expandAllMenuItem_Click(object sender, EventArgs e)
}
}

#endregion
public void ClearList()
{
Nodes.Clear();
}
public void ShowJson(string jsonString)
{
Message = jsonString;
try
{
object json = JsonConvert.DeserializeObject(jsonString);
LoadTree(json);
}
catch (Exception e)
{
}

}
}
}
1 change: 1 addition & 0 deletions Analogy/CommonChangeLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static IEnumerable<AnalogyChangeLog> GetChangeLog()
{
return new List<AnalogyChangeLog>
{
new AnalogyChangeLog("V4.11.0 - Refactor Json Viewer #1614",AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2023, 02, 04)),
new AnalogyChangeLog("V4.11.0 - Add RawText, LineNumber and MethodName columns #1616",AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2023, 02, 04)),
new AnalogyChangeLog("V4.11.0 - Message details window doesn't remember its size #1612",AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2023, 01, 28)),
new AnalogyChangeLog("V4.11.0 - Add a multiline value preview to the JSON inline viewer #1611",AnalogChangeLogType.Improvement, "Lior Banai", new DateTime(2023, 01, 28)),
Expand Down

0 comments on commit bf49636

Please sign in to comment.