功能:输入正则表达式即时匹配出结果

reg

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace RegexTool
{
    public partial class Form1 : Form
    {
        Regex reg;
        public Form1()
        {
            InitializeComponent();
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            richTextBox1.SelectAll();
            richTextBox1.SelectionBackColor = Color.White;
            regIt();
        }
        private void regIt()
        {
            try
            {
                if (textBox1.Text == "")
                {
                    label1.Text = "";
                }
                else
                {
                    reg = new Regex(textBox1.Text);
                    MatchCollection mc = reg.Matches(@richTextBox1.Text);
                    int count = 0;
                    for (int i = 0; i < mc.Count; i++)
                    {
                        richTextBox1.Select(mc[i].Index, mc[i].Length);
                        if ((i + 2) % 2 == 0)
                        {
                            richTextBox1.SelectionBackColor = ColorTranslator.FromHtml("#FFF000");
                        }
                        else
                        {
                            richTextBox1.SelectionBackColor = ColorTranslator.FromHtml("#D2F854");
                        }
                        if (mc[i].Length != 0)
                        {
                            count++;
                        }
                    }
                    label1.Text = "结果:" + count + "个";
                }
            }
            catch (Exception ex)
            {
                label1.Text = "错误:" + ex.Message;
            }
        }
        private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                e.Handled = true;
                richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Text));
            }
        }
        private void textBox1_MouseClick(object sender, MouseEventArgs e)
        {
            if (textBox1.Text == "在此输入正则表达式")
            {
                textBox1.Clear();
            }
        }
        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                textBox1.Text = "在此输入正则表达式";
            }
        }
    }
}

之前的自动更新 Smarthosts 到本地 hosts最后需要刷新 DNS 缓存,刷新 DNS 缓存首先想到的就是“ipconfig /flushdns” 命令,直接调用 cmd.exe 就可以了。不知道 .net 里是否提供了直接刷新 DNS 的方法,于是搜索了一下,很奇怪搜索“ C# 刷新 DNS 缓存”竟然找不到想要的结果,搜索“c# flush dns cache”一下就有答案了。方法大概有两种,一种就是调用 cmd.exe,一种就是调用系统 API:dnsapi.dll,其实 cmd 里方法也是调用 dnsapi.dll 实现的,为了不那么麻烦,这里就直接调用 cmd.exe 了。

using (System.Diagnostics.Process process = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "ipconfig /flushdns";
process.StartInfo = startInfo;
process.Start();
}

网上教程太多了已经分辨不出是谁原创的了,用自己的话写一遍

新建白色背景画布

新建图层“布纹颜色”,填充你想要的颜色

新建图层“深色横纹”,填充白色

选择“滤镜-杂色-添加杂色”,数量99%,平均分布,单色

选择“滤镜-模糊-动感模糊”,角度0度,距离25像素

更改图层混合模式为叠加,不透明度25%

新建图层“深色竖纹”,和上面一样,不同的是把动感模糊角度设为90度

新建图层“浅色横纹”和“浅色竖纹”,和上面一样,不同的是图层填充为黑色,把杂色数量变为101%,图层混合模式为滤色,透明度20%

你会发现画布的边缘部分的效果和其他地方不一样,剪裁掉即可~

iphone布纹