说来真是折腾,
先是找的AHK的代码高亮组件, 对中文支持不好,
接着找的C++代码, 遇到各种语法问题,
今天在github搜的时候, 找到一个.net组件名字叫EasyScintilla 编译成了exe用了一下, 居然支持8种编程语言语法着色, 完全满足需要, 更重要的时候, 我看了下源代码, 实际代码只要不到七八十行,
重要代码分布在了如下的 Form1.cs和Form1.Designer.cs两个文件中, 怎样把这两个文件合并后, 嵌入到ps中来运行呢? 求路过高手支招, 谢谢
编译后的EXE和源代码在下面链接
https://t.wss.ink/f/awy92us406a 复制链接到浏览器打开
效果展示
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using EasyScintilla.Stylers;
-
- namespace ExampleProject
- {
- public partial class Form1 : Form
- {
-
- private ExampleDisplay[] _examples = new ExampleDisplay[]
- {
- new ExampleDisplay("C#", "cs.txt", new CSharpStyler()),
- new ExampleDisplay("C# (Dark)", "cs.txt", new DarkCSharpStyler()),
- new ExampleDisplay("Windows Batch", "bat.txt", new BatchStyler()),
- new ExampleDisplay("HTML", "html.txt", new HtmlStyler()),
- new ExampleDisplay("JSON", "json.txt", new JsonStyler()),
- new ExampleDisplay("PowerShell", "ps1.txt", new PowerShellStyler()),
- new ExampleDisplay("Python", "py.txt", new PythonStyler()),
- new ExampleDisplay("Ruby", "rb.txt", new RubyStyler()),
- new ExampleDisplay("T-SQL", "sql.txt", new SqlStyler()),
- new ExampleDisplay("Teradata Parallel Transporter", "tpt.txt", new TptStyler()),
- };
-
- public Form1()
- {
- InitializeComponent();
- }
-
- private void Form1_Load(object sender, EventArgs e)
- {
- stylerPicker.DataSource = _examples;
- stylerPicker.DisplayMember = "Display";
- }
-
- private void stylerPicker_SelectedIndexChanged(object sender, EventArgs e)
- {
- var example = _examples[stylerPicker.SelectedIndex];
- editor.Text = example.ReadFile();
- editor.Styler = example.Styler;
- }
- }
- }
复制代码
- namespace ExampleProject
- {
- partial class Form1
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.editor = new EasyScintilla.SimpleEditor();
- this.stylerPicker = new System.Windows.Forms.ComboBox();
- this.SuspendLayout();
- //
- // editor
- //
- this.editor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.editor.IndentationGuides = ScintillaNET.IndentView.LookBoth;
- this.editor.Location = new System.Drawing.Point(12, 12);
- this.editor.Name = "editor";
- this.editor.Size = new System.Drawing.Size(854, 603);
- this.editor.Styler = null;
- this.editor.TabIndex = 0;
- //
- // stylerPicker
- //
- this.stylerPicker.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.stylerPicker.FormattingEnabled = true;
- this.stylerPicker.Location = new System.Drawing.Point(12, 621);
- this.stylerPicker.Name = "stylerPicker";
- this.stylerPicker.Size = new System.Drawing.Size(854, 21);
- this.stylerPicker.TabIndex = 1;
- this.stylerPicker.SelectedIndexChanged += new System.EventHandler(this.stylerPicker_SelectedIndexChanged);
- //
- // Form1
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(878, 656);
- this.Controls.Add(this.stylerPicker);
- this.Controls.Add(this.editor);
- this.Name = "Form1";
- this.Text = "EasyScintilla Test App";
- this.Load += new System.EventHandler(this.Form1_Load);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private EasyScintilla.SimpleEditor editor;
- private System.Windows.Forms.ComboBox stylerPicker;
- }
- }
复制代码
|