📄 frmaddtosnippet.cs
字号:
namespace Codematic
{
using Codematic.Properties;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using WiB.Pinkie.Controls;
public class FrmAddToSnippet : Form
{
private ButtonXP btnExit;
private ButtonXP btnOk;
private Container components;
private Label label1;
private RichTextBox qcEditor;
private TextBox txtCaption;
public FrmAddToSnippet(string text)
{
this.InitializeComponent();
this.qcEditor.Text = text;
}
private void btnExit_Click(object sender, EventArgs e)
{
base.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
if (this.txtCaption.Text.Length != 0)
{
XmlDocument document = new XmlDocument();
document.Load(Application.StartupPath + @"\Snippets.xml");
foreach (XmlNode node in document.GetElementsByTagName("snippets")[0].ChildNodes)
{
if (node.Attributes["name"].Value.ToUpper() == this.txtCaption.Text.ToUpper())
{
MessageBox.Show("对不起,该名称已经存在!");
return;
}
}
XmlNode documentElement = document.DocumentElement;
XmlElement newChild = document.CreateElement("snippet");
newChild.InnerText = this.qcEditor.Text;
XmlAttribute attribute = document.CreateAttribute("name");
attribute.Value = this.txtCaption.Text;
newChild.Attributes.Append(attribute);
documentElement.AppendChild(newChild);
document.Save(Application.StartupPath + @"\Snippets.xml");
base.Close();
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.label1 = new Label();
this.txtCaption = new TextBox();
this.qcEditor = new RichTextBox();
this.btnOk = new ButtonXP();
this.btnExit = new ButtonXP();
base.SuspendLayout();
this.label1.AutoSize = true;
this.label1.BackColor = Color.Transparent;
this.label1.Location = new Point(0x10, 0x59);
this.label1.Name = "label1";
this.label1.Size = new Size(0x2f, 12);
this.label1.TabIndex = 1;
this.label1.Text = "标 题:";
this.txtCaption.Location = new Point(0x48, 0x57);
this.txtCaption.Name = "txtCaption";
this.txtCaption.Size = new Size(0x180, 0x15);
this.txtCaption.TabIndex = 2;
this.qcEditor.Location = new Point(8, 0x70);
this.qcEditor.Name = "qcEditor";
this.qcEditor.Size = new Size(480, 0xb8);
this.qcEditor.TabIndex = 3;
this.qcEditor.Text = "";
this.btnOk._Image = null;
this.btnOk.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
this.btnOk.DefaultScheme = false;
this.btnOk.DialogResult = DialogResult.None;
this.btnOk.Image = null;
this.btnOk.Location = new Point(0x128, 0x132);
this.btnOk.Name = "btnOk";
this.btnOk.Scheme = ButtonXP.Schemes.Blue;
this.btnOk.Size = new Size(0x4b, 0x1a);
this.btnOk.TabIndex = 0x2a;
this.btnOk.Text = "保 存";
this.btnOk.Click += new EventHandler(this.btnOk_Click);
this.btnExit._Image = null;
this.btnExit.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
this.btnExit.DefaultScheme = false;
this.btnExit.DialogResult = DialogResult.None;
this.btnExit.Image = null;
this.btnExit.Location = new Point(0x188, 0x132);
this.btnExit.Name = "btnExit";
this.btnExit.Scheme = ButtonXP.Schemes.Blue;
this.btnExit.Size = new Size(0x4b, 0x1a);
this.btnExit.TabIndex = 0x2a;
this.btnExit.Text = "取 消";
this.btnExit.Click += new EventHandler(this.btnExit_Click);
this.AutoScaleBaseSize = new Size(6, 14);
this.BackgroundImage = Resources.about3;
base.ClientSize = new Size(0x1f2, 0x158);
base.Controls.Add(this.btnOk);
base.Controls.Add(this.qcEditor);
base.Controls.Add(this.txtCaption);
base.Controls.Add(this.label1);
base.Controls.Add(this.btnExit);
base.FormBorderStyle = FormBorderStyle.FixedDialog;
base.MaximizeBox = false;
base.MinimizeBox = false;
base.Name = "FrmAddToSnippet";
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.CenterScreen;
this.Text = "脚本片段管理";
base.ResumeLayout(false);
base.PerformLayout();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -