自定义搜索程序

  时常要开着几个网页,有的是英文翻译的,有的是官方api的。网页如果关了要再用又要重新开,不关又很乱。于是写了个搜索框,程序很简单。我觉得挺好玩的。

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 System.Threading;
using System.Diagnostics;


namespace UnityScriptAPIform
{

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void Form1_Load(object sender, EventArgs e)
        {

            this.notifyIcon1.Visible = true;//在通知区显示Form的Icon

            this.ShowInTaskbar = true;//使Form不在任务栏上显示

            this.TopMost = true;
            FormBorderStyle = FormBorderStyle.None;
            this.Location = new Point(1080, 0);
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            
            if (e.KeyCode == Keys.Enter)
            {
                string url = "https://docs.unity3d.com/ScriptReference/30_search.html?q="+ textBox1.Text.ToString();
                Process.Start("D:/QQBrowser/QQBrowser.exe", url);
                //create a new form
                
                textBox1.Clear();

            }
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
            {
                e.Handled = true;
            }
        }

        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Enter)
            {
                string url = "http://fanyi.baidu.com/?aldtype=16047#en/zh/" + textBox2.Text.ToString();
                Process.Start("D:/QQBrowser/QQBrowser.exe", url);
                textBox2.Clear();
            }
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(13) || e.KeyChar == Convert.ToChar(27))
            {
                e.Handled = true;
            }
        }

        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if(e.Button == MouseButtons.Right)
            {
                Exit.Show();
            }

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

  

  再向注册表添加个开机自启动,就是一个很完整的小程序了(●'◡'●)

posted on 2017-12-22 10:06  workhardplayhard  阅读(222)  评论(0)    收藏  举报

导航