文号
t72330
阅读
9194
回复
9
收藏
4
英文文档阅读助手,英语学习助手
2015/07/01
IP:山东
1.gif
1.gif

attachment icon 学英语_划词翻译.rar 6.50KB RAR 26次下载
[ 修改于11年5个月前 - 2015/07/01 13:08:16 ]
张静茹作者
11年5个月前IP:山东
776196
1楼
这个需要.net3.5,上面的需要.net4.5
attachment icon 学英语_划词翻译.rar 6.46KB RAR 43次下载
引用
评论
11年5个月前IP:山东
776327
2楼
不错,挺好用的,翻译英文方便多了
引用
评论
11年5个月前IP:四川
776352
3楼
源码能否一发?
引用
评论
11年5个月前IP:四川
776385
4楼
然而我也做了一个类似的[s:20]
捕获.png
引用
评论
张静茹作者
11年5个月前IP:山东
776440
5楼
public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体
        private void Form2_Load(object sender, EventArgs e)
        {
            webBrowser.ScriptErrorsSuppressed = true;
        }
        IntPtr _form1;
        public void Navigate(string urlString, IntPtr __form1)
        {
            _form1 = __form1;
            webBrowser.Navigate(urlString);
    
        }
        private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            SetForegroundWindow(_form1);
        }
    
        private void Form2_Activated(object sender, EventArgs e)
        {
            SetForegroundWindow(_form1);
        }
    }
引用 acmilan:
源码能否一发?



public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //调用API
        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr GetForegroundWindow(); //获得本窗体的句柄
        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体
        //定义变量,句柄类型
        public IntPtr han;
        private void textBox1_MouseDown(object sender, MouseEventArgs e)
        {
            //Text = string.Format("当前选中位置 {0} 当前选中字符长度 {1} 当前选中文本 {2}", textBoxSou.SelectionStart, textBoxSou.SelectionLength, textBoxSou.SelectedText);
    
    
            string poram  = WordStartEnd(textBoxSou.Text,textBoxSou.SelectionStart);
            if (string.IsNullOrEmpty(poram))
            {
                return;
            }
    
            IntPtr _form1 = GetForegroundWindow();
            F2.Navigate(string.Format("http://www.bing.com/dict/search?q={0}&go=%E6%8F%90%E4%BA%A4&qs=bs&form=CM", poram), _form1);
                
            Text = _form1.ToString("X");
    
            //this.Focus();
            //SetForegroundWindow(_form1);
            //MessageBox.Show(textBoxSou.Text.Substring(start, end - start));
        }
        /// <summary>
        /// 寻找单词起点与终点
        /// </summary>
        /// <param name="Text">
        /// <param name="SelectionStart">
        /// <param name="start">
        /// <param name="end">
        private string WordStartEnd(string Text, int SelectionStart)
        {
            int start = 0,end = 0;
            for (int i = SelectionStart; i < Text.Length; i++) //确定结束点
            {
                if (!char.IsLetter(Text))
                {
                    end = i;
                    break;
                }
            }
            if (end == 0) end = Text.Length;
    
            for (int i = SelectionStart - 1; i >= 0; i--) //确定起始点
            {
                if (!char.IsLetter(Text))
                {
                    start = i + 1;
                    break;
                }
            }
    
            string temp = Text.Substring(start, end - start);
            if (!Regex.IsMatch(temp,"[a-z]"))
            {
                return temp;
            }
    
            for (int i = SelectionStart; i < end; i++) //往终点寻找大写
            {
                if(char.IsUpper(Text))
                {
                    end = i;
                    break;
                }
            }
            for (int i = SelectionStart-1; i >= start; i--)//往起点寻找大写
            {
                if (char.IsUpper(Text))
                {
                    start = i;
                    break;
                }
            }
    
            return Text.Substring(start, end - start);
        }
    
        private void 设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("asd");
        }
    
        private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fontDialog字体.Font = textBoxSou.Font;
            fontDialog字体.Color = textBoxSou.ForeColor;
    
            fontDialog字体.ShowColor = true;
            fontDialog字体.ShowDialog();
            textBoxSou.Font = fontDialog字体.Font;
            textBoxSou.ForeColor = fontDialog字体.Color;
        }
    
        private void 背景颜色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            colorDialog颜色.ShowDialog();
            textBoxSou.BackColor = colorDialog颜色.Color;
        }
    
        private void textBoxSou_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox tbtem = (TextBox)sender;
            if (e.Control && e.KeyCode == Keys.A)
            {
                tbtem.SelectionStart = 0;
                tbtem.SelectionLength = tbtem.Text.Length;
                e.Handled = true;
            }
        }
    
        private void 测试ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //webBrowser.DocumentText = Http.Get("http://www.bing.com/dict/search?q=" + "browser" + "&go=%E6%8F%90%E4%BA%A4&qs=bs&form=CM", "");
            IntPtr ip = GetForegroundWindow();
            int i = ip.ToInt32();
            Text = i.ToString("X");
    
            SetForegroundWindow(new IntPtr(0x00391422));
    
        }
        Form2 F2 ;
        private void Form1_Load(object sender, EventArgs e)
        {
            F2 = new Form2();
            F2.Show();
        }
    }
引用
评论
张静茹作者
11年5个月前修改于 11年5个月前IP:山东
776634
6楼
更新V1.1:
加入点击朗读,点击一次朗读两遍
优化逻辑,重复点击一个单词,只重复朗读,不刷新网页
软件关闭之后保存文档,打开后自动载入
修复显示翻译的网页不能获取焦点

点击单词则翻译朗读单词,能分开中间没有空格的单词,如果选中了多个单词或某几个字母,则只翻译选中的部分
attachment icon 学英语_划词翻译.rar 7.58KB RAR 19次下载
引用
评论
张静茹作者
11年4个月前IP:北京
786749
7楼
最新版
attachment icon 学英语_划词翻译.rar 25.15KB RAR 27次下载

网页和文档改成一个窗口 F1阅读快捷键

RLC5NKZGP)64OZHZ$A$ZKHA.png
引用
评论
张静茹作者
11年3个月前IP:山东
791529
8楼
1.gif
新版本
attachment icon 学英语_划词翻译.rar 27.72KB RAR 17次下载
引用
评论
11年0个月前IP:浙江
798938
9楼
记号一下
引用
评论
笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的