winform翻译

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

namespace Win.Helper
{
    public partial class frmChineseReplace : Form
    {
        public frmChineseReplace()
        {
            InitializeComponent();
        }

        //越在前面,替换优先级越高
        Dictionary<string, string> dicCSharp = new Dictionary<string, string>() {
            {"using","引用" },
            {"System","系统" },
            {"Collections","集合" },
            {"Generic","泛型" },
            {"ComponentModel","组件模型" },
            {"Data","数据" },
        
            {"else","否则" },
            {"const","常量" },
            {"Tuple","元组" },
            {"Environment","环境" },
            {"Resource","资源" },

            {"Drawing","绘图" },
            {"Linq","语言集成查询" },
            {"Form","窗体" },
            {"namespace","命名空间" },
            {"public","公开的" },
            {"private","私有的" },
            {"partial","部分的" },
            {"class","" },
            {"void","无返回值" },
            {"TextChanged","文本改变" },
            {"sender","调用控件" },
            {"EventArgs","事件参数" },
            {"textBox","文本框控件" },
            {"Trim","去空格" },
            {"Contains","包含" },
            {"Replace","替换" },
            {"Model","模型" },
            {"Mode","模式" },
            {"Return","返回" },
            {"Result","结果" },
            {"result","结果" },
            {"PreView","预览" },
            {"View","视图" },
            {"Conn","连接" },
            {"SqlConnection","Sql连接" },
            {"Connect","连接" },
            {"ConnectionString","连接字符串" },
            {"Route","路由" },
            {"Paging","分页" },
            {"Status","状态" },
            {"Msg","消息" },
            {"Memo","通知" },
            {"InitializeComponent","初始化组件" },
            {"Init","初始化" },
            {"static","静态" },
            {"RegularExpressions","正则表达式" },
            {"Database","数据库" },
            {"throw","抛出" },
            {"Exception","异常" },
            {"EXCEPTION","异常" },
            {"null","" },
            {"Param","参数" },
            {"Exists","存在" },
            //{"where","过滤" },
            {"Where","过滤" },
            {"Field","字段" },
            {"Get","获取" },
            {"Name","名称" },
            {"Query","查询" },
            {"Execute","执行" },
            {"Transaction","事务" },
            {"Scope","范围" },
            {"Func","委托" },
            {"try","异常捕获" },
            {"catch","捕获处理" },
            {"Dispose","释放资源" },
            {"DISPOSED","释放资源" },
            {"Success","成功" },
            {"Load","加载" },
            {"Threading","线程" },
            {"Thread","线程" },
            //{"Tasks","任务" },
            {"Task","任务" },
            {"TASK","任务" },
            {"AddRange","添加集合" },
            {"Add","添加" },
            {"Sale","销售" },
            {"OrderNumber","单号" },
            {"Order","订单" },
            {"Product","产品" },
            {"Search","搜索" },
            {"user","用户" },
            {"User","用户" },
            {"Role","角色" },
            //{"List","集合" },
            //{"ToList","转集合" },
            {"Manager","管理" },
            {"Manage","管理" },
            {"Type","类型" },
            {"company","公司" },
            {"Company","公司" },
            {"Payment","支付" },
            {"Shop","店铺" },
            {"Record","记录" },
            {"Import","导入" },
            {"Menu","菜单" },
            {"Rule","规则" },
            {"FirstOrDefault","第一个" },
            {"IndexOf","索引" },
            {"ViewBag","视图包" },
            {"Configuration","配置" },
            {"Web","网站" },
            {"Common","通用" },
            {"Controller","控制器" },
            {"NPOI","NPOI第三方Excel类库" },
            {"Center","中心" },
            {"Achievement","成绩" },
            {"ActionResult","通用返回类型" },
            {"Action","动作" },
            {"Remark","备注" },
            {"Export","导出" },
            {"BeginDate","开始时间" },
            {"EndDate","结束时间" },
            {"ComKey","机构Key" },
            {"parms","参数" },
            {"Cilent","客户" },
            {"TotalMoney","总金额" },
            {"Dictionary","字典" },
            {"url","地址" },
            {"path","路径" },
            {"Path","路径" },
            {"Helper","帮助类" },
            {"Invalid","无效的" },
            {"Invoicing","单据" },
            {"Invoke","调用" },
            {"INVOKED","调用" },
            {"Inv","单据" },
            {"Detail","明细" },
            {"Cancellation","取消" },
            {"cancellation","取消" },
            {"Canceled","取消" },
            {"Token","令牌" },
            {"cell","单元格" },
            {"Cell","单元格" },
            {"header","" },
            {"JsonRequestBehavior.AllowGet","允许Get请求" },
            {"AfterSale","售后" },
            {"entity","实体" },
            {"Entity","实体" },
            {"SysKey","系统Key" },
            {"syskey","系统Key" },
            {"Contacts","联络人" },
            {"ContactNumber","联络号码" },
            {"Update","更新" },
            {"Convert","类型转换" },
            {"string.Format","字符串格式化" },
            {"Tel","电话" },
            {"Phone","手机" },
            {"TelePhone","电话" },
            {"ToLower","转成小写" },
            {"Level","等级" },
            {"State","状态" },
            {"STATE","状态" },
            {"Request","请求" },
            {"Directory","目录" },
            {"AppDomain","应用程序域" },
            {"Current","当前" },
            {"CurrentDomain","当前域" },
            {"BaseDirectory","根目录" },
            {"File","文件" },
            {"file","文件" },
            {"SaveAs","保存到" },
            {"Save","保存" },
            {"Stream","" },
            {"Access","访问" },
            {"Read","" },
            {"Write","" },
            {"Open","打开" },
            {"Creation","创建" },
            {"Create","创建" },
            {"Workbook","工作簿" },
            {"Input","输入" },
            {"Area","区域" },

            {"SelectionStart","选中文本开始的位置" },
            {"SelectionLength","选中文本长度" },
            {"SelectionColor","选中文本颜色" },
            {"SelectionBackColor","选中背景色" },

            {"Start","开始" },
            {"Column","" },
            {"Value","" },
            {"Reset","重置" },
            {"TrySet","尝试设置" },
            {"Set","设置" },
            {"province","省份" },
            {"Province","省份" },
            {"city","城市" },
            {"City","城市" },
            {"Row","" },
            {"Age","年龄" },
            {"AgeBand","年龄段" },
            {"project","项目" },
            {"Project","项目" },
            {"Text","文本" },
            {"Demo","示例" },
            {"Stop","停止" },
            {"Work","工作" },
            {"Group","分组" },
            {"Default","默认" },
            {"Color","颜色" },
            {"BackColor","背景色" },
            {"FillWeight","填充比重" },
            {"Style","样式" },
            {"Auto","自动" },
            {"Size","大小" },
            {"Font","字体" },
            {"Month","月份" },
            {"DateTime.Now","当前时间" },
            {"Clear","清除" },
            {"Completed","完成" },
            {"complete","完成" },
            {"Member","成员" },
            {"DisplayMember","显示成员" },
            {"DataSource","数据源" },
            {"Selected","选中的" },
            {"ComboBox","下拉框" },
            {"LineHeight","行高" },
            {"Service","服务" },
            {"Enum","枚举" },
            {"Insert","插入" },
            {"Event","事件" },
            {"Draw","绘制" },
            {"Handler","处理" },
            {"Background","背景" },
            {"Rectangle","矩形" },
            {"Focus","焦点" },
            {"ForeColor","字体颜色" },
            {"Solid","实心" },
            {"Brush","刷子" },
            {"Delivery","交货" },
            {"Submit","提交" },
            {"SubmitTime","提交时间" },
            {"AutoGenerate","自动生成" },
            {"Total","" },
            {"totalCount","总行数" },
            {"Table","" },
            {"Subtract","减去" },
            {"Hours","小时" },
            {"Math.Floor","向下取整" },
            {"Math.Ceiling","向上取整" },
            {"Description","描述" },
            {"SkyBlue","天蓝色" },
            {"Black","黑色" },
            {"White","白色" },
            {"IndianRed","印第安红" },
            {"PagesNext","下一页" },
            {"Click","单击" },
            {"Edit","编辑" },
            {"BeginEdit","开启编辑" },
            {"Document","文档" },
            {"ShowDialog","显示对话框" },
            {"DelayPromise","延迟答应" },
            {"Delay","延迟" },
            {"Del","删除" },
            {"Delete","删除" },
            {"MessageBox","消息窗口" },
            {"Process","进程" },
            {"Diagnostics","诊断" },
            {"Grid","表格" },
            {"Content","内容" },
            {"Runtime","运行时" },
            {"Interop","互操作" },
            {"Program","程序" },
            {"Enable","启用" },
            {"Application","应用程序" },
            {"Compatible","兼容的" },
            {"Rendering","翻译" },
            {"Icon","图标" },
            {"Login","登录" },
            {"Hook","钩子" },
            {"Hooker","钩子" },
            //{"Control","控件" },
            {"delegate","委托" },
            {"DELEGATE","委托" },
            {"IntPtr","指针" },
            {"Internal","内部的" },
            {"internal","内部的" },
            {"break","跳出" },
            {"using Dapper","使用Dapper访问数据库" },
            {"Dal","数据访问" },
            {"Section","部分" },
            {"Check","检查" },
            {"SqlBulkCopy","Sql批量复制" },
            {"Cast","转换" },
            {"Properties","属性" },
            {"Chinese","中文" },
            {"MouseDown","鼠标按下" },
            {"MouseUp","鼠标松开" },
            {"MouseMove","鼠标移动" },
            {"MouseLeave","鼠标离开" },
            {"Rest","重置" },
            {"Length","长度" },
            {"Print","打印" },
            {"Then","然后" },
            {"QRCode","二维码" },
            {"LastOrDefault","最后一个" },
            {"Template","模板" },
            {"Brand","品牌" },
            {"Doctor","医生" },
            {"Patients","患者" },
            {"PrintDialog","打印对话框" },
            {"Dialog","对话框" },
            {"Graphics","画板" },
            {"Bitmap","位图" },
            {"Pixel","像素" },
            {"Interpolation","插值" },
            {"High","" },
            {"Quality","质量" },
            {"CopyFromScreen","截屏" },
            {"Location","坐标" },
            {"Image","图片" },
            {"Append","追加" },
            {"SerializeObject","序列化对象" },
            {"Serialize","序列化" },

            {"Factory","工厂" },
            {"MedicalOrganization","医疗组织" },
            {"Colour","颜色" },
            {"LeftUp","左上" },
            {"RightUp","右上" },
            {"LeftBelow","左下" },
            {"RightBelow","右下" },
            {"DateProduced","生产日期" },
            {"Security","安全" },
            {"Ellipse","椭圆" },
            {"Permissions","权限" },
            {"Host","主机" },
            {"Protection","保护" },
            {"Pool","" },
            {"External","外部" },
            {"SecurityAction","安全动作" },
            {"LinkDemand","要求链接" },
            {"ExecutionContext","执行上下文" },
            {"Context","上下文" },
            {"Capture","捕获" },
            {"volatile","不稳定" },
            {"Manual","手动" },
            {"Completion","完成" },
            {"completion","完成" },
            {"completing","完成中" },
            {"Shared","共享" },
            {"Registration","注册" },
            {"Countdown","倒计时" },
            {"exceptionalChildren","子异常" },
            {"Deregister","撤销" },
            {"Callback","回调" },
            {"sealed","密封的" },
            {"Interlocked","原子锁" },
            {"Decrement","递减" },
            {"Timer ","定时器" },
            {"LoggingOn","日志记录" },
            {"Async","异步" },
            {"Sync","同步" },
            {"Causality","因果" },
            {"Trace","跟踪" },
            {"Tracer","跟踪" },
            {"TraceOperationCreation","跟踪创建操作" },
            {"Operation","操作" },
            {"Required","必需的" },
            {"Debugging","调试" },
            {"flag","标志" },
            {"Remove","移除" },
            {"From","" },
            {"Active","活动的" },
            {"When","" },
            {"All","全部" },
            {"readonly","只读" },
            {"override","重写" },
            {"WaitCompletion","等待完成" },
            {"Should","应该" },
            {"Notify","通知" },
            {"Any","任何" },
            {"Requires","要求" },
            {"Dispatch","派遣" },
            {"Info","信息" },
            {"Faulted","错误的" },
            {"Counter","计数器" },
            {"Scheduler","调度" },
            {"OptionsMask","掩码选项" },
            {"Options","选项" },
            {"STARTED","启动" },
            {"OBSERVED","观察" },
            {"BY","通过" },
            {"PARENT","parent" },
            {"Sentinel","哨兵" },
            {"Contingent","偶然" },
            {"Predicate","谓词" },
            {"Critical","关键" },
            {"NotRan","不运行" },
            {"IsRan","是运行" },
            {"Method","方法" },
            {"AggressiveInlining","主动内联" },
            {"NoInlining","不内联" },
            {"virtual","虚拟的" },
            {"Dynamically","动态的" },
            {"CompareExchange","比较交换" },
            {"StackGuard","堆栈保护" },
            {"SelfReplicatingRoot","自复制根" },
            {"ChildReplica","复制子项" },
            {"Child","子项" },
            {"PreAllocated","重新分配" },
            {"Ensure","确保" },
            {"HandedOver","交出" },
            {"Allow","允许" },
            {"Lock","" },
            {"Core","核心" },
            {"StackCrawlMark","堆栈爬行标记" },
            {"Possibly","可能的" },
            {"AttachedTo","依附于" }, 
            {"Continuation","继续" }, 
            {"Continue","继续" }, 
            {"Deny","拒绝" }, 
            {"Spin","旋转" }, 
            {"Wait","等待" }, 
            {"Atomic","原子的" }, 
            {"Once","一次" }, 
            {"FireTask","消防任务" }, 
            {"Argument","参数" }, 
            {"Null","" },
            {"PreviousReplica","以前的副本" },
            {"OutOfRange","超出范围" },
            {"Ignore","忽略" },




                {"if","如果" },
        };

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            var txt = textBox1.Text.Trim();

            foreach (var key in dicCSharp.Keys)
            {
                if (txt.Contains(key))
                {
                    txt = txt.Replace(key, dicCSharp[key]);
                    txt = txt.Replace(key.ToLower(), dicCSharp[key]);
                }
            }
            richTextBox1.Text = txt;
        }

        private void frmChineseReplace_Load(object sender, EventArgs e)
        {

        }





        bool isMouseDown = false;
        private void textBox1_MouseDown(object sender, MouseEventArgs e)
        {
            isMouseDown = true;
        }

        private void textBox1_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;

        }

        private void textBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown && textBox1.SelectedText != "")
            {

                RichTextBox_RestColor();

                //var lines = textBox1.Lines.ToList();
                //var selectedLineTxt = lines.FirstOrDefault(x => x.Contains(textBox1.SelectedText));

                int lineNum = textBox1.Text.Substring(0, textBox1.SelectionStart).Count(x => x == '\n');

                if (lineNum < 0)
                {
                    return;
                }

                var txt = richTextBox1.Lines[lineNum];
                int start = richTextBox1.Text.IndexOf(txt);


                richTextBox1.Select(start, textBox1.SelectionLength);
                richTextBox1.SelectionColor = Color.White;
                richTextBox1.SelectionBackColor = Color.Blue;

                richTextBox1.ScrollToCaret();
            }
        }

        private void textBox1_MouseLeave(object sender, EventArgs e)
        {
            isMouseDown = false;

            //RichTextBox_RestColor();
        }

        private void RichTextBox_RestColor()
        {

            richTextBox1.Select(0, richTextBox1.Text.Length);
            richTextBox1.SelectionColor = richTextBox1.ForeColor;
            richTextBox1.SelectionBackColor = richTextBox1.BackColor;
        }
    }
}

 

posted @ 2022-02-08 12:12  212的s  阅读(66)  评论(0编辑  收藏  举报