*.[新增]网页抓取工具和Json工具里支持代码折叠功能。
This commit is contained in:
parent
6dcf5500f2
commit
ae89a4aa1d
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,9 @@
|
|||
### 2020-12-07更新
|
||||
### 2020-12-09更新
|
||||
------
|
||||
##### SuperDesign V2.0.2012.0901
|
||||
- *.[新增]网页抓取工具和Json工具里支持代码折叠功能。
|
||||
|
||||
### 2020-12-07更新
|
||||
------
|
||||
##### SuperDesign V2.0.2012.0701
|
||||
- *.[修复]修复网页获取抓取工具Head设置不当会导致进度卡死的BUG。
|
||||
|
|
Binary file not shown.
143
Source/开发辅助工具/Controls/MingFolding.cs
Normal file
143
Source/开发辅助工具/Controls/MingFolding.cs
Normal file
|
@ -0,0 +1,143 @@
|
|||
using ICSharpCode.TextEditor.Document;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JackWangCUMT.WinForm
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The class to generate the foldings, it implements ICSharpCode.TextEditor.Document.IFoldingStrategy
|
||||
/// </summary>
|
||||
public class MingFolding : IFoldingStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates the foldings for our document.
|
||||
/// </summary>
|
||||
/// <param name="document">The current document.</param>
|
||||
/// <param name="fileName">The filename of the document.</param>
|
||||
/// <param name="parseInformation">Extra parse information, not used in this sample.</param>
|
||||
/// <returns>A list of FoldMarkers.</returns>
|
||||
public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation)
|
||||
{
|
||||
List<FoldMarker> list = new List<FoldMarker>();
|
||||
//stack 先进先出
|
||||
var startLines = new Stack<int>();
|
||||
// Create foldmarkers for the whole document, enumerate through every line.
|
||||
for (int i = 0; i < document.TotalNumberOfLines; i++)
|
||||
{
|
||||
// Get the text of current line.
|
||||
string text = document.GetText(document.GetLineSegment(i));
|
||||
var text_trim = text.Trim();
|
||||
if (text_trim.StartsWith("#region")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
|
||||
}
|
||||
if (text_trim.StartsWith("#endregion")) // Look for method endings
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
// Add a new FoldMarker to the list.
|
||||
// document = the current document
|
||||
// start = the start line for the FoldMarker
|
||||
// document.GetLineSegment(start).Length = the ending of the current line = the start column of our foldmarker.
|
||||
// i = The current line = end line of the FoldMarker.
|
||||
// 7 = The end column
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.Region, "..."));
|
||||
}
|
||||
//支持嵌套 {}
|
||||
if (text_trim.StartsWith("{")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("}")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "...}"));
|
||||
}
|
||||
}
|
||||
if (text_trim.StartsWith("[")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("]")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "...]"));
|
||||
}
|
||||
}
|
||||
if (text_trim.EndsWith("[")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("]")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "...]"));
|
||||
}
|
||||
}
|
||||
if (text_trim.StartsWith("<html>")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("</html>")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "</html>"));
|
||||
}
|
||||
}
|
||||
if (text_trim.StartsWith("<head>")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("</head>")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "</head>"));
|
||||
}
|
||||
}
|
||||
if (text_trim.StartsWith("<div>") || text_trim.StartsWith("<div ")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("</div>")) // Look for method endings
|
||||
{
|
||||
if (startLines.Count > 0)
|
||||
{
|
||||
int start = startLines.Pop();
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, "</div>"));
|
||||
}
|
||||
}
|
||||
// /// <summary>
|
||||
if (text_trim.StartsWith("/// <summary>")) // Look for method starts
|
||||
{
|
||||
startLines.Push(i);
|
||||
}
|
||||
if (text_trim.StartsWith("/// <returns>")) // Look for method endings
|
||||
{
|
||||
|
||||
int start = startLines.Pop();
|
||||
//获取注释文本(包括空格)
|
||||
string display = document.GetText(document.GetLineSegment(start + 1).Offset, document.GetLineSegment(start + 1).Length);
|
||||
//remove ///
|
||||
display = display.Trim().TrimStart('/');
|
||||
list.Add(new FoldMarker(document, start, document.GetLineSegment(start).Length, i, 57, FoldType.TypeBody, display));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
3289
Source/开发辅助工具/Manager/HtmlFormater.cs
Normal file
3289
Source/开发辅助工具/Manager/HtmlFormater.cs
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("开发辅助工具")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018-2019")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018-2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.0.2012.0701")]
|
||||
[assembly: AssemblyFileVersion("2.0.2012.0701")]
|
||||
[assembly: AssemblyVersion("2.0.2012.0901")]
|
||||
[assembly: AssemblyFileVersion("2.0.2012.0901")]
|
|
@ -129,6 +129,7 @@
|
|||
<Compile Include="Controls\MenuRight.Designer.cs">
|
||||
<DependentUpon>MenuRight.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\MingFolding.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -148,6 +149,7 @@
|
|||
<Compile Include="Manager\FrmSetting.Designer.cs">
|
||||
<DependentUpon>FrmSetting.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Manager\HtmlFormater.cs" />
|
||||
<Compile Include="Manager\JsonSplit.cs" />
|
||||
<Compile Include="Manager\ClsPY.cs" />
|
||||
<Compile Include="Manager\FrmAddTools.cs">
|
||||
|
|
15
Source/开发辅助工具/Tools/FrmJson.Designer.cs
generated
15
Source/开发辅助工具/Tools/FrmJson.Designer.cs
generated
|
@ -44,8 +44,8 @@
|
|||
this.BtnFormat = new System.Windows.Forms.ToolStripButton();
|
||||
this.BtnPasteJson = new System.Windows.Forms.ToolStripButton();
|
||||
this.BtnCopyJson = new System.Windows.Forms.ToolStripButton();
|
||||
this.menuRight1 = new ryPaiban.Model.MenuRight(this.components);
|
||||
this.CopyJsonByCHS = new System.Windows.Forms.ToolStripButton();
|
||||
this.menuRight1 = new ryPaiban.Model.MenuRight(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
|
@ -80,6 +80,7 @@
|
|||
this.textEditorControl1.Name = "textEditorControl1";
|
||||
this.textEditorControl1.Size = new System.Drawing.Size(400, 491);
|
||||
this.textEditorControl1.TabIndex = 22;
|
||||
this.textEditorControl1.TextChanged += new System.EventHandler(this.textEditorControl1_TextChanged);
|
||||
//
|
||||
// contextMenuStripHighlightText1
|
||||
//
|
||||
|
@ -187,12 +188,6 @@
|
|||
this.BtnCopyJson.Text = "复制Json";
|
||||
this.BtnCopyJson.Click += new System.EventHandler(this.BtnCopyJson_Click);
|
||||
//
|
||||
// menuRight1
|
||||
//
|
||||
this.menuRight1.Name = "menuRight1";
|
||||
this.menuRight1.Size = new System.Drawing.Size(173, 48);
|
||||
this.menuRight1.SourceContent = this;
|
||||
//
|
||||
// CopyJsonByCHS
|
||||
//
|
||||
this.CopyJsonByCHS.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
|
@ -203,6 +198,12 @@
|
|||
this.CopyJsonByCHS.Text = "中文转义复制";
|
||||
this.CopyJsonByCHS.Click += new System.EventHandler(this.CopyJsonByCHS_Click);
|
||||
//
|
||||
// menuRight1
|
||||
//
|
||||
this.menuRight1.Name = "menuRight1";
|
||||
this.menuRight1.Size = new System.Drawing.Size(185, 92);
|
||||
this.menuRight1.SourceContent = this;
|
||||
//
|
||||
// FrmJson
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace 开发辅助工具.Tools
|
|||
public FrmJson()
|
||||
{
|
||||
InitializeComponent();
|
||||
textEditorControl1.Document.FoldingManager.FoldingStrategy = new JackWangCUMT.WinForm.MingFolding();
|
||||
}
|
||||
private void LoadTreeList(TreeNodeCollection nodes,JObject jo)
|
||||
{
|
||||
|
@ -251,6 +252,11 @@ namespace 开发辅助工具.Tools
|
|||
MessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void textEditorControl1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
textEditorControl1.Document.FoldingManager.UpdateFoldings(null, null);
|
||||
}
|
||||
}
|
||||
public class JsonInfo
|
||||
{
|
||||
|
|
19
Source/开发辅助工具/Tools/FrmWebGet.Designer.cs
generated
19
Source/开发辅助工具/Tools/FrmWebGet.Designer.cs
generated
|
@ -179,7 +179,7 @@
|
|||
this.tabPage12.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage12.Name = "tabPage12";
|
||||
this.tabPage12.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage12.Size = new System.Drawing.Size(879, 280);
|
||||
this.tabPage12.Size = new System.Drawing.Size(881, 280);
|
||||
this.tabPage12.TabIndex = 4;
|
||||
this.tabPage12.Text = "HTML格式化";
|
||||
this.tabPage12.UseVisualStyleBackColor = true;
|
||||
|
@ -195,6 +195,7 @@
|
|||
this.Te_Format.Name = "Te_Format";
|
||||
this.Te_Format.Size = new System.Drawing.Size(870, 279);
|
||||
this.Te_Format.TabIndex = 0;
|
||||
this.Te_Format.TextChanged += new System.EventHandler(this.Te_Format_TextChanged);
|
||||
//
|
||||
// contextMenuStripHighlightText1
|
||||
//
|
||||
|
@ -207,7 +208,7 @@
|
|||
this.tabPage4.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage4.Size = new System.Drawing.Size(879, 280);
|
||||
this.tabPage4.Size = new System.Drawing.Size(881, 280);
|
||||
this.tabPage4.TabIndex = 1;
|
||||
this.tabPage4.Text = "Cookie";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
|
@ -221,7 +222,7 @@
|
|||
this.RichCookie.Location = new System.Drawing.Point(3, 3);
|
||||
this.RichCookie.Name = "RichCookie";
|
||||
this.RichCookie.ReadOnly = true;
|
||||
this.RichCookie.Size = new System.Drawing.Size(873, 274);
|
||||
this.RichCookie.Size = new System.Drawing.Size(875, 274);
|
||||
this.RichCookie.TabIndex = 1;
|
||||
this.RichCookie.Text = "";
|
||||
//
|
||||
|
@ -231,7 +232,7 @@
|
|||
this.tabPage5.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage5.Name = "tabPage5";
|
||||
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage5.Size = new System.Drawing.Size(879, 280);
|
||||
this.tabPage5.Size = new System.Drawing.Size(881, 280);
|
||||
this.tabPage5.TabIndex = 2;
|
||||
this.tabPage5.Text = "Status";
|
||||
this.tabPage5.UseVisualStyleBackColor = true;
|
||||
|
@ -245,7 +246,7 @@
|
|||
this.RichStatus.Location = new System.Drawing.Point(3, 3);
|
||||
this.RichStatus.Name = "RichStatus";
|
||||
this.RichStatus.ReadOnly = true;
|
||||
this.RichStatus.Size = new System.Drawing.Size(873, 274);
|
||||
this.RichStatus.Size = new System.Drawing.Size(875, 274);
|
||||
this.RichStatus.TabIndex = 2;
|
||||
this.RichStatus.Text = "";
|
||||
//
|
||||
|
@ -255,7 +256,7 @@
|
|||
this.tabPage6.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage6.Name = "tabPage6";
|
||||
this.tabPage6.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage6.Size = new System.Drawing.Size(879, 280);
|
||||
this.tabPage6.Size = new System.Drawing.Size(881, 280);
|
||||
this.tabPage6.TabIndex = 3;
|
||||
this.tabPage6.Text = "Header";
|
||||
this.tabPage6.UseVisualStyleBackColor = true;
|
||||
|
@ -269,7 +270,7 @@
|
|||
this.RichHeader.Location = new System.Drawing.Point(3, 3);
|
||||
this.RichHeader.Name = "RichHeader";
|
||||
this.RichHeader.ReadOnly = true;
|
||||
this.RichHeader.Size = new System.Drawing.Size(873, 274);
|
||||
this.RichHeader.Size = new System.Drawing.Size(875, 274);
|
||||
this.RichHeader.TabIndex = 3;
|
||||
this.RichHeader.Text = "";
|
||||
//
|
||||
|
@ -279,7 +280,7 @@
|
|||
this.tabPreview.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPreview.Name = "tabPreview";
|
||||
this.tabPreview.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPreview.Size = new System.Drawing.Size(879, 280);
|
||||
this.tabPreview.Size = new System.Drawing.Size(881, 280);
|
||||
this.tabPreview.TabIndex = 5;
|
||||
this.tabPreview.Text = "预览";
|
||||
this.tabPreview.UseVisualStyleBackColor = true;
|
||||
|
@ -292,7 +293,7 @@
|
|||
this.extendedWebBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
|
||||
this.extendedWebBrowser1.Name = "extendedWebBrowser1";
|
||||
this.extendedWebBrowser1.ScriptErrorsSuppressed = true;
|
||||
this.extendedWebBrowser1.Size = new System.Drawing.Size(873, 274);
|
||||
this.extendedWebBrowser1.Size = new System.Drawing.Size(875, 274);
|
||||
this.extendedWebBrowser1.TabIndex = 2;
|
||||
//
|
||||
// groupBox3
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace 开发辅助工具.Tools
|
|||
InitializeComponent();
|
||||
LoadPram();
|
||||
tabControl2.SelectedTab = tabPage12;
|
||||
Te_Format.Document.FoldingManager.FoldingStrategy = new JackWangCUMT.WinForm.MingFolding();
|
||||
}
|
||||
private void LoadPram()
|
||||
{
|
||||
|
@ -269,7 +270,14 @@ namespace 开发辅助工具.Tools
|
|||
_html += _format_html[i];
|
||||
}
|
||||
Te_Format.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("HTML");
|
||||
try
|
||||
{
|
||||
Te_Format.Text = JJCCX.Xml.HtmlFormater.ConvertToXml(_html, true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Te_Format.Text = _html;
|
||||
}
|
||||
if (result.StatusCode == System.Net.HttpStatusCode.Redirect || result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
string title = "";
|
||||
|
@ -298,11 +306,14 @@ namespace 开发辅助工具.Tools
|
|||
else { timespan_str = timespan / 1000 + "秒" + timespan % 1000 + "毫秒"; }
|
||||
this.RichStatus.Text = "StatusCode:" + result.StatusCode.ToString() + "\r\nStatusDescription:" + result.StatusDescription + "\r\n耗时:" + timespan_str;
|
||||
this.RichHeader.Text = "";
|
||||
if (result.Header != null)
|
||||
{
|
||||
foreach (string str1 in result.Header.AllKeys)
|
||||
{
|
||||
string text = this.RichHeader.Text;
|
||||
this.RichHeader.Text = text + str1 + ":" + result.Header[str1].ToString() + "\r\n";
|
||||
}
|
||||
}
|
||||
if (!ChkNoPreview.Checked)
|
||||
{
|
||||
if (ChkHtmlPreview.Checked)
|
||||
|
@ -760,6 +771,11 @@ namespace 开发辅助工具.Tools
|
|||
{
|
||||
ChkHtmlPreview.Enabled = !ChkNoPreview.Checked;
|
||||
}
|
||||
|
||||
private void Te_Format_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
Te_Format.Document.FoldingManager.UpdateFoldings(null, null);
|
||||
}
|
||||
}
|
||||
public class UserAgentInfo
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user